Skip to content

Commit 2b1f868

Browse files
committed
Improve migration and remove unused BucketedSort test
1 parent 16c88eb commit 2b1f868

File tree

2 files changed

+3
-27
lines changed

2 files changed

+3
-27
lines changed

x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/aggregation/blockhash/LongTopNBlockHash.java

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ private boolean acceptNull() {
9696

9797
if (nullsFirst) {
9898
hasNull = true;
99-
migrateToSmallTop();
99+
// Reduce the limit of the sort by one, as it's not filled with a null
100+
assert topValues.getLimit() == limit : "The top values can't be reduced twice";
101+
topValues.reduceLimitByOne();
100102
return true;
101103
}
102104

@@ -124,16 +126,6 @@ private boolean acceptValue(long value) {
124126
return true;
125127
}
126128

127-
/**
128-
* Converts the current BucketedSort to one with {@code limit - 1} values, as one value is a null.
129-
*/
130-
private void migrateToSmallTop() {
131-
assert nullsFirst : "The small top is only used when nulls are first";
132-
assert topValues.getLimit() == limit : "The top values can't be migrated twice";
133-
134-
topValues.reduceLimitByOne();
135-
}
136-
137129
/**
138130
* Returns true if the value is in, or can be added to the top; false otherwise.
139131
*/

x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/data/sort/BucketedSortTestCase.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -445,22 +445,6 @@ public final void testMergePastEnd() {
445445
}
446446
}
447447

448-
public final void testZeroBucketSize() {
449-
try (T sort = build(randomFrom(SortOrder.values()), 0)) {
450-
collect(sort, randomValue(), 0);
451-
452-
try (T otherSort = build(randomFrom(SortOrder.values()), randomIntBetween(1, 3))) {
453-
for (int i = 0; i < randomIntBetween(0, 3); i++) {
454-
collect(otherSort, randomValue(), 0);
455-
}
456-
457-
merge(sort, 0, otherSort, 0);
458-
}
459-
460-
assertBlock(sort, 0, List.of());
461-
}
462-
}
463-
464448
protected void assertBlock(T sort, int groupId, List<V> values) {
465449
var blockFactory = TestBlockFactory.getNonBreakingInstance();
466450

0 commit comments

Comments
 (0)