@@ -366,65 +366,6 @@ protected boolean lessThan(IteratorAndCurrent<B> a, IteratorAndCurrent<B> b) {
366366 return reducedBuckets ;
367367 }
368368
369- private List <B > reduceMergeSort3 (List <InternalAggregation > aggregations , BucketOrder thisReduceOrder , ReduceContext reduceContext ) {
370- assert isKeyOrder (thisReduceOrder );
371- final Comparator <MultiBucketsAggregation .Bucket > cmp = thisReduceOrder .comparator ();
372-
373- IteratorAndCurrent <B >[] iterators = new IteratorAndCurrent [aggregations .size ()];
374- int activeIterators = 0 ;
375- for (InternalAggregation aggregation : aggregations ) {
376- @ SuppressWarnings ("unchecked" )
377- InternalTerms <A , B > terms = (InternalTerms <A , B >) aggregation ;
378- if (!terms .getBuckets ().isEmpty ()) {
379- iterators [activeIterators ++] = new IteratorAndCurrent (terms .getBuckets ().iterator ());
380- }
381- }
382-
383- final PriorityQueue <B > pq = new PriorityQueue <B >(aggregations .size ()) {
384- @ Override
385- protected boolean lessThan (B a , B b ) {
386- return cmp .compare (a , b ) < 0 ;
387- }
388- };
389- Map <Object , List <Integer >> keysMap = new HashMap <>();
390- for (int i = 0 ; i < activeIterators ; i ++) {
391- if (keysMap .containsKey (iterators [i ].current ().getKey ())) {
392- keysMap .get (iterators [i ].current ().getKey ()).add (i );
393- } else {
394- pq .add (iterators [i ].current ());
395- List <Integer > idx = new ArrayList <>();
396- idx .add (i );
397- keysMap .put (iterators [i ].current ().getKey (), idx );
398- }
399- }
400-
401- List <B > reducedBuckets = new ArrayList <>();
402- List <B > currentBuckets = new ArrayList <>();
403-
404- while (pq .size () > 0 ) {
405- Object minKeyBucket = pq .pop ().getKey ();
406- List <Integer > minBucketIndices = keysMap .remove (minKeyBucket );
407- currentBuckets .clear ();
408- for (int i : minBucketIndices ) {
409- currentBuckets .add (iterators [i ].current ());
410- if (iterators [i ].hasNext ()) {
411- iterators [i ].next ();
412- if (keysMap .containsKey (iterators [i ].current ().getKey ())) {
413- keysMap .get (iterators [i ].current ().getKey ()).add (i );
414- } else {
415- pq .add (iterators [i ].current ());
416- List <Integer > idx = new ArrayList <>();
417- idx .add (i );
418- keysMap .put (iterators [i ].current ().getKey (), idx );
419- }
420- }
421- }
422- final B reduced = reduceBucket (currentBuckets , reduceContext );
423- reducedBuckets .add (reduced );
424- }
425- return reducedBuckets ;
426- }
427-
428369 private List <B > reduceLegacy (List <InternalAggregation > aggregations , ReduceContext reduceContext ) {
429370 Map <Object , List <B >> bucketMap = new HashMap <>();
430371 for (InternalAggregation aggregation : aggregations ) {
0 commit comments