Skip to content

Commit 3ae1dea

Browse files
authored
ESQL: Remove some unused code (#134322)
I committed it in #134235 by accident. We were going to use it as part of that but decided against it.
1 parent a3599ed commit 3ae1dea

File tree

1 file changed

+0
-64
lines changed

1 file changed

+0
-64
lines changed

x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/lucene/LuceneTopNSourceOperator.java

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
import org.apache.lucene.search.ScoreMode;
1717
import org.apache.lucene.search.Sort;
1818
import org.apache.lucene.search.SortField;
19-
import org.apache.lucene.search.SortedNumericSortField;
20-
import org.apache.lucene.search.SortedSetSortField;
2119
import org.apache.lucene.search.TopDocsCollector;
2220
import org.apache.lucene.search.TopFieldCollectorManager;
2321
import org.apache.lucene.search.TopScoreDocCollectorManager;
@@ -425,67 +423,5 @@ private static PerShardCollector newPerShardCollector(ShardContext context, List
425423
return new ScoringPerShardCollector(context, new TopFieldCollectorManager(sort, limit, null, 0).newCollector());
426424
}
427425

428-
private static int perDocMemoryUsage(SortField[] sorts) {
429-
int usage = FIELD_DOC_SIZE;
430-
for (SortField sort : sorts) {
431-
usage += perDocMemoryUsage(sort);
432-
}
433-
return usage;
434-
}
435-
436-
private static int perDocMemoryUsage(SortField sort) {
437-
if (sort.getType() == SortField.Type.CUSTOM) {
438-
return perDocMemoryUsageForCustom(sort);
439-
}
440-
return perDocMemoryUsageByType(sort, sort.getType());
441-
442-
}
443-
444-
private static int perDocMemoryUsageByType(SortField sort, SortField.Type type) {
445-
return switch (type) {
446-
case SCORE, DOC ->
447-
/* SCORE and DOC are always part of ScoreDoc/FieldDoc
448-
* So they are in FIELD_DOC_SIZE already.
449-
* And they can't be removed. */
450-
0;
451-
case DOUBLE, LONG ->
452-
// 8 for the long, 8 for the long copied to the topDoc.
453-
16;
454-
case INT, FLOAT ->
455-
// 4 for the int, 8 boxed object copied to topDoc.
456-
12;
457-
case STRING ->
458-
/* `keyword`-like fields. Compares ordinals when possible, otherwise
459-
* the strings. Does a bunch of deduplication, but in the worst
460-
* case we end up with the string itself, plus two BytesRefs. Let's
461-
* presume short-ish strings. */
462-
1024;
463-
case STRING_VAL ->
464-
/* Other string fields. Compares the string itself. Let's assume two
465-
* 2kb per string because they tend to be bigger than the keyword
466-
* versions. */
467-
2048;
468-
case CUSTOM -> throw new IllegalArgumentException("unsupported type " + sort.getClass() + ": " + sort);
469-
case REWRITEABLE -> {
470-
assert false : "rewriteable " + sort.getClass() + ": " + sort;
471-
yield 2048;
472-
}
473-
};
474-
}
475-
476-
private static int perDocMemoryUsageForCustom(SortField sort) {
477-
return switch (sort) {
478-
case SortedNumericSortField f -> perDocMemoryUsageByType(f, f.getNumericType());
479-
case SortedSetSortField f -> perDocMemoryUsageByType(f, SortField.Type.STRING);
480-
default -> {
481-
if (sort.getClass().getName().equals("org.apache.lucene.document.LatLonPointSortField")) {
482-
yield perDocMemoryUsageByType(sort, SortField.Type.DOUBLE);
483-
}
484-
assert false : "unknown type " + sort.getClass() + ": " + sort;
485-
yield 2048;
486-
}
487-
};
488-
}
489-
490426
private static final int FIELD_DOC_SIZE = Math.toIntExact(RamUsageEstimator.shallowSizeOf(FieldDoc.class));
491427
}

0 commit comments

Comments
 (0)