forked from opensearch-project/OpenSearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Star Tree] [Search] Resolve Date histogram with metric aggregation u…
…sing star-tree (opensearch-project#16674) --------- Signed-off-by: Sandesh Kumar <[email protected]> Co-authored-by: Sandesh Kumar <[email protected]>
- Loading branch information
1 parent
e6fc600
commit b5234a5
Showing
19 changed files
with
1,144 additions
and
78 deletions.
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
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
75 changes: 75 additions & 0 deletions
75
server/src/main/java/org/opensearch/search/aggregations/StarTreeBucketCollector.java
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 |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* 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 org.apache.lucene.util.FixedBitSet; | ||
import org.opensearch.common.annotation.ExperimentalApi; | ||
import org.opensearch.index.compositeindex.datacube.startree.index.StarTreeValues; | ||
|
||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* Collector for star tree aggregation | ||
* This abstract class exposes utilities to help avoid traversing star-tree multiple times and | ||
* collect relevant metrics across nested aggregations in a single traversal | ||
* @opensearch.internal | ||
*/ | ||
@ExperimentalApi | ||
public abstract class StarTreeBucketCollector { | ||
|
||
protected final StarTreeValues starTreeValues; | ||
protected final FixedBitSet matchingDocsBitSet; | ||
protected final List<StarTreeBucketCollector> subCollectors = new ArrayList<>(); | ||
|
||
public StarTreeBucketCollector(StarTreeValues starTreeValues, FixedBitSet matchingDocsBitSet) throws IOException { | ||
this.starTreeValues = starTreeValues; | ||
this.matchingDocsBitSet = matchingDocsBitSet; | ||
this.setSubCollectors(); | ||
} | ||
|
||
public StarTreeBucketCollector(StarTreeBucketCollector parent) throws IOException { | ||
this.starTreeValues = parent.getStarTreeValues(); | ||
this.matchingDocsBitSet = parent.getMatchingDocsBitSet(); | ||
this.setSubCollectors(); | ||
} | ||
|
||
/** | ||
* Sets the sub-collectors to track nested aggregators | ||
*/ | ||
public void setSubCollectors() throws IOException {}; | ||
|
||
/** | ||
* Returns a list of sub-collectors to track nested aggregators | ||
*/ | ||
public List<StarTreeBucketCollector> getSubCollectors() { | ||
return subCollectors; | ||
} | ||
|
||
/** | ||
* Returns the tree values to iterate | ||
*/ | ||
public StarTreeValues getStarTreeValues() { | ||
return starTreeValues; | ||
} | ||
|
||
/** | ||
* Returns the matching docs bitset to iterate upon the star-tree values based on search query | ||
*/ | ||
public FixedBitSet getMatchingDocsBitSet() { | ||
return matchingDocsBitSet; | ||
} | ||
|
||
/** | ||
* Collects the star tree entry and bucket ordinal to update | ||
* The method implementation should identify the metrics to collect from that star-tree entry to the specified bucket | ||
*/ | ||
public abstract void collectStarTreeEntry(int starTreeEntry, long bucket) throws IOException; | ||
} |
32 changes: 32 additions & 0 deletions
32
server/src/main/java/org/opensearch/search/aggregations/StarTreePreComputeCollector.java
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* 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 org.apache.lucene.index.LeafReaderContext; | ||
import org.opensearch.index.codec.composite.CompositeIndexFieldInfo; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* This interface is used to pre-compute the star tree bucket collector for each segment/leaf. | ||
* It is utilized by parent aggregation to retrieve a StarTreeBucketCollector which can be used to | ||
* pre-compute the associated aggregation along with its parent pre-computation using star-tree | ||
* | ||
* @opensearch.internal | ||
*/ | ||
public interface StarTreePreComputeCollector { | ||
/** | ||
* Get the star tree bucket collector for the specified segment/leaf | ||
*/ | ||
StarTreeBucketCollector getStarTreeBucketCollector( | ||
LeafReaderContext ctx, | ||
CompositeIndexFieldInfo starTree, | ||
StarTreeBucketCollector parentCollector | ||
) throws IOException; | ||
} |
Oops, something went wrong.