-
Notifications
You must be signed in to change notification settings - Fork 25k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build global ordinals terms bucket from matching ordinals #30166
Merged
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b46802c
Build terms bucket from matching ordinals
jimczi 333e338
unused import
jimczi 5b6ed93
typos
jimczi 69c8160
address review
jimczi fa905ab
Merge branch 'master' into global_ordinal_loop
jimczi 78034d1
Merge branch 'master' into global_ordinal_loop
jimczi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,7 +71,7 @@ public class GlobalOrdinalsStringTermsAggregator extends AbstractStringTermsAggr | |
protected final long valueCount; | ||
protected final GlobalOrdLookupFunction lookupGlobalOrd; | ||
|
||
private final LongHash bucketOrds; | ||
protected final LongHash bucketOrds; | ||
|
||
public interface GlobalOrdLookupFunction { | ||
BytesRef apply(long ord) throws IOException; | ||
|
@@ -107,10 +107,6 @@ boolean remapGlobalOrds() { | |
return bucketOrds != null; | ||
} | ||
|
||
protected final long getBucketOrd(long globalOrd) { | ||
return bucketOrds == null ? globalOrd : bucketOrds.find(globalOrd); | ||
} | ||
|
||
private void collectGlobalOrd(int doc, long globalOrd, LeafBucketCollector sub) throws IOException { | ||
if (bucketOrds == null) { | ||
collectExistingBucket(sub, doc, globalOrd); | ||
|
@@ -188,17 +184,28 @@ public InternalAggregation buildAggregation(long owningBucketOrdinal) throws IOE | |
long otherDocCount = 0; | ||
BucketPriorityQueue<OrdBucket> ordered = new BucketPriorityQueue<>(size, order.comparator(this)); | ||
OrdBucket spare = new OrdBucket(-1, 0, null, showTermDocCountError, 0); | ||
for (long globalTermOrd = 0; globalTermOrd < valueCount; ++globalTermOrd) { | ||
if (includeExclude != null && !acceptedGlobalOrdinals.get(globalTermOrd)) { | ||
boolean needsFullScan = bucketOrds == null || bucketCountThresholds.getMinDocCount() == 0; | ||
long maxId = needsFullScan ? valueCount : bucketOrds.size(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's make them final? |
||
for (long ord = 0; ord < maxId; ord++) { | ||
final long globalOrd; | ||
final long bucketOrd; | ||
if (needsFullScan) { | ||
bucketOrd = bucketOrds == null ? ord : bucketOrds.find(ord); | ||
globalOrd = ord; | ||
} else { | ||
assert bucketOrds != null; | ||
bucketOrd = ord; | ||
globalOrd = bucketOrds.get(ord); | ||
} | ||
if (includeExclude != null && !acceptedGlobalOrdinals.get(globalOrd)) { | ||
continue; | ||
} | ||
final long bucketOrd = getBucketOrd(globalTermOrd); | ||
final int bucketDocCount = bucketOrd < 0 ? 0 : bucketDocCount(bucketOrd); | ||
if (bucketCountThresholds.getMinDocCount() > 0 && bucketDocCount == 0) { | ||
continue; | ||
} | ||
otherDocCount += bucketDocCount; | ||
spare.globalOrd = globalTermOrd; | ||
spare.globalOrd = globalOrd; | ||
spare.bucketOrd = bucketOrd; | ||
spare.docCount = bucketDocCount; | ||
if (bucketCountThresholds.getShardMinDocCount() <= spare.docCount) { | ||
|
@@ -378,7 +385,7 @@ private void mapSegmentCountsToGlobalCounts(LongUnaryOperator mapping) throws IO | |
} | ||
final long ord = i - 1; // remember we do +1 when counting | ||
final long globalOrd = mapping.applyAsLong(ord); | ||
long bucketOrd = getBucketOrd(globalOrd); | ||
long bucketOrd = bucketOrds == null ? globalOrd : bucketOrds.find(globalOrd); | ||
incrementBucketDocCount(bucketOrd, inc); | ||
} | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo - "needsFullScan"