diff --git a/server/base/src/main/java/org/apache/accumulo/server/metadata/iterators/SetEqualityIterator.java b/server/base/src/main/java/org/apache/accumulo/server/metadata/iterators/SetEqualityIterator.java index a66368f58ad..1eeff202c4f 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/metadata/iterators/SetEqualityIterator.java +++ b/server/base/src/main/java/org/apache/accumulo/server/metadata/iterators/SetEqualityIterator.java @@ -22,7 +22,6 @@ import java.io.DataOutputStream; import java.io.IOException; import java.io.UncheckedIOException; -import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.Collection; import java.util.Map; @@ -88,7 +87,7 @@ public void seek(Range range, Collection columnFamilies, boolean i byte[] ba = source.getTopKey().getColumnQualifierData().toArray(); byte[] valueData = source.getTopValue().get(); - byte[] encodedData = encodeEntry(ba, valueData); + byte[] encodedData = encodeKeyValue(ba, valueData); dos.writeInt(encodedData.length); dos.write(encodedData, 0, encodedData.length); @@ -210,24 +209,24 @@ public static Condition createCondition(Collection set, Function Condition createCondition(Map map, - Function,byte[]> entryEncoder, Text family) { + Function,Map.Entry> entryEncoder, Text family) { IteratorSetting is = new IteratorSetting(ConditionalTabletMutatorImpl.INITIAL_ITERATOR_PRIO, SetEqualityIterator.class); is.addOption(ENCODE_VALUE_OPTION, "true"); - Function,byte[]> encoder = entry -> { - T value = entry.getValue(); - byte[] keyData = entryEncoder.apply(entry); - byte[] valueData = value instanceof byte[] ? (byte[]) value - : value.toString().getBytes(StandardCharsets.UTF_8); - return encodeEntry(keyData, valueData); - }; + Map.Entry byteEntry = entryEncoder.apply(entry); + return encodeKeyValue(byteEntry.getKey(), byteEntry.getValue()); + }; return new Condition(family, EMPTY).setValue(encode(map.entrySet(), encoder)).setIterators(is); } - private static byte[] encodeEntry(byte[] keyData, byte[] valueData) { - return ByteUtils.concat(ByteUtils.escape(keyData), ByteUtils.escape(valueData)); - + private static byte[] encodeKeyValue(byte[] key, byte[] value) { + return ByteUtils.concat(ByteUtils.escape(key), ByteUtils.escape(value)); } + + // private static byte[] encodeEntry(Map.Entry bytesEntry) { + // return ByteUtils.concat(ByteUtils.escape(bytesEntry.getKey()), + // ByteUtils.escape(bytesEntry.getValue())); + // } }