Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix TreeSet primitive byte[] comparator
Browse files Browse the repository at this point in the history
Signed-off-by: Nicholas Walter Knize <nknize@apache.org>
nknize committed Mar 30, 2023
1 parent bf84acf commit 4b9d24d
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -54,6 +54,7 @@
import java.util.Arrays;
import java.util.Base64;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.TreeSet;
@@ -255,8 +256,8 @@ public void add(byte[] bytes) {
@Override
public BytesRef binaryValue() {
try {
// sort and dedup in place
TreeSet<byte[]> bytesTree = new TreeSet(bytesList);
TreeSet<byte[]> bytesTree = new TreeSet((Comparator<byte[]>)((byte[] a, byte[] b) -> Arrays.compareUnsigned(a, b)));
bytesTree.addAll(bytesList);
int size = bytesTree.stream().mapToInt(b -> b.length).sum();
int length = bytesTree.size();
BytesStreamOutput out = new BytesStreamOutput(size + (length + 1) * 5);

0 comments on commit 4b9d24d

Please sign in to comment.