-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
[Draft] [Star Tree] [Search] Resolving Date histogram with metric aggregation using star-tree #16674
base: main
Are you sure you want to change the base?
[Draft] [Star Tree] [Search] Resolving Date histogram with metric aggregation using star-tree #16674
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/// * | ||
// * SPDX-License-Identifier: Apache-2.0 | ||
// * | ||
// * The OpenSearch Contributors require contributions made to | ||
// * this file be licensed under the Apache-2.0 license or a | ||
// * compatible open source license. | ||
// */ | ||
// | ||
// package org.opensearch.search.aggregations; | ||
// | ||
// import java.io.IOException; | ||
// | ||
// public abstract class StarTreeBucketCollector extends LeafBucketCollector { | ||
// | ||
// public abstract void collectStarEntry(int starTreeEntry, long bucket) throws IOException; | ||
// } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/// * | ||
// * SPDX-License-Identifier: Apache-2.0 | ||
// * | ||
// * The OpenSearch Contributors require contributions made to | ||
// * this file be licensed under the Apache-2.0 license or a | ||
// * compatible open source license. | ||
// */ | ||
// | ||
/// * | ||
// * Modifications Copyright OpenSearch Contributors. See | ||
// * GitHub history for details. | ||
// */ | ||
// package org.opensearch.search.aggregations; | ||
// | ||
// import org.apache.lucene.search.Scorable; | ||
// import org.opensearch.common.lucene.ScorerAware; | ||
// | ||
// import java.io.IOException; | ||
// | ||
/// ** | ||
// * A {@link LeafBucketCollector} that delegates all calls to the sub leaf | ||
// * aggregator and sets the scorer on its source of values if it implements | ||
// * {@link ScorerAware}. | ||
// * | ||
// * @opensearch.internal | ||
// */ | ||
// public class StarTreeLeafBucketCollectorBase extends StarTreeBucketCollector { | ||
// private final LeafBucketCollector sub; | ||
// private final ScorerAware values; | ||
// | ||
// /** | ||
// * @param sub The leaf collector for sub aggregations. | ||
// * @param values The values. {@link ScorerAware#setScorer} will be called automatically on them if they implement {@link ScorerAware}. | ||
// */ | ||
// public StarTreeLeafBucketCollectorBase(LeafBucketCollector sub, Object values) { | ||
// this.sub = sub; | ||
// if (values instanceof ScorerAware) { | ||
// this.values = (ScorerAware) values; | ||
// } else { | ||
// this.values = null; | ||
// } | ||
// } | ||
// | ||
// @Override | ||
// public void setScorer(Scorable s) throws IOException { | ||
// sub.setScorer(s); | ||
// if (values != null) { | ||
// values.setScorer(s); | ||
// } | ||
// } | ||
// | ||
// @Override | ||
// public void collect(int doc, long bucket) throws IOException { | ||
// sub.collect(doc, bucket); | ||
// } | ||
// | ||
// @Override | ||
// public void collectStarEntry(int starTreeEntry, long bucket) throws IOException {} | ||
// } |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -129,6 +129,15 @@ public final void collectExistingBucket(LeafBucketCollector subCollector, int do | |
subCollector.collect(doc, bucketOrd); | ||
} | ||
|
||
public final void collectStarTreeBucket(long docCount, long bucketOrd) | ||
throws IOException { | ||
if (docCounts.increment(bucketOrd, docCount) == docCount) { | ||
multiBucketConsumer.accept(0); | ||
} | ||
// Only collect own bucket & not sub-aggregator buckets | ||
// subCollector.collectStarEntry(entryBit, bucketOrd); | ||
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. This line won't exist, right? Could we also do this by calling |
||
} | ||
|
||
/** | ||
* This only tidies up doc counts. Call {@link MergingBucketsDeferringCollector#mergeBuckets(long[])} to merge the actual | ||
* ordinals and doc ID deltas. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.search.aggregations.metrics; | ||
|
||
import org.apache.lucene.index.LeafReaderContext; | ||
import org.opensearch.index.codec.composite.CompositeIndexFieldInfo; | ||
import org.opensearch.search.aggregations.bucket.terms.LongKeyedBucketOrds; | ||
|
||
import java.io.IOException; | ||
|
||
public interface StarTreeCollector { | ||
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. Maybe call this |
||
// public void collectStarEntry(int starTreeEntryBit, long bucket) throws IOException; | ||
|
||
public void preCompute(LeafReaderContext ctx, CompositeIndexFieldInfo starTree, LongKeyedBucketOrds bucketOrds) throws IOException; | ||
} |
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.
We can probably have a recursive method which checks if parent aggregator is star tree supported and if children aggregators are supported and so on.
And we can make the supported aggregators configurable.