forked from elastic/elasticsearch
-
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.
Add Aggregation Execution Context (elastic#85011)
Adds a place to store information during aggregation execution and use this context to store the current tsid. It allows us to achieve 3x improvement in the timeseries aggregation execution speed. In a follow up PR, I would like to remove the inheritance of BucketCollector from Collector and instead try wrapping it into a collector when needed. This should prevent us form using getLeafCollector(LeafReaderContext ctx) method in a wrong context in future. Relates to elastic#74660
- Loading branch information
Showing
17 changed files
with
126 additions
and
72 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
40 changes: 40 additions & 0 deletions
40
server/src/main/java/org/elasticsearch/search/aggregations/AggregationExecutionContext.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,40 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.search.aggregations; | ||
|
||
import org.apache.lucene.index.LeafReaderContext; | ||
import org.apache.lucene.util.BytesRef; | ||
import org.elasticsearch.common.CheckedSupplier; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* Used to preserve contextual information during aggregation execution. It can be used by search executors and parent | ||
* aggregations to provide contextual information for the child aggregation during execution such as the currently executed | ||
* time series id or the size of the current date histogram bucket. The information provided by this class is highly contextual and | ||
* only valid during the {@link LeafBucketCollector#collect} call. | ||
*/ | ||
public class AggregationExecutionContext { | ||
|
||
private final CheckedSupplier<BytesRef, IOException> tsidProvider; | ||
private final LeafReaderContext leafReaderContext; | ||
|
||
public AggregationExecutionContext(LeafReaderContext leafReaderContext, CheckedSupplier<BytesRef, IOException> tsidProvider) { | ||
this.leafReaderContext = leafReaderContext; | ||
this.tsidProvider = tsidProvider; | ||
} | ||
|
||
public LeafReaderContext getLeafReaderContext() { | ||
return leafReaderContext; | ||
} | ||
|
||
public BytesRef getTsid() throws IOException { | ||
return tsidProvider != null ? tsidProvider.get() : null; | ||
} | ||
} |
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
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
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
Oops, something went wrong.