-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Introduce execution hint for Cardinality aggregation #17301
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
Closed
asimmahmood1
wants to merge
23
commits into
opensearch-project:main
from
asimmahmood1:execution_hint
Closed
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
cabf900
Introduce execution hint for Cardinality aggregation
maitreya2954 0101e9f
Cleanup ExecutionMode enum declarations
maitreya2954 6f7ba1d
Remove unwanted lines
maitreya2954 fc14339
toString overrided for ExecutionHint
maitreya2954 7bca633
Testcases added for CardinalityAggregator execution hint
maitreya2954 7e62f5d
Test case for invalid execution hint added
maitreya2954 521939a
Java tags added for ExecutionMode
maitreya2954 0bd75bf
Test method names corrected
maitreya2954 fd02f7d
gradle format checks
maitreya2954 a6f3c65
Forbidden Apis fixed
maitreya2954 e205165
Merge branch 'main' into cardinality_agg_collectors_hint
maitreya2954 f8a2f4e
Introduce execution hint for Cardinality aggregation
maitreya2954 46c928e
Cleanup ExecutionMode enum declarations
maitreya2954 2d0bcf2
Remove unwanted lines
maitreya2954 5eca3a2
toString overrided for ExecutionHint
maitreya2954 9e34005
Testcases added for CardinalityAggregator execution hint
maitreya2954 3b8fc86
Test case for invalid execution hint added
maitreya2954 7ef6172
Java tags added for ExecutionMode
maitreya2954 16782fb
Test method names corrected
maitreya2954 3ea1a36
gradle format checks
maitreya2954 046f4e3
Forbidden Apis fixed
maitreya2954 c582cdc
Update Changelog
asimmahmood1 f4c2e05
Merge branch 'main' into execution_hint
asimmahmood1 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -89,6 +89,7 @@ public class CardinalityAggregator extends NumericMetricsAggregator.SingleValue | |
|
|
||
| private static final Logger logger = LogManager.getLogger(CardinalityAggregator.class); | ||
|
|
||
| private final CardinalityAggregatorFactory.ExecutionMode executionMode; | ||
| private final int precision; | ||
| private final ValuesSource valuesSource; | ||
|
|
||
|
|
@@ -111,6 +112,7 @@ public CardinalityAggregator( | |
| String name, | ||
| ValuesSourceConfig valuesSourceConfig, | ||
| int precision, | ||
| CardinalityAggregatorFactory.ExecutionMode executionMode, | ||
| SearchContext context, | ||
| Aggregator parent, | ||
| Map<String, Object> metadata | ||
|
|
@@ -121,6 +123,7 @@ public CardinalityAggregator( | |
| this.precision = precision; | ||
| this.counts = valuesSource == null ? null : new HyperLogLogPlusPlus(precision, context.bigArrays(), 1); | ||
| this.valuesSourceConfig = valuesSourceConfig; | ||
| this.executionMode = executionMode; | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -151,6 +154,9 @@ private Collector pickCollector(LeafReaderContext ctx) throws IOException { | |
| if (maxOrd == 0) { | ||
| emptyCollectorsUsed++; | ||
| return new EmptyCollector(); | ||
| } else if (executionMode == CardinalityAggregatorFactory.ExecutionMode.ORDINALS) { // Force OrdinalsCollector | ||
| ordinalsCollectorsUsed++; | ||
| collector = new OrdinalsCollector(counts, ordinalValues, context.bigArrays()); | ||
| } else { | ||
| final long ordinalsMemoryUsage = OrdinalsCollector.memoryOverhead(maxOrd); | ||
| final long countsMemoryUsage = HyperLogLogPlusPlus.memoryUsage(precision); | ||
|
|
@@ -480,7 +486,7 @@ public void close() { | |
| * | ||
| * @opensearch.internal | ||
| */ | ||
| private static class DirectCollector extends Collector { | ||
| public static class DirectCollector extends Collector { | ||
|
Member
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. Can these be package-protected? |
||
|
|
||
| private final MurmurHash3Values hashes; | ||
| private final HyperLogLogPlusPlus counts; | ||
|
|
@@ -517,7 +523,7 @@ public void close() { | |
| * | ||
| * @opensearch.internal | ||
| */ | ||
| private static class OrdinalsCollector extends Collector { | ||
| public static class OrdinalsCollector extends Collector { | ||
|
|
||
| private static final long SHALLOW_FIXEDBITSET_SIZE = RamUsageEstimator.shallowSizeOfInstance(FixedBitSet.class); | ||
|
|
||
|
|
||
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
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.
When making ser/de changes there can be issues in mixed clusters (fe during B/G) if this object is serialized to an older node that doesn't understand the value. In such cases, the serialization logic can check the target version (example) to see if the target node is of an older version and exclude it from serialization.
Similarly when deserializing if the request is coming from an older node then if you try to read the value from the StreamInput it will fail.
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.
Ah, good point, will update.