12
12
import org .apache .lucene .index .LeafReaderContext ;
13
13
import org .apache .lucene .search .DisiPriorityQueue ;
14
14
import org .apache .lucene .search .DisiWrapper ;
15
- import org .apache .lucene .search .DisjunctionDISIApproximation ;
16
15
import org .apache .lucene .search .DocIdSetIterator ;
17
16
import org .apache .lucene .search .LeafCollector ;
18
17
import org .apache .lucene .search .Scorable ;
@@ -313,10 +312,9 @@ protected LeafBucketCollector getLeafCollector(AggregationExecutionContext aggCt
313
312
// and the cost of per-filter doc iterator is smaller than maxDoc, indicating that there are docs matching the main
314
313
// query but not the filter query.
315
314
final boolean hasOtherBucket = otherBucketKey != null ;
316
- final boolean usesCompetitiveIterator = (parent == null
317
- && hasOtherBucket == false
318
- && filterWrappers .isEmpty () == false
319
- && totalCost < aggCtx .getLeafReaderContext ().reader ().maxDoc ());
315
+ // TODO: https://github.com/elastic/elasticsearch/issues/126955
316
+ // competitive iterator is currently broken, we would rather be slow than broken
317
+ final boolean usesCompetitiveIterator = false ;
320
318
321
319
if (filterWrappers .size () == 1 ) {
322
320
return new SingleFilterLeafCollector (
@@ -329,12 +327,7 @@ protected LeafBucketCollector getLeafCollector(AggregationExecutionContext aggCt
329
327
);
330
328
}
331
329
// TODO: https://github.com/elastic/elasticsearch/issues/126955
332
- // competitive iterator is currently broken, we would rather be slow than broken
333
330
return new MultiFilterLeafCollector (sub , filterWrappers , numFilters , totalNumKeys , hasOtherBucket );
334
- // if (usesCompetitiveIterator) {
335
- // return new MultiFilterCompetitiveLeafCollector(sub, filterWrappers, numFilters, totalNumKeys, hasOtherBucket);
336
- // } else {
337
- // }
338
331
}
339
332
}
340
333
@@ -458,46 +451,6 @@ public DocIdSetIterator competitiveIterator() {
458
451
}
459
452
}
460
453
461
- private final class MultiFilterCompetitiveLeafCollector extends AbstractLeafCollector {
462
-
463
- private final DisjunctionDISIApproximation disjunctionDisi ;
464
-
465
- MultiFilterCompetitiveLeafCollector (
466
- LeafBucketCollector sub ,
467
- List <FilterMatchingDisiWrapper > filterWrappers ,
468
- int numFilters ,
469
- int totalNumKeys ,
470
- boolean hasOtherBucket
471
- ) {
472
- super (sub , numFilters , totalNumKeys , true , hasOtherBucket );
473
- assert filterWrappers .isEmpty () == false ;
474
- disjunctionDisi = DisjunctionDISIApproximation .of (filterWrappers , Long .MAX_VALUE );
475
- }
476
-
477
- public void collect (int doc , long bucket ) throws IOException {
478
- boolean matched = false ;
479
- int target = disjunctionDisi .advance (doc );
480
- if (target == doc ) {
481
- for (DisiWrapper w = disjunctionDisi .topList (); w != null ; w = w .next ) {
482
- FilterMatchingDisiWrapper topMatch = (FilterMatchingDisiWrapper ) w ;
483
- if (topMatch .checkDocForMatch (doc )) {
484
- collectBucket (sub , doc , bucketOrd (bucket , topMatch .filterOrd ));
485
- matched = true ;
486
- }
487
- }
488
- }
489
-
490
- if (hasOtherBucket && false == matched ) {
491
- collectBucket (sub , doc , bucketOrd (bucket , numFilters ));
492
- }
493
- }
494
-
495
- @ Override
496
- public DocIdSetIterator competitiveIterator () {
497
- return disjunctionDisi ;
498
- }
499
- }
500
-
501
454
private static class FilterMatchingDisiWrapper extends DisiWrapper {
502
455
final int filterOrd ;
503
456
0 commit comments