|
16 | 16 | import org.apache.lucene.search.ScoreMode; |
17 | 17 | import org.apache.lucene.search.Sort; |
18 | 18 | import org.apache.lucene.search.SortField; |
19 | | -import org.apache.lucene.search.SortedNumericSortField; |
20 | | -import org.apache.lucene.search.SortedSetSortField; |
21 | 19 | import org.apache.lucene.search.TopDocsCollector; |
22 | 20 | import org.apache.lucene.search.TopFieldCollectorManager; |
23 | 21 | import org.apache.lucene.search.TopScoreDocCollectorManager; |
@@ -425,67 +423,5 @@ private static PerShardCollector newPerShardCollector(ShardContext context, List |
425 | 423 | return new ScoringPerShardCollector(context, new TopFieldCollectorManager(sort, limit, null, 0).newCollector()); |
426 | 424 | } |
427 | 425 |
|
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 | | - |
490 | 426 | private static final int FIELD_DOC_SIZE = Math.toIntExact(RamUsageEstimator.shallowSizeOf(FieldDoc.class)); |
491 | 427 | } |
0 commit comments