@@ -561,7 +561,7 @@ private InternalAggregation[] buildAggregations(long[] owningBucketOrds) throws
561
561
BucketUpdater <TB > updater = bucketUpdater (owningBucketOrds [ordIdx ]);
562
562
collectionStrategy .forEach (owningBucketOrds [ordIdx ], new BucketInfoConsumer () {
563
563
TB spare = null ;
564
-
564
+
565
565
@ Override
566
566
public void accept (long globalOrd , long bucketOrd , long docCount ) throws IOException {
567
567
otherDocCount [finalOrdIdx ] += docCount ;
@@ -574,7 +574,7 @@ public void accept(long globalOrd, long bucketOrd, long docCount) throws IOExcep
574
574
}
575
575
}
576
576
});
577
-
577
+
578
578
// Get the top buckets
579
579
topBucketsPreOrd [ordIdx ] = buildBuckets (ordered .size ());
580
580
for (int i = ordered .size () - 1 ; i >= 0 ; --i ) {
@@ -797,9 +797,14 @@ SignificantStringTerms.Bucket buildEmptyTemporaryBucket() {
797
797
return new SignificantStringTerms .Bucket (new BytesRef (), 0 , 0 , 0 , 0 , null , format , 0 );
798
798
}
799
799
800
+ private long subsetSize (long owningBucketOrd ) {
801
+ // if the owningBucketOrd is not in the array that means the bucket is empty so the size has to be 0
802
+ return owningBucketOrd < subsetSizes .size () ? subsetSizes .get (owningBucketOrd ) : 0 ;
803
+ }
804
+
800
805
@ Override
801
806
BucketUpdater <SignificantStringTerms .Bucket > bucketUpdater (long owningBucketOrd ) throws IOException {
802
- long subsetSize = subsetSizes . get (owningBucketOrd );
807
+ long subsetSize = subsetSize (owningBucketOrd );
803
808
return (spare , globalOrd , bucketOrd , docCount ) -> {
804
809
spare .bucketOrd = bucketOrd ;
805
810
oversizedCopy (lookupGlobalOrd .apply (globalOrd ), spare .termBytes );
@@ -839,7 +844,7 @@ SignificantStringTerms buildResult(long owningBucketOrd, long otherDocCount, Sig
839
844
bucketCountThresholds .getMinDocCount (),
840
845
metadata (),
841
846
format ,
842
- subsetSizes . get (owningBucketOrd ),
847
+ subsetSize (owningBucketOrd ),
843
848
supersetSize ,
844
849
significanceHeuristic ,
845
850
Arrays .asList (topBuckets )
0 commit comments