Don't create docCounts equal to maxOrd for the GlobalOrdinalsStringTermsAggregator.WithHash impl.
Relates #5873
This commit is contained in:
parent
eb9805389a
commit
a2aa167e6e
|
@ -42,9 +42,9 @@ import java.util.Arrays;
|
|||
*/
|
||||
public class GlobalOrdinalsStringTermsAggregator extends AbstractStringTermsAggregator {
|
||||
|
||||
private final ValuesSource.Bytes.WithOrdinals.FieldData valuesSource;
|
||||
private BytesValues.WithOrdinals globalValues;
|
||||
private Ordinals.Docs globalOrdinals;
|
||||
protected final ValuesSource.Bytes.WithOrdinals.FieldData valuesSource;
|
||||
protected BytesValues.WithOrdinals globalValues;
|
||||
protected Ordinals.Docs globalOrdinals;
|
||||
|
||||
public GlobalOrdinalsStringTermsAggregator(String name, AggregatorFactories factories, ValuesSource.Bytes.WithOrdinals.FieldData valuesSource, long estimatedBucketCount,
|
||||
InternalOrder order, int requiredSize, int shardSize, long minDocCount, AggregationContext aggregationContext, Aggregator parent) {
|
||||
|
@ -52,10 +52,6 @@ public class GlobalOrdinalsStringTermsAggregator extends AbstractStringTermsAggr
|
|||
this.valuesSource = valuesSource;
|
||||
}
|
||||
|
||||
protected long createBucketOrd(long termOrd) {
|
||||
return termOrd;
|
||||
}
|
||||
|
||||
protected long getBucketOrd(long termOrd) {
|
||||
return termOrd;
|
||||
}
|
||||
|
@ -77,7 +73,7 @@ public class GlobalOrdinalsStringTermsAggregator extends AbstractStringTermsAggr
|
|||
final int numOrds = globalOrdinals.setDocument(doc);
|
||||
for (int i = 0; i < numOrds; i++) {
|
||||
final long globalOrd = globalOrdinals.nextOrd();
|
||||
collectExistingBucket(doc, createBucketOrd(globalOrd));
|
||||
collectExistingBucket(doc, globalOrd);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -146,12 +142,22 @@ public class GlobalOrdinalsStringTermsAggregator extends AbstractStringTermsAggr
|
|||
}
|
||||
|
||||
@Override
|
||||
protected long createBucketOrd(long termOrd) {
|
||||
long bucketOrd = bucketOrds.add(termOrd);
|
||||
if (bucketOrd < 0) {
|
||||
bucketOrd = -1 - bucketOrd;
|
||||
public void setNextReader(AtomicReaderContext reader) {
|
||||
globalValues = valuesSource.globalBytesValues();
|
||||
globalOrdinals = globalValues.ordinals();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collect(int doc, long owningBucketOrdinal) throws IOException {
|
||||
final int numOrds = globalOrdinals.setDocument(doc);
|
||||
for (int i = 0; i < numOrds; i++) {
|
||||
final long globalOrd = globalOrdinals.nextOrd();
|
||||
long bucketOrd = bucketOrds.add(globalOrd);
|
||||
if (bucketOrd < 0) {
|
||||
bucketOrd = -1 - bucketOrd;
|
||||
}
|
||||
collectBucket(doc, bucketOrd);
|
||||
}
|
||||
return bucketOrd;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue