void filterCellByStore(Entry logEntry) { Map<byte[], Long> maxSeqIdInStores = regionMaxSeqIdInStores.get(Bytes.toString(logEntry.getKey().getEncodedRegionName())); if (MapUtils.isEmpty(maxSeqIdInStores)) { return; } // Create the array list for the cells that aren't filtered. // We make the assumption that most cells will be kept. ArrayList<Cell> keptCells = new ArrayList<>(logEntry.getEdit().getCells().size()); for (Cell cell : logEntry.getEdit().getCells()) { if (CellUtil.matchingFamily(cell, WALEdit.METAFAMILY)) { keptCells.add(cell); } else { byte[] family = CellUtil.cloneFamily(cell); Long maxSeqId = maxSeqIdInStores.get(family); // Do not skip cell even if maxSeqId is null. Maybe we are in a rolling upgrade, // or the master was crashed before and we can not get the information. if (maxSeqId == null || maxSeqId.longValue() < logEntry.getKey().getSequenceId()) { keptCells.add(cell); } } } // Anything in the keptCells array list is still live. // So rather than removing the cells from the array list // which would be an O(n^2) operation, we just replace the list logEntry.getEdit().setCells(keptCells); }
if (MapUtils.isNotEmpty(colFamTimeRangeMap)) { for (Map.Entry<ByteBuffer, TTimeRange> entry : colFamTimeRangeMap.entrySet()) { out.setColumnFamilyTimeRange(Bytes.toBytes(entry.getKey()),
/** * Looks up the given key in the given map, converting the result into * a number, using the default value if the the conversion fails. * * @param <K> the key type * @param map the map whose value to look up * @param key the key of the value to look up in that map * @param defaultValue what to return if the value is null or if the * conversion fails * @return the value in the map as a number, or defaultValue if the * original value is null, the map is null or the number conversion fails */ public static <K> Number getNumber(final Map<? super K, ?> map, final K key, final Number defaultValue) { Number answer = getNumber(map, key); if (answer == null) { answer = defaultValue; } return answer; }
/** * Looks up the given key in the given map, converting the result into * a double, using the default value if the the conversion fails. * * @param <K> the key type * @param map the map whose value to look up * @param key the key of the value to look up in that map * @param defaultValue what to return if the value is null or if the * conversion fails * @return the value in the map as a number, or defaultValue if the * original value is null, the map is null or the number conversion fails */ public static <K> Double getDouble(final Map<? super K, ?> map, final K key, final Double defaultValue) { Double answer = getDouble(map, key); if (answer == null) { answer = defaultValue; } return answer; }
/** * Looks up the given key in the given map, converting the result into * an integer, using the default value if the the conversion fails. * * @param <K> the key type * @param map the map whose value to look up * @param key the key of the value to look up in that map * @param defaultValue what to return if the value is null or if the * conversion fails * @return the value in the map as a number, or defaultValue if the * original value is null, the map is null or the number conversion fails */ public static <K> Integer getInteger(final Map<? super K, ?> map, final K key, final Integer defaultValue) { Integer answer = getInteger(map, key); if (answer == null) { answer = defaultValue; } return answer; }
/** * Looks up the given key in the given map, converting the result into * a float, using the default value if the the conversion fails. * * @param <K> the key type * @param map the map whose value to look up * @param key the key of the value to look up in that map * @param defaultValue what to return if the value is null or if the * conversion fails * @return the value in the map as a number, or defaultValue if the * original value is null, the map is null or the number conversion fails */ public static <K> Float getFloat(final Map<? super K, ?> map, final K key, final Float defaultValue) { Float answer = getFloat(map, key); if (answer == null) { answer = defaultValue; } return answer; }
/** * Looks up the given key in the given map, converting the result into * a long, using the default value if the the conversion fails. * * @param <K> the key type * @param map the map whose value to look up * @param key the key of the value to look up in that map * @param defaultValue what to return if the value is null or if the * conversion fails * @return the value in the map as a number, or defaultValue if the * original value is null, the map is null or the number conversion fails */ public static <K> Long getLong(final Map<? super K, ?> map, final K key, final Long defaultValue) { Long answer = getLong(map, key); if (answer == null) { answer = defaultValue; } return answer; }
/** * Looks up the given key in the given map, converting the result into * a byte, using the default value if the the conversion fails. * * @param <K> the key type * @param map the map whose value to look up * @param key the key of the value to look up in that map * @param defaultValue what to return if the value is null or if the * conversion fails * @return the value in the map as a number, or defaultValue if the * original value is null, the map is null or the number conversion fails */ public static <K> Byte getByte(final Map<? super K, ?> map, final K key, final Byte defaultValue) { Byte answer = getByte(map, key); if (answer == null) { answer = defaultValue; } return answer; }
/** * Looks up the given key in the given map, converting the result into * a boolean, using the default value if the the conversion fails. * * @param <K> the key type * @param map the map whose value to look up * @param key the key of the value to look up in that map * @param defaultValue what to return if the value is null or if the * conversion fails * @return the value in the map as a boolean, or defaultValue if the * original value is null, the map is null or the boolean conversion fails */ public static <K> Boolean getBoolean(final Map<? super K, ?> map, final K key, final Boolean defaultValue) { Boolean answer = getBoolean(map, key); if (answer == null) { answer = defaultValue; } return answer; }
/** * Looks up the given key in the given map, converting the result into * a map, using the default value if the the conversion fails. * * @param <K> the key type * @param map the map whose value to look up * @param key the key of the value to look up in that map * @param defaultValue what to return if the value is null or if the * conversion fails * @return the value in the map as a number, or defaultValue if the * original value is null, the map is null or the map conversion fails */ public static <K> Map<?, ?> getMap(final Map<? super K, ?> map, final K key, final Map<?, ?> defaultValue) { Map<?, ?> answer = getMap(map, key); if (answer == null) { answer = defaultValue; } return answer; }
/** * Gets a Byte from a Map in a null-safe manner. * <p> * The Byte is obtained from the results of {@link #getNumber(Map,Object)}. * * @param <K> the key type * @param map the map to use * @param key the key to look up * @return the value in the Map as a Byte, <code>null</code> if null map input */ public static <K> Byte getByte(final Map<? super K, ?> map, final K key) { final Number answer = getNumber(map, key); if (answer == null) { return null; } if (answer instanceof Byte) { return (Byte) answer; } return Byte.valueOf(answer.byteValue()); }
/** * Gets a double from a Map in a null-safe manner. * <p> * The double is obtained from the results of {@link #getNumber(Map,Object)}. * * @param <K> the key type * @param map the map to use * @param key the key to look up * @return the value in the Map as a double, <code>0.0</code> if null map input */ public static <K> double getDoubleValue(final Map<? super K, ?> map, final K key) { final Double doubleObject = getDouble(map, key); if (doubleObject == null) { return 0d; } return doubleObject.doubleValue(); }
/** * Gets an int from a Map in a null-safe manner. * <p> * The int is obtained from the results of {@link #getNumber(Map,Object)}. * * @param <K> the key type * @param map the map to use * @param key the key to look up * @return the value in the Map as an int, <code>0</code> if null map input */ public static <K> int getIntValue(final Map<? super K, ?> map, final K key) { final Integer integerObject = getInteger(map, key); if (integerObject == null) { return 0; } return integerObject.intValue(); }
/** * Gets a float from a Map in a null-safe manner. * <p> * The float is obtained from the results of {@link #getNumber(Map,Object)}. * * @param <K> the key type * @param map the map to use * @param key the key to look up * @return the value in the Map as a float, <code>0.0F</code> if null map input */ public static <K> float getFloatValue(final Map<? super K, ?> map, final K key) { final Float floatObject = getFloat(map, key); if (floatObject == null) { return 0f; } return floatObject.floatValue(); }
/** * Gets a long from a Map in a null-safe manner. * <p> * The long is obtained from the results of {@link #getNumber(Map,Object)}. * * @param <K> the key type * @param map the map to use * @param key the key to look up * @return the value in the Map as a long, <code>0L</code> if null map input */ public static <K> long getLongValue(final Map<? super K, ?> map, final K key) { final Long longObject = getLong(map, key); if (longObject == null) { return 0L; } return longObject.longValue(); }
/** * Gets a byte from a Map in a null-safe manner. * <p> * The byte is obtained from the results of {@link #getNumber(Map,Object)}. * * @param <K> the key type * @param map the map to use * @param key the key to look up * @return the value in the Map as a byte, <code>0</code> if null map input */ public static <K> byte getByteValue(final Map<? super K, ?> map, final K key) { final Byte byteObject = getByte(map, key); if (byteObject == null) { return 0; } return byteObject.byteValue(); }
/** * Gets a boolean from a Map in a null-safe manner. * <p> * If the value is a <code>Boolean</code> its value is returned. * If the value is a <code>String</code> and it equals 'true' ignoring case * then <code>true</code> is returned, otherwise <code>false</code>. * If the value is a <code>Number</code> an integer zero value returns * <code>false</code> and non-zero returns <code>true</code>. * Otherwise, <code>false</code> is returned. * * @param <K> the key type * @param map the map to use * @param key the key to look up * @return the value in the Map as a Boolean, <code>false</code> if null map input */ public static <K> boolean getBooleanValue(final Map<? super K, ?> map, final K key) { return Boolean.TRUE.equals(getBoolean(map, key)); }
if (MapUtils.isNotEmpty(colFamTimeRangeMap)) { for (Map.Entry<ByteBuffer, TTimeRange> entry : colFamTimeRangeMap.entrySet()) { out.setColumnFamilyTimeRange(Bytes.toBytes(entry.getKey()),
/** * Null-safe check if the specified map is not empty. * <p> * Null returns false. * * @param map the map to check, may be null * @return true if non-null and non-empty * @since 3.2 */ public static boolean isNotEmpty(final Map<?,?> map) { return !MapUtils.isEmpty(map); }
/** * Gets a Long from a Map in a null-safe manner. * <p> * The Long is obtained from the results of {@link #getNumber(Map,Object)}. * * @param <K> the key type * @param map the map to use * @param key the key to look up * @return the value in the Map as a Long, <code>null</code> if null map input */ public static <K> Long getLong(final Map<? super K, ?> map, final K key) { final Number answer = getNumber(map, key); if (answer == null) { return null; } if (answer instanceof Long) { return (Long) answer; } return Long.valueOf(answer.longValue()); }