-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[Star Tree] [Search] Support for metric aggregations with/without term query #15289
base: main
Are you sure you want to change the base?
Conversation
❌ Gradle check result for ad54ace: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
❌ Gradle check result for 6c6be02: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
995db38
to
885a383
Compare
❌ Gradle check result for 995db38: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
❌ Gradle check result for 885a383: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
❌ Gradle check result for 9491aae: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
❌ Gradle check result for a01c6e2: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
server/src/main/java/org/opensearch/index/query/QueryShardContext.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/opensearch/search/startree/StarTreeFilter.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/opensearch/search/startree/StarTreeQuery.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/opensearch/search/startree/StarTreeQuery.java
Outdated
Show resolved
Hide resolved
❌ Gradle check result for e4a270a: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
d812134
to
addb332
Compare
Signed-off-by: Sandesh Kumar <[email protected]>
Signed-off-by: Sandesh Kumar <[email protected]>
Signed-off-by: Sandesh Kumar <[email protected]>
Signed-off-by: Sandesh Kumar <[email protected]>
Signed-off-by: Sandesh Kumar <[email protected]>
Signed-off-by: Sandesh Kumar <[email protected]>
Signed-off-by: Sandesh Kumar <[email protected]>
Signed-off-by: Sandesh Kumar <[email protected]>
Signed-off-by: Sandesh Kumar <[email protected]>
Signed-off-by: Sandesh Kumar <[email protected]>
Signed-off-by: Sandesh Kumar <[email protected]>
Signed-off-by: Sandesh Kumar <[email protected]>
Signed-off-by: Sandesh Kumar <[email protected]>
Signed-off-by: Sandesh Kumar <[email protected]>
Signed-off-by: Sandesh Kumar <[email protected]>
Signed-off-by: Sandesh Kumar <[email protected]>
Signed-off-by: Sandesh Kumar <[email protected]>
Signed-off-by: Sandesh Kumar <[email protected]>
Signed-off-by: Sandesh Kumar <[email protected]>
Signed-off-by: Sandesh Kumar <[email protected]>
Signed-off-by: Sandesh Kumar <[email protected]>
Signed-off-by: Sandesh Kumar <[email protected]>
Signed-off-by: Sandesh Kumar <[email protected]>
Signed-off-by: Sandesh Kumar <[email protected]>
...in/java/org/opensearch/index/compositeindex/datacube/startree/utils/StarTreeQueryHelper.java
Show resolved
Hide resolved
...in/java/org/opensearch/index/compositeindex/datacube/startree/utils/StarTreeQueryHelper.java
Outdated
Show resolved
Hide resolved
if (!supportedDimensions.contains(field)) { | ||
return null; | ||
} | ||
long inputQueryVal = Long.parseLong(tq.value().toString()); |
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.
I guess you kind of have a check on the indexing side of things, since we currently only support dimensions defined over numeric fields, I think. So, the field wouldn't be present in supportedDimensions
if it's not numeric. Eventually, we will want to support non-string values, though, right?
server/src/main/java/org/opensearch/search/aggregations/metrics/SumAggregator.java
Outdated
Show resolved
Hide resolved
final DocIdSetBuilder _matchedDocIds; | ||
final Set<String> _remainingPredicateColumns; |
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.
Why do these field names start with underscore? That's kind of weird in Java.
* @opensearch.experimental | ||
* @opensearch.internal | ||
*/ | ||
public class StarTreeFilter { |
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.
Can you please add a dedicated unit test for this class with some randomized testing?
It has a lot of uncovered lines, and this logic is key to making sure the whole thing works.
Also, it would be nice to make this class package-private, since it's only used to help StarTreeQueryHelper
. Would it make sense to move StarTreeQueryHelper
into this package? Or move this class into that package? It feels like they should be in the same package, since they're closely connected.
Also, I'm not sure I see any value in instantiating an object of this class. The caller has StarTreeValues
and a set of predicateEvaluators
. They want to pass both to this code to get back a FixedBitSet
. Passing them in the constructor and immediately calling getStarTreeResult
is allocating an object that will never be used for anything else.
In theory, this whole thing could be a couple of static methods in StarTreeQueryHelper
. (That said, we should still have more unit test coverage, regardless of where it lands.)
server/src/main/java/org/opensearch/search/startree/StarTreeQueryContext.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/opensearch/search/startree/StarTreeQueryContext.java
Outdated
Show resolved
Hide resolved
if (cacheStarTreeValues) { | ||
starTreeValuesMap = new ConcurrentHashMap<>(); | ||
} |
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.
I would avoid the ConcurrentHashMap
and either take the IndexReader
as input and say starTreeValuesMap = new FixedBitSet[reader.leaves().size()]
or you could take numLeaves
as a parameter and say starTreeValuesMap = new FixedBitSet[numLeaves]
. (I have no real preference either way.)
If cacheStarTreeValues
is false
, you just say starTreeValuesMap = null
.
Then you could add a pair of methods:
FixedBitSet getStarTreeValues(LeafReaderContext ctx) {
if (starTreeValuesMap != null) {
return starTreeValuesMap[ctx.ord];
}
return null;
}
void setStarTreeValues(LeafReaderContext ctx, FixedBitSet values) {
if (starTreeValuesMap != null) {
starTreeValuesMap[ctx.ord] = values;
}
}
Nothing needs to be volatile
and no need for a ConcurrentHashMap
.
Signed-off-by: Sandesh Kumar <[email protected]>
❌ Gradle check result for c7b70b0: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
Disclaimer
These changes are built on top of unmerged/in-review indexing changes, Reviewers kindly ignore this commit while reviewing this change. When the depending changes are merged, will remove theDo not merge
from title, and addchngelog
to the PR - avoiding adding now to avoid unnecessary rebasing/conflicts.Description
For an index supporting star-tree composite index, this changes tries to achieve resolving a metric aggregation with/without a numeric terms query with the help of star-tree.
In present state, the PR capture changes for sum, max, min, avg, value-count aggregation.
Once the high level changes in sum aggregation are reviewed, will increment with other aggregations.Approach
A new StarTreeQuery is introduced which helps resolve to star-tree documents. This star-tree query is formed (if it can be) at the shard level, this is not done at coordinator level to avoid node to node transportation. Also, all the information is present at shard level and OpenSearch does majority of query rewrite at shard level itself. This star tree query is encapsulated in an OriginalOrStarTreeQuery which helps preserve the original query alongwith the new star tree query. This encapsulation is done so as to preserve both the queries and decision whether to use which query can be taken at a segment level.
High Level Operations (to make code reviewing simple):
TODO in this PR:
This PR depends on #14809, therefore the depending unmerged changes have been utilized for now in my private fork to discuss the changes in parallel.
Example query shape:
No query + Agg:
Original Response:
Star Tree Response:
Request:
Original Response:
Star Tree Flow Response:
Multi-aggs in a single request:
Star Tree Response:
Unsupported Metric Operation via star-tree:
Defaults to original code-flow (verified by hits reported):
Approach:
Related Issues
#15257
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.