Skip to content

Commit 531711b

Browse files
committed
Revert "Added LognHash to early discard values in set and avoid logn searches"
This reverts commit a3db630.
1 parent a3db630 commit 531711b

File tree

1 file changed

+3
-19
lines changed
  • x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/sort

1 file changed

+3
-19
lines changed

x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/sort/LongTopNSet.java

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import org.elasticsearch.common.util.BigArrays;
1111
import org.elasticsearch.common.util.BinarySearcher;
1212
import org.elasticsearch.common.util.LongArray;
13-
import org.elasticsearch.common.util.LongHash;
1413
import org.elasticsearch.core.Releasable;
1514
import org.elasticsearch.core.Releasables;
1615
import org.elasticsearch.search.sort.SortOrder;
@@ -28,25 +27,15 @@ public class LongTopNSet implements Releasable {
2827

2928
private final LongArray values;
3029
private final LongBinarySearcher searcher;
31-
private final LongHash seenValues;
3230

3331
private int count;
3432

3533
public LongTopNSet(BigArrays bigArrays, SortOrder order, int limit) {
3634
this.order = order;
3735
this.limit = limit;
3836
this.count = 0;
39-
boolean success = false;
40-
try {
41-
this.values = bigArrays.newLongArray(limit, false);
42-
this.searcher = new LongBinarySearcher(values, order);
43-
this.seenValues = new LongHash(limit, 0.05f, bigArrays);
44-
success = true;
45-
} finally {
46-
if (success == false) {
47-
close();
48-
}
49-
}
37+
this.values = bigArrays.newLongArray(limit, false);
38+
this.searcher = new LongBinarySearcher(values, order);
5039
}
5140

5241
/**
@@ -69,11 +58,6 @@ public boolean collect(long value) {
6958
return true;
7059
}
7160

72-
if (seenValues.add(value) < 0) {
73-
// The value was already added
74-
return true;
75-
}
76-
7761
int insertionIndex = this.searcher.search(0, count - 1, value);
7862

7963
if (insertionIndex == count - 1) {
@@ -184,6 +168,6 @@ private boolean betterThan(long lhs, long rhs) {
184168

185169
@Override
186170
public final void close() {
187-
Releasables.close(values, seenValues);
171+
Releasables.close(values);
188172
}
189173
}

0 commit comments

Comments
 (0)