diff --git a/docs/reference/aggregations.asciidoc b/docs/reference/aggregations.asciidoc index c6fb674834e..2464873b452 100644 --- a/docs/reference/aggregations.asciidoc +++ b/docs/reference/aggregations.asciidoc @@ -23,7 +23,7 @@ it is often easier to break them into two main families: <>:: Aggregations that keep track and compute metrics over a set of documents. -<>:: +<>:: Aggregations that aggregate the output of other aggregations and their associated metrics The interesting part comes next. Since each bucket effectively defines a document set (all documents belonging to @@ -100,6 +100,6 @@ include::aggregations/metrics.asciidoc[] include::aggregations/bucket.asciidoc[] -include::aggregations/reducer.asciidoc[] +include::aggregations/pipeline.asciidoc[] include::aggregations/misc.asciidoc[] diff --git a/docs/reference/aggregations/reducer.asciidoc b/docs/reference/aggregations/pipeline.asciidoc similarity index 69% rename from docs/reference/aggregations/reducer.asciidoc rename to docs/reference/aggregations/pipeline.asciidoc index 33f82e78523..c991086532e 100644 --- a/docs/reference/aggregations/reducer.asciidoc +++ b/docs/reference/aggregations/pipeline.asciidoc @@ -1,39 +1,39 @@ -[[search-aggregations-reducer]] +[[search-aggregations-pipeline]] -== Reducer Aggregations +== Pipeline Aggregations coming[2.0.0] experimental[] -Reducer aggregations work on the outputs produced from other aggregations rather than from document sets, adding -information to the output tree. There are many different types of reducer, each computing different information from +Pipeline aggregations work on the outputs produced from other aggregations rather than from document sets, adding +information to the output tree. There are many different types of pipeline aggregation, each computing different information from other aggregations, but these types can broken down into two families: _Parent_:: - A family of reducer aggregations that is provided with the output of its parent aggregation and is able + A family of pipeline aggregations that is provided with the output of its parent aggregation and is able to compute new buckets or new aggregations to add to existing buckets. _Sibling_:: - Reducer aggregations that are provided with the output of a sibling aggregation and are able to compute a + Pipeline aggregations that are provided with the output of a sibling aggregation and are able to compute a new aggregation which will be at the same level as the sibling aggregation. -Reducer aggregations can reference the aggregations they need to perform their computation by using the `buckets_paths` +Pipeline aggregations can reference the aggregations they need to perform their computation by using the `buckets_paths` parameter to indicate the paths to the required metrics. The syntax for defining these paths can be found in the <> section below. -Reducer aggregations cannot have sub-aggregations but depending on the type it can reference another reducer in the `buckets_path` -allowing reducers to be chained. For example, you can chain together two derivatives to calculate the second derivative +Pipeline aggregations cannot have sub-aggregations but depending on the type it can reference another pipeline in the `buckets_path` +allowing pipeline aggregations to be chained. For example, you can chain together two derivatives to calculate the second derivative (e.g. a derivative of a derivative). -NOTE: Because reducer aggregations only add to the output, when chaining reducer aggregations the output of each reducer will be -included in the final output. +NOTE: Because pipeline aggregations only add to the output, when chaining pipeline aggregations the output of each pipeline aggregation +will be included in the final output. [[bucket-path-syntax]] [float] === `buckets_path` Syntax -Most reducers require another aggregation as their input. The input aggregation is defined via the `buckets_path` +Most pipeline aggregations require another aggregation as their input. The input aggregation is defined via the `buckets_path` parameter, which follows a specific format: -------------------------------------------------- @@ -47,7 +47,7 @@ PATH := []*[my_stats.avg"` will path to the `avg` value in the `"my_stats"` metric, which is contained in the `"my_bucket"` bucket aggregation. -Paths are relative from the position of the reducer; they are not absolute paths, and the path cannot go back "up" the +Paths are relative from the position of the pipeline aggregation; they are not absolute paths, and the path cannot go back "up" the aggregation tree. For example, this moving average is embedded inside a date_histogram and refers to a "sibling" metric `"the_sum"`: @@ -73,7 +73,7 @@ metric `"the_sum"`: <1> The metric is called `"the_sum"` <2> The `buckets_path` refers to the metric via a relative path `"the_sum"` -`buckets_path` is also used for Sibling reducer aggregations, where the aggregation is "next" to a series of buckets +`buckets_path` is also used for Sibling pipeline aggregations, where the aggregation is "next" to a series of buckets instead of embedded "inside" them. For example, the `max_bucket` aggregation uses the `buckets_path` to specify a metric embedded inside a sibling aggregation: @@ -109,7 +109,7 @@ a metric embedded inside a sibling aggregation: ==== Special Paths Instead of pathing to a metric, `buckets_path` can use a special `"_count"` path. This instructs -the reducer to use the document count as it's input. For example, a moving average can be calculated on the document +the pipeline aggregation to use the document count as it's input. For example, a moving average can be calculated on the document count of each bucket, instead of a specific metric: [source,js] @@ -141,7 +141,7 @@ There are a couple of reasons why the data output by the enclosing histogram may on the enclosing histogram or with a query matching only a small number of documents) Where there is no data available in a bucket for a given metric it presents a problem for calculating the derivative value for both -the current bucket and the next bucket. In the derivative reducer aggregation has a `gap policy` parameter to define what the behavior +the current bucket and the next bucket. In the derivative pipeline aggregation has a `gap policy` parameter to define what the behavior should be when a gap in the data is found. There are currently two options for controlling the gap policy: _skip_:: @@ -154,9 +154,9 @@ _insert_zeros_:: -include::reducer/avg-bucket-aggregation.asciidoc[] -include::reducer/derivative-aggregation.asciidoc[] -include::reducer/max-bucket-aggregation.asciidoc[] -include::reducer/min-bucket-aggregation.asciidoc[] -include::reducer/sum-bucket-aggregation.asciidoc[] -include::reducer/movavg-aggregation.asciidoc[] +include::pipeline/avg-bucket-aggregation.asciidoc[] +include::pipeline/derivative-aggregation.asciidoc[] +include::pipeline/max-bucket-aggregation.asciidoc[] +include::pipeline/min-bucket-aggregation.asciidoc[] +include::pipeline/sum-bucket-aggregation.asciidoc[] +include::pipeline/movavg-aggregation.asciidoc[] diff --git a/docs/reference/aggregations/reducer/avg-bucket-aggregation.asciidoc b/docs/reference/aggregations/pipeline/avg-bucket-aggregation.asciidoc similarity index 93% rename from docs/reference/aggregations/reducer/avg-bucket-aggregation.asciidoc rename to docs/reference/aggregations/pipeline/avg-bucket-aggregation.asciidoc index 5c2d6b22db8..aaedece66d7 100644 --- a/docs/reference/aggregations/reducer/avg-bucket-aggregation.asciidoc +++ b/docs/reference/aggregations/pipeline/avg-bucket-aggregation.asciidoc @@ -1,7 +1,7 @@ -[[search-aggregations-reducer-avg-bucket-aggregation]] +[[search-aggregations-pipeline-avg-bucket-aggregation]] === Avg Bucket Aggregation -A sibling reducer aggregation which calculates the (mean) average value of a specified metric in a sibling aggregation. +A sibling pipeline aggregation which calculates the (mean) average value of a specified metric in a sibling aggregation. The specified metric must be numeric and the sibling aggregation must be a multi-bucket aggregation. ==== Syntax diff --git a/docs/reference/aggregations/reducer/derivative-aggregation.asciidoc b/docs/reference/aggregations/pipeline/derivative-aggregation.asciidoc similarity index 95% rename from docs/reference/aggregations/reducer/derivative-aggregation.asciidoc rename to docs/reference/aggregations/pipeline/derivative-aggregation.asciidoc index 766172f350b..97804fc067f 100644 --- a/docs/reference/aggregations/reducer/derivative-aggregation.asciidoc +++ b/docs/reference/aggregations/pipeline/derivative-aggregation.asciidoc @@ -1,7 +1,7 @@ -[[search-aggregations-reducer-derivative-aggregation]] +[[search-aggregations-pipeline-derivative-aggregation]] === Derivative Aggregation -A parent reducer aggregation which calculates the derivative of a specified metric in a parent histogram (or date_histogram) +A parent pipeline aggregation which calculates the derivative of a specified metric in a parent histogram (or date_histogram) aggregation. The specified metric must be numeric and the enclosing histogram must have `min_doc_count` set to `0` (default for `histogram` aggregations). @@ -112,8 +112,8 @@ would be $/month assuming the `price` field has units of $. ==== Second Order Derivative -A second order derivative can be calculated by chaining the derivative reducer aggregation onto the result of another derivative -reducer aggregation as in the following example which will calculate both the first and the second order derivative of the total +A second order derivative can be calculated by chaining the derivative pipeline aggregation onto the result of another derivative +pipeline aggregation as in the following example which will calculate both the first and the second order derivative of the total monthly sales: [source,js] diff --git a/docs/reference/aggregations/reducer/max-bucket-aggregation.asciidoc b/docs/reference/aggregations/pipeline/max-bucket-aggregation.asciidoc similarity index 93% rename from docs/reference/aggregations/reducer/max-bucket-aggregation.asciidoc rename to docs/reference/aggregations/pipeline/max-bucket-aggregation.asciidoc index 703702a1a81..226ec61065c 100644 --- a/docs/reference/aggregations/reducer/max-bucket-aggregation.asciidoc +++ b/docs/reference/aggregations/pipeline/max-bucket-aggregation.asciidoc @@ -1,7 +1,7 @@ -[[search-aggregations-reducer-max-bucket-aggregation]] +[[search-aggregations-pipeline-max-bucket-aggregation]] === Max Bucket Aggregation -A sibling reducer aggregation which identifies the bucket(s) with the maximum value of a specified metric in a sibling aggregation +A sibling pipeline aggregation which identifies the bucket(s) with the maximum value of a specified metric in a sibling aggregation and outputs both the value and the key(s) of the bucket(s). The specified metric must be numeric and the sibling aggregation must be a multi-bucket aggregation. diff --git a/docs/reference/aggregations/reducer/min-bucket-aggregation.asciidoc b/docs/reference/aggregations/pipeline/min-bucket-aggregation.asciidoc similarity index 93% rename from docs/reference/aggregations/reducer/min-bucket-aggregation.asciidoc rename to docs/reference/aggregations/pipeline/min-bucket-aggregation.asciidoc index d03e5ddb6c9..478441a27f9 100644 --- a/docs/reference/aggregations/reducer/min-bucket-aggregation.asciidoc +++ b/docs/reference/aggregations/pipeline/min-bucket-aggregation.asciidoc @@ -1,7 +1,7 @@ -[[search-aggregations-reducer-min-bucket-aggregation]] +[[search-aggregations-pipeline-min-bucket-aggregation]] === Min Bucket Aggregation -A sibling reducer aggregation which identifies the bucket(s) with the minimum value of a specified metric in a sibling aggregation +A sibling pipeline aggregation which identifies the bucket(s) with the minimum value of a specified metric in a sibling aggregation and outputs both the value and the key(s) of the bucket(s). The specified metric must be numeric and the sibling aggregation must be a multi-bucket aggregation. diff --git a/docs/reference/aggregations/reducer/movavg-aggregation.asciidoc b/docs/reference/aggregations/pipeline/movavg-aggregation.asciidoc similarity index 94% rename from docs/reference/aggregations/reducer/movavg-aggregation.asciidoc rename to docs/reference/aggregations/pipeline/movavg-aggregation.asciidoc index ef5f97e12ee..a4e20793849 100644 --- a/docs/reference/aggregations/reducer/movavg-aggregation.asciidoc +++ b/docs/reference/aggregations/pipeline/movavg-aggregation.asciidoc @@ -1,4 +1,4 @@ -[[search-aggregations-reducers-movavg-reducer]] +[[search-aggregations-pipeline-movavg-aggregation]] === Moving Average Aggregation Given an ordered series of data, the Moving Average aggregation will slide a window across the data and emit the average @@ -109,14 +109,14 @@ track the data and only smooth out small scale fluctuations: [[movavg_10window]] .Moving average with window of size 10 -image::images/reducers_movavg/movavg_10window.png[] +image::images/pipeline_movavg/movavg_10window.png[] In contrast, a `simple` moving average with larger window (`"window": 100`) will smooth out all higher-frequency fluctuations, leaving only low-frequency, long term trends. It also tends to "lag" behind the actual data by a substantial amount: [[movavg_100window]] .Moving average with window of size 100 -image::images/reducers_movavg/movavg_100window.png[] +image::images/pipeline_movavg/movavg_100window.png[] ==== Linear @@ -143,7 +143,7 @@ will closely track the data and only smooth out small scale fluctuations: [[linear_10window]] .Linear moving average with window of size 10 -image::images/reducers_movavg/linear_10window.png[] +image::images/pipeline_movavg/linear_10window.png[] In contrast, a `linear` moving average with larger window (`"window": 100`) will smooth out all higher-frequency fluctuations, leaving only low-frequency, long term trends. It also tends to "lag" behind the actual data by a substantial amount, @@ -151,7 +151,7 @@ although typically less than the `simple` model: [[linear_100window]] .Linear moving average with window of size 100 -image::images/reducers_movavg/linear_100window.png[] +image::images/pipeline_movavg/linear_100window.png[] ==== EWMA (Exponentially Weighted) @@ -181,11 +181,11 @@ The default value of `alpha` is `0.5`, and the setting accepts any float from 0- [[single_0.2alpha]] .Single Exponential moving average with window of size 10, alpha = 0.2 -image::images/reducers_movavg/single_0.2alpha.png[] +image::images/pipeline_movavg/single_0.2alpha.png[] [[single_0.7alpha]] .Single Exponential moving average with window of size 10, alpha = 0.7 -image::images/reducers_movavg/single_0.7alpha.png[] +image::images/pipeline_movavg/single_0.7alpha.png[] ==== Holt-Linear @@ -224,11 +224,11 @@ values emphasize short-term trends. This will become more apparently when you a [[double_0.2beta]] .Double Exponential moving average with window of size 100, alpha = 0.5, beta = 0.2 -image::images/reducers_movavg/double_0.2beta.png[] +image::images/pipeline_movavg/double_0.2beta.png[] [[double_0.7beta]] .Double Exponential moving average with window of size 100, alpha = 0.5, beta = 0.7 -image::images/reducers_movavg/double_0.7beta.png[] +image::images/pipeline_movavg/double_0.7beta.png[] ==== Prediction @@ -256,7 +256,7 @@ of the last value in the series, producing a flat: [[simple_prediction]] .Simple moving average with window of size 10, predict = 50 -image::images/reducers_movavg/simple_prediction.png[] +image::images/pipeline_movavg/simple_prediction.png[] In contrast, the `holt` model can extrapolate based on local or global constant trends. If we set a high `beta` value, we can extrapolate based on local constant trends (in this case the predictions head down, because the data at the end @@ -264,11 +264,11 @@ of the series was heading in a downward direction): [[double_prediction_local]] .Double Exponential moving average with window of size 100, predict = 20, alpha = 0.5, beta = 0.8 -image::images/reducers_movavg/double_prediction_local.png[] +image::images/pipeline_movavg/double_prediction_local.png[] In contrast, if we choose a small `beta`, the predictions are based on the global constant trend. In this series, the global trend is slightly positive, so the prediction makes a sharp u-turn and begins a positive slope: [[double_prediction_global]] .Double Exponential moving average with window of size 100, predict = 20, alpha = 0.5, beta = 0.1 -image::images/reducers_movavg/double_prediction_global.png[] +image::images/pipeline_movavg/double_prediction_global.png[] diff --git a/docs/reference/aggregations/reducer/sum-bucket-aggregation.asciidoc b/docs/reference/aggregations/pipeline/sum-bucket-aggregation.asciidoc similarity index 93% rename from docs/reference/aggregations/reducer/sum-bucket-aggregation.asciidoc rename to docs/reference/aggregations/pipeline/sum-bucket-aggregation.asciidoc index 0a6a98cc977..b0624fac466 100644 --- a/docs/reference/aggregations/reducer/sum-bucket-aggregation.asciidoc +++ b/docs/reference/aggregations/pipeline/sum-bucket-aggregation.asciidoc @@ -1,7 +1,7 @@ -[[search-aggregations-reducer-sum-bucket-aggregation]] +[[search-aggregations-pipeline-sum-bucket-aggregation]] === Sum Bucket Aggregation -A sibling reducer aggregation which calculates the sum across all bucket of a specified metric in a sibling aggregation. +A sibling pipeline aggregation which calculates the sum across all bucket of a specified metric in a sibling aggregation. The specified metric must be numeric and the sibling aggregation must be a multi-bucket aggregation. ==== Syntax diff --git a/docs/reference/images/reducers_movavg/double_0.2beta.png b/docs/reference/images/pipeline_movavg/double_0.2beta.png similarity index 100% rename from docs/reference/images/reducers_movavg/double_0.2beta.png rename to docs/reference/images/pipeline_movavg/double_0.2beta.png diff --git a/docs/reference/images/reducers_movavg/double_0.7beta.png b/docs/reference/images/pipeline_movavg/double_0.7beta.png similarity index 100% rename from docs/reference/images/reducers_movavg/double_0.7beta.png rename to docs/reference/images/pipeline_movavg/double_0.7beta.png diff --git a/docs/reference/images/reducers_movavg/double_prediction_global.png b/docs/reference/images/pipeline_movavg/double_prediction_global.png similarity index 100% rename from docs/reference/images/reducers_movavg/double_prediction_global.png rename to docs/reference/images/pipeline_movavg/double_prediction_global.png diff --git a/docs/reference/images/reducers_movavg/double_prediction_local.png b/docs/reference/images/pipeline_movavg/double_prediction_local.png similarity index 100% rename from docs/reference/images/reducers_movavg/double_prediction_local.png rename to docs/reference/images/pipeline_movavg/double_prediction_local.png diff --git a/docs/reference/images/reducers_movavg/linear_100window.png b/docs/reference/images/pipeline_movavg/linear_100window.png similarity index 100% rename from docs/reference/images/reducers_movavg/linear_100window.png rename to docs/reference/images/pipeline_movavg/linear_100window.png diff --git a/docs/reference/images/reducers_movavg/linear_10window.png b/docs/reference/images/pipeline_movavg/linear_10window.png similarity index 100% rename from docs/reference/images/reducers_movavg/linear_10window.png rename to docs/reference/images/pipeline_movavg/linear_10window.png diff --git a/docs/reference/images/reducers_movavg/movavg_100window.png b/docs/reference/images/pipeline_movavg/movavg_100window.png similarity index 100% rename from docs/reference/images/reducers_movavg/movavg_100window.png rename to docs/reference/images/pipeline_movavg/movavg_100window.png diff --git a/docs/reference/images/reducers_movavg/movavg_10window.png b/docs/reference/images/pipeline_movavg/movavg_10window.png similarity index 100% rename from docs/reference/images/reducers_movavg/movavg_10window.png rename to docs/reference/images/pipeline_movavg/movavg_10window.png diff --git a/docs/reference/images/reducers_movavg/simple_prediction.png b/docs/reference/images/pipeline_movavg/simple_prediction.png similarity index 100% rename from docs/reference/images/reducers_movavg/simple_prediction.png rename to docs/reference/images/pipeline_movavg/simple_prediction.png diff --git a/docs/reference/images/reducers_movavg/single_0.2alpha.png b/docs/reference/images/pipeline_movavg/single_0.2alpha.png similarity index 100% rename from docs/reference/images/reducers_movavg/single_0.2alpha.png rename to docs/reference/images/pipeline_movavg/single_0.2alpha.png diff --git a/docs/reference/images/reducers_movavg/single_0.7alpha.png b/docs/reference/images/pipeline_movavg/single_0.7alpha.png similarity index 100% rename from docs/reference/images/reducers_movavg/single_0.7alpha.png rename to docs/reference/images/pipeline_movavg/single_0.7alpha.png diff --git a/src/main/java/org/elasticsearch/action/ActionRequestBuilder.java b/src/main/java/org/elasticsearch/action/ActionRequestBuilder.java index bbb2c508ebe..e675e8befed 100644 --- a/src/main/java/org/elasticsearch/action/ActionRequestBuilder.java +++ b/src/main/java/org/elasticsearch/action/ActionRequestBuilder.java @@ -20,6 +20,7 @@ package org.elasticsearch.action; import com.google.common.base.Preconditions; + import org.elasticsearch.ElasticsearchException; import org.elasticsearch.action.support.PlainListenableActionFuture; import org.elasticsearch.client.Client; @@ -27,7 +28,7 @@ import org.elasticsearch.client.ClusterAdminClient; import org.elasticsearch.client.ElasticsearchClient; import org.elasticsearch.client.IndicesAdminClient; import org.elasticsearch.common.unit.TimeValue; -import org.elasticsearch.search.aggregations.reducers.ReducerBuilder; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilder; import org.elasticsearch.threadpool.ThreadPool; /** diff --git a/src/main/java/org/elasticsearch/action/percolate/PercolateShardResponse.java b/src/main/java/org/elasticsearch/action/percolate/PercolateShardResponse.java index 6507dac6603..b731208def7 100644 --- a/src/main/java/org/elasticsearch/action/percolate/PercolateShardResponse.java +++ b/src/main/java/org/elasticsearch/action/percolate/PercolateShardResponse.java @@ -28,9 +28,9 @@ import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.percolator.PercolateContext; import org.elasticsearch.search.aggregations.InternalAggregations; -import org.elasticsearch.search.aggregations.reducers.Reducer; -import org.elasticsearch.search.aggregations.reducers.ReducerStreams; -import org.elasticsearch.search.aggregations.reducers.SiblingReducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorStreams; +import org.elasticsearch.search.aggregations.pipeline.SiblingPipelineAggregator; import org.elasticsearch.search.highlight.HighlightField; import org.elasticsearch.search.query.QuerySearchResult; @@ -56,7 +56,7 @@ public class PercolateShardResponse extends BroadcastShardOperationResponse { private int requestedSize; private InternalAggregations aggregations; - private List reducers; + private List pipelineAggregators; PercolateShardResponse() { hls = new ArrayList<>(); @@ -75,7 +75,7 @@ public class PercolateShardResponse extends BroadcastShardOperationResponse { if (result.aggregations() != null) { this.aggregations = (InternalAggregations) result.aggregations(); } - this.reducers = result.reducers(); + this.pipelineAggregators = result.pipelineAggregators(); } } @@ -119,8 +119,8 @@ public class PercolateShardResponse extends BroadcastShardOperationResponse { return aggregations; } - public List reducers() { - return reducers; + public List pipelineAggregators() { + return pipelineAggregators; } public byte percolatorTypeId() { @@ -156,14 +156,14 @@ public class PercolateShardResponse extends BroadcastShardOperationResponse { } aggregations = InternalAggregations.readOptionalAggregations(in); if (in.readBoolean()) { - int reducersSize = in.readVInt(); - List reducers = new ArrayList<>(reducersSize); - for (int i = 0; i < reducersSize; i++) { + int pipelineAggregatorsSize = in.readVInt(); + List pipelineAggregators = new ArrayList<>(pipelineAggregatorsSize); + for (int i = 0; i < pipelineAggregatorsSize; i++) { BytesReference type = in.readBytesReference(); - Reducer reducer = ReducerStreams.stream(type).readResult(in); - reducers.add((SiblingReducer) reducer); + PipelineAggregator pipelineAggregator = PipelineAggregatorStreams.stream(type).readResult(in); + pipelineAggregators.add((SiblingPipelineAggregator) pipelineAggregator); } - this.reducers = reducers; + this.pipelineAggregators = pipelineAggregators; } } @@ -190,14 +190,14 @@ public class PercolateShardResponse extends BroadcastShardOperationResponse { } } out.writeOptionalStreamable(aggregations); - if (reducers == null) { + if (pipelineAggregators == null) { out.writeBoolean(false); } else { out.writeBoolean(true); - out.writeVInt(reducers.size()); - for (Reducer reducer : reducers) { - out.writeBytesReference(reducer.type().stream()); - reducer.writeTo(out); + out.writeVInt(pipelineAggregators.size()); + for (PipelineAggregator pipelineAggregator : pipelineAggregators) { + out.writeBytesReference(pipelineAggregator.type().stream()); + pipelineAggregator.writeTo(out); } } } diff --git a/src/main/java/org/elasticsearch/percolator/PercolatorService.java b/src/main/java/org/elasticsearch/percolator/PercolatorService.java index 9fd56f11778..5503f8ecf8b 100644 --- a/src/main/java/org/elasticsearch/percolator/PercolatorService.java +++ b/src/main/java/org/elasticsearch/percolator/PercolatorService.java @@ -86,8 +86,8 @@ import org.elasticsearch.search.aggregations.AggregationPhase; import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.InternalAggregation.ReduceContext; import org.elasticsearch.search.aggregations.InternalAggregations; -import org.elasticsearch.search.aggregations.reducers.Reducer; -import org.elasticsearch.search.aggregations.reducers.SiblingReducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; +import org.elasticsearch.search.aggregations.pipeline.SiblingPipelineAggregator; import org.elasticsearch.search.highlight.HighlightField; import org.elasticsearch.search.highlight.HighlightPhase; import org.elasticsearch.search.internal.SearchContext; @@ -852,11 +852,11 @@ public class PercolatorService extends AbstractComponent { } InternalAggregations aggregations = InternalAggregations.reduce(aggregationsList, new ReduceContext(bigArrays, scriptService)); if (aggregations != null) { - List reducers = shardResults.get(0).reducers(); - if (reducers != null) { - List newAggs = new ArrayList<>(Lists.transform(aggregations.asList(), Reducer.AGGREGATION_TRANFORM_FUNCTION)); - for (SiblingReducer reducer : reducers) { - InternalAggregation newAgg = reducer.doReduce(new InternalAggregations(newAggs), new ReduceContext(bigArrays, + List pipelineAggregators = shardResults.get(0).pipelineAggregators(); + if (pipelineAggregators != null) { + List newAggs = new ArrayList<>(Lists.transform(aggregations.asList(), PipelineAggregator.AGGREGATION_TRANFORM_FUNCTION)); + for (SiblingPipelineAggregator pipelineAggregator : pipelineAggregators) { + InternalAggregation newAgg = pipelineAggregator.doReduce(new InternalAggregations(newAggs), new ReduceContext(bigArrays, scriptService)); newAggs.add(newAgg); } diff --git a/src/main/java/org/elasticsearch/search/aggregations/AggregationModule.java b/src/main/java/org/elasticsearch/search/aggregations/AggregationModule.java index 9c41dc63379..fd6eabd15f5 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/AggregationModule.java +++ b/src/main/java/org/elasticsearch/search/aggregations/AggregationModule.java @@ -56,14 +56,14 @@ import org.elasticsearch.search.aggregations.metrics.stats.extended.ExtendedStat import org.elasticsearch.search.aggregations.metrics.sum.SumParser; import org.elasticsearch.search.aggregations.metrics.tophits.TopHitsParser; import org.elasticsearch.search.aggregations.metrics.valuecount.ValueCountParser; -import org.elasticsearch.search.aggregations.reducers.Reducer; -import org.elasticsearch.search.aggregations.reducers.bucketmetrics.avg.AvgBucketParser; -import org.elasticsearch.search.aggregations.reducers.bucketmetrics.max.MaxBucketParser; -import org.elasticsearch.search.aggregations.reducers.bucketmetrics.min.MinBucketParser; -import org.elasticsearch.search.aggregations.reducers.bucketmetrics.sum.SumBucketParser; -import org.elasticsearch.search.aggregations.reducers.derivative.DerivativeParser; -import org.elasticsearch.search.aggregations.reducers.movavg.MovAvgParser; -import org.elasticsearch.search.aggregations.reducers.movavg.models.MovAvgModelModule; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; +import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.avg.AvgBucketParser; +import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.max.MaxBucketParser; +import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.min.MinBucketParser; +import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.sum.SumBucketParser; +import org.elasticsearch.search.aggregations.pipeline.derivative.DerivativeParser; +import org.elasticsearch.search.aggregations.pipeline.movavg.MovAvgParser; +import org.elasticsearch.search.aggregations.pipeline.movavg.models.MovAvgModelModule; import java.util.List; @@ -73,7 +73,7 @@ import java.util.List; public class AggregationModule extends AbstractModule implements SpawnModules{ private List> aggParsers = Lists.newArrayList(); - private List> reducerParsers = Lists.newArrayList(); + private List> pipelineAggParsers = Lists.newArrayList(); public AggregationModule() { aggParsers.add(AvgParser.class); @@ -108,12 +108,12 @@ public class AggregationModule extends AbstractModule implements SpawnModules{ aggParsers.add(ScriptedMetricParser.class); aggParsers.add(ChildrenParser.class); - reducerParsers.add(DerivativeParser.class); - reducerParsers.add(MaxBucketParser.class); - reducerParsers.add(MinBucketParser.class); - reducerParsers.add(AvgBucketParser.class); - reducerParsers.add(SumBucketParser.class); - reducerParsers.add(MovAvgParser.class); + pipelineAggParsers.add(DerivativeParser.class); + pipelineAggParsers.add(MaxBucketParser.class); + pipelineAggParsers.add(MinBucketParser.class); + pipelineAggParsers.add(AvgBucketParser.class); + pipelineAggParsers.add(SumBucketParser.class); + pipelineAggParsers.add(MovAvgParser.class); } /** @@ -131,9 +131,9 @@ public class AggregationModule extends AbstractModule implements SpawnModules{ for (Class parser : aggParsers) { multibinderAggParser.addBinding().to(parser); } - Multibinder multibinderReducerParser = Multibinder.newSetBinder(binder(), Reducer.Parser.class); - for (Class parser : reducerParsers) { - multibinderReducerParser.addBinding().to(parser); + Multibinder multibinderPipelineAggParser = Multibinder.newSetBinder(binder(), PipelineAggregator.Parser.class); + for (Class parser : pipelineAggParsers) { + multibinderPipelineAggParser.addBinding().to(parser); } bind(AggregatorParsers.class).asEagerSingleton(); bind(AggregationParseElement.class).asEagerSingleton(); diff --git a/src/main/java/org/elasticsearch/search/aggregations/AggregationPhase.java b/src/main/java/org/elasticsearch/search/aggregations/AggregationPhase.java index 717834b045c..c983c40495f 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/AggregationPhase.java +++ b/src/main/java/org/elasticsearch/search/aggregations/AggregationPhase.java @@ -23,14 +23,13 @@ import com.google.common.collect.ImmutableMap; import org.apache.lucene.search.BooleanClause.Occur; import org.apache.lucene.search.BooleanQuery; import org.apache.lucene.search.Query; -import org.elasticsearch.ElasticsearchException; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.lucene.search.Queries; import org.elasticsearch.search.SearchParseElement; import org.elasticsearch.search.SearchPhase; import org.elasticsearch.search.aggregations.bucket.global.GlobalAggregator; -import org.elasticsearch.search.aggregations.reducers.Reducer; -import org.elasticsearch.search.aggregations.reducers.SiblingReducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; +import org.elasticsearch.search.aggregations.pipeline.SiblingPipelineAggregator; import org.elasticsearch.search.aggregations.support.AggregationContext; import org.elasticsearch.search.internal.SearchContext; import org.elasticsearch.search.query.QueryPhaseExecutionException; @@ -145,19 +144,20 @@ public class AggregationPhase implements SearchPhase { } context.queryResult().aggregations(new InternalAggregations(aggregations)); try { - List reducers = context.aggregations().factories().createReducers(); - List siblingReducers = new ArrayList<>(reducers.size()); - for (Reducer reducer : reducers) { - if (reducer instanceof SiblingReducer) { - siblingReducers.add((SiblingReducer) reducer); + List pipelineAggregators = context.aggregations().factories().createPipelineAggregators(); + List siblingPipelineAggregators = new ArrayList<>(pipelineAggregators.size()); + for (PipelineAggregator pipelineAggregator : pipelineAggregators) { + if (pipelineAggregator instanceof SiblingPipelineAggregator) { + siblingPipelineAggregators.add((SiblingPipelineAggregator) pipelineAggregator); } else { - throw new AggregationExecutionException("Invalid reducer named [" + reducer.name() + "] of type [" - + reducer.type().name() + "]. Only sibling reducers are allowed at the top level"); + throw new AggregationExecutionException("Invalid pipeline aggregation named [" + pipelineAggregator.name() + + "] of type [" + pipelineAggregator.type().name() + + "]. Only sibling pipeline aggregations are allowed at the top level"); } } - context.queryResult().reducers(siblingReducers); + context.queryResult().pipelineAggregators(siblingPipelineAggregators); } catch (IOException e) { - throw new AggregationExecutionException("Failed to build top level reducers", e); + throw new AggregationExecutionException("Failed to build top level pipeline aggregators", e); } // disable aggregations so that they don't run on next pages in case of scrolling diff --git a/src/main/java/org/elasticsearch/search/aggregations/AggregatorBase.java b/src/main/java/org/elasticsearch/search/aggregations/AggregatorBase.java index bb1e18be09d..a44d01b1a5f 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/AggregatorBase.java +++ b/src/main/java/org/elasticsearch/search/aggregations/AggregatorBase.java @@ -21,7 +21,7 @@ package org.elasticsearch.search.aggregations; import org.apache.lucene.index.LeafReaderContext; import org.elasticsearch.search.aggregations.bucket.BestBucketsDeferringCollector; import org.elasticsearch.search.aggregations.bucket.DeferringBucketCollector; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.AggregationContext; import org.elasticsearch.search.internal.SearchContext.Lifetime; import org.elasticsearch.search.query.QueryPhaseExecutionException; @@ -47,7 +47,7 @@ public abstract class AggregatorBase extends Aggregator { private Map subAggregatorbyName; private DeferringBucketCollector recordingWrapper; - private final List reducers; + private final List pipelineAggregators; /** * Constructs a new Aggregator. @@ -59,9 +59,9 @@ public abstract class AggregatorBase extends Aggregator { * @param metaData The metaData associated with this aggregator */ protected AggregatorBase(String name, AggregatorFactories factories, AggregationContext context, Aggregator parent, - List reducers, Map metaData) throws IOException { + List pipelineAggregators, Map metaData) throws IOException { this.name = name; - this.reducers = reducers; + this.pipelineAggregators = pipelineAggregators; this.metaData = metaData; this.parent = parent; this.context = context; @@ -116,8 +116,8 @@ public abstract class AggregatorBase extends Aggregator { return this.metaData; } - public List reducers() { - return this.reducers; + public List pipelineAggregators() { + return this.pipelineAggregators; } /** diff --git a/src/main/java/org/elasticsearch/search/aggregations/AggregatorFactories.java b/src/main/java/org/elasticsearch/search/aggregations/AggregatorFactories.java index ba464531b8b..344d92de008 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/AggregatorFactories.java +++ b/src/main/java/org/elasticsearch/search/aggregations/AggregatorFactories.java @@ -18,8 +18,8 @@ */ package org.elasticsearch.search.aggregations; -import org.elasticsearch.search.aggregations.reducers.Reducer; -import org.elasticsearch.search.aggregations.reducers.ReducerFactory; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorFactory; import org.elasticsearch.search.aggregations.support.AggregationContext; import org.elasticsearch.search.aggregations.support.AggregationPath; @@ -41,23 +41,23 @@ public class AggregatorFactories { private AggregatorFactory parent; private AggregatorFactory[] factories; - private List reducerFactories; + private List pipelineAggregatorFactories; public static Builder builder() { return new Builder(); } - private AggregatorFactories(AggregatorFactory[] factories, List reducers) { + private AggregatorFactories(AggregatorFactory[] factories, List pipelineAggregators) { this.factories = factories; - this.reducerFactories = reducers; + this.pipelineAggregatorFactories = pipelineAggregators; } - public List createReducers() throws IOException { - List reducers = new ArrayList<>(); - for (ReducerFactory factory : this.reducerFactories) { - reducers.add(factory.create()); + public List createPipelineAggregators() throws IOException { + List pipelineAggregators = new ArrayList<>(); + for (PipelineAggregatorFactory factory : this.pipelineAggregatorFactories) { + pipelineAggregators.add(factory.create()); } - return reducers; + return pipelineAggregators; } /** @@ -103,8 +103,8 @@ public class AggregatorFactories { for (AggregatorFactory factory : factories) { factory.validate(); } - for (ReducerFactory factory : reducerFactories) { - factory.validate(parent, factories, reducerFactories); + for (PipelineAggregatorFactory factory : pipelineAggregatorFactories) { + factory.validate(parent, factories, pipelineAggregatorFactories); } } @@ -112,10 +112,10 @@ public class AggregatorFactories { private static final AggregatorFactory[] EMPTY_FACTORIES = new AggregatorFactory[0]; private static final Aggregator[] EMPTY_AGGREGATORS = new Aggregator[0]; - private static final List EMPTY_REDUCERS = new ArrayList<>(); + private static final List EMPTY_PIPELINE_AGGREGATORS = new ArrayList<>(); private Empty() { - super(EMPTY_FACTORIES, EMPTY_REDUCERS); + super(EMPTY_FACTORIES, EMPTY_PIPELINE_AGGREGATORS); } @Override @@ -134,7 +134,7 @@ public class AggregatorFactories { private final Set names = new HashSet<>(); private final List factories = new ArrayList<>(); - private final List reducerFactories = new ArrayList<>(); + private final List pipelineAggregatorFactories = new ArrayList<>(); public Builder addAggregator(AggregatorFactory factory) { if (!names.add(factory.name)) { @@ -144,43 +144,43 @@ public class AggregatorFactories { return this; } - public Builder addReducer(ReducerFactory reducerFactory) { - this.reducerFactories.add(reducerFactory); + public Builder addPipelineAggregator(PipelineAggregatorFactory pipelineAggregatorFactory) { + this.pipelineAggregatorFactories.add(pipelineAggregatorFactory); return this; } public AggregatorFactories build() { - if (factories.isEmpty() && reducerFactories.isEmpty()) { + if (factories.isEmpty() && pipelineAggregatorFactories.isEmpty()) { return EMPTY; } - List orderedReducers = resolveReducerOrder(this.reducerFactories, this.factories); - return new AggregatorFactories(factories.toArray(new AggregatorFactory[factories.size()]), orderedReducers); + List orderedpipelineAggregators = resolvePipelineAggregatorOrder(this.pipelineAggregatorFactories, this.factories); + return new AggregatorFactories(factories.toArray(new AggregatorFactory[factories.size()]), orderedpipelineAggregators); } - private List resolveReducerOrder(List reducerFactories, List aggFactories) { - Map reducerFactoriesMap = new HashMap<>(); - for (ReducerFactory factory : reducerFactories) { - reducerFactoriesMap.put(factory.getName(), factory); + private List resolvePipelineAggregatorOrder(List pipelineAggregatorFactories, List aggFactories) { + Map pipelineAggregatorFactoriesMap = new HashMap<>(); + for (PipelineAggregatorFactory factory : pipelineAggregatorFactories) { + pipelineAggregatorFactoriesMap.put(factory.getName(), factory); } Set aggFactoryNames = new HashSet<>(); for (AggregatorFactory aggFactory : aggFactories) { aggFactoryNames.add(aggFactory.name); } - List orderedReducers = new LinkedList<>(); - List unmarkedFactories = new ArrayList(reducerFactories); - Set temporarilyMarked = new HashSet(); + List orderedPipelineAggregatorrs = new LinkedList<>(); + List unmarkedFactories = new ArrayList(pipelineAggregatorFactories); + Set temporarilyMarked = new HashSet(); while (!unmarkedFactories.isEmpty()) { - ReducerFactory factory = unmarkedFactories.get(0); - resolveReducerOrder(aggFactoryNames, reducerFactoriesMap, orderedReducers, unmarkedFactories, temporarilyMarked, factory); + PipelineAggregatorFactory factory = unmarkedFactories.get(0); + resolvePipelineAggregatorOrder(aggFactoryNames, pipelineAggregatorFactoriesMap, orderedPipelineAggregatorrs, unmarkedFactories, temporarilyMarked, factory); } - return orderedReducers; + return orderedPipelineAggregatorrs; } - private void resolveReducerOrder(Set aggFactoryNames, Map reducerFactoriesMap, - List orderedReducers, List unmarkedFactories, Set temporarilyMarked, - ReducerFactory factory) { + private void resolvePipelineAggregatorOrder(Set aggFactoryNames, Map pipelineAggregatorFactoriesMap, + List orderedPipelineAggregators, List unmarkedFactories, Set temporarilyMarked, + PipelineAggregatorFactory factory) { if (temporarilyMarked.contains(factory)) { - throw new IllegalStateException("Cyclical dependancy found with reducer [" + factory.getName() + "]"); + throw new IllegalStateException("Cyclical dependancy found with pipeline aggregator [" + factory.getName() + "]"); } else if (unmarkedFactories.contains(factory)) { temporarilyMarked.add(factory); String[] bucketsPaths = factory.getBucketsPaths(); @@ -190,9 +190,9 @@ public class AggregatorFactories { if (bucketsPath.equals("_count") || bucketsPath.equals("_key") || aggFactoryNames.contains(firstAggName)) { continue; } else { - ReducerFactory matchingFactory = reducerFactoriesMap.get(firstAggName); + PipelineAggregatorFactory matchingFactory = pipelineAggregatorFactoriesMap.get(firstAggName); if (matchingFactory != null) { - resolveReducerOrder(aggFactoryNames, reducerFactoriesMap, orderedReducers, unmarkedFactories, + resolvePipelineAggregatorOrder(aggFactoryNames, pipelineAggregatorFactoriesMap, orderedPipelineAggregators, unmarkedFactories, temporarilyMarked, matchingFactory); } else { throw new IllegalStateException("No aggregation found for path [" + bucketsPath + "]"); @@ -201,7 +201,7 @@ public class AggregatorFactories { } unmarkedFactories.remove(factory); temporarilyMarked.remove(factory); - orderedReducers.add(factory); + orderedPipelineAggregators.add(factory); } } } diff --git a/src/main/java/org/elasticsearch/search/aggregations/AggregatorFactory.java b/src/main/java/org/elasticsearch/search/aggregations/AggregatorFactory.java index f69e54ee710..680e3ef2e92 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/AggregatorFactory.java +++ b/src/main/java/org/elasticsearch/search/aggregations/AggregatorFactory.java @@ -23,7 +23,7 @@ import org.apache.lucene.search.Scorer; import org.elasticsearch.common.lease.Releasables; import org.elasticsearch.common.util.BigArrays; import org.elasticsearch.common.util.ObjectArray; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.AggregationContext; import org.elasticsearch.search.internal.SearchContext.Lifetime; @@ -86,7 +86,7 @@ public abstract class AggregatorFactory { } protected abstract Aggregator createInternal(AggregationContext context, Aggregator parent, boolean collectsFromSingleBucket, - List reducers, Map metaData) throws IOException; + List pipelineAggregators, Map metaData) throws IOException; /** * Creates the aggregator @@ -99,7 +99,7 @@ public abstract class AggregatorFactory { * @return The created aggregator */ public final Aggregator create(AggregationContext context, Aggregator parent, boolean collectsFromSingleBucket) throws IOException { - return createInternal(context, parent, collectsFromSingleBucket, this.factories.createReducers(), this.metaData); + return createInternal(context, parent, collectsFromSingleBucket, this.factories.createPipelineAggregators(), this.metaData); } public void doValidate() { diff --git a/src/main/java/org/elasticsearch/search/aggregations/AggregatorParsers.java b/src/main/java/org/elasticsearch/search/aggregations/AggregatorParsers.java index 32969104733..d299b099b9d 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/AggregatorParsers.java +++ b/src/main/java/org/elasticsearch/search/aggregations/AggregatorParsers.java @@ -24,8 +24,8 @@ import org.elasticsearch.common.collect.MapBuilder; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.search.SearchParseException; -import org.elasticsearch.search.aggregations.reducers.Reducer; -import org.elasticsearch.search.aggregations.reducers.ReducerFactory; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorFactory; import org.elasticsearch.search.internal.SearchContext; import java.io.IOException; @@ -41,7 +41,7 @@ public class AggregatorParsers { public static final Pattern VALID_AGG_NAME = Pattern.compile("[^\\[\\]>]+"); private final ImmutableMap aggParsers; - private final ImmutableMap reducerParsers; + private final ImmutableMap pipelineAggregatorParsers; /** @@ -53,17 +53,17 @@ public class AggregatorParsers { * ). */ @Inject - public AggregatorParsers(Set aggParsers, Set reducerParsers) { + public AggregatorParsers(Set aggParsers, Set pipelineAggregatorParsers) { MapBuilder aggParsersBuilder = MapBuilder.newMapBuilder(); for (Aggregator.Parser parser : aggParsers) { aggParsersBuilder.put(parser.type(), parser); } this.aggParsers = aggParsersBuilder.immutableMap(); - MapBuilder reducerParsersBuilder = MapBuilder.newMapBuilder(); - for (Reducer.Parser parser : reducerParsers) { - reducerParsersBuilder.put(parser.type(), parser); + MapBuilder pipelineAggregatorParsersBuilder = MapBuilder.newMapBuilder(); + for (PipelineAggregator.Parser parser : pipelineAggregatorParsers) { + pipelineAggregatorParsersBuilder.put(parser.type(), parser); } - this.reducerParsers = reducerParsersBuilder.immutableMap(); + this.pipelineAggregatorParsers = pipelineAggregatorParsersBuilder.immutableMap(); } /** @@ -77,14 +77,15 @@ public class AggregatorParsers { } /** - * Returns the parser that is registered under the given reducer type. + * Returns the parser that is registered under the given pipeline aggregator + * type. * * @param type - * The reducer type - * @return The parser associated with the given reducer type. + * The pipeline aggregator type + * @return The parser associated with the given pipeline aggregator type. */ - public Reducer.Parser reducer(String type) { - return reducerParsers.get(type); + public PipelineAggregator.Parser pipelineAggregator(String type) { + return pipelineAggregatorParsers.get(type); } /** @@ -125,7 +126,7 @@ public class AggregatorParsers { } AggregatorFactory aggFactory = null; - ReducerFactory reducerFactory = null; + PipelineAggregatorFactory pipelineAggregatorFactory = null; AggregatorFactories subFactories = null; Map metaData = null; @@ -161,20 +162,19 @@ public class AggregatorParsers { throw new SearchParseException(context, "Found two aggregation type definitions in [" + aggregationName + "]: [" + aggFactory.type + "] and [" + fieldName + "]", parser.getTokenLocation()); } - if (reducerFactory != null) { - // TODO we would need a .type property on reducers too for this error message? + if (pipelineAggregatorFactory != null) { throw new SearchParseException(context, "Found two aggregation type definitions in [" + aggregationName + "]: [" - + reducerFactory + "] and [" + fieldName + "]", parser.getTokenLocation()); + + pipelineAggregatorFactory + "] and [" + fieldName + "]", parser.getTokenLocation()); } Aggregator.Parser aggregatorParser = parser(fieldName); if (aggregatorParser == null) { - Reducer.Parser reducerParser = reducer(fieldName); - if (reducerParser == null) { + PipelineAggregator.Parser pipelineAggregatorParser = pipelineAggregator(fieldName); + if (pipelineAggregatorParser == null) { throw new SearchParseException(context, "Could not find aggregator type [" + fieldName + "] in [" + aggregationName + "]", parser.getTokenLocation()); } else { - reducerFactory = reducerParser.parse(aggregationName, parser, context); + pipelineAggregatorFactory = pipelineAggregatorParser.parse(aggregationName, parser, context); } } else { aggFactory = aggregatorParser.parse(aggregationName, parser, context); @@ -182,11 +182,11 @@ public class AggregatorParsers { } } - if (aggFactory == null && reducerFactory == null) { + if (aggFactory == null && pipelineAggregatorFactory == null) { throw new SearchParseException(context, "Missing definition for aggregation [" + aggregationName + "]", parser.getTokenLocation()); } else if (aggFactory != null) { - assert reducerFactory == null; + assert pipelineAggregatorFactory == null; if (metaData != null) { aggFactory.setMetaData(metaData); } @@ -201,12 +201,12 @@ public class AggregatorParsers { factories.addAggregator(aggFactory); } else { - assert reducerFactory != null; + assert pipelineAggregatorFactory != null; if (subFactories != null) { throw new SearchParseException(context, "Aggregation [" + aggregationName + "] cannot define sub-aggregations", parser.getTokenLocation()); } - factories.addReducer(reducerFactory); + factories.addPipelineAggregator(pipelineAggregatorFactory); } } diff --git a/src/main/java/org/elasticsearch/search/aggregations/InternalAggregation.java b/src/main/java/org/elasticsearch/search/aggregations/InternalAggregation.java index c9bb647c0f3..1f32c0a1687 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/InternalAggregation.java +++ b/src/main/java/org/elasticsearch/search/aggregations/InternalAggregation.java @@ -31,8 +31,8 @@ import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilderString; import org.elasticsearch.script.ScriptService; -import org.elasticsearch.search.aggregations.reducers.Reducer; -import org.elasticsearch.search.aggregations.reducers.ReducerStreams; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorStreams; import org.elasticsearch.search.aggregations.support.AggregationPath; import java.io.IOException; @@ -115,7 +115,7 @@ public abstract class InternalAggregation implements Aggregation, ToXContent, St protected Map metaData; - private List reducers; + private List pipelineAggregators; /** Constructs an un initialized addAggregation (used for serialization) **/ protected InternalAggregation() {} @@ -125,9 +125,9 @@ public abstract class InternalAggregation implements Aggregation, ToXContent, St * * @param name The name of the get. */ - protected InternalAggregation(String name, List reducers, Map metaData) { + protected InternalAggregation(String name, List pipelineAggregators, Map metaData) { this.name = name; - this.reducers = reducers; + this.pipelineAggregators = pipelineAggregators; this.metaData = metaData; } @@ -149,8 +149,8 @@ public abstract class InternalAggregation implements Aggregation, ToXContent, St */ public final InternalAggregation reduce(List aggregations, ReduceContext reduceContext) { InternalAggregation aggResult = doReduce(aggregations, reduceContext); - for (Reducer reducer : reducers) { - aggResult = reducer.reduce(aggResult, reduceContext); + for (PipelineAggregator pipelineAggregator : pipelineAggregators) { + aggResult = pipelineAggregator.reduce(aggResult, reduceContext); } return aggResult; } @@ -188,8 +188,8 @@ public abstract class InternalAggregation implements Aggregation, ToXContent, St return metaData; } - public List reducers() { - return reducers; + public List pipelineAggregators() { + return pipelineAggregators; } @Override @@ -210,10 +210,10 @@ public abstract class InternalAggregation implements Aggregation, ToXContent, St public final void writeTo(StreamOutput out) throws IOException { out.writeString(name); out.writeGenericValue(metaData); - out.writeVInt(reducers.size()); - for (Reducer reducer : reducers) { - out.writeBytesReference(reducer.type().stream()); - reducer.writeTo(out); + out.writeVInt(pipelineAggregators.size()); + for (PipelineAggregator pipelineAggregator : pipelineAggregators) { + out.writeBytesReference(pipelineAggregator.type().stream()); + pipelineAggregator.writeTo(out); } doWriteTo(out); } @@ -226,13 +226,13 @@ public abstract class InternalAggregation implements Aggregation, ToXContent, St metaData = in.readMap(); int size = in.readVInt(); if (size == 0) { - reducers = ImmutableList.of(); + pipelineAggregators = ImmutableList.of(); } else { - reducers = Lists.newArrayListWithCapacity(size); + pipelineAggregators = Lists.newArrayListWithCapacity(size); for (int i = 0; i < size; i++) { BytesReference type = in.readBytesReference(); - Reducer reducer = ReducerStreams.stream(type).readResult(in); - reducers.add(reducer); + PipelineAggregator pipelineAggregator = PipelineAggregatorStreams.stream(type).readResult(in); + pipelineAggregators.add(pipelineAggregator); } } doReadFrom(in); diff --git a/src/main/java/org/elasticsearch/search/aggregations/InternalMultiBucketAggregation.java b/src/main/java/org/elasticsearch/search/aggregations/InternalMultiBucketAggregation.java index db2ac49bf38..e46f24c2425 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/InternalMultiBucketAggregation.java +++ b/src/main/java/org/elasticsearch/search/aggregations/InternalMultiBucketAggregation.java @@ -20,7 +20,7 @@ package org.elasticsearch.search.aggregations; import org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import java.util.List; import java.util.Map; @@ -31,8 +31,8 @@ public abstract class InternalMultiBucketAggregation reducers, Map metaData) { - super(name, reducers, metaData); + public InternalMultiBucketAggregation(String name, List pipelineAggregators, Map metaData) { + super(name, pipelineAggregators, metaData); } /** diff --git a/src/main/java/org/elasticsearch/search/aggregations/NonCollectingAggregator.java b/src/main/java/org/elasticsearch/search/aggregations/NonCollectingAggregator.java index 9b64c647b38..7e0e3cc9f9f 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/NonCollectingAggregator.java +++ b/src/main/java/org/elasticsearch/search/aggregations/NonCollectingAggregator.java @@ -20,7 +20,7 @@ package org.elasticsearch.search.aggregations; import org.apache.lucene.index.LeafReaderContext; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.AggregationContext; import java.io.IOException; @@ -34,13 +34,13 @@ import java.util.Map; public abstract class NonCollectingAggregator extends AggregatorBase { protected NonCollectingAggregator(String name, AggregationContext context, Aggregator parent, AggregatorFactories subFactories, - List reducers, Map metaData) throws IOException { - super(name, subFactories, context, parent, reducers, metaData); + List pipelineAggregators, Map metaData) throws IOException { + super(name, subFactories, context, parent, pipelineAggregators, metaData); } - protected NonCollectingAggregator(String name, AggregationContext context, Aggregator parent, List reducers, - Map metaData) throws IOException { - this(name, context, parent, AggregatorFactories.EMPTY, reducers, metaData); + protected NonCollectingAggregator(String name, AggregationContext context, Aggregator parent, + List pipelineAggregators, Map metaData) throws IOException { + this(name, context, parent, AggregatorFactories.EMPTY, pipelineAggregators, metaData); } @Override diff --git a/src/main/java/org/elasticsearch/search/aggregations/TransportAggregationModule.java b/src/main/java/org/elasticsearch/search/aggregations/TransportAggregationModule.java index 81051a7d9bb..358abcdfda4 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/TransportAggregationModule.java +++ b/src/main/java/org/elasticsearch/search/aggregations/TransportAggregationModule.java @@ -59,16 +59,16 @@ import org.elasticsearch.search.aggregations.metrics.stats.extended.InternalExte import org.elasticsearch.search.aggregations.metrics.sum.InternalSum; import org.elasticsearch.search.aggregations.metrics.tophits.InternalTopHits; import org.elasticsearch.search.aggregations.metrics.valuecount.InternalValueCount; -import org.elasticsearch.search.aggregations.reducers.InternalSimpleValue; -import org.elasticsearch.search.aggregations.reducers.bucketmetrics.InternalBucketMetricValue; -import org.elasticsearch.search.aggregations.reducers.bucketmetrics.avg.AvgBucketReducer; -import org.elasticsearch.search.aggregations.reducers.bucketmetrics.max.MaxBucketReducer; -import org.elasticsearch.search.aggregations.reducers.bucketmetrics.min.MinBucketReducer; -import org.elasticsearch.search.aggregations.reducers.bucketmetrics.sum.SumBucketReducer; -import org.elasticsearch.search.aggregations.reducers.derivative.DerivativeReducer; -import org.elasticsearch.search.aggregations.reducers.derivative.InternalDerivative; -import org.elasticsearch.search.aggregations.reducers.movavg.MovAvgReducer; -import org.elasticsearch.search.aggregations.reducers.movavg.models.TransportMovAvgModelModule; +import org.elasticsearch.search.aggregations.pipeline.InternalSimpleValue; +import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.InternalBucketMetricValue; +import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.avg.AvgBucketPipelineAggregator; +import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.max.MaxBucketPipelineAggregator; +import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.min.MinBucketPipelineAggregator; +import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.sum.SumBucketPipelineAggregator; +import org.elasticsearch.search.aggregations.pipeline.derivative.DerivativePipelineAggregator; +import org.elasticsearch.search.aggregations.pipeline.derivative.InternalDerivative; +import org.elasticsearch.search.aggregations.pipeline.movavg.MovAvgPipelineAggregator; +import org.elasticsearch.search.aggregations.pipeline.movavg.models.TransportMovAvgModelModule; /** * A module that registers all the transport streams for the addAggregation @@ -117,16 +117,16 @@ public class TransportAggregationModule extends AbstractModule implements SpawnM InternalGeoBounds.registerStream(); InternalChildren.registerStream(); - // Reducers - DerivativeReducer.registerStreams(); + // Pipeline Aggregations + DerivativePipelineAggregator.registerStreams(); InternalDerivative.registerStreams(); InternalSimpleValue.registerStreams(); InternalBucketMetricValue.registerStreams(); - MaxBucketReducer.registerStreams(); - MinBucketReducer.registerStreams(); - AvgBucketReducer.registerStreams(); - SumBucketReducer.registerStreams(); - MovAvgReducer.registerStreams(); + MaxBucketPipelineAggregator.registerStreams(); + MinBucketPipelineAggregator.registerStreams(); + AvgBucketPipelineAggregator.registerStreams(); + SumBucketPipelineAggregator.registerStreams(); + MovAvgPipelineAggregator.registerStreams(); } @Override diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/BucketsAggregator.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/BucketsAggregator.java index 041c15a5dc1..e34bc95bb31 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/BucketsAggregator.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/BucketsAggregator.java @@ -27,7 +27,7 @@ import org.elasticsearch.search.aggregations.AggregatorFactories; import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.InternalAggregations; import org.elasticsearch.search.aggregations.LeafBucketCollector; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.AggregationContext; import java.io.IOException; @@ -44,8 +44,8 @@ public abstract class BucketsAggregator extends AggregatorBase { private IntArray docCounts; public BucketsAggregator(String name, AggregatorFactories factories, AggregationContext context, Aggregator parent, - List reducers, Map metaData) throws IOException { - super(name, factories, context, parent, reducers, metaData); + List pipelineAggregators, Map metaData) throws IOException { + super(name, factories, context, parent, pipelineAggregators, metaData); bigArrays = context.bigArrays(); docCounts = bigArrays.newIntArray(1, true); } diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/InternalSingleBucketAggregation.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/InternalSingleBucketAggregation.java index b9ff232b626..eacc7471743 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/InternalSingleBucketAggregation.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/InternalSingleBucketAggregation.java @@ -23,7 +23,7 @@ import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.InternalAggregations; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import java.io.IOException; import java.util.ArrayList; @@ -47,8 +47,8 @@ public abstract class InternalSingleBucketAggregation extends InternalAggregatio * @param docCount The document count in the single bucket. * @param aggregations The already built sub-aggregations that are associated with the bucket. */ - protected InternalSingleBucketAggregation(String name, long docCount, InternalAggregations aggregations, List reducers, Map metaData) { - super(name, reducers, metaData); + protected InternalSingleBucketAggregation(String name, long docCount, InternalAggregations aggregations, List pipelineAggregators, Map metaData) { + super(name, pipelineAggregators, metaData); this.docCount = docCount; this.aggregations = aggregations; } diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/SingleBucketAggregator.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/SingleBucketAggregator.java index 2e032640f98..44b1eea9146 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/SingleBucketAggregator.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/SingleBucketAggregator.java @@ -20,7 +20,7 @@ package org.elasticsearch.search.aggregations.bucket; import org.elasticsearch.search.aggregations.Aggregator; import org.elasticsearch.search.aggregations.AggregatorFactories; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.AggregationContext; import java.io.IOException; @@ -34,8 +34,8 @@ public abstract class SingleBucketAggregator extends BucketsAggregator { protected SingleBucketAggregator(String name, AggregatorFactories factories, AggregationContext aggregationContext, Aggregator parent, - List reducers, Map metaData) throws IOException { - super(name, factories, aggregationContext, parent, reducers, metaData); + List pipelineAggregators, Map metaData) throws IOException { + super(name, factories, aggregationContext, parent, pipelineAggregators, metaData); } } diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/children/InternalChildren.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/children/InternalChildren.java index cfac7f834bc..324f32a3813 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/children/InternalChildren.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/children/InternalChildren.java @@ -23,7 +23,7 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.search.aggregations.AggregationStreams; import org.elasticsearch.search.aggregations.InternalAggregations; import org.elasticsearch.search.aggregations.bucket.InternalSingleBucketAggregation; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import java.io.IOException; import java.util.List; @@ -51,9 +51,9 @@ public class InternalChildren extends InternalSingleBucketAggregation implements public InternalChildren() { } - public InternalChildren(String name, long docCount, InternalAggregations aggregations, List reducers, + public InternalChildren(String name, long docCount, InternalAggregations aggregations, List pipelineAggregators, Map metaData) { - super(name, docCount, aggregations, reducers, metaData); + super(name, docCount, aggregations, pipelineAggregators, metaData); } @Override @@ -63,6 +63,6 @@ public class InternalChildren extends InternalSingleBucketAggregation implements @Override protected InternalSingleBucketAggregation newAggregation(String name, long docCount, InternalAggregations subAggregations) { - return new InternalChildren(name, docCount, subAggregations, reducers(), getMetaData()); + return new InternalChildren(name, docCount, subAggregations, pipelineAggregators(), getMetaData()); } } diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/children/ParentToChildrenAggregator.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/children/ParentToChildrenAggregator.java index 4107bcde479..beefbc64508 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/children/ParentToChildrenAggregator.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/children/ParentToChildrenAggregator.java @@ -36,7 +36,7 @@ import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.LeafBucketCollector; import org.elasticsearch.search.aggregations.NonCollectingAggregator; import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregator; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.AggregationContext; import org.elasticsearch.search.aggregations.support.ValuesSource; import org.elasticsearch.search.aggregations.support.ValuesSourceAggregatorFactory; @@ -74,8 +74,8 @@ public class ParentToChildrenAggregator extends SingleBucketAggregator { public ParentToChildrenAggregator(String name, AggregatorFactories factories, AggregationContext aggregationContext, Aggregator parent, String parentType, Filter childFilter, Filter parentFilter, ValuesSource.Bytes.WithOrdinals.ParentChild valuesSource, - long maxOrd, List reducers, Map metaData) throws IOException { - super(name, factories, aggregationContext, parent, reducers, metaData); + long maxOrd, List pipelineAggregators, Map metaData) throws IOException { + super(name, factories, aggregationContext, parent, pipelineAggregators, metaData); this.parentType = parentType; // these two filters are cached in the parser this.childFilter = aggregationContext.searchContext().searcher().createNormalizedWeight(childFilter, false); @@ -88,13 +88,13 @@ public class ParentToChildrenAggregator extends SingleBucketAggregator { @Override public InternalAggregation buildAggregation(long owningBucketOrdinal) throws IOException { - return new InternalChildren(name, bucketDocCount(owningBucketOrdinal), bucketAggregations(owningBucketOrdinal), reducers(), + return new InternalChildren(name, bucketDocCount(owningBucketOrdinal), bucketAggregations(owningBucketOrdinal), pipelineAggregators(), metaData()); } @Override public InternalAggregation buildEmptyAggregation() { - return new InternalChildren(name, 0, buildEmptySubAggregations(), reducers(), metaData()); + return new InternalChildren(name, 0, buildEmptySubAggregations(), pipelineAggregators(), metaData()); } @Override @@ -196,13 +196,13 @@ public class ParentToChildrenAggregator extends SingleBucketAggregator { } @Override - protected Aggregator createUnmapped(AggregationContext aggregationContext, Aggregator parent, List reducers, + protected Aggregator createUnmapped(AggregationContext aggregationContext, Aggregator parent, List pipelineAggregators, Map metaData) throws IOException { - return new NonCollectingAggregator(name, aggregationContext, parent, reducers, metaData) { + return new NonCollectingAggregator(name, aggregationContext, parent, pipelineAggregators, metaData) { @Override public InternalAggregation buildEmptyAggregation() { - return new InternalChildren(name, 0, buildEmptySubAggregations(), reducers(), metaData()); + return new InternalChildren(name, 0, buildEmptySubAggregations(), pipelineAggregators(), metaData()); } }; @@ -210,11 +210,11 @@ public class ParentToChildrenAggregator extends SingleBucketAggregator { @Override protected Aggregator doCreateInternal(ValuesSource.Bytes.WithOrdinals.ParentChild valuesSource, - AggregationContext aggregationContext, Aggregator parent, boolean collectsFromSingleBucket, List reducers, + AggregationContext aggregationContext, Aggregator parent, boolean collectsFromSingleBucket, List pipelineAggregators, Map metaData) throws IOException { long maxOrd = valuesSource.globalMaxOrd(aggregationContext.searchContext().searcher(), parentType); return new ParentToChildrenAggregator(name, factories, aggregationContext, parent, parentType, childFilter, parentFilter, - valuesSource, maxOrd, reducers, metaData); + valuesSource, maxOrd, pipelineAggregators, metaData); } } diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/filter/FilterAggregator.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/filter/FilterAggregator.java index 4995a2216d8..0f904e4da03 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/filter/FilterAggregator.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/filter/FilterAggregator.java @@ -30,7 +30,7 @@ import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.LeafBucketCollector; import org.elasticsearch.search.aggregations.LeafBucketCollectorBase; import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregator; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.AggregationContext; import java.io.IOException; @@ -48,9 +48,9 @@ public class FilterAggregator extends SingleBucketAggregator { Query filter, AggregatorFactories factories, AggregationContext aggregationContext, - Aggregator parent, List reducers, + Aggregator parent, List pipelineAggregators, Map metaData) throws IOException { - super(name, factories, aggregationContext, parent, reducers, metaData); + super(name, factories, aggregationContext, parent, pipelineAggregators, metaData); this.filter = aggregationContext.searchContext().searcher().createNormalizedWeight(filter, false); } @@ -71,13 +71,13 @@ public class FilterAggregator extends SingleBucketAggregator { @Override public InternalAggregation buildAggregation(long owningBucketOrdinal) throws IOException { - return new InternalFilter(name, bucketDocCount(owningBucketOrdinal), bucketAggregations(owningBucketOrdinal), reducers(), + return new InternalFilter(name, bucketDocCount(owningBucketOrdinal), bucketAggregations(owningBucketOrdinal), pipelineAggregators(), metaData()); } @Override public InternalAggregation buildEmptyAggregation() { - return new InternalFilter(name, 0, buildEmptySubAggregations(), reducers(), metaData()); + return new InternalFilter(name, 0, buildEmptySubAggregations(), pipelineAggregators(), metaData()); } public static class Factory extends AggregatorFactory { @@ -91,8 +91,8 @@ public class FilterAggregator extends SingleBucketAggregator { @Override public Aggregator createInternal(AggregationContext context, Aggregator parent, boolean collectsFromSingleBucket, - List reducers, Map metaData) throws IOException { - return new FilterAggregator(name, filter, factories, context, parent, reducers, metaData); + List pipelineAggregators, Map metaData) throws IOException { + return new FilterAggregator(name, filter, factories, context, parent, pipelineAggregators, metaData); } } diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/filter/InternalFilter.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/filter/InternalFilter.java index 0429ea20a59..19f3b5a7e94 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/filter/InternalFilter.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/filter/InternalFilter.java @@ -22,7 +22,7 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.search.aggregations.AggregationStreams; import org.elasticsearch.search.aggregations.InternalAggregations; import org.elasticsearch.search.aggregations.bucket.InternalSingleBucketAggregation; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import java.io.IOException; import java.util.List; @@ -50,8 +50,8 @@ public class InternalFilter extends InternalSingleBucketAggregation implements F InternalFilter() {} // for serialization - InternalFilter(String name, long docCount, InternalAggregations subAggregations, List reducers, Map metaData) { - super(name, docCount, subAggregations, reducers, metaData); + InternalFilter(String name, long docCount, InternalAggregations subAggregations, List pipelineAggregators, Map metaData) { + super(name, docCount, subAggregations, pipelineAggregators, metaData); } @Override @@ -61,6 +61,6 @@ public class InternalFilter extends InternalSingleBucketAggregation implements F @Override protected InternalSingleBucketAggregation newAggregation(String name, long docCount, InternalAggregations subAggregations) { - return new InternalFilter(name, docCount, subAggregations, reducers(), getMetaData()); + return new InternalFilter(name, docCount, subAggregations, pipelineAggregators(), getMetaData()); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/filters/FiltersAggregator.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/filters/FiltersAggregator.java index 531c79451c7..22220c50af4 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/filters/FiltersAggregator.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/filters/FiltersAggregator.java @@ -34,7 +34,7 @@ import org.elasticsearch.search.aggregations.InternalAggregations; import org.elasticsearch.search.aggregations.LeafBucketCollector; import org.elasticsearch.search.aggregations.LeafBucketCollectorBase; import org.elasticsearch.search.aggregations.bucket.BucketsAggregator; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.AggregationContext; import java.io.IOException; @@ -62,9 +62,9 @@ public class FiltersAggregator extends BucketsAggregator { private final boolean keyed; public FiltersAggregator(String name, AggregatorFactories factories, List filters, boolean keyed, AggregationContext aggregationContext, - Aggregator parent, List reducers, Map metaData) + Aggregator parent, List pipelineAggregators, Map metaData) throws IOException { - super(name, factories, aggregationContext, parent, reducers, metaData); + super(name, factories, aggregationContext, parent, pipelineAggregators, metaData); this.keyed = keyed; this.keys = new String[filters.size()]; this.filters = new Weight[filters.size()]; @@ -103,7 +103,7 @@ public class FiltersAggregator extends BucketsAggregator { InternalFilters.Bucket bucket = new InternalFilters.Bucket(keys[i], bucketDocCount(bucketOrd), bucketAggregations(bucketOrd), keyed); buckets.add(bucket); } - return new InternalFilters(name, buckets, keyed, reducers(), metaData()); + return new InternalFilters(name, buckets, keyed, pipelineAggregators(), metaData()); } @Override @@ -114,7 +114,7 @@ public class FiltersAggregator extends BucketsAggregator { InternalFilters.Bucket bucket = new InternalFilters.Bucket(keys[i], 0, subAggs, keyed); buckets.add(bucket); } - return new InternalFilters(name, buckets, keyed, reducers(), metaData()); + return new InternalFilters(name, buckets, keyed, pipelineAggregators(), metaData()); } final long bucketOrd(long owningBucketOrdinal, int filterOrd) { @@ -134,8 +134,8 @@ public class FiltersAggregator extends BucketsAggregator { @Override public Aggregator createInternal(AggregationContext context, Aggregator parent, boolean collectsFromSingleBucket, - List reducers, Map metaData) throws IOException { - return new FiltersAggregator(name, factories, filters, keyed, context, parent, reducers, metaData); + List pipelineAggregators, Map metaData) throws IOException { + return new FiltersAggregator(name, factories, filters, keyed, context, parent, pipelineAggregators, metaData); } } diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/filters/InternalFilters.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/filters/InternalFilters.java index 85477b0d70c..f5209330009 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/filters/InternalFilters.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/filters/InternalFilters.java @@ -32,7 +32,7 @@ import org.elasticsearch.search.aggregations.InternalMultiBucketAggregation; import org.elasticsearch.search.aggregations.InternalMultiBucketAggregation.InternalBucket; import org.elasticsearch.search.aggregations.bucket.BucketStreamContext; import org.elasticsearch.search.aggregations.bucket.BucketStreams; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import java.io.IOException; import java.util.ArrayList; @@ -165,8 +165,8 @@ public class InternalFilters extends InternalMultiBucketAggregation buckets, boolean keyed, List reducers, Map metaData) { - super(name, reducers, metaData); + public InternalFilters(String name, List buckets, boolean keyed, List pipelineAggregators, Map metaData) { + super(name, pipelineAggregators, metaData); this.buckets = buckets; this.keyed = keyed; } @@ -178,7 +178,7 @@ public class InternalFilters extends InternalMultiBucketAggregation buckets) { - return new InternalFilters(this.name, buckets, this.keyed, this.reducers(), this.metaData); + return new InternalFilters(this.name, buckets, this.keyed, this.pipelineAggregators(), this.metaData); } @Override @@ -222,7 +222,7 @@ public class InternalFilters extends InternalMultiBucketAggregation(bucketsList.size()), keyed, reducers(), getMetaData()); + InternalFilters reduced = new InternalFilters(name, new ArrayList(bucketsList.size()), keyed, pipelineAggregators(), getMetaData()); for (List sameRangeList : bucketsList) { reduced.buckets.add((sameRangeList.get(0)).reduce(sameRangeList, reduceContext)); } diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoHashGridAggregator.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoHashGridAggregator.java index 36448a103c1..d92c55d9156 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoHashGridAggregator.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoHashGridAggregator.java @@ -28,7 +28,7 @@ import org.elasticsearch.search.aggregations.LeafBucketCollectorBase; import org.elasticsearch.search.aggregations.InternalAggregations; import org.elasticsearch.search.aggregations.LeafBucketCollector; import org.elasticsearch.search.aggregations.bucket.BucketsAggregator; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.AggregationContext; import org.elasticsearch.search.aggregations.support.ValuesSource; @@ -51,9 +51,9 @@ public class GeoHashGridAggregator extends BucketsAggregator { private final LongHash bucketOrds; public GeoHashGridAggregator(String name, AggregatorFactories factories, ValuesSource.Numeric valuesSource, - int requiredSize, int shardSize, AggregationContext aggregationContext, Aggregator parent, List reducers, + int requiredSize, int shardSize, AggregationContext aggregationContext, Aggregator parent, List pipelineAggregators, Map metaData) throws IOException { - super(name, factories, aggregationContext, parent, reducers, metaData); + super(name, factories, aggregationContext, parent, pipelineAggregators, metaData); this.valuesSource = valuesSource; this.requiredSize = requiredSize; this.shardSize = shardSize; @@ -129,12 +129,12 @@ public class GeoHashGridAggregator extends BucketsAggregator { bucket.aggregations = bucketAggregations(bucket.bucketOrd); list[i] = bucket; } - return new InternalGeoHashGrid(name, requiredSize, Arrays.asList(list), reducers(), metaData()); + return new InternalGeoHashGrid(name, requiredSize, Arrays.asList(list), pipelineAggregators(), metaData()); } @Override public InternalGeoHashGrid buildEmptyAggregation() { - return new InternalGeoHashGrid(name, requiredSize, Collections. emptyList(), reducers(), metaData()); + return new InternalGeoHashGrid(name, requiredSize, Collections. emptyList(), pipelineAggregators(), metaData()); } diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoHashGridParser.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoHashGridParser.java index 8a8ac2de2dc..0fe78c1c4e2 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoHashGridParser.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoHashGridParser.java @@ -34,7 +34,7 @@ import org.elasticsearch.search.aggregations.AggregatorFactory; import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.NonCollectingAggregator; import org.elasticsearch.search.aggregations.bucket.BucketUtils; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.AggregationContext; import org.elasticsearch.search.aggregations.support.ValuesSource; import org.elasticsearch.search.aggregations.support.ValuesSourceAggregatorFactory; @@ -125,11 +125,11 @@ public class GeoHashGridParser implements Aggregator.Parser { } @Override - protected Aggregator createUnmapped(AggregationContext aggregationContext, Aggregator parent, List reducers, + protected Aggregator createUnmapped(AggregationContext aggregationContext, Aggregator parent, List pipelineAggregators, Map metaData) throws IOException { final InternalAggregation aggregation = new InternalGeoHashGrid(name, requiredSize, - Collections. emptyList(), reducers, metaData); - return new NonCollectingAggregator(name, aggregationContext, parent, reducers, metaData) { + Collections. emptyList(), pipelineAggregators, metaData); + return new NonCollectingAggregator(name, aggregationContext, parent, pipelineAggregators, metaData) { public InternalAggregation buildEmptyAggregation() { return aggregation; } @@ -138,13 +138,13 @@ public class GeoHashGridParser implements Aggregator.Parser { @Override protected Aggregator doCreateInternal(final ValuesSource.GeoPoint valuesSource, AggregationContext aggregationContext, - Aggregator parent, boolean collectsFromSingleBucket, List reducers, Map metaData) + Aggregator parent, boolean collectsFromSingleBucket, List pipelineAggregators, Map metaData) throws IOException { if (collectsFromSingleBucket == false) { return asMultiBucketAggregator(this, aggregationContext, parent); } ValuesSource.Numeric cellIdSource = new CellIdSource(valuesSource, precision); - return new GeoHashGridAggregator(name, factories, cellIdSource, requiredSize, shardSize, aggregationContext, parent, reducers, + return new GeoHashGridAggregator(name, factories, cellIdSource, requiredSize, shardSize, aggregationContext, parent, pipelineAggregators, metaData); } diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/InternalGeoHashGrid.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/InternalGeoHashGrid.java index c480aa667c7..8bf9cdd4c7b 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/InternalGeoHashGrid.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/InternalGeoHashGrid.java @@ -32,7 +32,7 @@ import org.elasticsearch.search.aggregations.InternalAggregations; import org.elasticsearch.search.aggregations.InternalMultiBucketAggregation; import org.elasticsearch.search.aggregations.bucket.BucketStreamContext; import org.elasticsearch.search.aggregations.bucket.BucketStreams; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import java.io.IOException; import java.util.ArrayList; @@ -171,9 +171,9 @@ public class InternalGeoHashGrid extends InternalMultiBucketAggregation buckets, List reducers, + public InternalGeoHashGrid(String name, int requiredSize, Collection buckets, List pipelineAggregators, Map metaData) { - super(name, reducers, metaData); + super(name, pipelineAggregators, metaData); this.requiredSize = requiredSize; this.buckets = buckets; } @@ -185,7 +185,7 @@ public class InternalGeoHashGrid extends InternalMultiBucketAggregation buckets) { - return new InternalGeoHashGrid(this.name, this.requiredSize, buckets, this.reducers(), this.metaData); + return new InternalGeoHashGrid(this.name, this.requiredSize, buckets, this.pipelineAggregators(), this.metaData); } @Override @@ -229,7 +229,7 @@ public class InternalGeoHashGrid extends InternalMultiBucketAggregation= 0; i--) { list[i] = ordered.pop(); } - return new InternalGeoHashGrid(getName(), requiredSize, Arrays.asList(list), reducers(), getMetaData()); + return new InternalGeoHashGrid(getName(), requiredSize, Arrays.asList(list), pipelineAggregators(), getMetaData()); } @Override diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/global/GlobalAggregator.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/global/GlobalAggregator.java index 1fa3e95d876..63f47e152f6 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/global/GlobalAggregator.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/global/GlobalAggregator.java @@ -27,7 +27,7 @@ import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.LeafBucketCollector; import org.elasticsearch.search.aggregations.LeafBucketCollectorBase; import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregator; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.AggregationContext; import java.io.IOException; @@ -39,9 +39,9 @@ import java.util.Map; */ public class GlobalAggregator extends SingleBucketAggregator { - public GlobalAggregator(String name, AggregatorFactories subFactories, AggregationContext aggregationContext, List reducers, + public GlobalAggregator(String name, AggregatorFactories subFactories, AggregationContext aggregationContext, List pipelineAggregators, Map metaData) throws IOException { - super(name, subFactories, aggregationContext, null, reducers, metaData); + super(name, subFactories, aggregationContext, null, pipelineAggregators, metaData); } @Override @@ -59,7 +59,7 @@ public class GlobalAggregator extends SingleBucketAggregator { @Override public InternalAggregation buildAggregation(long owningBucketOrdinal) throws IOException { assert owningBucketOrdinal == 0 : "global aggregator can only be a top level aggregator"; - return new InternalGlobal(name, bucketDocCount(owningBucketOrdinal), bucketAggregations(owningBucketOrdinal), reducers(), + return new InternalGlobal(name, bucketDocCount(owningBucketOrdinal), bucketAggregations(owningBucketOrdinal), pipelineAggregators(), metaData()); } @@ -76,7 +76,7 @@ public class GlobalAggregator extends SingleBucketAggregator { @Override public Aggregator createInternal(AggregationContext context, Aggregator parent, boolean collectsFromSingleBucket, - List reducers, Map metaData) throws IOException { + List pipelineAggregators, Map metaData) throws IOException { if (parent != null) { throw new AggregationExecutionException("Aggregation [" + parent.name() + "] cannot have a global " + "sub-aggregation [" + name + "]. Global aggregations can only be defined as top level aggregations"); @@ -84,7 +84,7 @@ public class GlobalAggregator extends SingleBucketAggregator { if (collectsFromSingleBucket == false) { throw new IllegalStateException(); } - return new GlobalAggregator(name, factories, context, reducers, metaData); + return new GlobalAggregator(name, factories, context, pipelineAggregators, metaData); } } diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/global/InternalGlobal.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/global/InternalGlobal.java index 157d2c5c7f9..abd5479ba42 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/global/InternalGlobal.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/global/InternalGlobal.java @@ -22,7 +22,7 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.search.aggregations.AggregationStreams; import org.elasticsearch.search.aggregations.InternalAggregations; import org.elasticsearch.search.aggregations.bucket.InternalSingleBucketAggregation; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import java.io.IOException; import java.util.List; @@ -51,8 +51,8 @@ public class InternalGlobal extends InternalSingleBucketAggregation implements G InternalGlobal() {} // for serialization - InternalGlobal(String name, long docCount, InternalAggregations aggregations, List reducers, Map metaData) { - super(name, docCount, aggregations, reducers, metaData); + InternalGlobal(String name, long docCount, InternalAggregations aggregations, List pipelineAggregators, Map metaData) { + super(name, docCount, aggregations, pipelineAggregators, metaData); } @Override @@ -62,6 +62,6 @@ public class InternalGlobal extends InternalSingleBucketAggregation implements G @Override protected InternalSingleBucketAggregation newAggregation(String name, long docCount, InternalAggregations subAggregations) { - return new InternalGlobal(name, docCount, subAggregations, reducers(), getMetaData()); + return new InternalGlobal(name, docCount, subAggregations, pipelineAggregators(), getMetaData()); } } diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/HistogramAggregator.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/HistogramAggregator.java index 44342366b3f..b0596e41129 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/HistogramAggregator.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/HistogramAggregator.java @@ -31,7 +31,7 @@ import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.LeafBucketCollector; import org.elasticsearch.search.aggregations.LeafBucketCollectorBase; import org.elasticsearch.search.aggregations.bucket.BucketsAggregator; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.AggregationContext; import org.elasticsearch.search.aggregations.support.ValuesSource; import org.elasticsearch.search.aggregations.support.ValuesSourceAggregatorFactory; @@ -62,9 +62,9 @@ public class HistogramAggregator extends BucketsAggregator { boolean keyed, long minDocCount, @Nullable ExtendedBounds extendedBounds, @Nullable ValuesSource.Numeric valuesSource, @Nullable ValueFormatter formatter, InternalHistogram.Factory histogramFactory, AggregationContext aggregationContext, - Aggregator parent, List reducers, Map metaData) throws IOException { + Aggregator parent, List pipelineAggregators, Map metaData) throws IOException { - super(name, factories, aggregationContext, parent, reducers, metaData); + super(name, factories, aggregationContext, parent, pipelineAggregators, metaData); this.rounding = rounding; this.order = order; this.keyed = keyed; @@ -130,13 +130,13 @@ public class HistogramAggregator extends BucketsAggregator { // value source will be null for unmapped fields InternalHistogram.EmptyBucketInfo emptyBucketInfo = minDocCount == 0 ? new InternalHistogram.EmptyBucketInfo(rounding, buildEmptySubAggregations(), extendedBounds) : null; - return histogramFactory.create(name, buckets, order, minDocCount, emptyBucketInfo, formatter, keyed, reducers(), metaData()); + return histogramFactory.create(name, buckets, order, minDocCount, emptyBucketInfo, formatter, keyed, pipelineAggregators(), metaData()); } @Override public InternalAggregation buildEmptyAggregation() { InternalHistogram.EmptyBucketInfo emptyBucketInfo = minDocCount == 0 ? new InternalHistogram.EmptyBucketInfo(rounding, buildEmptySubAggregations(), extendedBounds) : null; - return histogramFactory.create(name, Collections.emptyList(), order, minDocCount, emptyBucketInfo, formatter, keyed, reducers(), + return histogramFactory.create(name, Collections.emptyList(), order, minDocCount, emptyBucketInfo, formatter, keyed, pipelineAggregators(), metaData()); } @@ -172,15 +172,15 @@ public class HistogramAggregator extends BucketsAggregator { } @Override - protected Aggregator createUnmapped(AggregationContext aggregationContext, Aggregator parent, List reducers, + protected Aggregator createUnmapped(AggregationContext aggregationContext, Aggregator parent, List pipelineAggregators, Map metaData) throws IOException { return new HistogramAggregator(name, factories, rounding, order, keyed, minDocCount, null, null, config.formatter(), - histogramFactory, aggregationContext, parent, reducers, metaData); + histogramFactory, aggregationContext, parent, pipelineAggregators, metaData); } @Override protected Aggregator doCreateInternal(ValuesSource.Numeric valuesSource, AggregationContext aggregationContext, Aggregator parent, - boolean collectsFromSingleBucket, List reducers, Map metaData) throws IOException { + boolean collectsFromSingleBucket, List pipelineAggregators, Map metaData) throws IOException { if (collectsFromSingleBucket == false) { return asMultiBucketAggregator(this, aggregationContext, parent); } @@ -194,7 +194,7 @@ public class HistogramAggregator extends BucketsAggregator { roundedBounds = extendedBounds.round(rounding); } return new HistogramAggregator(name, factories, rounding, order, keyed, minDocCount, roundedBounds, valuesSource, - config.formatter(), histogramFactory, aggregationContext, parent, reducers, metaData); + config.formatter(), histogramFactory, aggregationContext, parent, pipelineAggregators, metaData); } } diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/InternalHistogram.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/InternalHistogram.java index 3516e9d5ddb..18a58cdba45 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/InternalHistogram.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/InternalHistogram.java @@ -37,7 +37,7 @@ import org.elasticsearch.search.aggregations.InternalAggregations; import org.elasticsearch.search.aggregations.InternalMultiBucketAggregation; import org.elasticsearch.search.aggregations.bucket.BucketStreamContext; import org.elasticsearch.search.aggregations.bucket.BucketStreams; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.format.ValueFormatter; import org.elasticsearch.search.aggregations.support.format.ValueFormatterStreams; @@ -243,14 +243,16 @@ public class InternalHistogram extends Inter } public InternalHistogram create(String name, List buckets, InternalOrder order, long minDocCount, - EmptyBucketInfo emptyBucketInfo, @Nullable ValueFormatter formatter, boolean keyed, List reducers, + EmptyBucketInfo emptyBucketInfo, @Nullable ValueFormatter formatter, boolean keyed, + List pipelineAggregators, Map metaData) { - return new InternalHistogram<>(name, buckets, order, minDocCount, emptyBucketInfo, formatter, keyed, this, reducers, metaData); + return new InternalHistogram<>(name, buckets, order, minDocCount, emptyBucketInfo, formatter, keyed, this, pipelineAggregators, + metaData); } public InternalHistogram create(List buckets, InternalHistogram prototype) { return new InternalHistogram<>(prototype.name, buckets, prototype.order, prototype.minDocCount, prototype.emptyBucketInfo, - prototype.formatter, prototype.keyed, this, prototype.reducers(), prototype.metaData); + prototype.formatter, prototype.keyed, this, prototype.pipelineAggregators(), prototype.metaData); } public B createBucket(InternalAggregations aggregations, B prototype) { @@ -284,8 +286,9 @@ public class InternalHistogram extends Inter InternalHistogram(String name, List buckets, InternalOrder order, long minDocCount, EmptyBucketInfo emptyBucketInfo, - @Nullable ValueFormatter formatter, boolean keyed, Factory factory, List reducers, Map metaData) { - super(name, reducers, metaData); + @Nullable ValueFormatter formatter, boolean keyed, Factory factory, List pipelineAggregators, + Map metaData) { + super(name, pipelineAggregators, metaData); this.buckets = buckets; this.order = order; assert (minDocCount == 0) == (emptyBucketInfo != null); @@ -470,7 +473,7 @@ public class InternalHistogram extends Inter CollectionUtil.introSort(reducedBuckets, order.comparator()); } - return getFactory().create(getName(), reducedBuckets, order, minDocCount, emptyBucketInfo, formatter, keyed, reducers(), + return getFactory().create(getName(), reducedBuckets, order, minDocCount, emptyBucketInfo, formatter, keyed, pipelineAggregators(), getMetaData()); } diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/missing/InternalMissing.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/missing/InternalMissing.java index 0245f117835..9931f29613f 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/missing/InternalMissing.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/missing/InternalMissing.java @@ -22,7 +22,7 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.search.aggregations.AggregationStreams; import org.elasticsearch.search.aggregations.InternalAggregations; import org.elasticsearch.search.aggregations.bucket.InternalSingleBucketAggregation; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import java.io.IOException; import java.util.List; @@ -52,8 +52,8 @@ public class InternalMissing extends InternalSingleBucketAggregation implements InternalMissing() { } - InternalMissing(String name, long docCount, InternalAggregations aggregations, List reducers, Map metaData) { - super(name, docCount, aggregations, reducers, metaData); + InternalMissing(String name, long docCount, InternalAggregations aggregations, List pipelineAggregators, Map metaData) { + super(name, docCount, aggregations, pipelineAggregators, metaData); } @Override @@ -63,6 +63,6 @@ public class InternalMissing extends InternalSingleBucketAggregation implements @Override protected InternalSingleBucketAggregation newAggregation(String name, long docCount, InternalAggregations subAggregations) { - return new InternalMissing(name, docCount, subAggregations, reducers(), getMetaData()); + return new InternalMissing(name, docCount, subAggregations, pipelineAggregators(), getMetaData()); } } diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/missing/MissingAggregator.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/missing/MissingAggregator.java index b60c8510238..1ae7341f611 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/missing/MissingAggregator.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/missing/MissingAggregator.java @@ -26,7 +26,7 @@ import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.LeafBucketCollector; import org.elasticsearch.search.aggregations.LeafBucketCollectorBase; import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregator; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.AggregationContext; import org.elasticsearch.search.aggregations.support.ValuesSource; import org.elasticsearch.search.aggregations.support.ValuesSourceAggregatorFactory; @@ -44,9 +44,9 @@ public class MissingAggregator extends SingleBucketAggregator { private final ValuesSource valuesSource; public MissingAggregator(String name, AggregatorFactories factories, ValuesSource valuesSource, - AggregationContext aggregationContext, Aggregator parent, List reducers, + AggregationContext aggregationContext, Aggregator parent, List pipelineAggregators, Map metaData) throws IOException { - super(name, factories, aggregationContext, parent, reducers, metaData); + super(name, factories, aggregationContext, parent, pipelineAggregators, metaData); this.valuesSource = valuesSource; } @@ -72,13 +72,13 @@ public class MissingAggregator extends SingleBucketAggregator { @Override public InternalAggregation buildAggregation(long owningBucketOrdinal) throws IOException { - return new InternalMissing(name, bucketDocCount(owningBucketOrdinal), bucketAggregations(owningBucketOrdinal), reducers(), + return new InternalMissing(name, bucketDocCount(owningBucketOrdinal), bucketAggregations(owningBucketOrdinal), pipelineAggregators(), metaData()); } @Override public InternalAggregation buildEmptyAggregation() { - return new InternalMissing(name, 0, buildEmptySubAggregations(), reducers(), metaData()); + return new InternalMissing(name, 0, buildEmptySubAggregations(), pipelineAggregators(), metaData()); } public static class Factory extends ValuesSourceAggregatorFactory { @@ -88,15 +88,15 @@ public class MissingAggregator extends SingleBucketAggregator { } @Override - protected MissingAggregator createUnmapped(AggregationContext aggregationContext, Aggregator parent, List reducers, + protected MissingAggregator createUnmapped(AggregationContext aggregationContext, Aggregator parent, List pipelineAggregators, Map metaData) throws IOException { - return new MissingAggregator(name, factories, null, aggregationContext, parent, reducers, metaData); + return new MissingAggregator(name, factories, null, aggregationContext, parent, pipelineAggregators, metaData); } @Override protected MissingAggregator doCreateInternal(ValuesSource valuesSource, AggregationContext aggregationContext, Aggregator parent, - boolean collectsFromSingleBucket, List reducers, Map metaData) throws IOException { - return new MissingAggregator(name, factories, valuesSource, aggregationContext, parent, reducers, metaData); + boolean collectsFromSingleBucket, List pipelineAggregators, Map metaData) throws IOException { + return new MissingAggregator(name, factories, valuesSource, aggregationContext, parent, pipelineAggregators, metaData); } } diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/nested/InternalNested.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/nested/InternalNested.java index 86ad26edab3..badd63eb2ce 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/nested/InternalNested.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/nested/InternalNested.java @@ -22,7 +22,7 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.search.aggregations.AggregationStreams; import org.elasticsearch.search.aggregations.InternalAggregations; import org.elasticsearch.search.aggregations.bucket.InternalSingleBucketAggregation; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import java.io.IOException; import java.util.List; @@ -51,9 +51,9 @@ public class InternalNested extends InternalSingleBucketAggregation implements N public InternalNested() { } - public InternalNested(String name, long docCount, InternalAggregations aggregations, List reducers, + public InternalNested(String name, long docCount, InternalAggregations aggregations, List pipelineAggregators, Map metaData) { - super(name, docCount, aggregations, reducers, metaData); + super(name, docCount, aggregations, pipelineAggregators, metaData); } @Override @@ -63,6 +63,6 @@ public class InternalNested extends InternalSingleBucketAggregation implements N @Override protected InternalSingleBucketAggregation newAggregation(String name, long docCount, InternalAggregations subAggregations) { - return new InternalNested(name, docCount, subAggregations, reducers(), getMetaData()); + return new InternalNested(name, docCount, subAggregations, pipelineAggregators(), getMetaData()); } } diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/nested/InternalReverseNested.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/nested/InternalReverseNested.java index 6dfaad42b03..78fb6ecab5e 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/nested/InternalReverseNested.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/nested/InternalReverseNested.java @@ -22,7 +22,7 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.search.aggregations.AggregationStreams; import org.elasticsearch.search.aggregations.InternalAggregations; import org.elasticsearch.search.aggregations.bucket.InternalSingleBucketAggregation; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import java.io.IOException; import java.util.List; @@ -51,9 +51,9 @@ public class InternalReverseNested extends InternalSingleBucketAggregation imple public InternalReverseNested() { } - public InternalReverseNested(String name, long docCount, InternalAggregations aggregations, List reducers, + public InternalReverseNested(String name, long docCount, InternalAggregations aggregations, List pipelineAggregators, Map metaData) { - super(name, docCount, aggregations, reducers, metaData); + super(name, docCount, aggregations, pipelineAggregators, metaData); } @Override @@ -63,6 +63,6 @@ public class InternalReverseNested extends InternalSingleBucketAggregation imple @Override protected InternalSingleBucketAggregation newAggregation(String name, long docCount, InternalAggregations subAggregations) { - return new InternalReverseNested(name, docCount, subAggregations, reducers(), getMetaData()); + return new InternalReverseNested(name, docCount, subAggregations, pipelineAggregators(), getMetaData()); } } diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/nested/NestedAggregator.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/nested/NestedAggregator.java index 0a212d0a4ad..7f540c250d5 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/nested/NestedAggregator.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/nested/NestedAggregator.java @@ -38,7 +38,7 @@ import org.elasticsearch.search.aggregations.LeafBucketCollector; import org.elasticsearch.search.aggregations.LeafBucketCollectorBase; import org.elasticsearch.search.aggregations.NonCollectingAggregator; import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregator; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.AggregationContext; import java.io.IOException; @@ -56,8 +56,8 @@ public class NestedAggregator extends SingleBucketAggregator { private DocIdSetIterator childDocs; private BitSet parentDocs; - public NestedAggregator(String name, AggregatorFactories factories, ObjectMapper objectMapper, AggregationContext aggregationContext, Aggregator parentAggregator, List reducers, Map metaData) throws IOException { - super(name, factories, aggregationContext, parentAggregator, reducers, metaData); + public NestedAggregator(String name, AggregatorFactories factories, ObjectMapper objectMapper, AggregationContext aggregationContext, Aggregator parentAggregator, List pipelineAggregators, Map metaData) throws IOException { + super(name, factories, aggregationContext, parentAggregator, pipelineAggregators, metaData); childFilter = objectMapper.nestedTypeFilter(); } @@ -121,13 +121,13 @@ public class NestedAggregator extends SingleBucketAggregator { @Override public InternalAggregation buildAggregation(long owningBucketOrdinal) throws IOException { - return new InternalNested(name, bucketDocCount(owningBucketOrdinal), bucketAggregations(owningBucketOrdinal), reducers(), + return new InternalNested(name, bucketDocCount(owningBucketOrdinal), bucketAggregations(owningBucketOrdinal), pipelineAggregators(), metaData()); } @Override public InternalAggregation buildEmptyAggregation() { - return new InternalNested(name, 0, buildEmptySubAggregations(), reducers(), metaData()); + return new InternalNested(name, 0, buildEmptySubAggregations(), pipelineAggregators(), metaData()); } private static Filter findClosestNestedPath(Aggregator parent) { @@ -152,34 +152,34 @@ public class NestedAggregator extends SingleBucketAggregator { @Override public Aggregator createInternal(AggregationContext context, Aggregator parent, boolean collectsFromSingleBucket, - List reducers, Map metaData) throws IOException { + List pipelineAggregators, Map metaData) throws IOException { if (collectsFromSingleBucket == false) { return asMultiBucketAggregator(this, context, parent); } MapperService.SmartNameObjectMapper mapper = context.searchContext().smartNameObjectMapper(path); if (mapper == null) { - return new Unmapped(name, context, parent, reducers, metaData); + return new Unmapped(name, context, parent, pipelineAggregators, metaData); } ObjectMapper objectMapper = mapper.mapper(); if (objectMapper == null) { - return new Unmapped(name, context, parent, reducers, metaData); + return new Unmapped(name, context, parent, pipelineAggregators, metaData); } if (!objectMapper.nested().isNested()) { throw new AggregationExecutionException("[nested] nested path [" + path + "] is not nested"); } - return new NestedAggregator(name, factories, objectMapper, context, parent, reducers, metaData); + return new NestedAggregator(name, factories, objectMapper, context, parent, pipelineAggregators, metaData); } private final static class Unmapped extends NonCollectingAggregator { - public Unmapped(String name, AggregationContext context, Aggregator parent, List reducers, Map metaData) + public Unmapped(String name, AggregationContext context, Aggregator parent, List pipelineAggregators, Map metaData) throws IOException { - super(name, context, parent, reducers, metaData); + super(name, context, parent, pipelineAggregators, metaData); } @Override public InternalAggregation buildEmptyAggregation() { - return new InternalNested(name, 0, buildEmptySubAggregations(), reducers(), metaData()); + return new InternalNested(name, 0, buildEmptySubAggregations(), pipelineAggregators(), metaData()); } } } diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/nested/ReverseNestedAggregator.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/nested/ReverseNestedAggregator.java index 367853e5f04..c658f204840 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/nested/ReverseNestedAggregator.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/nested/ReverseNestedAggregator.java @@ -40,7 +40,7 @@ import org.elasticsearch.search.aggregations.LeafBucketCollector; import org.elasticsearch.search.aggregations.LeafBucketCollectorBase; import org.elasticsearch.search.aggregations.NonCollectingAggregator; import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregator; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.AggregationContext; import java.io.IOException; @@ -55,9 +55,9 @@ public class ReverseNestedAggregator extends SingleBucketAggregator { private final BitDocIdSetFilter parentFilter; public ReverseNestedAggregator(String name, AggregatorFactories factories, ObjectMapper objectMapper, - AggregationContext aggregationContext, Aggregator parent, List reducers, Map metaData) + AggregationContext aggregationContext, Aggregator parent, List pipelineAggregators, Map metaData) throws IOException { - super(name, factories, aggregationContext, parent, reducers, metaData); + super(name, factories, aggregationContext, parent, pipelineAggregators, metaData); if (objectMapper == null) { parentFilter = context.searchContext().bitsetFilterCache().getBitDocIdSetFilter(Queries.newNonNestedFilter()); } else { @@ -111,13 +111,13 @@ public class ReverseNestedAggregator extends SingleBucketAggregator { @Override public InternalAggregation buildAggregation(long owningBucketOrdinal) throws IOException { - return new InternalReverseNested(name, bucketDocCount(owningBucketOrdinal), bucketAggregations(owningBucketOrdinal), reducers(), + return new InternalReverseNested(name, bucketDocCount(owningBucketOrdinal), bucketAggregations(owningBucketOrdinal), pipelineAggregators(), metaData()); } @Override public InternalAggregation buildEmptyAggregation() { - return new InternalReverseNested(name, 0, buildEmptySubAggregations(), reducers(), metaData()); + return new InternalReverseNested(name, 0, buildEmptySubAggregations(), pipelineAggregators(), metaData()); } Filter getParentFilter() { @@ -135,7 +135,7 @@ public class ReverseNestedAggregator extends SingleBucketAggregator { @Override public Aggregator createInternal(AggregationContext context, Aggregator parent, boolean collectsFromSingleBucket, - List reducers, Map metaData) throws IOException { + List pipelineAggregators, Map metaData) throws IOException { // Early validation NestedAggregator closestNestedAggregator = findClosestNestedAggregator(parent); if (closestNestedAggregator == null) { @@ -147,11 +147,11 @@ public class ReverseNestedAggregator extends SingleBucketAggregator { if (path != null) { MapperService.SmartNameObjectMapper mapper = context.searchContext().smartNameObjectMapper(path); if (mapper == null) { - return new Unmapped(name, context, parent, reducers, metaData); + return new Unmapped(name, context, parent, pipelineAggregators, metaData); } objectMapper = mapper.mapper(); if (objectMapper == null) { - return new Unmapped(name, context, parent, reducers, metaData); + return new Unmapped(name, context, parent, pipelineAggregators, metaData); } if (!objectMapper.nested().isNested()) { throw new AggregationExecutionException("[reverse_nested] nested path [" + path + "] is not nested"); @@ -159,19 +159,19 @@ public class ReverseNestedAggregator extends SingleBucketAggregator { } else { objectMapper = null; } - return new ReverseNestedAggregator(name, factories, objectMapper, context, parent, reducers, metaData); + return new ReverseNestedAggregator(name, factories, objectMapper, context, parent, pipelineAggregators, metaData); } private final static class Unmapped extends NonCollectingAggregator { - public Unmapped(String name, AggregationContext context, Aggregator parent, List reducers, Map metaData) + public Unmapped(String name, AggregationContext context, Aggregator parent, List pipelineAggregators, Map metaData) throws IOException { - super(name, context, parent, reducers, metaData); + super(name, context, parent, pipelineAggregators, metaData); } @Override public InternalAggregation buildEmptyAggregation() { - return new InternalReverseNested(name, 0, buildEmptySubAggregations(), reducers(), metaData()); + return new InternalReverseNested(name, 0, buildEmptySubAggregations(), pipelineAggregators(), metaData()); } } } diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/range/InternalRange.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/range/InternalRange.java index db0ccee33e5..7680648ebf5 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/range/InternalRange.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/range/InternalRange.java @@ -31,7 +31,7 @@ import org.elasticsearch.search.aggregations.InternalAggregations; import org.elasticsearch.search.aggregations.InternalMultiBucketAggregation; import org.elasticsearch.search.aggregations.bucket.BucketStreamContext; import org.elasticsearch.search.aggregations.bucket.BucketStreams; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.format.ValueFormatter; import org.elasticsearch.search.aggregations.support.format.ValueFormatterStreams; @@ -231,9 +231,9 @@ public class InternalRange ranges, @Nullable ValueFormatter formatter, boolean keyed, List reducers, + public R create(String name, List ranges, @Nullable ValueFormatter formatter, boolean keyed, List pipelineAggregators, Map metaData) { - return (R) new InternalRange<>(name, ranges, formatter, keyed, reducers, metaData); + return (R) new InternalRange<>(name, ranges, formatter, keyed, pipelineAggregators, metaData); } public B createBucket(String key, double from, double to, long docCount, InternalAggregations aggregations, boolean keyed, @@ -242,7 +242,7 @@ public class InternalRange ranges, R prototype) { - return (R) new InternalRange<>(prototype.name, ranges, prototype.formatter, prototype.keyed, prototype.reducers(), + return (R) new InternalRange<>(prototype.name, ranges, prototype.formatter, prototype.keyed, prototype.pipelineAggregators(), prototype.metaData); } @@ -260,9 +260,9 @@ public class InternalRange ranges, @Nullable ValueFormatter formatter, boolean keyed, List reducers, + public InternalRange(String name, List ranges, @Nullable ValueFormatter formatter, boolean keyed, List pipelineAggregators, Map metaData) { - super(name, reducers, metaData); + super(name, pipelineAggregators, metaData); this.ranges = ranges; this.formatter = formatter; this.keyed = keyed; @@ -311,7 +311,7 @@ public class InternalRange ranges, boolean keyed, AggregationContext aggregationContext, - Aggregator parent, List reducers, + Aggregator parent, List pipelineAggregators, Map metaData) throws IOException { - super(name, factories, aggregationContext, parent, reducers, metaData); + super(name, factories, aggregationContext, parent, pipelineAggregators, metaData); assert valuesSource != null; this.valuesSource = valuesSource; this.formatter = format != null ? format.formatter() : null; @@ -216,7 +216,7 @@ public class RangeAggregator extends BucketsAggregator { buckets.add(bucket); } // value source can be null in the case of unmapped fields - return rangeFactory.create(name, buckets, formatter, keyed, reducers(), metaData()); + return rangeFactory.create(name, buckets, formatter, keyed, pipelineAggregators(), metaData()); } @Override @@ -230,7 +230,7 @@ public class RangeAggregator extends BucketsAggregator { buckets.add(bucket); } // value source can be null in the case of unmapped fields - return rangeFactory.create(name, buckets, formatter, keyed, reducers(), metaData()); + return rangeFactory.create(name, buckets, formatter, keyed, pipelineAggregators(), metaData()); } private static final void sortRanges(final Range[] ranges) { @@ -267,10 +267,10 @@ public class RangeAggregator extends BucketsAggregator { ValueFormat format, AggregationContext context, Aggregator parent, - InternalRange.Factory factory, List reducers, + InternalRange.Factory factory, List pipelineAggregators, Map metaData) throws IOException { - super(name, context, parent, reducers, metaData); + super(name, context, parent, pipelineAggregators, metaData); this.ranges = ranges; ValueParser parser = format != null ? format.parser() : ValueParser.RAW; for (Range range : this.ranges) { @@ -288,7 +288,7 @@ public class RangeAggregator extends BucketsAggregator { for (RangeAggregator.Range range : ranges) { buckets.add(factory.createBucket(range.key, range.from, range.to, 0, subAggs, keyed, formatter)); } - return factory.create(name, buckets, formatter, keyed, reducers(), metaData()); + return factory.create(name, buckets, formatter, keyed, pipelineAggregators(), metaData()); } } @@ -306,15 +306,15 @@ public class RangeAggregator extends BucketsAggregator { } @Override - protected Aggregator createUnmapped(AggregationContext aggregationContext, Aggregator parent, List reducers, + protected Aggregator createUnmapped(AggregationContext aggregationContext, Aggregator parent, List pipelineAggregators, Map metaData) throws IOException { - return new Unmapped(name, ranges, keyed, config.format(), aggregationContext, parent, rangeFactory, reducers, metaData); + return new Unmapped(name, ranges, keyed, config.format(), aggregationContext, parent, rangeFactory, pipelineAggregators, metaData); } @Override protected Aggregator doCreateInternal(ValuesSource.Numeric valuesSource, AggregationContext aggregationContext, Aggregator parent, - boolean collectsFromSingleBucket, List reducers, Map metaData) throws IOException { - return new RangeAggregator(name, factories, valuesSource, config.format(), rangeFactory, ranges, keyed, aggregationContext, parent, reducers, metaData); + boolean collectsFromSingleBucket, List pipelineAggregators, Map metaData) throws IOException { + return new RangeAggregator(name, factories, valuesSource, config.format(), rangeFactory, ranges, keyed, aggregationContext, parent, pipelineAggregators, metaData); } } diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/range/date/InternalDateRange.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/range/date/InternalDateRange.java index 6444f53e527..48e6cd0e0a2 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/range/date/InternalDateRange.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/range/date/InternalDateRange.java @@ -26,7 +26,7 @@ import org.elasticsearch.search.aggregations.InternalAggregations; import org.elasticsearch.search.aggregations.bucket.BucketStreamContext; import org.elasticsearch.search.aggregations.bucket.BucketStreams; import org.elasticsearch.search.aggregations.bucket.range.InternalRange; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.format.ValueFormatter; import org.joda.time.DateTime; import org.joda.time.DateTimeZone; @@ -122,13 +122,13 @@ public class InternalDateRange extends InternalRange ranges, ValueFormatter formatter, boolean keyed, - List reducers, Map metaData) { - return new InternalDateRange(name, ranges, formatter, keyed, reducers, metaData); + List pipelineAggregators, Map metaData) { + return new InternalDateRange(name, ranges, formatter, keyed, pipelineAggregators, metaData); } @Override public InternalDateRange create(List ranges, InternalDateRange prototype) { - return new InternalDateRange(prototype.name, ranges, prototype.formatter, prototype.keyed, prototype.reducers(), + return new InternalDateRange(prototype.name, ranges, prototype.formatter, prototype.keyed, prototype.pipelineAggregators(), prototype.metaData); } @@ -147,8 +147,8 @@ public class InternalDateRange extends InternalRange ranges, @Nullable ValueFormatter formatter, boolean keyed, - List reducers, Map metaData) { - super(name, ranges, formatter, keyed, reducers, metaData); + List pipelineAggregators, Map metaData) { + super(name, ranges, formatter, keyed, pipelineAggregators, metaData); } @Override diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/range/geodistance/GeoDistanceParser.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/range/geodistance/GeoDistanceParser.java index 3eee3ceb704..edc9c2813e4 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/range/geodistance/GeoDistanceParser.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/range/geodistance/GeoDistanceParser.java @@ -35,7 +35,7 @@ import org.elasticsearch.search.aggregations.AggregatorFactory; import org.elasticsearch.search.aggregations.bucket.range.InternalRange; import org.elasticsearch.search.aggregations.bucket.range.RangeAggregator; import org.elasticsearch.search.aggregations.bucket.range.RangeAggregator.Unmapped; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.AggregationContext; import org.elasticsearch.search.aggregations.support.GeoPointParser; import org.elasticsearch.search.aggregations.support.ValuesSource; @@ -186,18 +186,19 @@ public class GeoDistanceParser implements Aggregator.Parser { } @Override - protected Aggregator createUnmapped(AggregationContext aggregationContext, Aggregator parent, List reducers, + protected Aggregator createUnmapped(AggregationContext aggregationContext, Aggregator parent, List pipelineAggregators, Map metaData) throws IOException { - return new Unmapped(name, ranges, keyed, null, aggregationContext, parent, rangeFactory, reducers, metaData); + return new Unmapped(name, ranges, keyed, null, aggregationContext, parent, rangeFactory, pipelineAggregators, metaData); } @Override protected Aggregator doCreateInternal(final ValuesSource.GeoPoint valuesSource, AggregationContext aggregationContext, - Aggregator parent, boolean collectsFromSingleBucket, List reducers, Map metaData) + Aggregator parent, boolean collectsFromSingleBucket, List pipelineAggregators, + Map metaData) throws IOException { DistanceSource distanceSource = new DistanceSource(valuesSource, distanceType, origin, unit); return new RangeAggregator(name, factories, distanceSource, null, rangeFactory, ranges, keyed, aggregationContext, parent, - reducers, metaData); + pipelineAggregators, metaData); } private static class DistanceSource extends ValuesSource.Numeric { diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/range/geodistance/InternalGeoDistance.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/range/geodistance/InternalGeoDistance.java index b271c3336e0..4a91b5c3df2 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/range/geodistance/InternalGeoDistance.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/range/geodistance/InternalGeoDistance.java @@ -26,7 +26,7 @@ import org.elasticsearch.search.aggregations.InternalAggregations; import org.elasticsearch.search.aggregations.bucket.BucketStreamContext; import org.elasticsearch.search.aggregations.bucket.BucketStreams; import org.elasticsearch.search.aggregations.bucket.range.InternalRange; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.format.ValueFormatter; import java.io.IOException; @@ -110,13 +110,13 @@ public class InternalGeoDistance extends InternalRange ranges, @Nullable ValueFormatter formatter, boolean keyed, - List reducers, Map metaData) { - return new InternalGeoDistance(name, ranges, formatter, keyed, reducers, metaData); + List pipelineAggregators, Map metaData) { + return new InternalGeoDistance(name, ranges, formatter, keyed, pipelineAggregators, metaData); } @Override public InternalGeoDistance create(List ranges, InternalGeoDistance prototype) { - return new InternalGeoDistance(prototype.name, ranges, prototype.formatter, prototype.keyed, prototype.reducers(), + return new InternalGeoDistance(prototype.name, ranges, prototype.formatter, prototype.keyed, prototype.pipelineAggregators(), prototype.metaData); } @@ -134,9 +134,9 @@ public class InternalGeoDistance extends InternalRange ranges, @Nullable ValueFormatter formatter, boolean keyed, List reducers, + public InternalGeoDistance(String name, List ranges, @Nullable ValueFormatter formatter, boolean keyed, List pipelineAggregators, Map metaData) { - super(name, ranges, formatter, keyed, reducers, metaData); + super(name, ranges, formatter, keyed, pipelineAggregators, metaData); } @Override diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/range/ipv4/InternalIPv4Range.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/range/ipv4/InternalIPv4Range.java index 96668e67c69..9fbd90530e9 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/range/ipv4/InternalIPv4Range.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/range/ipv4/InternalIPv4Range.java @@ -26,7 +26,7 @@ import org.elasticsearch.search.aggregations.InternalAggregations; import org.elasticsearch.search.aggregations.bucket.BucketStreamContext; import org.elasticsearch.search.aggregations.bucket.BucketStreams; import org.elasticsearch.search.aggregations.bucket.range.InternalRange; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.format.ValueFormatter; import java.io.IOException; @@ -119,13 +119,13 @@ public class InternalIPv4Range extends InternalRange ranges, @Nullable ValueFormatter formatter, boolean keyed, - List reducers, Map metaData) { - return new InternalIPv4Range(name, ranges, keyed, reducers, metaData); + List pipelineAggregators, Map metaData) { + return new InternalIPv4Range(name, ranges, keyed, pipelineAggregators, metaData); } @Override public InternalIPv4Range create(List ranges, InternalIPv4Range prototype) { - return new InternalIPv4Range(prototype.name, ranges, prototype.keyed, prototype.reducers(), prototype.metaData); + return new InternalIPv4Range(prototype.name, ranges, prototype.keyed, prototype.pipelineAggregators(), prototype.metaData); } @Override @@ -142,9 +142,9 @@ public class InternalIPv4Range extends InternalRange ranges, boolean keyed, List reducers, + public InternalIPv4Range(String name, List ranges, boolean keyed, List pipelineAggregators, Map metaData) { - super(name, ranges, ValueFormatter.IPv4, keyed, reducers, metaData); + super(name, ranges, ValueFormatter.IPv4, keyed, pipelineAggregators, metaData); } @Override diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/DiversifiedBytesHashSamplerAggregator.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/DiversifiedBytesHashSamplerAggregator.java index 5487e200fac..61182c5d162 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/DiversifiedBytesHashSamplerAggregator.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/DiversifiedBytesHashSamplerAggregator.java @@ -31,7 +31,7 @@ import org.elasticsearch.search.aggregations.Aggregator; import org.elasticsearch.search.aggregations.AggregatorFactories; import org.elasticsearch.search.aggregations.bucket.BestDocsDeferringCollector; import org.elasticsearch.search.aggregations.bucket.DeferringBucketCollector; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.AggregationContext; import org.elasticsearch.search.aggregations.support.ValuesSource; @@ -49,10 +49,10 @@ public class DiversifiedBytesHashSamplerAggregator extends SamplerAggregator { private int maxDocsPerValue; public DiversifiedBytesHashSamplerAggregator(String name, int shardSize, AggregatorFactories factories, - AggregationContext aggregationContext, Aggregator parent, List reducers, Map metaData, + AggregationContext aggregationContext, Aggregator parent, List pipelineAggregators, Map metaData, ValuesSource valuesSource, int maxDocsPerValue) throws IOException { - super(name, shardSize, factories, aggregationContext, parent, reducers, metaData); + super(name, shardSize, factories, aggregationContext, parent, pipelineAggregators, metaData); this.valuesSource = valuesSource; this.maxDocsPerValue = maxDocsPerValue; } diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/DiversifiedMapSamplerAggregator.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/DiversifiedMapSamplerAggregator.java index bb34ea1c1a8..b8c0abbe317 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/DiversifiedMapSamplerAggregator.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/DiversifiedMapSamplerAggregator.java @@ -33,7 +33,7 @@ import org.elasticsearch.search.aggregations.Aggregator; import org.elasticsearch.search.aggregations.AggregatorFactories; import org.elasticsearch.search.aggregations.bucket.BestDocsDeferringCollector; import org.elasticsearch.search.aggregations.bucket.DeferringBucketCollector; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.AggregationContext; import org.elasticsearch.search.aggregations.support.ValuesSource; @@ -48,9 +48,9 @@ public class DiversifiedMapSamplerAggregator extends SamplerAggregator { private BytesRefHash bucketOrds; public DiversifiedMapSamplerAggregator(String name, int shardSize, AggregatorFactories factories, - AggregationContext aggregationContext, Aggregator parent, List reducers, Map metaData, + AggregationContext aggregationContext, Aggregator parent, List pipelineAggregators, Map metaData, ValuesSource valuesSource, int maxDocsPerValue) throws IOException { - super(name, shardSize, factories, aggregationContext, parent, reducers, metaData); + super(name, shardSize, factories, aggregationContext, parent, pipelineAggregators, metaData); this.valuesSource = valuesSource; this.maxDocsPerValue = maxDocsPerValue; bucketOrds = new BytesRefHash(shardSize, aggregationContext.bigArrays()); diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/DiversifiedNumericSamplerAggregator.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/DiversifiedNumericSamplerAggregator.java index 4947dff39e5..df26688c93c 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/DiversifiedNumericSamplerAggregator.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/DiversifiedNumericSamplerAggregator.java @@ -30,7 +30,7 @@ import org.elasticsearch.search.aggregations.Aggregator; import org.elasticsearch.search.aggregations.AggregatorFactories; import org.elasticsearch.search.aggregations.bucket.BestDocsDeferringCollector; import org.elasticsearch.search.aggregations.bucket.DeferringBucketCollector; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.AggregationContext; import org.elasticsearch.search.aggregations.support.ValuesSource; @@ -44,9 +44,9 @@ public class DiversifiedNumericSamplerAggregator extends SamplerAggregator { private int maxDocsPerValue; public DiversifiedNumericSamplerAggregator(String name, int shardSize, AggregatorFactories factories, - AggregationContext aggregationContext, Aggregator parent, List reducers, Map metaData, + AggregationContext aggregationContext, Aggregator parent, List pipelineAggregators, Map metaData, ValuesSource.Numeric valuesSource, int maxDocsPerValue) throws IOException { - super(name, shardSize, factories, aggregationContext, parent, reducers, metaData); + super(name, shardSize, factories, aggregationContext, parent, pipelineAggregators, metaData); this.valuesSource = valuesSource; this.maxDocsPerValue = maxDocsPerValue; } diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/DiversifiedOrdinalsSamplerAggregator.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/DiversifiedOrdinalsSamplerAggregator.java index 87f1d5d8ab2..4909af5ffca 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/DiversifiedOrdinalsSamplerAggregator.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/DiversifiedOrdinalsSamplerAggregator.java @@ -31,7 +31,7 @@ import org.elasticsearch.search.aggregations.Aggregator; import org.elasticsearch.search.aggregations.AggregatorFactories; import org.elasticsearch.search.aggregations.bucket.BestDocsDeferringCollector; import org.elasticsearch.search.aggregations.bucket.DeferringBucketCollector; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.AggregationContext; import org.elasticsearch.search.aggregations.support.ValuesSource; @@ -45,9 +45,9 @@ public class DiversifiedOrdinalsSamplerAggregator extends SamplerAggregator { private int maxDocsPerValue; public DiversifiedOrdinalsSamplerAggregator(String name, int shardSize, AggregatorFactories factories, - AggregationContext aggregationContext, Aggregator parent, List reducers, Map metaData, + AggregationContext aggregationContext, Aggregator parent, List pipelineAggregators, Map metaData, ValuesSource.Bytes.WithOrdinals.FieldData valuesSource, int maxDocsPerValue) throws IOException { - super(name, shardSize, factories, aggregationContext, parent, reducers, metaData); + super(name, shardSize, factories, aggregationContext, parent, pipelineAggregators, metaData); this.valuesSource = valuesSource; this.maxDocsPerValue = maxDocsPerValue; } diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/InternalSampler.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/InternalSampler.java index ce24c60a3e4..f33cdb5f846 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/InternalSampler.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/InternalSampler.java @@ -22,7 +22,7 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.search.aggregations.AggregationStreams; import org.elasticsearch.search.aggregations.InternalAggregations; import org.elasticsearch.search.aggregations.bucket.InternalSingleBucketAggregation; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import java.io.IOException; import java.util.List; @@ -51,8 +51,8 @@ public class InternalSampler extends InternalSingleBucketAggregation implements InternalSampler() { } // for serialization - InternalSampler(String name, long docCount, InternalAggregations subAggregations, List reducers, Map metaData) { - super(name, docCount, subAggregations, reducers, metaData); + InternalSampler(String name, long docCount, InternalAggregations subAggregations, List pipelineAggregators, Map metaData) { + super(name, docCount, subAggregations, pipelineAggregators, metaData); } @Override @@ -63,6 +63,6 @@ public class InternalSampler extends InternalSingleBucketAggregation implements @Override protected InternalSingleBucketAggregation newAggregation(String name, long docCount, InternalAggregations subAggregations) { - return new InternalSampler(name, docCount, subAggregations, reducers(), metaData); + return new InternalSampler(name, docCount, subAggregations, pipelineAggregators(), metaData); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/SamplerAggregator.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/SamplerAggregator.java index a3b7137975a..a07c248a6a9 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/SamplerAggregator.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/SamplerAggregator.java @@ -30,7 +30,7 @@ import org.elasticsearch.search.aggregations.NonCollectingAggregator; import org.elasticsearch.search.aggregations.bucket.BestDocsDeferringCollector; import org.elasticsearch.search.aggregations.bucket.DeferringBucketCollector; import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregator; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.AggregationContext; import org.elasticsearch.search.aggregations.support.ValuesSource; import org.elasticsearch.search.aggregations.support.ValuesSource.Numeric; @@ -60,9 +60,11 @@ public class SamplerAggregator extends SingleBucketAggregator { @Override Aggregator create(String name, AggregatorFactories factories, int shardSize, int maxDocsPerValue, ValuesSource valuesSource, - AggregationContext context, Aggregator parent, List reducers, Map metaData) throws IOException { + AggregationContext context, Aggregator parent, List pipelineAggregators, + Map metaData) throws IOException { - return new DiversifiedMapSamplerAggregator(name, shardSize, factories, context, parent, reducers, metaData, valuesSource, + return new DiversifiedMapSamplerAggregator(name, shardSize, factories, context, parent, pipelineAggregators, metaData, + valuesSource, maxDocsPerValue); } @@ -76,9 +78,11 @@ public class SamplerAggregator extends SingleBucketAggregator { @Override Aggregator create(String name, AggregatorFactories factories, int shardSize, int maxDocsPerValue, ValuesSource valuesSource, - AggregationContext context, Aggregator parent, List reducers, Map metaData) throws IOException { + AggregationContext context, Aggregator parent, List pipelineAggregators, + Map metaData) throws IOException { - return new DiversifiedBytesHashSamplerAggregator(name, shardSize, factories, context, parent, reducers, metaData, + return new DiversifiedBytesHashSamplerAggregator(name, shardSize, factories, context, parent, pipelineAggregators, + metaData, valuesSource, maxDocsPerValue); } @@ -93,8 +97,9 @@ public class SamplerAggregator extends SingleBucketAggregator { @Override Aggregator create(String name, AggregatorFactories factories, int shardSize, int maxDocsPerValue, ValuesSource valuesSource, - AggregationContext context, Aggregator parent, List reducers, Map metaData) throws IOException { - return new DiversifiedOrdinalsSamplerAggregator(name, shardSize, factories, context, parent, reducers, metaData, + AggregationContext context, Aggregator parent, List pipelineAggregators, + Map metaData) throws IOException { + return new DiversifiedOrdinalsSamplerAggregator(name, shardSize, factories, context, parent, pipelineAggregators, metaData, (ValuesSource.Bytes.WithOrdinals.FieldData) valuesSource, maxDocsPerValue); } @@ -121,7 +126,7 @@ public class SamplerAggregator extends SingleBucketAggregator { } abstract Aggregator create(String name, AggregatorFactories factories, int shardSize, int maxDocsPerValue, ValuesSource valuesSource, - AggregationContext context, Aggregator parent, List reducers, + AggregationContext context, Aggregator parent, List pipelineAggregators, Map metaData) throws IOException; abstract boolean needsGlobalOrdinals(); @@ -137,8 +142,8 @@ public class SamplerAggregator extends SingleBucketAggregator { protected BestDocsDeferringCollector bdd; public SamplerAggregator(String name, int shardSize, AggregatorFactories factories, AggregationContext aggregationContext, - Aggregator parent, List reducers, Map metaData) throws IOException { - super(name, factories, aggregationContext, parent, reducers, metaData); + Aggregator parent, List pipelineAggregators, Map metaData) throws IOException { + super(name, factories, aggregationContext, parent, pipelineAggregators, metaData); this.shardSize = shardSize; } @@ -163,13 +168,13 @@ public class SamplerAggregator extends SingleBucketAggregator { @Override public InternalAggregation buildAggregation(long owningBucketOrdinal) throws IOException { runDeferredCollections(owningBucketOrdinal); - return new InternalSampler(name, bdd == null ? 0 : bdd.getDocCount(), bucketAggregations(owningBucketOrdinal), reducers(), + return new InternalSampler(name, bdd == null ? 0 : bdd.getDocCount(), bucketAggregations(owningBucketOrdinal), pipelineAggregators(), metaData()); } @Override public InternalAggregation buildEmptyAggregation() { - return new InternalSampler(name, 0, buildEmptySubAggregations(), reducers(), metaData()); + return new InternalSampler(name, 0, buildEmptySubAggregations(), pipelineAggregators(), metaData()); } public static class Factory extends AggregatorFactory { @@ -183,12 +188,12 @@ public class SamplerAggregator extends SingleBucketAggregator { @Override public Aggregator createInternal(AggregationContext context, Aggregator parent, boolean collectsFromSingleBucket, - List reducers, Map metaData) throws IOException { + List pipelineAggregators, Map metaData) throws IOException { if (collectsFromSingleBucket == false) { return asMultiBucketAggregator(this, context, parent); } - return new SamplerAggregator(name, shardSize, factories, context, parent, reducers, metaData); + return new SamplerAggregator(name, shardSize, factories, context, parent, pipelineAggregators, metaData); } } @@ -208,7 +213,8 @@ public class SamplerAggregator extends SingleBucketAggregator { @Override protected Aggregator doCreateInternal(ValuesSource valuesSource, AggregationContext context, Aggregator parent, - boolean collectsFromSingleBucket, List reducers, Map metaData) throws IOException { + boolean collectsFromSingleBucket, List pipelineAggregators, Map metaData) + throws IOException { if (collectsFromSingleBucket == false) { return asMultiBucketAggregator(this, context, parent); @@ -216,7 +222,7 @@ public class SamplerAggregator extends SingleBucketAggregator { if (valuesSource instanceof ValuesSource.Numeric) { - return new DiversifiedNumericSamplerAggregator(name, shardSize, factories, context, parent, reducers, metaData, + return new DiversifiedNumericSamplerAggregator(name, shardSize, factories, context, parent, pipelineAggregators, metaData, (Numeric) valuesSource, maxDocsPerValue); } @@ -234,7 +240,8 @@ public class SamplerAggregator extends SingleBucketAggregator { if ((execution.needsGlobalOrdinals()) && (!(valuesSource instanceof ValuesSource.Bytes.WithOrdinals))) { execution = ExecutionMode.MAP; } - return execution.create(name, factories, shardSize, maxDocsPerValue, valuesSource, context, parent, reducers, metaData); + return execution.create(name, factories, shardSize, maxDocsPerValue, valuesSource, context, parent, pipelineAggregators, + metaData); } throw new AggregationExecutionException("Sampler aggregation cannot be applied to field [" + config.fieldContext().field() + @@ -242,11 +249,12 @@ public class SamplerAggregator extends SingleBucketAggregator { } @Override - protected Aggregator createUnmapped(AggregationContext aggregationContext, Aggregator parent, List reducers, + protected Aggregator createUnmapped(AggregationContext aggregationContext, Aggregator parent, + List pipelineAggregators, Map metaData) throws IOException { - final UnmappedSampler aggregation = new UnmappedSampler(name, reducers, metaData); + final UnmappedSampler aggregation = new UnmappedSampler(name, pipelineAggregators, metaData); - return new NonCollectingAggregator(name, aggregationContext, parent, factories, reducers, metaData) { + return new NonCollectingAggregator(name, aggregationContext, parent, factories, pipelineAggregators, metaData) { @Override public InternalAggregation buildEmptyAggregation() { return aggregation; diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/UnmappedSampler.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/UnmappedSampler.java index 5b019ee8bfb..f35f6b4c462 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/UnmappedSampler.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/UnmappedSampler.java @@ -23,7 +23,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.search.aggregations.AggregationStreams; import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.InternalAggregations; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import java.io.IOException; import java.util.List; @@ -53,8 +53,8 @@ public class UnmappedSampler extends InternalSampler { UnmappedSampler() { } - public UnmappedSampler(String name, List reducers, Map metaData) { - super(name, 0, InternalAggregations.EMPTY, reducers, metaData); + public UnmappedSampler(String name, List pipelineAggregators, Map metaData) { + super(name, 0, InternalAggregations.EMPTY, pipelineAggregators, metaData); } @Override diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/GlobalOrdinalsSignificantTermsAggregator.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/GlobalOrdinalsSignificantTermsAggregator.java index c46041dc29f..e48979969f9 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/GlobalOrdinalsSignificantTermsAggregator.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/GlobalOrdinalsSignificantTermsAggregator.java @@ -29,7 +29,7 @@ import org.elasticsearch.search.aggregations.LeafBucketCollector; import org.elasticsearch.search.aggregations.LeafBucketCollectorBase; import org.elasticsearch.search.aggregations.bucket.terms.GlobalOrdinalsStringTermsAggregator; import org.elasticsearch.search.aggregations.bucket.terms.support.IncludeExclude; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.AggregationContext; import org.elasticsearch.search.aggregations.support.ValuesSource; import org.elasticsearch.search.internal.ContextIndexSearcher; @@ -51,10 +51,11 @@ public class GlobalOrdinalsSignificantTermsAggregator extends GlobalOrdinalsStri public GlobalOrdinalsSignificantTermsAggregator(String name, AggregatorFactories factories, ValuesSource.Bytes.WithOrdinals.FieldData valuesSource, BucketCountThresholds bucketCountThresholds, IncludeExclude.OrdinalsFilter includeExclude, AggregationContext aggregationContext, Aggregator parent, - SignificantTermsAggregatorFactory termsAggFactory, List reducers, Map metaData) throws IOException { + SignificantTermsAggregatorFactory termsAggFactory, List pipelineAggregators, Map metaData) + throws IOException { super(name, factories, valuesSource, null, bucketCountThresholds, includeExclude, aggregationContext, parent, - SubAggCollectionMode.DEPTH_FIRST, false, reducers, metaData); + SubAggCollectionMode.DEPTH_FIRST, false, pipelineAggregators, metaData); this.termsAggFactory = termsAggFactory; } @@ -130,7 +131,7 @@ public class GlobalOrdinalsSignificantTermsAggregator extends GlobalOrdinalsStri } return new SignificantStringTerms(subsetSize, supersetSize, name, bucketCountThresholds.getRequiredSize(), - bucketCountThresholds.getMinDocCount(), termsAggFactory.getSignificanceHeuristic(), Arrays.asList(list), reducers(), + bucketCountThresholds.getMinDocCount(), termsAggFactory.getSignificanceHeuristic(), Arrays.asList(list), pipelineAggregators(), metaData()); } @@ -142,7 +143,7 @@ public class GlobalOrdinalsSignificantTermsAggregator extends GlobalOrdinalsStri int supersetSize = topReader.numDocs(); return new SignificantStringTerms(0, supersetSize, name, bucketCountThresholds.getRequiredSize(), bucketCountThresholds.getMinDocCount(), termsAggFactory.getSignificanceHeuristic(), - Collections. emptyList(), reducers(), metaData()); + Collections. emptyList(), pipelineAggregators(), metaData()); } @Override @@ -154,8 +155,12 @@ public class GlobalOrdinalsSignificantTermsAggregator extends GlobalOrdinalsStri private final LongHash bucketOrds; - public WithHash(String name, AggregatorFactories factories, ValuesSource.Bytes.WithOrdinals.FieldData valuesSource, BucketCountThresholds bucketCountThresholds, IncludeExclude.OrdinalsFilter includeExclude, AggregationContext aggregationContext, Aggregator parent, SignificantTermsAggregatorFactory termsAggFactory, List reducers, Map metaData) throws IOException { - super(name, factories, valuesSource, bucketCountThresholds, includeExclude, aggregationContext, parent, termsAggFactory, reducers, metaData); + public WithHash(String name, AggregatorFactories factories, ValuesSource.Bytes.WithOrdinals.FieldData valuesSource, + BucketCountThresholds bucketCountThresholds, IncludeExclude.OrdinalsFilter includeExclude, + AggregationContext aggregationContext, Aggregator parent, SignificantTermsAggregatorFactory termsAggFactory, + List pipelineAggregators, Map metaData) throws IOException { + super(name, factories, valuesSource, bucketCountThresholds, includeExclude, aggregationContext, parent, termsAggFactory, + pipelineAggregators, metaData); bucketOrds = new LongHash(1, aggregationContext.bigArrays()); } diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/InternalSignificantTerms.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/InternalSignificantTerms.java index 825bb637fef..831d92ae81e 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/InternalSignificantTerms.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/InternalSignificantTerms.java @@ -27,7 +27,7 @@ import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.InternalAggregations; import org.elasticsearch.search.aggregations.InternalMultiBucketAggregation; import org.elasticsearch.search.aggregations.bucket.significant.heuristics.SignificanceHeuristic; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import java.util.ArrayList; import java.util.Arrays; @@ -125,9 +125,9 @@ public abstract class InternalSignificantTerms buckets, List reducers, + SignificanceHeuristic significanceHeuristic, List buckets, List pipelineAggregators, Map metaData) { - super(name, reducers, metaData); + super(name, pipelineAggregators, metaData); this.requiredSize = requiredSize; this.minDocCount = minDocCount; this.buckets = buckets; diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/SignificantLongTerms.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/SignificantLongTerms.java index a450f9d0933..e055a5b075c 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/SignificantLongTerms.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/SignificantLongTerms.java @@ -18,7 +18,6 @@ */ package org.elasticsearch.search.aggregations.bucket.significant; -import org.elasticsearch.Version; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; @@ -29,7 +28,7 @@ import org.elasticsearch.search.aggregations.bucket.BucketStreamContext; import org.elasticsearch.search.aggregations.bucket.BucketStreams; import org.elasticsearch.search.aggregations.bucket.significant.heuristics.SignificanceHeuristic; import org.elasticsearch.search.aggregations.bucket.significant.heuristics.SignificanceHeuristicStreams; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.format.ValueFormatter; import org.elasticsearch.search.aggregations.support.format.ValueFormatterStreams; @@ -169,9 +168,9 @@ public class SignificantLongTerms extends InternalSignificantTerms buckets, - List reducers, Map metaData) { + List pipelineAggregators, Map metaData) { - super(subsetSize, supersetSize, name, requiredSize, minDocCount, significanceHeuristic, buckets, reducers, metaData); + super(subsetSize, supersetSize, name, requiredSize, minDocCount, significanceHeuristic, buckets, pipelineAggregators, metaData); this.formatter = formatter; } @@ -183,7 +182,7 @@ public class SignificantLongTerms extends InternalSignificantTerms buckets) { return new SignificantLongTerms(this.subsetSize, this.supersetSize, this.name, this.formatter, this.requiredSize, this.minDocCount, - this.significanceHeuristic, buckets, this.reducers(), this.metaData); + this.significanceHeuristic, buckets, this.pipelineAggregators(), this.metaData); } @Override @@ -197,7 +196,7 @@ public class SignificantLongTerms extends InternalSignificantTerms buckets, InternalSignificantTerms prototype) { return new SignificantLongTerms(subsetSize, supersetSize, prototype.getName(), ((SignificantLongTerms) prototype).formatter, - prototype.requiredSize, prototype.minDocCount, prototype.significanceHeuristic, buckets, prototype.reducers(), + prototype.requiredSize, prototype.minDocCount, prototype.significanceHeuristic, buckets, prototype.pipelineAggregators(), prototype.getMetaData()); } diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/SignificantLongTermsAggregator.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/SignificantLongTermsAggregator.java index 0a33ab39a8e..3bc9674bebd 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/SignificantLongTermsAggregator.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/SignificantLongTermsAggregator.java @@ -28,7 +28,7 @@ import org.elasticsearch.search.aggregations.LeafBucketCollector; import org.elasticsearch.search.aggregations.LeafBucketCollectorBase; import org.elasticsearch.search.aggregations.bucket.terms.LongTermsAggregator; import org.elasticsearch.search.aggregations.bucket.terms.support.IncludeExclude; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.AggregationContext; import org.elasticsearch.search.aggregations.support.ValuesSource; import org.elasticsearch.search.aggregations.support.format.ValueFormat; @@ -48,10 +48,10 @@ public class SignificantLongTermsAggregator extends LongTermsAggregator { public SignificantLongTermsAggregator(String name, AggregatorFactories factories, ValuesSource.Numeric valuesSource, @Nullable ValueFormat format, BucketCountThresholds bucketCountThresholds, AggregationContext aggregationContext, Aggregator parent, SignificantTermsAggregatorFactory termsAggFactory, IncludeExclude.LongFilter includeExclude, - List reducers, Map metaData) throws IOException { + List pipelineAggregators, Map metaData) throws IOException { super(name, factories, valuesSource, format, null, bucketCountThresholds, aggregationContext, parent, - SubAggCollectionMode.DEPTH_FIRST, false, includeExclude, reducers, metaData); + SubAggCollectionMode.DEPTH_FIRST, false, includeExclude, pipelineAggregators, metaData); this.termsAggFactory = termsAggFactory; } @@ -109,7 +109,7 @@ public class SignificantLongTermsAggregator extends LongTermsAggregator { list[i] = bucket; } return new SignificantLongTerms(subsetSize, supersetSize, name, formatter, bucketCountThresholds.getRequiredSize(), - bucketCountThresholds.getMinDocCount(), termsAggFactory.getSignificanceHeuristic(), Arrays.asList(list), reducers(), + bucketCountThresholds.getMinDocCount(), termsAggFactory.getSignificanceHeuristic(), Arrays.asList(list), pipelineAggregators(), metaData()); } @@ -121,7 +121,7 @@ public class SignificantLongTermsAggregator extends LongTermsAggregator { int supersetSize = topReader.numDocs(); return new SignificantLongTerms(0, supersetSize, name, formatter, bucketCountThresholds.getRequiredSize(), bucketCountThresholds.getMinDocCount(), termsAggFactory.getSignificanceHeuristic(), - Collections. emptyList(), reducers(), metaData()); + Collections. emptyList(), pipelineAggregators(), metaData()); } @Override diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/SignificantStringTerms.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/SignificantStringTerms.java index 9fbaa6cc375..6c1ca0a11a0 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/SignificantStringTerms.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/SignificantStringTerms.java @@ -19,7 +19,6 @@ package org.elasticsearch.search.aggregations.bucket.significant; import org.apache.lucene.util.BytesRef; -import org.elasticsearch.Version; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -30,7 +29,7 @@ import org.elasticsearch.search.aggregations.bucket.BucketStreamContext; import org.elasticsearch.search.aggregations.bucket.BucketStreams; import org.elasticsearch.search.aggregations.bucket.significant.heuristics.SignificanceHeuristic; import org.elasticsearch.search.aggregations.bucket.significant.heuristics.SignificanceHeuristicStreams; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import java.io.IOException; import java.util.ArrayList; @@ -161,9 +160,10 @@ public class SignificantStringTerms extends InternalSignificantTerms buckets, List reducers, + SignificanceHeuristic significanceHeuristic, List buckets, + List pipelineAggregators, Map metaData) { - super(subsetSize, supersetSize, name, requiredSize, minDocCount, significanceHeuristic, buckets, reducers, metaData); + super(subsetSize, supersetSize, name, requiredSize, minDocCount, significanceHeuristic, buckets, pipelineAggregators, metaData); } @Override @@ -174,7 +174,7 @@ public class SignificantStringTerms extends InternalSignificantTerms buckets) { return new SignificantStringTerms(this.subsetSize, this.supersetSize, this.name, this.requiredSize, this.minDocCount, - this.significanceHeuristic, buckets, this.reducers(), this.metaData); + this.significanceHeuristic, buckets, this.pipelineAggregators(), this.metaData); } @Override @@ -187,7 +187,7 @@ public class SignificantStringTerms extends InternalSignificantTerms buckets, InternalSignificantTerms prototype) { return new SignificantStringTerms(subsetSize, supersetSize, prototype.getName(), prototype.requiredSize, prototype.minDocCount, - prototype.significanceHeuristic, buckets, prototype.reducers(), prototype.getMetaData()); + prototype.significanceHeuristic, buckets, prototype.pipelineAggregators(), prototype.getMetaData()); } @Override diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/SignificantStringTermsAggregator.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/SignificantStringTermsAggregator.java index 990a17ab7c9..1218bba814c 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/SignificantStringTermsAggregator.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/SignificantStringTermsAggregator.java @@ -28,7 +28,7 @@ import org.elasticsearch.search.aggregations.LeafBucketCollector; import org.elasticsearch.search.aggregations.LeafBucketCollectorBase; import org.elasticsearch.search.aggregations.bucket.terms.StringTermsAggregator; import org.elasticsearch.search.aggregations.bucket.terms.support.IncludeExclude; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.AggregationContext; import org.elasticsearch.search.aggregations.support.ValuesSource; import org.elasticsearch.search.internal.ContextIndexSearcher; @@ -50,11 +50,12 @@ public class SignificantStringTermsAggregator extends StringTermsAggregator { public SignificantStringTermsAggregator(String name, AggregatorFactories factories, ValuesSource valuesSource, BucketCountThresholds bucketCountThresholds, IncludeExclude.StringFilter includeExclude, AggregationContext aggregationContext, Aggregator parent, - SignificantTermsAggregatorFactory termsAggFactory, List reducers, Map metaData) + SignificantTermsAggregatorFactory termsAggFactory, List pipelineAggregators, + Map metaData) throws IOException { super(name, factories, valuesSource, null, bucketCountThresholds, includeExclude, aggregationContext, parent, - SubAggCollectionMode.DEPTH_FIRST, false, reducers, metaData); + SubAggCollectionMode.DEPTH_FIRST, false, pipelineAggregators, metaData); this.termsAggFactory = termsAggFactory; } @@ -115,7 +116,7 @@ public class SignificantStringTermsAggregator extends StringTermsAggregator { } return new SignificantStringTerms(subsetSize, supersetSize, name, bucketCountThresholds.getRequiredSize(), - bucketCountThresholds.getMinDocCount(), termsAggFactory.getSignificanceHeuristic(), Arrays.asList(list), reducers(), + bucketCountThresholds.getMinDocCount(), termsAggFactory.getSignificanceHeuristic(), Arrays.asList(list), pipelineAggregators(), metaData()); } @@ -127,7 +128,7 @@ public class SignificantStringTermsAggregator extends StringTermsAggregator { int supersetSize = topReader.numDocs(); return new SignificantStringTerms(0, supersetSize, name, bucketCountThresholds.getRequiredSize(), bucketCountThresholds.getMinDocCount(), termsAggFactory.getSignificanceHeuristic(), - Collections. emptyList(), reducers(), metaData()); + Collections. emptyList(), pipelineAggregators(), metaData()); } @Override diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/SignificantTermsAggregatorFactory.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/SignificantTermsAggregatorFactory.java index 942c3d66236..f60555dd086 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/SignificantTermsAggregatorFactory.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/SignificantTermsAggregatorFactory.java @@ -37,7 +37,7 @@ import org.elasticsearch.search.aggregations.NonCollectingAggregator; import org.elasticsearch.search.aggregations.bucket.significant.heuristics.SignificanceHeuristic; import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregator; import org.elasticsearch.search.aggregations.bucket.terms.support.IncludeExclude; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.AggregationContext; import org.elasticsearch.search.aggregations.support.ValuesSource; import org.elasticsearch.search.aggregations.support.ValuesSourceAggregatorFactory; @@ -65,10 +65,10 @@ public class SignificantTermsAggregatorFactory extends ValuesSourceAggregatorFac Aggregator create(String name, AggregatorFactories factories, ValuesSource valuesSource, TermsAggregator.BucketCountThresholds bucketCountThresholds, IncludeExclude includeExclude, AggregationContext aggregationContext, Aggregator parent, SignificantTermsAggregatorFactory termsAggregatorFactory, - List reducers, Map metaData) throws IOException { + List pipelineAggregators, Map metaData) throws IOException { final IncludeExclude.StringFilter filter = includeExclude == null ? null : includeExclude.convertToStringFilter(); return new SignificantStringTermsAggregator(name, factories, valuesSource, bucketCountThresholds, filter, - aggregationContext, parent, termsAggregatorFactory, reducers, metaData); + aggregationContext, parent, termsAggregatorFactory, pipelineAggregators, metaData); } }, @@ -78,11 +78,13 @@ public class SignificantTermsAggregatorFactory extends ValuesSourceAggregatorFac Aggregator create(String name, AggregatorFactories factories, ValuesSource valuesSource, TermsAggregator.BucketCountThresholds bucketCountThresholds, IncludeExclude includeExclude, AggregationContext aggregationContext, Aggregator parent, SignificantTermsAggregatorFactory termsAggregatorFactory, - List reducers, Map metaData) throws IOException { + List pipelineAggregators, Map metaData) throws IOException { ValuesSource.Bytes.WithOrdinals valueSourceWithOrdinals = (ValuesSource.Bytes.WithOrdinals) valuesSource; IndexSearcher indexSearcher = aggregationContext.searchContext().searcher(); final IncludeExclude.OrdinalsFilter filter = includeExclude == null ? null : includeExclude.convertToOrdinalsFilter(); - return new GlobalOrdinalsSignificantTermsAggregator(name, factories, (ValuesSource.Bytes.WithOrdinals.FieldData) valuesSource, bucketCountThresholds, filter, aggregationContext, parent, termsAggregatorFactory, reducers, metaData); + return new GlobalOrdinalsSignificantTermsAggregator(name, factories, + (ValuesSource.Bytes.WithOrdinals.FieldData) valuesSource, bucketCountThresholds, filter, aggregationContext, + parent, termsAggregatorFactory, pipelineAggregators, metaData); } }, @@ -92,11 +94,12 @@ public class SignificantTermsAggregatorFactory extends ValuesSourceAggregatorFac Aggregator create(String name, AggregatorFactories factories, ValuesSource valuesSource, TermsAggregator.BucketCountThresholds bucketCountThresholds, IncludeExclude includeExclude, AggregationContext aggregationContext, Aggregator parent, SignificantTermsAggregatorFactory termsAggregatorFactory, - List reducers, Map metaData) throws IOException { + List pipelineAggregators, Map metaData) throws IOException { final IncludeExclude.OrdinalsFilter filter = includeExclude == null ? null : includeExclude.convertToOrdinalsFilter(); return new GlobalOrdinalsSignificantTermsAggregator.WithHash(name, factories, (ValuesSource.Bytes.WithOrdinals.FieldData) valuesSource, bucketCountThresholds, filter, - aggregationContext, parent, termsAggregatorFactory, reducers, metaData); + aggregationContext, + parent, termsAggregatorFactory, pipelineAggregators, metaData); } }; @@ -118,7 +121,7 @@ public class SignificantTermsAggregatorFactory extends ValuesSourceAggregatorFac abstract Aggregator create(String name, AggregatorFactories factories, ValuesSource valuesSource, TermsAggregator.BucketCountThresholds bucketCountThresholds, IncludeExclude includeExclude, AggregationContext aggregationContext, Aggregator parent, SignificantTermsAggregatorFactory termsAggregatorFactory, - List reducers, Map metaData) throws IOException; + List pipelineAggregators, Map metaData) throws IOException; @Override public String toString() { @@ -155,11 +158,12 @@ public class SignificantTermsAggregatorFactory extends ValuesSourceAggregatorFac } @Override - protected Aggregator createUnmapped(AggregationContext aggregationContext, Aggregator parent, List reducers, + protected Aggregator createUnmapped(AggregationContext aggregationContext, Aggregator parent, + List pipelineAggregators, Map metaData) throws IOException { final InternalAggregation aggregation = new UnmappedSignificantTerms(name, bucketCountThresholds.getRequiredSize(), - bucketCountThresholds.getMinDocCount(), reducers, metaData); - return new NonCollectingAggregator(name, aggregationContext, parent, reducers, metaData) { + bucketCountThresholds.getMinDocCount(), pipelineAggregators, metaData); + return new NonCollectingAggregator(name, aggregationContext, parent, pipelineAggregators, metaData) { @Override public InternalAggregation buildEmptyAggregation() { return aggregation; @@ -169,7 +173,8 @@ public class SignificantTermsAggregatorFactory extends ValuesSourceAggregatorFac @Override protected Aggregator doCreateInternal(ValuesSource valuesSource, AggregationContext aggregationContext, Aggregator parent, - boolean collectsFromSingleBucket, List reducers, Map metaData) throws IOException { + boolean collectsFromSingleBucket, List pipelineAggregators, Map metaData) + throws IOException { if (collectsFromSingleBucket == false) { return asMultiBucketAggregator(this, aggregationContext, parent); } @@ -193,7 +198,7 @@ public class SignificantTermsAggregatorFactory extends ValuesSourceAggregatorFac } assert execution != null; return execution.create(name, factories, valuesSource, bucketCountThresholds, includeExclude, aggregationContext, parent, this, - reducers, metaData); + pipelineAggregators, metaData); } @@ -212,7 +217,7 @@ public class SignificantTermsAggregatorFactory extends ValuesSourceAggregatorFac longFilter = includeExclude.convertToLongFilter(); } return new SignificantLongTermsAggregator(name, factories, (ValuesSource.Numeric) valuesSource, config.format(), - bucketCountThresholds, aggregationContext, parent, this, longFilter, reducers, metaData); + bucketCountThresholds, aggregationContext, parent, this, longFilter, pipelineAggregators, metaData); } throw new AggregationExecutionException("sigfnificant_terms aggregation cannot be applied to field [" + config.fieldContext().field() + diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/UnmappedSignificantTerms.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/UnmappedSignificantTerms.java index cfd765dbf6c..c7569db612c 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/UnmappedSignificantTerms.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/significant/UnmappedSignificantTerms.java @@ -25,7 +25,7 @@ import org.elasticsearch.search.aggregations.AggregationStreams; import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.InternalAggregations; import org.elasticsearch.search.aggregations.bucket.significant.heuristics.JLHScore; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import java.io.IOException; import java.util.Collections; @@ -57,10 +57,10 @@ public class UnmappedSignificantTerms extends InternalSignificantTerms reducers, Map metaData) { + public UnmappedSignificantTerms(String name, int requiredSize, long minDocCount, List pipelineAggregators, Map metaData) { //We pass zero for index/subset sizes because for the purpose of significant term analysis // we assume an unmapped index's size is irrelevant to the proceedings. - super(0, 0, name, requiredSize, minDocCount, JLHScore.INSTANCE, BUCKETS, reducers, metaData); + super(0, 0, name, requiredSize, minDocCount, JLHScore.INSTANCE, BUCKETS, pipelineAggregators, metaData); } @Override @@ -70,7 +70,7 @@ public class UnmappedSignificantTerms extends InternalSignificantTerms buckets) { - return new UnmappedSignificantTerms(this.name, this.requiredSize, this.minDocCount, this.reducers(), this.metaData); + return new UnmappedSignificantTerms(this.name, this.requiredSize, this.minDocCount, this.pipelineAggregators(), this.metaData); } @Override diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/AbstractStringTermsAggregator.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/AbstractStringTermsAggregator.java index 363895c5a39..cfdf2a7af2f 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/AbstractStringTermsAggregator.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/AbstractStringTermsAggregator.java @@ -22,7 +22,7 @@ package org.elasticsearch.search.aggregations.bucket.terms; import org.elasticsearch.search.aggregations.Aggregator; import org.elasticsearch.search.aggregations.AggregatorFactories; import org.elasticsearch.search.aggregations.InternalAggregation; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.AggregationContext; import java.io.IOException; @@ -36,8 +36,8 @@ abstract class AbstractStringTermsAggregator extends TermsAggregator { public AbstractStringTermsAggregator(String name, AggregatorFactories factories, AggregationContext context, Aggregator parent, Terms.Order order, BucketCountThresholds bucketCountThresholds, SubAggCollectionMode subAggCollectMode, - boolean showTermDocCountError, List reducers, Map metaData) throws IOException { - super(name, factories, context, parent, bucketCountThresholds, order, subAggCollectMode, reducers, metaData); + boolean showTermDocCountError, List pipelineAggregators, Map metaData) throws IOException { + super(name, factories, context, parent, bucketCountThresholds, order, subAggCollectMode, pipelineAggregators, metaData); this.showTermDocCountError = showTermDocCountError; } @@ -45,7 +45,7 @@ abstract class AbstractStringTermsAggregator extends TermsAggregator { public InternalAggregation buildEmptyAggregation() { return new StringTerms(name, order, bucketCountThresholds.getRequiredSize(), bucketCountThresholds.getShardSize(), bucketCountThresholds.getMinDocCount(), Collections. emptyList(), showTermDocCountError, 0, 0, - reducers(), metaData()); + pipelineAggregators(), metaData()); } } diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/DoubleTerms.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/DoubleTerms.java index dbb8061db09..f9dd75b8991 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/DoubleTerms.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/DoubleTerms.java @@ -27,7 +27,7 @@ import org.elasticsearch.search.aggregations.AggregationStreams; import org.elasticsearch.search.aggregations.InternalAggregations; import org.elasticsearch.search.aggregations.bucket.BucketStreamContext; import org.elasticsearch.search.aggregations.bucket.BucketStreams; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.format.ValueFormatter; import org.elasticsearch.search.aggregations.support.format.ValueFormatterStreams; @@ -162,8 +162,8 @@ public class DoubleTerms extends InternalTerms public DoubleTerms(String name, Terms.Order order, @Nullable ValueFormatter formatter, int requiredSize, int shardSize, long minDocCount, List buckets, boolean showTermDocCountError, long docCountError, - long otherDocCount, List reducers, Map metaData) { - super(name, order, requiredSize, shardSize, minDocCount, buckets, showTermDocCountError, docCountError, otherDocCount, reducers, + long otherDocCount, List pipelineAggregators, Map metaData) { + super(name, order, requiredSize, shardSize, minDocCount, buckets, showTermDocCountError, docCountError, otherDocCount, pipelineAggregators, metaData); this.formatter = formatter; } @@ -176,7 +176,7 @@ public class DoubleTerms extends InternalTerms @Override public DoubleTerms create(List buckets) { return new DoubleTerms(this.name, this.order, this.formatter, this.requiredSize, this.shardSize, this.minDocCount, buckets, - this.showTermDocCountError, this.docCountError, this.otherDocCount, this.reducers(), this.metaData); + this.showTermDocCountError, this.docCountError, this.otherDocCount, this.pipelineAggregators(), this.metaData); } @Override @@ -189,7 +189,7 @@ public class DoubleTerms extends InternalTerms protected DoubleTerms create(String name, List buckets, long docCountError, long otherDocCount, InternalTerms prototype) { return new DoubleTerms(name, prototype.order, ((DoubleTerms) prototype).formatter, prototype.requiredSize, prototype.shardSize, - prototype.minDocCount, buckets, prototype.showTermDocCountError, docCountError, otherDocCount, prototype.reducers(), + prototype.minDocCount, buckets, prototype.showTermDocCountError, docCountError, otherDocCount, prototype.pipelineAggregators(), prototype.getMetaData()); } diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/DoubleTermsAggregator.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/DoubleTermsAggregator.java index 9250495524e..ecae831d267 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/DoubleTermsAggregator.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/DoubleTermsAggregator.java @@ -26,7 +26,7 @@ import org.elasticsearch.index.fielddata.FieldData; import org.elasticsearch.search.aggregations.Aggregator; import org.elasticsearch.search.aggregations.AggregatorFactories; import org.elasticsearch.search.aggregations.bucket.terms.support.IncludeExclude; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.AggregationContext; import org.elasticsearch.search.aggregations.support.ValuesSource; import org.elasticsearch.search.aggregations.support.ValuesSource.Numeric; @@ -45,9 +45,9 @@ public class DoubleTermsAggregator extends LongTermsAggregator { public DoubleTermsAggregator(String name, AggregatorFactories factories, ValuesSource.Numeric valuesSource, @Nullable ValueFormat format, Terms.Order order, BucketCountThresholds bucketCountThresholds, AggregationContext aggregationContext, Aggregator parent, SubAggCollectionMode collectionMode, boolean showTermDocCountError, - IncludeExclude.LongFilter longFilter, List reducers, Map metaData) throws IOException { + IncludeExclude.LongFilter longFilter, List pipelineAggregators, Map metaData) throws IOException { super(name, factories, valuesSource, format, order, bucketCountThresholds, aggregationContext, parent, collectionMode, - showTermDocCountError, longFilter, reducers, metaData); + showTermDocCountError, longFilter, pipelineAggregators, metaData); } @Override @@ -79,7 +79,7 @@ public class DoubleTermsAggregator extends LongTermsAggregator { buckets[i] = convertToDouble(buckets[i]); } return new DoubleTerms(terms.getName(), terms.order, terms.formatter, terms.requiredSize, terms.shardSize, terms.minDocCount, - Arrays.asList(buckets), terms.showTermDocCountError, terms.docCountError, terms.otherDocCount, terms.reducers(), + Arrays.asList(buckets), terms.showTermDocCountError, terms.docCountError, terms.otherDocCount, terms.pipelineAggregators(), terms.getMetaData()); } diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/GlobalOrdinalsStringTermsAggregator.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/GlobalOrdinalsStringTermsAggregator.java index 2d2cebde163..6598f6dbdbb 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/GlobalOrdinalsStringTermsAggregator.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/GlobalOrdinalsStringTermsAggregator.java @@ -44,7 +44,7 @@ import org.elasticsearch.search.aggregations.LeafBucketCollectorBase; import org.elasticsearch.search.aggregations.bucket.terms.InternalTerms.Bucket; import org.elasticsearch.search.aggregations.bucket.terms.support.BucketPriorityQueue; import org.elasticsearch.search.aggregations.bucket.terms.support.IncludeExclude; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.AggregationContext; import org.elasticsearch.search.aggregations.support.ValuesSource; @@ -73,8 +73,11 @@ public class GlobalOrdinalsStringTermsAggregator extends AbstractStringTermsAggr public GlobalOrdinalsStringTermsAggregator(String name, AggregatorFactories factories, ValuesSource.Bytes.WithOrdinals valuesSource, Terms.Order order, BucketCountThresholds bucketCountThresholds, - IncludeExclude.OrdinalsFilter includeExclude, AggregationContext aggregationContext, Aggregator parent, SubAggCollectionMode collectionMode, boolean showTermDocCountError, List reducers, Map metaData) throws IOException { - super(name, factories, aggregationContext, parent, order, bucketCountThresholds, collectionMode, showTermDocCountError, reducers, + IncludeExclude.OrdinalsFilter includeExclude, + AggregationContext aggregationContext, Aggregator parent, SubAggCollectionMode collectionMode, boolean showTermDocCountError, + List pipelineAggregators, Map metaData) throws IOException { + super(name, factories, aggregationContext, parent, order, bucketCountThresholds, collectionMode, showTermDocCountError, + pipelineAggregators, metaData); this.valuesSource = valuesSource; this.includeExclude = includeExclude; @@ -200,7 +203,7 @@ public class GlobalOrdinalsStringTermsAggregator extends AbstractStringTermsAggr } return new StringTerms(name, order, bucketCountThresholds.getRequiredSize(), bucketCountThresholds.getShardSize(), - bucketCountThresholds.getMinDocCount(), Arrays.asList(list), showTermDocCountError, 0, otherDocCount, reducers(), + bucketCountThresholds.getMinDocCount(), Arrays.asList(list), showTermDocCountError, 0, otherDocCount, pipelineAggregators(), metaData()); } @@ -266,8 +269,11 @@ public class GlobalOrdinalsStringTermsAggregator extends AbstractStringTermsAggr public WithHash(String name, AggregatorFactories factories, ValuesSource.Bytes.WithOrdinals.FieldData valuesSource, Terms.Order order, BucketCountThresholds bucketCountThresholds, IncludeExclude.OrdinalsFilter includeExclude, AggregationContext aggregationContext, - Aggregator parent, SubAggCollectionMode collectionMode, boolean showTermDocCountError, List reducers, Map metaData) throws IOException { - super(name, factories, valuesSource, order, bucketCountThresholds, includeExclude, aggregationContext, parent, collectionMode, showTermDocCountError, reducers, metaData); + Aggregator parent, SubAggCollectionMode collectionMode, + boolean showTermDocCountError, List pipelineAggregators, Map metaData) + throws IOException { + super(name, factories, valuesSource, order, bucketCountThresholds, includeExclude, aggregationContext, parent, collectionMode, + showTermDocCountError, pipelineAggregators, metaData); bucketOrds = new LongHash(1, aggregationContext.bigArrays()); } @@ -335,8 +341,12 @@ public class GlobalOrdinalsStringTermsAggregator extends AbstractStringTermsAggr private RandomAccessOrds segmentOrds; public LowCardinality(String name, AggregatorFactories factories, ValuesSource.Bytes.WithOrdinals valuesSource, - Terms.Order order, BucketCountThresholds bucketCountThresholds, AggregationContext aggregationContext, Aggregator parent, SubAggCollectionMode collectionMode, boolean showTermDocCountError, List reducers, Map metaData) throws IOException { - super(name, factories, valuesSource, order, bucketCountThresholds, null, aggregationContext, parent, collectionMode, showTermDocCountError, reducers, metaData); + Terms.Order order, + BucketCountThresholds bucketCountThresholds, AggregationContext aggregationContext, Aggregator parent, + SubAggCollectionMode collectionMode, boolean showTermDocCountError, List pipelineAggregators, + Map metaData) throws IOException { + super(name, factories, valuesSource, order, bucketCountThresholds, null, aggregationContext, parent, collectionMode, + showTermDocCountError, pipelineAggregators, metaData); assert factories == null || factories.count() == 0; this.segmentDocCounts = context.bigArrays().newIntArray(1, true); } diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/InternalTerms.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/InternalTerms.java index c5fedd659f0..9521f8edf60 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/InternalTerms.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/InternalTerms.java @@ -30,7 +30,7 @@ import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.InternalAggregations; import org.elasticsearch.search.aggregations.InternalMultiBucketAggregation; import org.elasticsearch.search.aggregations.bucket.terms.support.BucketPriorityQueue; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.format.ValueFormatter; import java.util.ArrayList; @@ -124,9 +124,9 @@ public abstract class InternalTerms buckets, boolean showTermDocCountError, long docCountError, long otherDocCount, List reducers, + List buckets, boolean showTermDocCountError, long docCountError, long otherDocCount, List pipelineAggregators, Map metaData) { - super(name, reducers, metaData); + super(name, pipelineAggregators, metaData); this.order = order; this.requiredSize = requiredSize; this.shardSize = shardSize; diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/LongTerms.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/LongTerms.java index eee9e6bfc4b..486a0339daf 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/LongTerms.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/LongTerms.java @@ -26,7 +26,7 @@ import org.elasticsearch.search.aggregations.AggregationStreams; import org.elasticsearch.search.aggregations.InternalAggregations; import org.elasticsearch.search.aggregations.bucket.BucketStreamContext; import org.elasticsearch.search.aggregations.bucket.BucketStreams; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.format.ValueFormatter; import org.elasticsearch.search.aggregations.support.format.ValueFormatterStreams; @@ -158,8 +158,8 @@ public class LongTerms extends InternalTerms { public LongTerms(String name, Terms.Order order, @Nullable ValueFormatter formatter, int requiredSize, int shardSize, long minDocCount, List buckets, boolean showTermDocCountError, long docCountError, long otherDocCount, - List reducers, Map metaData) { - super(name, order, requiredSize, shardSize, minDocCount, buckets, showTermDocCountError, docCountError, otherDocCount, reducers, + List pipelineAggregators, Map metaData) { + super(name, order, requiredSize, shardSize, minDocCount, buckets, showTermDocCountError, docCountError, otherDocCount, pipelineAggregators, metaData); this.formatter = formatter; } @@ -172,7 +172,7 @@ public class LongTerms extends InternalTerms { @Override public LongTerms create(List buckets) { return new LongTerms(this.name, this.order, this.formatter, this.requiredSize, this.shardSize, this.minDocCount, buckets, - this.showTermDocCountError, this.docCountError, this.otherDocCount, this.reducers(), this.metaData); + this.showTermDocCountError, this.docCountError, this.otherDocCount, this.pipelineAggregators(), this.metaData); } @Override @@ -185,7 +185,7 @@ public class LongTerms extends InternalTerms { protected LongTerms create(String name, List buckets, long docCountError, long otherDocCount, InternalTerms prototype) { return new LongTerms(name, prototype.order, ((LongTerms) prototype).formatter, prototype.requiredSize, prototype.shardSize, - prototype.minDocCount, buckets, prototype.showTermDocCountError, docCountError, otherDocCount, prototype.reducers(), + prototype.minDocCount, buckets, prototype.showTermDocCountError, docCountError, otherDocCount, prototype.pipelineAggregators(), prototype.getMetaData()); } diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/LongTermsAggregator.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/LongTermsAggregator.java index ea32e388fe6..84ca2f3818d 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/LongTermsAggregator.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/LongTermsAggregator.java @@ -31,7 +31,7 @@ import org.elasticsearch.search.aggregations.LeafBucketCollector; import org.elasticsearch.search.aggregations.bucket.terms.support.BucketPriorityQueue; import org.elasticsearch.search.aggregations.bucket.terms.support.IncludeExclude; import org.elasticsearch.search.aggregations.bucket.terms.support.IncludeExclude.LongFilter; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.AggregationContext; import org.elasticsearch.search.aggregations.support.ValuesSource; import org.elasticsearch.search.aggregations.support.format.ValueFormat; @@ -57,8 +57,8 @@ public class LongTermsAggregator extends TermsAggregator { public LongTermsAggregator(String name, AggregatorFactories factories, ValuesSource.Numeric valuesSource, @Nullable ValueFormat format, Terms.Order order, BucketCountThresholds bucketCountThresholds, AggregationContext aggregationContext, Aggregator parent, SubAggCollectionMode subAggCollectMode, boolean showTermDocCountError, IncludeExclude.LongFilter longFilter, - List reducers, Map metaData) throws IOException { - super(name, factories, aggregationContext, parent, bucketCountThresholds, order, subAggCollectMode, reducers, metaData); + List pipelineAggregators, Map metaData) throws IOException { + super(name, factories, aggregationContext, parent, bucketCountThresholds, order, subAggCollectMode, pipelineAggregators, metaData); this.valuesSource = valuesSource; this.showTermDocCountError = showTermDocCountError; this.formatter = format != null ? format.formatter() : null; @@ -162,7 +162,7 @@ public class LongTermsAggregator extends TermsAggregator { } return new LongTerms(name, order, formatter, bucketCountThresholds.getRequiredSize(), bucketCountThresholds.getShardSize(), - bucketCountThresholds.getMinDocCount(), Arrays.asList(list), showTermDocCountError, 0, otherDocCount, reducers(), + bucketCountThresholds.getMinDocCount(), Arrays.asList(list), showTermDocCountError, 0, otherDocCount, pipelineAggregators(), metaData()); } @@ -170,7 +170,7 @@ public class LongTermsAggregator extends TermsAggregator { public InternalAggregation buildEmptyAggregation() { return new LongTerms(name, order, formatter, bucketCountThresholds.getRequiredSize(), bucketCountThresholds.getShardSize(), bucketCountThresholds.getMinDocCount(), Collections. emptyList(), showTermDocCountError, 0, 0, - reducers(), metaData()); + pipelineAggregators(), metaData()); } @Override diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/StringTerms.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/StringTerms.java index ee458acdf13..0b9ebd97cf9 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/StringTerms.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/StringTerms.java @@ -27,7 +27,7 @@ import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.InternalAggregations; import org.elasticsearch.search.aggregations.bucket.BucketStreamContext; import org.elasticsearch.search.aggregations.bucket.BucketStreams; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import java.io.IOException; import java.util.ArrayList; @@ -153,8 +153,8 @@ public class StringTerms extends InternalTerms public StringTerms(String name, Terms.Order order, int requiredSize, int shardSize, long minDocCount, List buckets, boolean showTermDocCountError, long docCountError, long otherDocCount, - List reducers, Map metaData) { - super(name, order, requiredSize, shardSize, minDocCount, buckets, showTermDocCountError, docCountError, otherDocCount, reducers, + List pipelineAggregators, Map metaData) { + super(name, order, requiredSize, shardSize, minDocCount, buckets, showTermDocCountError, docCountError, otherDocCount, pipelineAggregators, metaData); } @@ -166,7 +166,7 @@ public class StringTerms extends InternalTerms @Override public StringTerms create(List buckets) { return new StringTerms(this.name, this.order, this.requiredSize, this.shardSize, this.minDocCount, buckets, - this.showTermDocCountError, this.docCountError, this.otherDocCount, this.reducers(), this.metaData); + this.showTermDocCountError, this.docCountError, this.otherDocCount, this.pipelineAggregators(), this.metaData); } @Override @@ -178,7 +178,7 @@ public class StringTerms extends InternalTerms protected StringTerms create(String name, List buckets, long docCountError, long otherDocCount, InternalTerms prototype) { return new StringTerms(name, prototype.order, prototype.requiredSize, prototype.shardSize, prototype.minDocCount, buckets, - prototype.showTermDocCountError, docCountError, otherDocCount, prototype.reducers(), prototype.getMetaData()); + prototype.showTermDocCountError, docCountError, otherDocCount, prototype.pipelineAggregators(), prototype.getMetaData()); } @Override diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/StringTermsAggregator.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/StringTermsAggregator.java index 6f80142da27..4f9faae962c 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/StringTermsAggregator.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/StringTermsAggregator.java @@ -31,7 +31,7 @@ import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.LeafBucketCollector; import org.elasticsearch.search.aggregations.bucket.terms.support.BucketPriorityQueue; import org.elasticsearch.search.aggregations.bucket.terms.support.IncludeExclude; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.AggregationContext; import org.elasticsearch.search.aggregations.support.ValuesSource; @@ -52,10 +52,10 @@ public class StringTermsAggregator extends AbstractStringTermsAggregator { public StringTermsAggregator(String name, AggregatorFactories factories, ValuesSource valuesSource, Terms.Order order, BucketCountThresholds bucketCountThresholds, IncludeExclude.StringFilter includeExclude, AggregationContext aggregationContext, - Aggregator parent, SubAggCollectionMode collectionMode, boolean showTermDocCountError, List reducers, + Aggregator parent, SubAggCollectionMode collectionMode, boolean showTermDocCountError, List pipelineAggregators, Map metaData) throws IOException { - super(name, factories, aggregationContext, parent, order, bucketCountThresholds, collectionMode, showTermDocCountError, reducers, + super(name, factories, aggregationContext, parent, order, bucketCountThresholds, collectionMode, showTermDocCountError, pipelineAggregators, metaData); this.valuesSource = valuesSource; this.includeExclude = includeExclude; @@ -164,7 +164,7 @@ public class StringTermsAggregator extends AbstractStringTermsAggregator { } return new StringTerms(name, order, bucketCountThresholds.getRequiredSize(), bucketCountThresholds.getShardSize(), - bucketCountThresholds.getMinDocCount(), Arrays.asList(list), showTermDocCountError, 0, otherDocCount, reducers(), + bucketCountThresholds.getMinDocCount(), Arrays.asList(list), showTermDocCountError, 0, otherDocCount, pipelineAggregators(), metaData()); } diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/TermsAggregator.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/TermsAggregator.java index 165675d0ddf..7971d1f5ae5 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/TermsAggregator.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/TermsAggregator.java @@ -28,7 +28,7 @@ import org.elasticsearch.search.aggregations.AggregatorFactories; import org.elasticsearch.search.aggregations.bucket.BucketsAggregator; import org.elasticsearch.search.aggregations.bucket.terms.InternalOrder.Aggregation; import org.elasticsearch.search.aggregations.bucket.terms.InternalOrder.CompoundOrder; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.AggregationContext; import org.elasticsearch.search.aggregations.support.AggregationPath; @@ -137,8 +137,8 @@ public abstract class TermsAggregator extends BucketsAggregator { protected final Set aggsUsedForSorting = new HashSet<>(); protected final SubAggCollectionMode collectMode; - public TermsAggregator(String name, AggregatorFactories factories, AggregationContext context, Aggregator parent, BucketCountThresholds bucketCountThresholds, Terms.Order order, SubAggCollectionMode collectMode, List reducers, Map metaData) throws IOException { - super(name, factories, context, parent, reducers, metaData); + public TermsAggregator(String name, AggregatorFactories factories, AggregationContext context, Aggregator parent, BucketCountThresholds bucketCountThresholds, Terms.Order order, SubAggCollectionMode collectMode, List pipelineAggregators, Map metaData) throws IOException { + super(name, factories, context, parent, pipelineAggregators, metaData); this.bucketCountThresholds = bucketCountThresholds; this.order = InternalOrder.validate(order, this); this.collectMode = collectMode; diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/TermsAggregatorFactory.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/TermsAggregatorFactory.java index 84196067a86..1b0657ff657 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/TermsAggregatorFactory.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/TermsAggregatorFactory.java @@ -27,7 +27,7 @@ import org.elasticsearch.search.aggregations.AggregatorFactories; import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.NonCollectingAggregator; import org.elasticsearch.search.aggregations.bucket.terms.support.IncludeExclude; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.AggregationContext; import org.elasticsearch.search.aggregations.support.ValuesSource; import org.elasticsearch.search.aggregations.support.ValuesSourceAggregatorFactory; @@ -40,20 +40,21 @@ import java.util.Map; /** * */ -public class TermsAggregatorFactory extends ValuesSourceAggregatorFactory { +public class TermsAggregatorFactory extends ValuesSourceAggregatorFactory { public enum ExecutionMode { MAP(new ParseField("map")) { @Override - Aggregator create(String name, AggregatorFactories factories, ValuesSource valuesSource, - Terms.Order order, TermsAggregator.BucketCountThresholds bucketCountThresholds, IncludeExclude includeExclude, + Aggregator create(String name, AggregatorFactories factories, ValuesSource valuesSource, Terms.Order order, + TermsAggregator.BucketCountThresholds bucketCountThresholds, IncludeExclude includeExclude, AggregationContext aggregationContext, Aggregator parent, SubAggCollectionMode subAggCollectMode, - boolean showTermDocCountError, List reducers, Map metaData) throws IOException { + boolean showTermDocCountError, List pipelineAggregators, Map metaData) + throws IOException { final IncludeExclude.StringFilter filter = includeExclude == null ? null : includeExclude.convertToStringFilter(); - return new StringTermsAggregator(name, factories, valuesSource, order, bucketCountThresholds, filter, - aggregationContext, parent, subAggCollectMode, showTermDocCountError, reducers, metaData); + return new StringTermsAggregator(name, factories, valuesSource, order, bucketCountThresholds, filter, aggregationContext, + parent, subAggCollectMode, showTermDocCountError, pipelineAggregators, metaData); } @Override @@ -65,11 +66,15 @@ public class TermsAggregatorFactory extends ValuesSourceAggregatorFactory reducers, Map metaData) throws IOException { + Aggregator create(String name, AggregatorFactories factories, ValuesSource valuesSource, Terms.Order order, + TermsAggregator.BucketCountThresholds bucketCountThresholds, IncludeExclude includeExclude, + AggregationContext aggregationContext, Aggregator parent, SubAggCollectionMode subAggCollectMode, + boolean showTermDocCountError, List pipelineAggregators, Map metaData) + throws IOException { final IncludeExclude.OrdinalsFilter filter = includeExclude == null ? null : includeExclude.convertToOrdinalsFilter(); - return new GlobalOrdinalsStringTermsAggregator(name, factories, (ValuesSource.Bytes.WithOrdinals) valuesSource, order, bucketCountThresholds, filter, aggregationContext, parent, subAggCollectMode, showTermDocCountError, reducers, metaData); + return new GlobalOrdinalsStringTermsAggregator(name, factories, (ValuesSource.Bytes.WithOrdinals) valuesSource, order, + bucketCountThresholds, filter, aggregationContext, parent, subAggCollectMode, showTermDocCountError, + pipelineAggregators, metaData); } @Override @@ -81,11 +86,15 @@ public class TermsAggregatorFactory extends ValuesSourceAggregatorFactory reducers, Map metaData) throws IOException { + Aggregator create(String name, AggregatorFactories factories, ValuesSource valuesSource, Terms.Order order, + TermsAggregator.BucketCountThresholds bucketCountThresholds, IncludeExclude includeExclude, + AggregationContext aggregationContext, Aggregator parent, SubAggCollectionMode subAggCollectMode, + boolean showTermDocCountError, List pipelineAggregators, Map metaData) + throws IOException { final IncludeExclude.OrdinalsFilter filter = includeExclude == null ? null : includeExclude.convertToOrdinalsFilter(); - return new GlobalOrdinalsStringTermsAggregator.WithHash(name, factories, (ValuesSource.Bytes.WithOrdinals.FieldData) valuesSource, order, bucketCountThresholds, filter, aggregationContext, parent, subAggCollectMode, showTermDocCountError, reducers, metaData); + return new GlobalOrdinalsStringTermsAggregator.WithHash(name, factories, + (ValuesSource.Bytes.WithOrdinals.FieldData) valuesSource, order, bucketCountThresholds, filter, aggregationContext, + parent, subAggCollectMode, showTermDocCountError, pipelineAggregators, metaData); } @Override @@ -96,14 +105,18 @@ public class TermsAggregatorFactory extends ValuesSourceAggregatorFactory reducers, Map metaData) throws IOException { + boolean showTermDocCountError, List pipelineAggregators, Map metaData) + throws IOException { if (includeExclude != null || factories.count() > 0) { - return GLOBAL_ORDINALS.create(name, factories, valuesSource, order, bucketCountThresholds, includeExclude, aggregationContext, parent, subAggCollectMode, showTermDocCountError, reducers, metaData); + return GLOBAL_ORDINALS.create(name, factories, valuesSource, order, bucketCountThresholds, includeExclude, + aggregationContext, parent, subAggCollectMode, showTermDocCountError, pipelineAggregators, metaData); } - return new GlobalOrdinalsStringTermsAggregator.LowCardinality(name, factories, (ValuesSource.Bytes.WithOrdinals) valuesSource, order, bucketCountThresholds, aggregationContext, parent, subAggCollectMode, showTermDocCountError, reducers, metaData); + return new GlobalOrdinalsStringTermsAggregator.LowCardinality(name, factories, + (ValuesSource.Bytes.WithOrdinals) valuesSource, order, bucketCountThresholds, aggregationContext, parent, + subAggCollectMode, showTermDocCountError, pipelineAggregators, metaData); } @Override @@ -127,10 +140,11 @@ public class TermsAggregatorFactory extends ValuesSourceAggregatorFactory reducers, Map metaData) throws IOException; + abstract Aggregator create(String name, AggregatorFactories factories, ValuesSource valuesSource, Terms.Order order, + TermsAggregator.BucketCountThresholds bucketCountThresholds, IncludeExclude includeExclude, + AggregationContext aggregationContext, Aggregator parent, SubAggCollectionMode subAggCollectMode, + boolean showTermDocCountError, List pipelineAggregators, Map metaData) + throws IOException; abstract boolean needsGlobalOrdinals(); @@ -147,7 +161,9 @@ public class TermsAggregatorFactory extends ValuesSourceAggregatorFactory reducers, - Map metaData) throws IOException { + protected Aggregator createUnmapped(AggregationContext aggregationContext, Aggregator parent, + List pipelineAggregators, Map metaData) throws IOException { final InternalAggregation aggregation = new UnmappedTerms(name, order, bucketCountThresholds.getRequiredSize(), - bucketCountThresholds.getShardSize(), bucketCountThresholds.getMinDocCount(), reducers, metaData); - return new NonCollectingAggregator(name, aggregationContext, parent, factories, reducers, metaData) { + bucketCountThresholds.getShardSize(), bucketCountThresholds.getMinDocCount(), pipelineAggregators, metaData); + return new NonCollectingAggregator(name, aggregationContext, parent, factories, pipelineAggregators, metaData) { { // even in the case of an unmapped aggregator, validate the order InternalOrder.validate(order, this); } + @Override public InternalAggregation buildEmptyAggregation() { return aggregation; @@ -176,7 +193,8 @@ public class TermsAggregatorFactory extends ValuesSourceAggregatorFactory reducers, Map metaData) throws IOException { + boolean collectsFromSingleBucket, List pipelineAggregators, Map metaData) + throws IOException { if (collectsFromSingleBucket == false) { return asMultiBucketAggregator(this, aggregationContext, parent); } @@ -226,12 +244,16 @@ public class TermsAggregatorFactory extends ValuesSourceAggregatorFactory reducers, + public UnmappedTerms(String name, Terms.Order order, int requiredSize, int shardSize, long minDocCount, List pipelineAggregators, Map metaData) { - super(name, order, requiredSize, shardSize, minDocCount, BUCKETS, false, 0, 0, reducers, metaData); + super(name, order, requiredSize, shardSize, minDocCount, BUCKETS, false, 0, 0, pipelineAggregators, metaData); } @Override @@ -68,7 +68,7 @@ public class UnmappedTerms extends InternalTerms buckets) { - return new UnmappedTerms(this.name, this.order, this.requiredSize, this.shardSize, this.minDocCount, this.reducers(), this.metaData); + return new UnmappedTerms(this.name, this.order, this.requiredSize, this.shardSize, this.minDocCount, this.pipelineAggregators(), this.metaData); } @Override diff --git a/src/main/java/org/elasticsearch/search/aggregations/metrics/InternalMetricsAggregation.java b/src/main/java/org/elasticsearch/search/aggregations/metrics/InternalMetricsAggregation.java index 8facf4c1ae5..c67b7dc6b2f 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/metrics/InternalMetricsAggregation.java +++ b/src/main/java/org/elasticsearch/search/aggregations/metrics/InternalMetricsAggregation.java @@ -20,7 +20,7 @@ package org.elasticsearch.search.aggregations.metrics; import org.elasticsearch.search.aggregations.InternalAggregation; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import java.util.List; import java.util.Map; @@ -29,7 +29,7 @@ public abstract class InternalMetricsAggregation extends InternalAggregation { protected InternalMetricsAggregation() {} // for serialization - protected InternalMetricsAggregation(String name, List reducers, Map metaData) { - super(name, reducers, metaData); + protected InternalMetricsAggregation(String name, List pipelineAggregators, Map metaData) { + super(name, pipelineAggregators, metaData); } } diff --git a/src/main/java/org/elasticsearch/search/aggregations/metrics/InternalNumericMetricsAggregation.java b/src/main/java/org/elasticsearch/search/aggregations/metrics/InternalNumericMetricsAggregation.java index d9d0aeeb1a8..21af3363601 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/metrics/InternalNumericMetricsAggregation.java +++ b/src/main/java/org/elasticsearch/search/aggregations/metrics/InternalNumericMetricsAggregation.java @@ -18,7 +18,7 @@ */ package org.elasticsearch.search.aggregations.metrics; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.format.ValueFormatter; import java.util.List; @@ -35,8 +35,8 @@ public abstract class InternalNumericMetricsAggregation extends InternalMetricsA protected SingleValue() {} - protected SingleValue(String name, List reducers, Map metaData) { - super(name, reducers, metaData); + protected SingleValue(String name, List pipelineAggregators, Map metaData) { + super(name, pipelineAggregators, metaData); } @Override @@ -65,8 +65,8 @@ public abstract class InternalNumericMetricsAggregation extends InternalMetricsA protected MultiValue() {} - protected MultiValue(String name, List reducers, Map metaData) { - super(name, reducers, metaData); + protected MultiValue(String name, List pipelineAggregators, Map metaData) { + super(name, pipelineAggregators, metaData); } public abstract double value(String name); @@ -93,8 +93,8 @@ public abstract class InternalNumericMetricsAggregation extends InternalMetricsA private InternalNumericMetricsAggregation() {} // for serialization - private InternalNumericMetricsAggregation(String name, List reducers, Map metaData) { - super(name, reducers, metaData); + private InternalNumericMetricsAggregation(String name, List pipelineAggregators, Map metaData) { + super(name, pipelineAggregators, metaData); } } diff --git a/src/main/java/org/elasticsearch/search/aggregations/metrics/MetricsAggregator.java b/src/main/java/org/elasticsearch/search/aggregations/metrics/MetricsAggregator.java index f3160cf464c..30330e61719 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/metrics/MetricsAggregator.java +++ b/src/main/java/org/elasticsearch/search/aggregations/metrics/MetricsAggregator.java @@ -22,7 +22,7 @@ package org.elasticsearch.search.aggregations.metrics; import org.elasticsearch.search.aggregations.Aggregator; import org.elasticsearch.search.aggregations.AggregatorBase; import org.elasticsearch.search.aggregations.AggregatorFactories; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.AggregationContext; import java.io.IOException; @@ -31,8 +31,8 @@ import java.util.Map; public abstract class MetricsAggregator extends AggregatorBase { - protected MetricsAggregator(String name, AggregationContext context, Aggregator parent, List reducers, + protected MetricsAggregator(String name, AggregationContext context, Aggregator parent, List pipelineAggregators, Map metaData) throws IOException { - super(name, AggregatorFactories.EMPTY, context, parent, reducers, metaData); + super(name, AggregatorFactories.EMPTY, context, parent, pipelineAggregators, metaData); } } diff --git a/src/main/java/org/elasticsearch/search/aggregations/metrics/NumericMetricsAggregator.java b/src/main/java/org/elasticsearch/search/aggregations/metrics/NumericMetricsAggregator.java index 6342df383ed..e7306e9667a 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/metrics/NumericMetricsAggregator.java +++ b/src/main/java/org/elasticsearch/search/aggregations/metrics/NumericMetricsAggregator.java @@ -19,7 +19,7 @@ package org.elasticsearch.search.aggregations.metrics; import org.elasticsearch.search.aggregations.Aggregator; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.AggregationContext; import java.io.IOException; @@ -31,16 +31,16 @@ import java.util.Map; */ public abstract class NumericMetricsAggregator extends MetricsAggregator { - private NumericMetricsAggregator(String name, AggregationContext context, Aggregator parent, List reducers, - Map metaData) throws IOException { - super(name, context, parent, reducers, metaData); + private NumericMetricsAggregator(String name, AggregationContext context, Aggregator parent, + List pipelineAggregators, Map metaData) throws IOException { + super(name, context, parent, pipelineAggregators, metaData); } public static abstract class SingleValue extends NumericMetricsAggregator { - protected SingleValue(String name, AggregationContext context, Aggregator parent, List reducers, + protected SingleValue(String name, AggregationContext context, Aggregator parent, List pipelineAggregators, Map metaData) throws IOException { - super(name, context, parent, reducers, metaData); + super(name, context, parent, pipelineAggregators, metaData); } public abstract double metric(long owningBucketOrd); @@ -48,9 +48,9 @@ public abstract class NumericMetricsAggregator extends MetricsAggregator { public static abstract class MultiValue extends NumericMetricsAggregator { - protected MultiValue(String name, AggregationContext context, Aggregator parent, List reducers, + protected MultiValue(String name, AggregationContext context, Aggregator parent, List pipelineAggregators, Map metaData) throws IOException { - super(name, context, parent, reducers, metaData); + super(name, context, parent, pipelineAggregators, metaData); } public abstract boolean hasMetric(String name); diff --git a/src/main/java/org/elasticsearch/search/aggregations/metrics/avg/AvgAggregator.java b/src/main/java/org/elasticsearch/search/aggregations/metrics/avg/AvgAggregator.java index 6bcf5902233..a494c88c35e 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/metrics/avg/AvgAggregator.java +++ b/src/main/java/org/elasticsearch/search/aggregations/metrics/avg/AvgAggregator.java @@ -30,7 +30,7 @@ import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.LeafBucketCollector; import org.elasticsearch.search.aggregations.LeafBucketCollectorBase; import org.elasticsearch.search.aggregations.metrics.NumericMetricsAggregator; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.AggregationContext; import org.elasticsearch.search.aggregations.support.ValuesSource; import org.elasticsearch.search.aggregations.support.ValuesSourceAggregatorFactory; @@ -53,8 +53,9 @@ public class AvgAggregator extends NumericMetricsAggregator.SingleValue { ValueFormatter formatter; public AvgAggregator(String name, ValuesSource.Numeric valuesSource, @Nullable ValueFormatter formatter, - AggregationContext context, Aggregator parent, List reducers, Map metaData) throws IOException { - super(name, context, parent, reducers, metaData); + AggregationContext context, + Aggregator parent, List pipelineAggregators, Map metaData) throws IOException { + super(name, context, parent, pipelineAggregators, metaData); this.valuesSource = valuesSource; this.formatter = formatter; if (valuesSource != null) { @@ -105,12 +106,12 @@ public class AvgAggregator extends NumericMetricsAggregator.SingleValue { if (valuesSource == null || bucket >= sums.size()) { return buildEmptyAggregation(); } - return new InternalAvg(name, sums.get(bucket), counts.get(bucket), formatter, reducers(), metaData()); + return new InternalAvg(name, sums.get(bucket), counts.get(bucket), formatter, pipelineAggregators(), metaData()); } @Override public InternalAggregation buildEmptyAggregation() { - return new InternalAvg(name, 0.0, 0l, formatter, reducers(), metaData()); + return new InternalAvg(name, 0.0, 0l, formatter, pipelineAggregators(), metaData()); } public static class Factory extends ValuesSourceAggregatorFactory.LeafOnly { @@ -120,15 +121,17 @@ public class AvgAggregator extends NumericMetricsAggregator.SingleValue { } @Override - protected Aggregator createUnmapped(AggregationContext aggregationContext, Aggregator parent, List reducers, + protected Aggregator createUnmapped(AggregationContext aggregationContext, Aggregator parent, + List pipelineAggregators, Map metaData) throws IOException { - return new AvgAggregator(name, null, config.formatter(), aggregationContext, parent, reducers, metaData); + return new AvgAggregator(name, null, config.formatter(), aggregationContext, parent, pipelineAggregators, metaData); } @Override protected Aggregator doCreateInternal(ValuesSource.Numeric valuesSource, AggregationContext aggregationContext, Aggregator parent, - boolean collectsFromSingleBucket, List reducers, Map metaData) throws IOException { - return new AvgAggregator(name, valuesSource, config.formatter(), aggregationContext, parent, reducers, metaData); + boolean collectsFromSingleBucket, List pipelineAggregators, Map metaData) + throws IOException { + return new AvgAggregator(name, valuesSource, config.formatter(), aggregationContext, parent, pipelineAggregators, metaData); } } diff --git a/src/main/java/org/elasticsearch/search/aggregations/metrics/avg/InternalAvg.java b/src/main/java/org/elasticsearch/search/aggregations/metrics/avg/InternalAvg.java index 3f4af6cdf5c..8fdb6be5fdd 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/metrics/avg/InternalAvg.java +++ b/src/main/java/org/elasticsearch/search/aggregations/metrics/avg/InternalAvg.java @@ -25,7 +25,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.search.aggregations.AggregationStreams; import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.metrics.InternalNumericMetricsAggregation; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.format.ValueFormatter; import org.elasticsearch.search.aggregations.support.format.ValueFormatterStreams; @@ -58,9 +58,9 @@ public class InternalAvg extends InternalNumericMetricsAggregation.SingleValue i InternalAvg() {} // for serialization - public InternalAvg(String name, double sum, long count, @Nullable ValueFormatter formatter, List reducers, + public InternalAvg(String name, double sum, long count, @Nullable ValueFormatter formatter, List pipelineAggregators, Map metaData) { - super(name, reducers, metaData); + super(name, pipelineAggregators, metaData); this.sum = sum; this.count = count; this.valueFormatter = formatter; @@ -89,7 +89,7 @@ public class InternalAvg extends InternalNumericMetricsAggregation.SingleValue i count += ((InternalAvg) aggregation).count; sum += ((InternalAvg) aggregation).sum; } - return new InternalAvg(getName(), sum, count, valueFormatter, reducers(), getMetaData()); + return new InternalAvg(getName(), sum, count, valueFormatter, pipelineAggregators(), getMetaData()); } @Override diff --git a/src/main/java/org/elasticsearch/search/aggregations/metrics/cardinality/CardinalityAggregator.java b/src/main/java/org/elasticsearch/search/aggregations/metrics/cardinality/CardinalityAggregator.java index c00acc4d626..9e4c9e13d35 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/metrics/cardinality/CardinalityAggregator.java +++ b/src/main/java/org/elasticsearch/search/aggregations/metrics/cardinality/CardinalityAggregator.java @@ -42,7 +42,7 @@ import org.elasticsearch.search.aggregations.Aggregator; import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.LeafBucketCollector; import org.elasticsearch.search.aggregations.metrics.NumericMetricsAggregator; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.AggregationContext; import org.elasticsearch.search.aggregations.support.ValuesSource; import org.elasticsearch.search.aggregations.support.format.ValueFormatter; @@ -68,8 +68,8 @@ public class CardinalityAggregator extends NumericMetricsAggregator.SingleValue private ValueFormatter formatter; public CardinalityAggregator(String name, ValuesSource valuesSource, boolean rehash, int precision, @Nullable ValueFormatter formatter, - AggregationContext context, Aggregator parent, List reducers, Map metaData) throws IOException { - super(name, context, parent, reducers, metaData); + AggregationContext context, Aggregator parent, List pipelineAggregators, Map metaData) throws IOException { + super(name, context, parent, pipelineAggregators, metaData); this.valuesSource = valuesSource; this.rehash = rehash; this.precision = precision; @@ -158,12 +158,12 @@ public class CardinalityAggregator extends NumericMetricsAggregator.SingleValue // this Aggregator (and its HLL++ counters) is released. HyperLogLogPlusPlus copy = new HyperLogLogPlusPlus(precision, BigArrays.NON_RECYCLING_INSTANCE, 1); copy.merge(0, counts, owningBucketOrdinal); - return new InternalCardinality(name, copy, formatter, reducers(), metaData()); + return new InternalCardinality(name, copy, formatter, pipelineAggregators(), metaData()); } @Override public InternalAggregation buildEmptyAggregation() { - return new InternalCardinality(name, null, formatter, reducers(), metaData()); + return new InternalCardinality(name, null, formatter, pipelineAggregators(), metaData()); } @Override diff --git a/src/main/java/org/elasticsearch/search/aggregations/metrics/cardinality/CardinalityAggregatorFactory.java b/src/main/java/org/elasticsearch/search/aggregations/metrics/cardinality/CardinalityAggregatorFactory.java index d2341bb2647..9320020ca5b 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/metrics/cardinality/CardinalityAggregatorFactory.java +++ b/src/main/java/org/elasticsearch/search/aggregations/metrics/cardinality/CardinalityAggregatorFactory.java @@ -22,7 +22,7 @@ package org.elasticsearch.search.aggregations.metrics.cardinality; import org.elasticsearch.search.aggregations.AggregationExecutionException; import org.elasticsearch.search.aggregations.Aggregator; import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregator; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.AggregationContext; import org.elasticsearch.search.aggregations.support.ValuesSource; import org.elasticsearch.search.aggregations.support.ValuesSourceAggregatorFactory; @@ -48,18 +48,18 @@ final class CardinalityAggregatorFactory extends ValuesSourceAggregatorFactory reducers, Map metaData) + protected Aggregator createUnmapped(AggregationContext context, Aggregator parent, List pipelineAggregators, Map metaData) throws IOException { - return new CardinalityAggregator(name, null, true, precision(parent), config.formatter(), context, parent, reducers, metaData); + return new CardinalityAggregator(name, null, true, precision(parent), config.formatter(), context, parent, pipelineAggregators, metaData); } @Override protected Aggregator doCreateInternal(ValuesSource valuesSource, AggregationContext context, Aggregator parent, - boolean collectsFromSingleBucket, List reducers, Map metaData) throws IOException { + boolean collectsFromSingleBucket, List pipelineAggregators, Map metaData) throws IOException { if (!(valuesSource instanceof ValuesSource.Numeric) && !rehash) { throw new AggregationExecutionException("Turning off rehashing for cardinality aggregation [" + name + "] on non-numeric values in not allowed"); } - return new CardinalityAggregator(name, valuesSource, rehash, precision(parent), config.formatter(), context, parent, reducers, + return new CardinalityAggregator(name, valuesSource, rehash, precision(parent), config.formatter(), context, parent, pipelineAggregators, metaData); } diff --git a/src/main/java/org/elasticsearch/search/aggregations/metrics/cardinality/InternalCardinality.java b/src/main/java/org/elasticsearch/search/aggregations/metrics/cardinality/InternalCardinality.java index 5517702142c..f37efc51684 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/metrics/cardinality/InternalCardinality.java +++ b/src/main/java/org/elasticsearch/search/aggregations/metrics/cardinality/InternalCardinality.java @@ -27,7 +27,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.search.aggregations.AggregationStreams; import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.metrics.InternalNumericMetricsAggregation; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.format.ValueFormatter; import org.elasticsearch.search.aggregations.support.format.ValueFormatterStreams; @@ -54,9 +54,9 @@ public final class InternalCardinality extends InternalNumericMetricsAggregation private HyperLogLogPlusPlus counts; - InternalCardinality(String name, HyperLogLogPlusPlus counts, @Nullable ValueFormatter formatter, List reducers, + InternalCardinality(String name, HyperLogLogPlusPlus counts, @Nullable ValueFormatter formatter, List pipelineAggregators, Map metaData) { - super(name, reducers, metaData); + super(name, pipelineAggregators, metaData); this.counts = counts; this.valueFormatter = formatter; } @@ -108,7 +108,7 @@ public final class InternalCardinality extends InternalNumericMetricsAggregation if (cardinality.counts != null) { if (reduced == null) { reduced = new InternalCardinality(name, new HyperLogLogPlusPlus(cardinality.counts.precision(), - BigArrays.NON_RECYCLING_INSTANCE, 1), this.valueFormatter, reducers(), getMetaData()); + BigArrays.NON_RECYCLING_INSTANCE, 1), this.valueFormatter, pipelineAggregators(), getMetaData()); } reduced.merge(cardinality); } diff --git a/src/main/java/org/elasticsearch/search/aggregations/metrics/geobounds/GeoBoundsAggregator.java b/src/main/java/org/elasticsearch/search/aggregations/metrics/geobounds/GeoBoundsAggregator.java index 67b320f98e6..8c6159ec0e1 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/metrics/geobounds/GeoBoundsAggregator.java +++ b/src/main/java/org/elasticsearch/search/aggregations/metrics/geobounds/GeoBoundsAggregator.java @@ -30,7 +30,7 @@ import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.LeafBucketCollector; import org.elasticsearch.search.aggregations.LeafBucketCollectorBase; import org.elasticsearch.search.aggregations.metrics.MetricsAggregator; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.AggregationContext; import org.elasticsearch.search.aggregations.support.ValuesSource; import org.elasticsearch.search.aggregations.support.ValuesSourceAggregatorFactory; @@ -52,9 +52,9 @@ public final class GeoBoundsAggregator extends MetricsAggregator { DoubleArray negRights; protected GeoBoundsAggregator(String name, AggregationContext aggregationContext, Aggregator parent, - ValuesSource.GeoPoint valuesSource, boolean wrapLongitude, List reducers, + ValuesSource.GeoPoint valuesSource, boolean wrapLongitude, List pipelineAggregators, Map metaData) throws IOException { - super(name, aggregationContext, parent, reducers, metaData); + super(name, aggregationContext, parent, pipelineAggregators, metaData); this.valuesSource = valuesSource; this.wrapLongitude = wrapLongitude; if (valuesSource != null) { @@ -152,13 +152,13 @@ public final class GeoBoundsAggregator extends MetricsAggregator { double posRight = posRights.get(owningBucketOrdinal); double negLeft = negLefts.get(owningBucketOrdinal); double negRight = negRights.get(owningBucketOrdinal); - return new InternalGeoBounds(name, top, bottom, posLeft, posRight, negLeft, negRight, wrapLongitude, reducers(), metaData()); + return new InternalGeoBounds(name, top, bottom, posLeft, posRight, negLeft, negRight, wrapLongitude, pipelineAggregators(), metaData()); } @Override public InternalAggregation buildEmptyAggregation() { return new InternalGeoBounds(name, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, - Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, wrapLongitude, reducers(), metaData()); + Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, wrapLongitude, pipelineAggregators(), metaData()); } @Override @@ -176,15 +176,16 @@ public final class GeoBoundsAggregator extends MetricsAggregator { } @Override - protected Aggregator createUnmapped(AggregationContext aggregationContext, Aggregator parent, List reducers, - Map metaData) throws IOException { - return new GeoBoundsAggregator(name, aggregationContext, parent, null, wrapLongitude, reducers, metaData); + protected Aggregator createUnmapped(AggregationContext aggregationContext, Aggregator parent, + List pipelineAggregators, Map metaData) throws IOException { + return new GeoBoundsAggregator(name, aggregationContext, parent, null, wrapLongitude, pipelineAggregators, metaData); } @Override - protected Aggregator doCreateInternal(ValuesSource.GeoPoint valuesSource, AggregationContext aggregationContext, - Aggregator parent, boolean collectsFromSingleBucket, List reducers, Map metaData) throws IOException { - return new GeoBoundsAggregator(name, aggregationContext, parent, valuesSource, wrapLongitude, reducers, metaData); + protected Aggregator doCreateInternal(ValuesSource.GeoPoint valuesSource, AggregationContext aggregationContext, Aggregator parent, + boolean collectsFromSingleBucket, List pipelineAggregators, Map metaData) + throws IOException { + return new GeoBoundsAggregator(name, aggregationContext, parent, valuesSource, wrapLongitude, pipelineAggregators, metaData); } } diff --git a/src/main/java/org/elasticsearch/search/aggregations/metrics/geobounds/InternalGeoBounds.java b/src/main/java/org/elasticsearch/search/aggregations/metrics/geobounds/InternalGeoBounds.java index 0da4e6bfcc7..c3bd5deb5b3 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/metrics/geobounds/InternalGeoBounds.java +++ b/src/main/java/org/elasticsearch/search/aggregations/metrics/geobounds/InternalGeoBounds.java @@ -26,7 +26,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.search.aggregations.AggregationStreams; import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.metrics.InternalMetricsAggregation; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import java.io.IOException; import java.util.List; @@ -57,8 +57,8 @@ public class InternalGeoBounds extends InternalMetricsAggregation implements Geo InternalGeoBounds(String name, double top, double bottom, double posLeft, double posRight, double negLeft, double negRight, boolean wrapLongitude, - List reducers, Map metaData) { - super(name, reducers, metaData); + List pipelineAggregators, Map metaData) { + super(name, pipelineAggregators, metaData); this.top = top; this.bottom = bottom; this.posLeft = posLeft; @@ -104,7 +104,7 @@ public class InternalGeoBounds extends InternalMetricsAggregation implements Geo negRight = bounds.negRight; } } - return new InternalGeoBounds(name, top, bottom, posLeft, posRight, negLeft, negRight, wrapLongitude, reducers(), getMetaData()); + return new InternalGeoBounds(name, top, bottom, posLeft, posRight, negLeft, negRight, wrapLongitude, pipelineAggregators(), getMetaData()); } @Override diff --git a/src/main/java/org/elasticsearch/search/aggregations/metrics/max/InternalMax.java b/src/main/java/org/elasticsearch/search/aggregations/metrics/max/InternalMax.java index b2f103fc488..f695af834c4 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/metrics/max/InternalMax.java +++ b/src/main/java/org/elasticsearch/search/aggregations/metrics/max/InternalMax.java @@ -25,7 +25,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.search.aggregations.AggregationStreams; import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.metrics.InternalNumericMetricsAggregation; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.format.ValueFormatter; import org.elasticsearch.search.aggregations.support.format.ValueFormatterStreams; @@ -57,8 +57,8 @@ public class InternalMax extends InternalNumericMetricsAggregation.SingleValue i InternalMax() {} // for serialization - public InternalMax(String name, double max, @Nullable ValueFormatter formatter, List reducers, Map metaData) { - super(name, reducers, metaData); + public InternalMax(String name, double max, @Nullable ValueFormatter formatter, List pipelineAggregators, Map metaData) { + super(name, pipelineAggregators, metaData); this.valueFormatter = formatter; this.max = max; } @@ -84,7 +84,7 @@ public class InternalMax extends InternalNumericMetricsAggregation.SingleValue i for (InternalAggregation aggregation : aggregations) { max = Math.max(max, ((InternalMax) aggregation).max); } - return new InternalMax(name, max, valueFormatter, reducers(), getMetaData()); + return new InternalMax(name, max, valueFormatter, pipelineAggregators(), getMetaData()); } @Override diff --git a/src/main/java/org/elasticsearch/search/aggregations/metrics/max/MaxAggregator.java b/src/main/java/org/elasticsearch/search/aggregations/metrics/max/MaxAggregator.java index 7ade492660e..6ebae48b864 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/metrics/max/MaxAggregator.java +++ b/src/main/java/org/elasticsearch/search/aggregations/metrics/max/MaxAggregator.java @@ -31,7 +31,7 @@ import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.LeafBucketCollector; import org.elasticsearch.search.aggregations.LeafBucketCollectorBase; import org.elasticsearch.search.aggregations.metrics.NumericMetricsAggregator; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.AggregationContext; import org.elasticsearch.search.aggregations.support.ValuesSource; import org.elasticsearch.search.aggregations.support.ValuesSourceAggregatorFactory; @@ -53,9 +53,10 @@ public class MaxAggregator extends NumericMetricsAggregator.SingleValue { DoubleArray maxes; public MaxAggregator(String name, ValuesSource.Numeric valuesSource, @Nullable ValueFormatter formatter, - AggregationContext context, Aggregator parent, List reducers, + AggregationContext context, + Aggregator parent, List pipelineAggregators, Map metaData) throws IOException { - super(name, context, parent, reducers, metaData); + super(name, context, parent, pipelineAggregators, metaData); this.valuesSource = valuesSource; this.formatter = formatter; if (valuesSource != null) { @@ -106,12 +107,12 @@ public class MaxAggregator extends NumericMetricsAggregator.SingleValue { if (valuesSource == null || bucket >= maxes.size()) { return buildEmptyAggregation(); } - return new InternalMax(name, maxes.get(bucket), formatter, reducers(), metaData()); + return new InternalMax(name, maxes.get(bucket), formatter, pipelineAggregators(), metaData()); } @Override public InternalAggregation buildEmptyAggregation() { - return new InternalMax(name, Double.NEGATIVE_INFINITY, formatter, reducers(), metaData()); + return new InternalMax(name, Double.NEGATIVE_INFINITY, formatter, pipelineAggregators(), metaData()); } public static class Factory extends ValuesSourceAggregatorFactory.LeafOnly { @@ -121,15 +122,16 @@ public class MaxAggregator extends NumericMetricsAggregator.SingleValue { } @Override - protected Aggregator createUnmapped(AggregationContext aggregationContext, Aggregator parent, List reducers, - Map metaData) throws IOException { - return new MaxAggregator(name, null, config.formatter(), aggregationContext, parent, reducers, metaData); + protected Aggregator createUnmapped(AggregationContext aggregationContext, Aggregator parent, + List pipelineAggregators, Map metaData) throws IOException { + return new MaxAggregator(name, null, config.formatter(), aggregationContext, parent, pipelineAggregators, metaData); } @Override protected Aggregator doCreateInternal(ValuesSource.Numeric valuesSource, AggregationContext aggregationContext, Aggregator parent, - boolean collectsFromSingleBucket, List reducers, Map metaData) throws IOException { - return new MaxAggregator(name, valuesSource, config.formatter(), aggregationContext, parent, reducers, metaData); + boolean collectsFromSingleBucket, List pipelineAggregators, Map metaData) + throws IOException { + return new MaxAggregator(name, valuesSource, config.formatter(), aggregationContext, parent, pipelineAggregators, metaData); } } diff --git a/src/main/java/org/elasticsearch/search/aggregations/metrics/min/InternalMin.java b/src/main/java/org/elasticsearch/search/aggregations/metrics/min/InternalMin.java index d6269602169..033dd8d310f 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/metrics/min/InternalMin.java +++ b/src/main/java/org/elasticsearch/search/aggregations/metrics/min/InternalMin.java @@ -25,7 +25,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.search.aggregations.AggregationStreams; import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.metrics.InternalNumericMetricsAggregation; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.format.ValueFormatter; import org.elasticsearch.search.aggregations.support.format.ValueFormatterStreams; @@ -58,8 +58,8 @@ public class InternalMin extends InternalNumericMetricsAggregation.SingleValue i InternalMin() {} // for serialization - public InternalMin(String name, double min, @Nullable ValueFormatter formatter, List reducers, Map metaData) { - super(name, reducers, metaData); + public InternalMin(String name, double min, @Nullable ValueFormatter formatter, List pipelineAggregators, Map metaData) { + super(name, pipelineAggregators, metaData); this.min = min; this.valueFormatter = formatter; } @@ -85,7 +85,7 @@ public class InternalMin extends InternalNumericMetricsAggregation.SingleValue i for (InternalAggregation aggregation : aggregations) { min = Math.min(min, ((InternalMin) aggregation).min); } - return new InternalMin(getName(), min, this.valueFormatter, reducers(), getMetaData()); + return new InternalMin(getName(), min, this.valueFormatter, pipelineAggregators(), getMetaData()); } @Override diff --git a/src/main/java/org/elasticsearch/search/aggregations/metrics/min/MinAggregator.java b/src/main/java/org/elasticsearch/search/aggregations/metrics/min/MinAggregator.java index cf832cabe1f..b25a42c1027 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/metrics/min/MinAggregator.java +++ b/src/main/java/org/elasticsearch/search/aggregations/metrics/min/MinAggregator.java @@ -31,7 +31,7 @@ import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.LeafBucketCollector; import org.elasticsearch.search.aggregations.LeafBucketCollectorBase; import org.elasticsearch.search.aggregations.metrics.NumericMetricsAggregator; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.AggregationContext; import org.elasticsearch.search.aggregations.support.ValuesSource; import org.elasticsearch.search.aggregations.support.ValuesSourceAggregatorFactory; @@ -53,9 +53,9 @@ public class MinAggregator extends NumericMetricsAggregator.SingleValue { DoubleArray mins; public MinAggregator(String name, ValuesSource.Numeric valuesSource, @Nullable ValueFormatter formatter, - AggregationContext context, Aggregator parent, List reducers, + AggregationContext context, Aggregator parent, List pipelineAggregators, Map metaData) throws IOException { - super(name, context, parent, reducers, metaData); + super(name, context, parent, pipelineAggregators, metaData); this.valuesSource = valuesSource; if (valuesSource != null) { mins = context.bigArrays().newDoubleArray(1, false); @@ -106,12 +106,12 @@ public class MinAggregator extends NumericMetricsAggregator.SingleValue { if (valuesSource == null || bucket >= mins.size()) { return buildEmptyAggregation(); } - return new InternalMin(name, mins.get(bucket), formatter, reducers(), metaData()); + return new InternalMin(name, mins.get(bucket), formatter, pipelineAggregators(), metaData()); } @Override public InternalAggregation buildEmptyAggregation() { - return new InternalMin(name, Double.POSITIVE_INFINITY, formatter, reducers(), metaData()); + return new InternalMin(name, Double.POSITIVE_INFINITY, formatter, pipelineAggregators(), metaData()); } public static class Factory extends ValuesSourceAggregatorFactory.LeafOnly { @@ -121,15 +121,16 @@ public class MinAggregator extends NumericMetricsAggregator.SingleValue { } @Override - protected Aggregator createUnmapped(AggregationContext aggregationContext, Aggregator parent, List reducers, - Map metaData) throws IOException { - return new MinAggregator(name, null, config.formatter(), aggregationContext, parent, reducers, metaData); + protected Aggregator createUnmapped(AggregationContext aggregationContext, Aggregator parent, + List pipelineAggregators, Map metaData) throws IOException { + return new MinAggregator(name, null, config.formatter(), aggregationContext, parent, pipelineAggregators, metaData); } @Override protected Aggregator doCreateInternal(ValuesSource.Numeric valuesSource, AggregationContext aggregationContext, Aggregator parent, - boolean collectsFromSingleBucket, List reducers, Map metaData) throws IOException { - return new MinAggregator(name, valuesSource, config.formatter(), aggregationContext, parent, reducers, metaData); + boolean collectsFromSingleBucket, List pipelineAggregators, Map metaData) + throws IOException { + return new MinAggregator(name, valuesSource, config.formatter(), aggregationContext, parent, pipelineAggregators, metaData); } } diff --git a/src/main/java/org/elasticsearch/search/aggregations/metrics/percentiles/AbstractInternalPercentiles.java b/src/main/java/org/elasticsearch/search/aggregations/metrics/percentiles/AbstractInternalPercentiles.java index 081e5e07fda..05bc0f95683 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/metrics/percentiles/AbstractInternalPercentiles.java +++ b/src/main/java/org/elasticsearch/search/aggregations/metrics/percentiles/AbstractInternalPercentiles.java @@ -27,7 +27,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.metrics.InternalNumericMetricsAggregation; import org.elasticsearch.search.aggregations.metrics.percentiles.tdigest.TDigestState; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.format.ValueFormatter; import org.elasticsearch.search.aggregations.support.format.ValueFormatterStreams; @@ -44,9 +44,9 @@ abstract class AbstractInternalPercentiles extends InternalNumericMetricsAggrega AbstractInternalPercentiles() {} // for serialization public AbstractInternalPercentiles(String name, double[] keys, TDigestState state, boolean keyed, @Nullable ValueFormatter formatter, - List reducers, + List pipelineAggregators, Map metaData) { - super(name, reducers, metaData); + super(name, pipelineAggregators, metaData); this.keys = keys; this.state = state; this.keyed = keyed; @@ -70,11 +70,11 @@ abstract class AbstractInternalPercentiles extends InternalNumericMetricsAggrega } merged.add(percentiles.state); } - return createReduced(getName(), keys, merged, keyed, reducers(), getMetaData()); + return createReduced(getName(), keys, merged, keyed, pipelineAggregators(), getMetaData()); } protected abstract AbstractInternalPercentiles createReduced(String name, double[] keys, TDigestState merged, boolean keyed, - List reducers, Map metaData); + List pipelineAggregators, Map metaData); @Override protected void doReadFrom(StreamInput in) throws IOException { diff --git a/src/main/java/org/elasticsearch/search/aggregations/metrics/percentiles/AbstractPercentilesAggregator.java b/src/main/java/org/elasticsearch/search/aggregations/metrics/percentiles/AbstractPercentilesAggregator.java index a73639a3d7f..bb2c5752e75 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/metrics/percentiles/AbstractPercentilesAggregator.java +++ b/src/main/java/org/elasticsearch/search/aggregations/metrics/percentiles/AbstractPercentilesAggregator.java @@ -27,11 +27,11 @@ import org.elasticsearch.common.util.BigArrays; import org.elasticsearch.common.util.ObjectArray; import org.elasticsearch.index.fielddata.SortedNumericDoubleValues; import org.elasticsearch.search.aggregations.Aggregator; -import org.elasticsearch.search.aggregations.LeafBucketCollectorBase; import org.elasticsearch.search.aggregations.LeafBucketCollector; +import org.elasticsearch.search.aggregations.LeafBucketCollectorBase; import org.elasticsearch.search.aggregations.metrics.NumericMetricsAggregator; import org.elasticsearch.search.aggregations.metrics.percentiles.tdigest.TDigestState; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.AggregationContext; import org.elasticsearch.search.aggregations.support.ValuesSource; import org.elasticsearch.search.aggregations.support.format.ValueFormatter; @@ -53,11 +53,10 @@ public abstract class AbstractPercentilesAggregator extends NumericMetricsAggreg protected final double compression; protected final boolean keyed; - public AbstractPercentilesAggregator(String name, ValuesSource.Numeric valuesSource, AggregationContext context, - Aggregator parent, double[] keys, double compression, boolean keyed, - @Nullable ValueFormatter formatter, List reducers, - Map metaData) throws IOException { - super(name, context, parent, reducers, metaData); + public AbstractPercentilesAggregator(String name, ValuesSource.Numeric valuesSource, AggregationContext context, Aggregator parent, + double[] keys, double compression, boolean keyed, @Nullable ValueFormatter formatter, + List pipelineAggregators, Map metaData) throws IOException { + super(name, context, parent, pipelineAggregators, metaData); this.valuesSource = valuesSource; this.keyed = keyed; this.formatter = formatter; diff --git a/src/main/java/org/elasticsearch/search/aggregations/metrics/percentiles/InternalPercentileRanks.java b/src/main/java/org/elasticsearch/search/aggregations/metrics/percentiles/InternalPercentileRanks.java index 291db0451b0..da430354766 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/metrics/percentiles/InternalPercentileRanks.java +++ b/src/main/java/org/elasticsearch/search/aggregations/metrics/percentiles/InternalPercentileRanks.java @@ -24,7 +24,7 @@ import org.elasticsearch.common.inject.internal.Nullable; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.search.aggregations.AggregationStreams; import org.elasticsearch.search.aggregations.metrics.percentiles.tdigest.TDigestState; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.format.ValueFormatter; import java.io.IOException; @@ -55,9 +55,8 @@ public class InternalPercentileRanks extends AbstractInternalPercentiles impleme InternalPercentileRanks() {} // for serialization public InternalPercentileRanks(String name, double[] cdfValues, TDigestState state, boolean keyed, @Nullable ValueFormatter formatter, - List reducers, - Map metaData) { - super(name, cdfValues, state, keyed, formatter, reducers, metaData); + List pipelineAggregators, Map metaData) { + super(name, cdfValues, state, keyed, formatter, pipelineAggregators, metaData); } @Override @@ -82,8 +81,8 @@ public class InternalPercentileRanks extends AbstractInternalPercentiles impleme @Override protected AbstractInternalPercentiles createReduced(String name, double[] keys, TDigestState merged, boolean keyed, - List reducers, Map metaData) { - return new InternalPercentileRanks(name, keys, merged, keyed, valueFormatter, reducers, metaData); + List pipelineAggregators, Map metaData) { + return new InternalPercentileRanks(name, keys, merged, keyed, valueFormatter, pipelineAggregators, metaData); } @Override diff --git a/src/main/java/org/elasticsearch/search/aggregations/metrics/percentiles/InternalPercentiles.java b/src/main/java/org/elasticsearch/search/aggregations/metrics/percentiles/InternalPercentiles.java index 71360dad8fb..799a9a28958 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/metrics/percentiles/InternalPercentiles.java +++ b/src/main/java/org/elasticsearch/search/aggregations/metrics/percentiles/InternalPercentiles.java @@ -24,7 +24,7 @@ import org.elasticsearch.common.inject.internal.Nullable; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.search.aggregations.AggregationStreams; import org.elasticsearch.search.aggregations.metrics.percentiles.tdigest.TDigestState; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.format.ValueFormatter; import java.io.IOException; @@ -52,12 +52,12 @@ public class InternalPercentiles extends AbstractInternalPercentiles implements AggregationStreams.registerStream(STREAM, TYPE.stream()); } - InternalPercentiles() {} // for serialization + InternalPercentiles() { + } // for serialization public InternalPercentiles(String name, double[] percents, TDigestState state, boolean keyed, @Nullable ValueFormatter formatter, - List reducers, - Map metaData) { - super(name, percents, state, keyed, formatter, reducers, metaData); + List pipelineAggregators, Map metaData) { + super(name, percents, state, keyed, formatter, pipelineAggregators, metaData); } @Override @@ -82,8 +82,8 @@ public class InternalPercentiles extends AbstractInternalPercentiles implements @Override protected AbstractInternalPercentiles createReduced(String name, double[] keys, TDigestState merged, boolean keyed, - List reducers, Map metaData) { - return new InternalPercentiles(name, keys, merged, keyed, valueFormatter, reducers, metaData); + List pipelineAggregators, Map metaData) { + return new InternalPercentiles(name, keys, merged, keyed, valueFormatter, pipelineAggregators, metaData); } @Override diff --git a/src/main/java/org/elasticsearch/search/aggregations/metrics/percentiles/PercentileRanksAggregator.java b/src/main/java/org/elasticsearch/search/aggregations/metrics/percentiles/PercentileRanksAggregator.java index 380482b8ab3..7f1a7bbe9e7 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/metrics/percentiles/PercentileRanksAggregator.java +++ b/src/main/java/org/elasticsearch/search/aggregations/metrics/percentiles/PercentileRanksAggregator.java @@ -22,7 +22,7 @@ import org.elasticsearch.common.inject.internal.Nullable; import org.elasticsearch.search.aggregations.Aggregator; import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.metrics.percentiles.tdigest.TDigestState; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.AggregationContext; import org.elasticsearch.search.aggregations.support.ValuesSource; import org.elasticsearch.search.aggregations.support.ValuesSource.Numeric; @@ -40,9 +40,10 @@ import java.util.Map; public class PercentileRanksAggregator extends AbstractPercentilesAggregator { public PercentileRanksAggregator(String name, Numeric valuesSource, AggregationContext context, Aggregator parent, double[] percents, - double compression, boolean keyed, @Nullable ValueFormatter formatter, List reducers, Map metaData) + double compression, boolean keyed, @Nullable ValueFormatter formatter, List pipelineAggregators, + Map metaData) throws IOException { - super(name, valuesSource, context, parent, percents, compression, keyed, formatter, reducers, metaData); + super(name, valuesSource, context, parent, percents, compression, keyed, formatter, pipelineAggregators, metaData); } @Override @@ -51,13 +52,13 @@ public class PercentileRanksAggregator extends AbstractPercentilesAggregator { if (state == null) { return buildEmptyAggregation(); } else { - return new InternalPercentileRanks(name, keys, state, keyed, formatter, reducers(), metaData()); + return new InternalPercentileRanks(name, keys, state, keyed, formatter, pipelineAggregators(), metaData()); } } @Override public InternalAggregation buildEmptyAggregation() { - return new InternalPercentileRanks(name, keys, new TDigestState(compression), keyed, formatter, reducers(), metaData()); + return new InternalPercentileRanks(name, keys, new TDigestState(compression), keyed, formatter, pipelineAggregators(), metaData()); } @Override @@ -85,18 +86,18 @@ public class PercentileRanksAggregator extends AbstractPercentilesAggregator { } @Override - protected Aggregator createUnmapped(AggregationContext aggregationContext, Aggregator parent, List reducers, - Map metaData) throws IOException { + protected Aggregator createUnmapped(AggregationContext aggregationContext, Aggregator parent, + List pipelineAggregators, Map metaData) throws IOException { return new PercentileRanksAggregator(name, null, aggregationContext, parent, values, compression, keyed, config.formatter(), - reducers, - metaData); + pipelineAggregators, metaData); } @Override protected Aggregator doCreateInternal(ValuesSource.Numeric valuesSource, AggregationContext aggregationContext, Aggregator parent, - boolean collectsFromSingleBucket, List reducers, Map metaData) throws IOException { - return new PercentileRanksAggregator(name, valuesSource, aggregationContext, parent, values, compression, - keyed, config.formatter(), reducers, metaData); + boolean collectsFromSingleBucket, List pipelineAggregators, Map metaData) + throws IOException { + return new PercentileRanksAggregator(name, valuesSource, aggregationContext, parent, values, compression, keyed, + config.formatter(), pipelineAggregators, metaData); } } } diff --git a/src/main/java/org/elasticsearch/search/aggregations/metrics/percentiles/PercentilesAggregator.java b/src/main/java/org/elasticsearch/search/aggregations/metrics/percentiles/PercentilesAggregator.java index 2a42dc94620..b5394f19b82 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/metrics/percentiles/PercentilesAggregator.java +++ b/src/main/java/org/elasticsearch/search/aggregations/metrics/percentiles/PercentilesAggregator.java @@ -22,7 +22,7 @@ import org.elasticsearch.common.inject.internal.Nullable; import org.elasticsearch.search.aggregations.Aggregator; import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.metrics.percentiles.tdigest.TDigestState; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.AggregationContext; import org.elasticsearch.search.aggregations.support.ValuesSource; import org.elasticsearch.search.aggregations.support.ValuesSource.Numeric; @@ -41,9 +41,9 @@ public class PercentilesAggregator extends AbstractPercentilesAggregator { public PercentilesAggregator(String name, Numeric valuesSource, AggregationContext context, Aggregator parent, double[] percents, - double compression, boolean keyed, @Nullable ValueFormatter formatter, List reducers, + double compression, boolean keyed, @Nullable ValueFormatter formatter, List pipelineAggregators, Map metaData) throws IOException { - super(name, valuesSource, context, parent, percents, compression, keyed, formatter, reducers, metaData); + super(name, valuesSource, context, parent, percents, compression, keyed, formatter, pipelineAggregators, metaData); } @Override @@ -52,7 +52,7 @@ public class PercentilesAggregator extends AbstractPercentilesAggregator { if (state == null) { return buildEmptyAggregation(); } else { - return new InternalPercentiles(name, keys, state, keyed, formatter, reducers(), metaData()); + return new InternalPercentiles(name, keys, state, keyed, formatter, pipelineAggregators(), metaData()); } } @@ -68,7 +68,7 @@ public class PercentilesAggregator extends AbstractPercentilesAggregator { @Override public InternalAggregation buildEmptyAggregation() { - return new InternalPercentiles(name, keys, new TDigestState(compression), keyed, formatter, reducers(), metaData()); + return new InternalPercentiles(name, keys, new TDigestState(compression), keyed, formatter, pipelineAggregators(), metaData()); } public static class Factory extends ValuesSourceAggregatorFactory.LeafOnly { @@ -86,18 +86,18 @@ public class PercentilesAggregator extends AbstractPercentilesAggregator { } @Override - protected Aggregator createUnmapped(AggregationContext aggregationContext, Aggregator parent, List reducers, - Map metaData) throws IOException { + protected Aggregator createUnmapped(AggregationContext aggregationContext, Aggregator parent, + List pipelineAggregators, Map metaData) throws IOException { return new PercentilesAggregator(name, null, aggregationContext, parent, percents, compression, keyed, config.formatter(), - reducers, - metaData); + pipelineAggregators, metaData); } @Override protected Aggregator doCreateInternal(ValuesSource.Numeric valuesSource, AggregationContext aggregationContext, Aggregator parent, - boolean collectsFromSingleBucket, List reducers, Map metaData) throws IOException { - return new PercentilesAggregator(name, valuesSource, aggregationContext, parent, percents, compression, - keyed, config.formatter(), reducers, metaData); + boolean collectsFromSingleBucket, List pipelineAggregators, Map metaData) + throws IOException { + return new PercentilesAggregator(name, valuesSource, aggregationContext, parent, percents, compression, keyed, + config.formatter(), pipelineAggregators, metaData); } } } diff --git a/src/main/java/org/elasticsearch/search/aggregations/metrics/scripted/InternalScriptedMetric.java b/src/main/java/org/elasticsearch/search/aggregations/metrics/scripted/InternalScriptedMetric.java index 4f80befc440..7f774eab488 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/metrics/scripted/InternalScriptedMetric.java +++ b/src/main/java/org/elasticsearch/search/aggregations/metrics/scripted/InternalScriptedMetric.java @@ -29,7 +29,7 @@ import org.elasticsearch.script.ScriptService.ScriptType; import org.elasticsearch.search.aggregations.AggregationStreams; import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.metrics.InternalMetricsAggregation; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import java.io.IOException; import java.util.ArrayList; @@ -63,13 +63,13 @@ public class InternalScriptedMetric extends InternalMetricsAggregation implement private InternalScriptedMetric() { } - private InternalScriptedMetric(String name, List reducers, Map metaData) { - super(name, reducers, metaData); + private InternalScriptedMetric(String name, List pipelineAggregators, Map metaData) { + super(name, pipelineAggregators, metaData); } public InternalScriptedMetric(String name, Object aggregation, String scriptLang, ScriptType scriptType, String reduceScript, - Map reduceParams, List reducers, Map metaData) { - this(name, reducers, metaData); + Map reduceParams, List pipelineAggregators, Map metaData) { + this(name, pipelineAggregators, metaData); this.aggregation = aggregation; this.scriptType = scriptType; this.reduceScript = reduceScript; @@ -106,7 +106,7 @@ public class InternalScriptedMetric extends InternalMetricsAggregation implement aggregation = aggregationObjects; } return new InternalScriptedMetric(firstAggregation.getName(), aggregation, firstAggregation.scriptLang, firstAggregation.scriptType, - firstAggregation.reduceScript, firstAggregation.reduceParams, reducers(), getMetaData()); + firstAggregation.reduceScript, firstAggregation.reduceParams, pipelineAggregators(), getMetaData()); } diff --git a/src/main/java/org/elasticsearch/search/aggregations/metrics/scripted/ScriptedMetricAggregator.java b/src/main/java/org/elasticsearch/search/aggregations/metrics/scripted/ScriptedMetricAggregator.java index 6ac07a6fedc..fd00f9f3c5f 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/metrics/scripted/ScriptedMetricAggregator.java +++ b/src/main/java/org/elasticsearch/search/aggregations/metrics/scripted/ScriptedMetricAggregator.java @@ -34,7 +34,7 @@ import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.LeafBucketCollector; import org.elasticsearch.search.aggregations.LeafBucketCollectorBase; import org.elasticsearch.search.aggregations.metrics.MetricsAggregator; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.AggregationContext; import org.elasticsearch.search.internal.SearchContext; @@ -61,8 +61,8 @@ public class ScriptedMetricAggregator extends MetricsAggregator { protected ScriptedMetricAggregator(String name, String scriptLang, ScriptType initScriptType, String initScript, ScriptType mapScriptType, String mapScript, ScriptType combineScriptType, String combineScript, ScriptType reduceScriptType, String reduceScript, Map params, Map reduceParams, AggregationContext context, - Aggregator parent, List reducers, Map metaData) throws IOException { - super(name, context, parent, reducers, metaData); + Aggregator parent, List pipelineAggregators, Map metaData) throws IOException { + super(name, context, parent, pipelineAggregators, metaData); this.scriptLang = scriptLang; this.reduceScriptType = reduceScriptType; if (params == null) { @@ -116,13 +116,13 @@ public class ScriptedMetricAggregator extends MetricsAggregator { } else { aggregation = params.get("_agg"); } - return new InternalScriptedMetric(name, aggregation, scriptLang, reduceScriptType, reduceScript, reduceParams, reducers(), + return new InternalScriptedMetric(name, aggregation, scriptLang, reduceScriptType, reduceScript, reduceParams, pipelineAggregators(), metaData()); } @Override public InternalAggregation buildEmptyAggregation() { - return new InternalScriptedMetric(name, null, scriptLang, reduceScriptType, reduceScript, reduceParams, reducers(), metaData()); + return new InternalScriptedMetric(name, null, scriptLang, reduceScriptType, reduceScript, reduceParams, pipelineAggregators(), metaData()); } public static class Factory extends AggregatorFactory { @@ -157,7 +157,7 @@ public class ScriptedMetricAggregator extends MetricsAggregator { @Override public Aggregator createInternal(AggregationContext context, Aggregator parent, boolean collectsFromSingleBucket, - List reducers, Map metaData) throws IOException { + List pipelineAggregators, Map metaData) throws IOException { if (collectsFromSingleBucket == false) { return asMultiBucketAggregator(this, context, parent); } @@ -170,7 +170,7 @@ public class ScriptedMetricAggregator extends MetricsAggregator { reduceParams = deepCopyParams(this.reduceParams, context.searchContext()); } return new ScriptedMetricAggregator(name, scriptLang, initScriptType, initScript, mapScriptType, mapScript, combineScriptType, - combineScript, reduceScriptType, reduceScript, params, reduceParams, context, parent, reducers, metaData); + combineScript, reduceScriptType, reduceScript, params, reduceParams, context, parent, pipelineAggregators, metaData); } @SuppressWarnings({ "unchecked" }) diff --git a/src/main/java/org/elasticsearch/search/aggregations/metrics/stats/InternalStats.java b/src/main/java/org/elasticsearch/search/aggregations/metrics/stats/InternalStats.java index c7b68da9a88..3d016f73eaa 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/metrics/stats/InternalStats.java +++ b/src/main/java/org/elasticsearch/search/aggregations/metrics/stats/InternalStats.java @@ -26,7 +26,7 @@ import org.elasticsearch.common.xcontent.XContentBuilderString; import org.elasticsearch.search.aggregations.AggregationStreams; import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.metrics.InternalNumericMetricsAggregation; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.format.ValueFormatter; import org.elasticsearch.search.aggregations.support.format.ValueFormatterStreams; @@ -71,9 +71,9 @@ public class InternalStats extends InternalNumericMetricsAggregation.MultiValue protected InternalStats() {} // for serialization public InternalStats(String name, long count, double sum, double min, double max, @Nullable ValueFormatter formatter, - List reducers, + List pipelineAggregators, Map metaData) { - super(name, reducers, metaData); + super(name, pipelineAggregators, metaData); this.count = count; this.sum = sum; this.min = min; @@ -163,7 +163,7 @@ public class InternalStats extends InternalNumericMetricsAggregation.MultiValue max = Math.max(max, stats.getMax()); sum += stats.getSum(); } - return new InternalStats(name, count, sum, min, max, valueFormatter, reducers(), getMetaData()); + return new InternalStats(name, count, sum, min, max, valueFormatter, pipelineAggregators(), getMetaData()); } @Override diff --git a/src/main/java/org/elasticsearch/search/aggregations/metrics/stats/StatsAggegator.java b/src/main/java/org/elasticsearch/search/aggregations/metrics/stats/StatsAggegator.java index cf9356fee1e..8c86d6d6096 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/metrics/stats/StatsAggegator.java +++ b/src/main/java/org/elasticsearch/search/aggregations/metrics/stats/StatsAggegator.java @@ -30,7 +30,7 @@ import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.LeafBucketCollector; import org.elasticsearch.search.aggregations.LeafBucketCollectorBase; import org.elasticsearch.search.aggregations.metrics.NumericMetricsAggregator; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.AggregationContext; import org.elasticsearch.search.aggregations.support.ValuesSource; import org.elasticsearch.search.aggregations.support.ValuesSourceAggregatorFactory; @@ -56,9 +56,10 @@ public class StatsAggegator extends NumericMetricsAggregator.MultiValue { public StatsAggegator(String name, ValuesSource.Numeric valuesSource, @Nullable ValueFormatter formatter, - AggregationContext context, Aggregator parent, List reducers, + AggregationContext context, + Aggregator parent, List pipelineAggregators, Map metaData) throws IOException { - super(name, context, parent, reducers, metaData); + super(name, context, parent, pipelineAggregators, metaData); this.valuesSource = valuesSource; if (valuesSource != null) { final BigArrays bigArrays = context.bigArrays(); @@ -147,12 +148,12 @@ public class StatsAggegator extends NumericMetricsAggregator.MultiValue { return buildEmptyAggregation(); } return new InternalStats(name, counts.get(bucket), sums.get(bucket), mins.get(bucket), - maxes.get(bucket), formatter, reducers(), metaData()); + maxes.get(bucket), formatter, pipelineAggregators(), metaData()); } @Override public InternalAggregation buildEmptyAggregation() { - return new InternalStats(name, 0, 0, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, formatter, reducers(), metaData()); + return new InternalStats(name, 0, 0, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, formatter, pipelineAggregators(), metaData()); } public static class Factory extends ValuesSourceAggregatorFactory.LeafOnly { @@ -162,15 +163,16 @@ public class StatsAggegator extends NumericMetricsAggregator.MultiValue { } @Override - protected Aggregator createUnmapped(AggregationContext aggregationContext, Aggregator parent, List reducers, - Map metaData) throws IOException { - return new StatsAggegator(name, null, config.formatter(), aggregationContext, parent, reducers, metaData); + protected Aggregator createUnmapped(AggregationContext aggregationContext, Aggregator parent, + List pipelineAggregators, Map metaData) throws IOException { + return new StatsAggegator(name, null, config.formatter(), aggregationContext, parent, pipelineAggregators, metaData); } @Override protected Aggregator doCreateInternal(ValuesSource.Numeric valuesSource, AggregationContext aggregationContext, Aggregator parent, - boolean collectsFromSingleBucket, List reducers, Map metaData) throws IOException { - return new StatsAggegator(name, valuesSource, config.formatter(), aggregationContext, parent, reducers, metaData); + boolean collectsFromSingleBucket, List pipelineAggregators, Map metaData) + throws IOException { + return new StatsAggegator(name, valuesSource, config.formatter(), aggregationContext, parent, pipelineAggregators, metaData); } } diff --git a/src/main/java/org/elasticsearch/search/aggregations/metrics/stats/extended/ExtendedStatsAggregator.java b/src/main/java/org/elasticsearch/search/aggregations/metrics/stats/extended/ExtendedStatsAggregator.java index 164fb86d00a..2fece21a7fb 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/metrics/stats/extended/ExtendedStatsAggregator.java +++ b/src/main/java/org/elasticsearch/search/aggregations/metrics/stats/extended/ExtendedStatsAggregator.java @@ -30,7 +30,7 @@ import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.LeafBucketCollector; import org.elasticsearch.search.aggregations.LeafBucketCollectorBase; import org.elasticsearch.search.aggregations.metrics.NumericMetricsAggregator; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.AggregationContext; import org.elasticsearch.search.aggregations.support.ValuesSource; import org.elasticsearch.search.aggregations.support.ValuesSourceAggregatorFactory; @@ -57,9 +57,10 @@ public class ExtendedStatsAggregator extends NumericMetricsAggregator.MultiValue DoubleArray sumOfSqrs; public ExtendedStatsAggregator(String name, ValuesSource.Numeric valuesSource, @Nullable ValueFormatter formatter, - AggregationContext context, Aggregator parent, double sigma, List reducers, Map metaData) + AggregationContext context, Aggregator parent, double sigma, List pipelineAggregators, + Map metaData) throws IOException { - super(name, context, parent, reducers, metaData); + super(name, context, parent, pipelineAggregators, metaData); this.valuesSource = valuesSource; this.formatter = formatter; this.sigma = sigma; @@ -169,17 +170,17 @@ public class ExtendedStatsAggregator extends NumericMetricsAggregator.MultiValue public InternalAggregation buildAggregation(long owningBucketOrdinal) { if (valuesSource == null) { return new InternalExtendedStats(name, 0, 0d, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, 0d, 0d, formatter, - reducers(), metaData()); + pipelineAggregators(), metaData()); } assert owningBucketOrdinal < counts.size(); return new InternalExtendedStats(name, counts.get(owningBucketOrdinal), sums.get(owningBucketOrdinal), mins.get(owningBucketOrdinal), maxes.get(owningBucketOrdinal), sumOfSqrs.get(owningBucketOrdinal), sigma, formatter, - reducers(), metaData()); + pipelineAggregators(), metaData()); } @Override public InternalAggregation buildEmptyAggregation() { - return new InternalExtendedStats(name, 0, 0d, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, 0d, 0d, formatter, reducers(), + return new InternalExtendedStats(name, 0, 0d, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, 0d, 0d, formatter, pipelineAggregators(), metaData()); } @@ -199,16 +200,18 @@ public class ExtendedStatsAggregator extends NumericMetricsAggregator.MultiValue } @Override - protected Aggregator createUnmapped(AggregationContext aggregationContext, Aggregator parent, List reducers, - Map metaData) throws IOException { - return new ExtendedStatsAggregator(name, null, config.formatter(), aggregationContext, parent, sigma, reducers, metaData); + protected Aggregator createUnmapped(AggregationContext aggregationContext, Aggregator parent, + List pipelineAggregators, Map metaData) throws IOException { + return new ExtendedStatsAggregator(name, null, config.formatter(), aggregationContext, parent, sigma, pipelineAggregators, + metaData); } @Override protected Aggregator doCreateInternal(ValuesSource.Numeric valuesSource, AggregationContext aggregationContext, Aggregator parent, - boolean collectsFromSingleBucket, List reducers, Map metaData) throws IOException { - return new ExtendedStatsAggregator(name, valuesSource, config.formatter(), aggregationContext, parent, sigma, reducers, - metaData); + boolean collectsFromSingleBucket, List pipelineAggregators, Map metaData) + throws IOException { + return new ExtendedStatsAggregator(name, valuesSource, config.formatter(), aggregationContext, parent, sigma, + pipelineAggregators, metaData); } } } diff --git a/src/main/java/org/elasticsearch/search/aggregations/metrics/stats/extended/InternalExtendedStats.java b/src/main/java/org/elasticsearch/search/aggregations/metrics/stats/extended/InternalExtendedStats.java index 7d1568156f5..0f958c22e03 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/metrics/stats/extended/InternalExtendedStats.java +++ b/src/main/java/org/elasticsearch/search/aggregations/metrics/stats/extended/InternalExtendedStats.java @@ -27,7 +27,7 @@ import org.elasticsearch.common.xcontent.XContentBuilderString; import org.elasticsearch.search.aggregations.AggregationStreams; import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.metrics.stats.InternalStats; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.format.ValueFormatter; import java.io.IOException; @@ -69,8 +69,9 @@ public class InternalExtendedStats extends InternalStats implements ExtendedStat InternalExtendedStats() {} // for serialization public InternalExtendedStats(String name, long count, double sum, double min, double max, double sumOfSqrs, - double sigma, @Nullable ValueFormatter formatter, List reducers, Map metaData) { - super(name, count, sum, min, max, formatter, reducers, metaData); + double sigma, + @Nullable ValueFormatter formatter, List pipelineAggregators, Map metaData) { + super(name, count, sum, min, max, formatter, pipelineAggregators, metaData); this.sumOfSqrs = sumOfSqrs; this.sigma = sigma; } @@ -153,7 +154,7 @@ public class InternalExtendedStats extends InternalStats implements ExtendedStat } final InternalStats stats = super.doReduce(aggregations, reduceContext); return new InternalExtendedStats(name, stats.getCount(), stats.getSum(), stats.getMin(), stats.getMax(), sumOfSqrs, sigma, - valueFormatter, reducers(), getMetaData()); + valueFormatter, pipelineAggregators(), getMetaData()); } @Override diff --git a/src/main/java/org/elasticsearch/search/aggregations/metrics/sum/InternalSum.java b/src/main/java/org/elasticsearch/search/aggregations/metrics/sum/InternalSum.java index 00c8050e714..4cacfb4ea80 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/metrics/sum/InternalSum.java +++ b/src/main/java/org/elasticsearch/search/aggregations/metrics/sum/InternalSum.java @@ -25,7 +25,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.search.aggregations.AggregationStreams; import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.metrics.InternalNumericMetricsAggregation; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.format.ValueFormatter; import org.elasticsearch.search.aggregations.support.format.ValueFormatterStreams; @@ -57,8 +57,9 @@ public class InternalSum extends InternalNumericMetricsAggregation.SingleValue i InternalSum() {} // for serialization - InternalSum(String name, double sum, @Nullable ValueFormatter formatter, List reducers, Map metaData) { - super(name, reducers, metaData); + InternalSum(String name, double sum, @Nullable ValueFormatter formatter, List pipelineAggregators, + Map metaData) { + super(name, pipelineAggregators, metaData); this.sum = sum; this.valueFormatter = formatter; } @@ -84,7 +85,7 @@ public class InternalSum extends InternalNumericMetricsAggregation.SingleValue i for (InternalAggregation aggregation : aggregations) { sum += ((InternalSum) aggregation).sum; } - return new InternalSum(name, sum, valueFormatter, reducers(), getMetaData()); + return new InternalSum(name, sum, valueFormatter, pipelineAggregators(), getMetaData()); } @Override diff --git a/src/main/java/org/elasticsearch/search/aggregations/metrics/sum/SumAggregator.java b/src/main/java/org/elasticsearch/search/aggregations/metrics/sum/SumAggregator.java index 4c7981422f3..e201cf75981 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/metrics/sum/SumAggregator.java +++ b/src/main/java/org/elasticsearch/search/aggregations/metrics/sum/SumAggregator.java @@ -29,7 +29,7 @@ import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.LeafBucketCollector; import org.elasticsearch.search.aggregations.LeafBucketCollectorBase; import org.elasticsearch.search.aggregations.metrics.NumericMetricsAggregator; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.AggregationContext; import org.elasticsearch.search.aggregations.support.ValuesSource; import org.elasticsearch.search.aggregations.support.ValuesSourceAggregatorFactory; @@ -51,9 +51,10 @@ public class SumAggregator extends NumericMetricsAggregator.SingleValue { DoubleArray sums; public SumAggregator(String name, ValuesSource.Numeric valuesSource, @Nullable ValueFormatter formatter, - AggregationContext context, Aggregator parent, List reducers, + AggregationContext context, + Aggregator parent, List pipelineAggregators, Map metaData) throws IOException { - super(name, context, parent, reducers, metaData); + super(name, context, parent, pipelineAggregators, metaData); this.valuesSource = valuesSource; this.formatter = formatter; if (valuesSource != null) { @@ -99,12 +100,12 @@ public class SumAggregator extends NumericMetricsAggregator.SingleValue { if (valuesSource == null || bucket >= sums.size()) { return buildEmptyAggregation(); } - return new InternalSum(name, sums.get(bucket), formatter, reducers(), metaData()); + return new InternalSum(name, sums.get(bucket), formatter, pipelineAggregators(), metaData()); } @Override public InternalAggregation buildEmptyAggregation() { - return new InternalSum(name, 0.0, formatter, reducers(), metaData()); + return new InternalSum(name, 0.0, formatter, pipelineAggregators(), metaData()); } public static class Factory extends ValuesSourceAggregatorFactory.LeafOnly { @@ -114,15 +115,16 @@ public class SumAggregator extends NumericMetricsAggregator.SingleValue { } @Override - protected Aggregator createUnmapped(AggregationContext aggregationContext, Aggregator parent, List reducers, - Map metaData) throws IOException { - return new SumAggregator(name, null, config.formatter(), aggregationContext, parent, reducers, metaData); + protected Aggregator createUnmapped(AggregationContext aggregationContext, Aggregator parent, + List pipelineAggregators, Map metaData) throws IOException { + return new SumAggregator(name, null, config.formatter(), aggregationContext, parent, pipelineAggregators, metaData); } @Override protected Aggregator doCreateInternal(ValuesSource.Numeric valuesSource, AggregationContext aggregationContext, Aggregator parent, - boolean collectsFromSingleBucket, List reducers, Map metaData) throws IOException { - return new SumAggregator(name, valuesSource, config.formatter(), aggregationContext, parent, reducers, metaData); + boolean collectsFromSingleBucket, List pipelineAggregators, Map metaData) + throws IOException { + return new SumAggregator(name, valuesSource, config.formatter(), aggregationContext, parent, pipelineAggregators, metaData); } } diff --git a/src/main/java/org/elasticsearch/search/aggregations/metrics/tophits/InternalTopHits.java b/src/main/java/org/elasticsearch/search/aggregations/metrics/tophits/InternalTopHits.java index 2ae1d3d50c9..b91cafd6e04 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/metrics/tophits/InternalTopHits.java +++ b/src/main/java/org/elasticsearch/search/aggregations/metrics/tophits/InternalTopHits.java @@ -31,7 +31,7 @@ import org.elasticsearch.search.SearchHits; import org.elasticsearch.search.aggregations.AggregationStreams; import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.metrics.InternalMetricsAggregation; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.internal.InternalSearchHit; import org.elasticsearch.search.internal.InternalSearchHits; @@ -66,9 +66,9 @@ public class InternalTopHits extends InternalMetricsAggregation implements TopHi InternalTopHits() { } - public InternalTopHits(String name, int from, int size, TopDocs topDocs, InternalSearchHits searchHits, List reducers, - Map metaData) { - super(name, reducers, metaData); + public InternalTopHits(String name, int from, int size, TopDocs topDocs, InternalSearchHits searchHits, + List pipelineAggregators, Map metaData) { + super(name, pipelineAggregators, metaData); this.from = from; this.size = size; this.topDocs = topDocs; @@ -124,7 +124,7 @@ public class InternalTopHits extends InternalMetricsAggregation implements TopHi } return new InternalTopHits(name, from, size, reducedTopDocs, new InternalSearchHits(hits, reducedTopDocs.totalHits, reducedTopDocs.getMaxScore()), - reducers(), getMetaData()); + pipelineAggregators(), getMetaData()); } catch (IOException e) { throw ExceptionsHelper.convertToElastic(e); } diff --git a/src/main/java/org/elasticsearch/search/aggregations/metrics/tophits/TopHitsAggregator.java b/src/main/java/org/elasticsearch/search/aggregations/metrics/tophits/TopHitsAggregator.java index 1f211471457..8433022b6c6 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/metrics/tophits/TopHitsAggregator.java +++ b/src/main/java/org/elasticsearch/search/aggregations/metrics/tophits/TopHitsAggregator.java @@ -38,11 +38,10 @@ import org.elasticsearch.search.aggregations.Aggregator; import org.elasticsearch.search.aggregations.AggregatorFactories; import org.elasticsearch.search.aggregations.AggregatorFactory; import org.elasticsearch.search.aggregations.InternalAggregation; -import org.elasticsearch.search.aggregations.LeafBucketCollectorBase; -import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.LeafBucketCollector; +import org.elasticsearch.search.aggregations.LeafBucketCollectorBase; import org.elasticsearch.search.aggregations.metrics.MetricsAggregator; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.AggregationContext; import org.elasticsearch.search.fetch.FetchPhase; import org.elasticsearch.search.fetch.FetchSearchResult; @@ -73,8 +72,8 @@ public class TopHitsAggregator extends MetricsAggregator { final LongObjectPagedHashMap topDocsCollectors; public TopHitsAggregator(FetchPhase fetchPhase, SubSearchContext subSearchContext, String name, AggregationContext context, - Aggregator parent, List reducers, Map metaData) throws IOException { - super(name, context, parent, reducers, metaData); + Aggregator parent, List pipelineAggregators, Map metaData) throws IOException { + super(name, context, parent, pipelineAggregators, metaData); this.fetchPhase = fetchPhase; topDocsCollectors = new LongObjectPagedHashMap<>(1, context.bigArrays()); this.subSearchContext = subSearchContext; @@ -157,7 +156,7 @@ public class TopHitsAggregator extends MetricsAggregator { searchHitFields.sortValues(fieldDoc.fields); } } - topHits = new InternalTopHits(name, subSearchContext.from(), subSearchContext.size(), topDocs, fetchResult.hits(), reducers(), + topHits = new InternalTopHits(name, subSearchContext.from(), subSearchContext.size(), topDocs, fetchResult.hits(), pipelineAggregators(), metaData()); } return topHits; @@ -171,7 +170,7 @@ public class TopHitsAggregator extends MetricsAggregator { } else { topDocs = Lucene.EMPTY_TOP_DOCS; } - return new InternalTopHits(name, subSearchContext.from(), subSearchContext.size(), topDocs, InternalSearchHits.empty(), reducers(), metaData()); + return new InternalTopHits(name, subSearchContext.from(), subSearchContext.size(), topDocs, InternalSearchHits.empty(), pipelineAggregators(), metaData()); } @Override @@ -192,8 +191,8 @@ public class TopHitsAggregator extends MetricsAggregator { @Override public Aggregator createInternal(AggregationContext aggregationContext, Aggregator parent, boolean collectsFromSingleBucket, - List reducers, Map metaData) throws IOException { - return new TopHitsAggregator(fetchPhase, subSearchContext, name, aggregationContext, parent, reducers, metaData); + List pipelineAggregators, Map metaData) throws IOException { + return new TopHitsAggregator(fetchPhase, subSearchContext, name, aggregationContext, parent, pipelineAggregators, metaData); } @Override diff --git a/src/main/java/org/elasticsearch/search/aggregations/metrics/valuecount/InternalValueCount.java b/src/main/java/org/elasticsearch/search/aggregations/metrics/valuecount/InternalValueCount.java index 9ebb7e534ea..baae0555536 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/metrics/valuecount/InternalValueCount.java +++ b/src/main/java/org/elasticsearch/search/aggregations/metrics/valuecount/InternalValueCount.java @@ -25,7 +25,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.search.aggregations.AggregationStreams; import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.metrics.InternalNumericMetricsAggregation; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.format.ValueFormatter; import java.io.IOException; @@ -56,9 +56,9 @@ public class InternalValueCount extends InternalNumericMetricsAggregation.Single InternalValueCount() {} // for serialization - public InternalValueCount(String name, long value, @Nullable ValueFormatter formatter, List reducers, + public InternalValueCount(String name, long value, @Nullable ValueFormatter formatter, List pipelineAggregators, Map metaData) { - super(name, reducers, metaData); + super(name, pipelineAggregators, metaData); this.value = value; this.valueFormatter = formatter; } @@ -84,7 +84,7 @@ public class InternalValueCount extends InternalNumericMetricsAggregation.Single for (InternalAggregation aggregation : aggregations) { valueCount += ((InternalValueCount) aggregation).value; } - return new InternalValueCount(name, valueCount, valueFormatter, reducers(), getMetaData()); + return new InternalValueCount(name, valueCount, valueFormatter, pipelineAggregators(), getMetaData()); } @Override diff --git a/src/main/java/org/elasticsearch/search/aggregations/metrics/valuecount/ValueCountAggregator.java b/src/main/java/org/elasticsearch/search/aggregations/metrics/valuecount/ValueCountAggregator.java index fedd7e09a2b..984898a6f8b 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/metrics/valuecount/ValueCountAggregator.java +++ b/src/main/java/org/elasticsearch/search/aggregations/metrics/valuecount/ValueCountAggregator.java @@ -29,7 +29,7 @@ import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.LeafBucketCollector; import org.elasticsearch.search.aggregations.LeafBucketCollectorBase; import org.elasticsearch.search.aggregations.metrics.NumericMetricsAggregator; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.AggregationContext; import org.elasticsearch.search.aggregations.support.ValuesSource; import org.elasticsearch.search.aggregations.support.ValuesSourceAggregatorFactory; @@ -55,9 +55,10 @@ public class ValueCountAggregator extends NumericMetricsAggregator.SingleValue { LongArray counts; public ValueCountAggregator(String name, ValuesSource valuesSource, @Nullable ValueFormatter formatter, - AggregationContext aggregationContext, Aggregator parent, List reducers, Map metaData) + AggregationContext aggregationContext, Aggregator parent, List pipelineAggregators, + Map metaData) throws IOException { - super(name, aggregationContext, parent, reducers, metaData); + super(name, aggregationContext, parent, pipelineAggregators, metaData); this.valuesSource = valuesSource; this.formatter = formatter; if (valuesSource != null) { @@ -95,12 +96,12 @@ public class ValueCountAggregator extends NumericMetricsAggregator.SingleValue { if (valuesSource == null || bucket >= counts.size()) { return buildEmptyAggregation(); } - return new InternalValueCount(name, counts.get(bucket), formatter, reducers(), metaData()); + return new InternalValueCount(name, counts.get(bucket), formatter, pipelineAggregators(), metaData()); } @Override public InternalAggregation buildEmptyAggregation() { - return new InternalValueCount(name, 0l, formatter, reducers(), metaData()); + return new InternalValueCount(name, 0l, formatter, pipelineAggregators(), metaData()); } @Override @@ -115,15 +116,16 @@ public class ValueCountAggregator extends NumericMetricsAggregator.SingleValue { } @Override - protected Aggregator createUnmapped(AggregationContext aggregationContext, Aggregator parent, List reducers, - Map metaData) throws IOException { - return new ValueCountAggregator(name, null, config.formatter(), aggregationContext, parent, reducers, metaData); + protected Aggregator createUnmapped(AggregationContext aggregationContext, Aggregator parent, + List pipelineAggregators, Map metaData) throws IOException { + return new ValueCountAggregator(name, null, config.formatter(), aggregationContext, parent, pipelineAggregators, metaData); } @Override protected Aggregator doCreateInternal(VS valuesSource, AggregationContext aggregationContext, Aggregator parent, - boolean collectsFromSingleBucket, List reducers, Map metaData) throws IOException { - return new ValueCountAggregator(name, valuesSource, config.formatter(), aggregationContext, parent, reducers, + boolean collectsFromSingleBucket, List pipelineAggregators, Map metaData) + throws IOException { + return new ValueCountAggregator(name, valuesSource, config.formatter(), aggregationContext, parent, pipelineAggregators, metaData); } diff --git a/src/main/java/org/elasticsearch/search/aggregations/reducers/BucketHelpers.java b/src/main/java/org/elasticsearch/search/aggregations/pipeline/BucketHelpers.java similarity index 86% rename from src/main/java/org/elasticsearch/search/aggregations/reducers/BucketHelpers.java rename to src/main/java/org/elasticsearch/search/aggregations/pipeline/BucketHelpers.java index 9eb70d860e5..b96bf4af176 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/reducers/BucketHelpers.java +++ b/src/main/java/org/elasticsearch/search/aggregations/pipeline/BucketHelpers.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.search.aggregations.reducers; +package org.elasticsearch.search.aggregations.pipeline; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.io.stream.StreamInput; @@ -28,7 +28,7 @@ import org.elasticsearch.search.aggregations.AggregationExecutionException; import org.elasticsearch.search.aggregations.InternalMultiBucketAggregation; import org.elasticsearch.search.aggregations.InvalidAggregationPathException; import org.elasticsearch.search.aggregations.metrics.InternalNumericMetricsAggregation; -import org.elasticsearch.search.aggregations.reducers.derivative.DerivativeParser; +import org.elasticsearch.search.aggregations.pipeline.derivative.DerivativeParser; import org.elasticsearch.search.aggregations.support.AggregationPath; import org.elasticsearch.search.internal.SearchContext; @@ -38,8 +38,8 @@ import java.util.Arrays; import java.util.List; /** - * A set of static helpers to simplify working with aggregation buckets, in particular - * providing utilities that help reducers. + * A set of static helpers to simplify working with aggregation buckets, in + * particular providing utilities that help pipeline aggregations. */ public class BucketHelpers { @@ -130,18 +130,26 @@ public class BucketHelpers { } /** - * Given a path and a set of buckets, this method will return the value inside the agg at - * that path. This is used to extract values for use by reducers (e.g. a derivative might need - * the price for each bucket). If the bucket is empty, the configured GapPolicy is invoked to + * Given a path and a set of buckets, this method will return the value + * inside the agg at that path. This is used to extract values for use by + * pipeline aggregations (e.g. a derivative might need the price for each + * bucket). If the bucket is empty, the configured GapPolicy is invoked to * resolve the missing bucket * - * @param histo A series of agg buckets in the form of a histogram - * @param bucket A specific bucket that a value needs to be extracted from. This bucket should be present - * in the histo parameter - * @param aggPath The path to a particular value that needs to be extracted. This path should point to a metric - * inside the bucket - * @param gapPolicy The gap policy to apply if empty buckets are found - * @return The value extracted from bucket found at aggPath + * @param histo + * A series of agg buckets in the form of a histogram + * @param bucket + * A specific bucket that a value needs to be extracted from. + * This bucket should be present in the histo + * parameter + * @param aggPath + * The path to a particular value that needs to be extracted. + * This path should point to a metric inside the + * bucket + * @param gapPolicy + * The gap policy to apply if empty buckets are found + * @return The value extracted from bucket found at + * aggPath */ public static Double resolveBucketValue(InternalMultiBucketAggregation agg, InternalMultiBucketAggregation.Bucket bucket, String aggPath, GapPolicy gapPolicy) { diff --git a/src/main/java/org/elasticsearch/search/aggregations/reducers/InternalSimpleValue.java b/src/main/java/org/elasticsearch/search/aggregations/pipeline/InternalSimpleValue.java similarity index 94% rename from src/main/java/org/elasticsearch/search/aggregations/reducers/InternalSimpleValue.java rename to src/main/java/org/elasticsearch/search/aggregations/pipeline/InternalSimpleValue.java index 6c0edd811d3..ed0041d2da3 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/reducers/InternalSimpleValue.java +++ b/src/main/java/org/elasticsearch/search/aggregations/pipeline/InternalSimpleValue.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.search.aggregations.reducers; +package org.elasticsearch.search.aggregations.pipeline; import org.elasticsearch.common.inject.internal.Nullable; import org.elasticsearch.common.io.stream.StreamInput; @@ -56,8 +56,8 @@ public class InternalSimpleValue extends InternalNumericMetricsAggregation.Singl protected InternalSimpleValue() { } // for serialization - public InternalSimpleValue(String name, double value, @Nullable ValueFormatter formatter, List reducers, Map metaData) { - super(name, reducers, metaData); + public InternalSimpleValue(String name, double value, @Nullable ValueFormatter formatter, List pipelineAggregators, Map metaData) { + super(name, pipelineAggregators, metaData); this.valueFormatter = formatter; this.value = value; } diff --git a/src/main/java/org/elasticsearch/search/aggregations/reducers/Reducer.java b/src/main/java/org/elasticsearch/search/aggregations/pipeline/PipelineAggregator.java similarity index 79% rename from src/main/java/org/elasticsearch/search/aggregations/reducers/Reducer.java rename to src/main/java/org/elasticsearch/search/aggregations/pipeline/PipelineAggregator.java index 8daa4d6180a..17ea3a791b4 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/reducers/Reducer.java +++ b/src/main/java/org/elasticsearch/search/aggregations/pipeline/PipelineAggregator.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.search.aggregations.reducers; +package org.elasticsearch.search.aggregations.pipeline; import com.google.common.base.Function; @@ -35,13 +35,13 @@ import org.elasticsearch.search.internal.SearchContext; import java.io.IOException; import java.util.Map; -public abstract class Reducer implements Streamable { +public abstract class PipelineAggregator implements Streamable { /** - * Parses the reducer request and creates the appropriate reducer factory - * for it. + * Parses the pipeline aggregation request and creates the appropriate + * pipeline aggregator factory for it. * - * @see {@link ReducerFactory} + * @see {@link PipelineAggregatorFactory} */ public static interface Parser { @@ -51,24 +51,25 @@ public abstract class Reducer implements Streamable { public static final ParseField GAP_POLICY = new ParseField("gap_policy"); /** - * @return The reducer type this parser is associated with. + * @return The aggregation type this parser is associated with. */ String type(); /** - * Returns the reducer factory with which this parser is associated. + * Returns the pipeline aggregator factory with which this parser is + * associated. * - * @param reducerName - * The name of the reducer + * @param pipelineAggregatorName + * The name of the pipeline aggregation * @param parser * The xcontent parser * @param context * The search context - * @return The resolved reducer factory + * @return The resolved pipeline aggregator factory * @throws java.io.IOException * When parsing fails */ - ReducerFactory parse(String reducerName, XContentParser parser, SearchContext context) throws IOException; + PipelineAggregatorFactory parse(String pipelineAggregatorName, XContentParser parser, SearchContext context) throws IOException; } @@ -83,10 +84,10 @@ public abstract class Reducer implements Streamable { private String[] bucketsPaths; private Map metaData; - protected Reducer() { // for Serialisation + protected PipelineAggregator() { // for Serialisation } - protected Reducer(String name, String[] bucketsPaths, Map metaData) { + protected PipelineAggregator(String name, String[] bucketsPaths, Map metaData) { this.name = name; this.bucketsPaths = bucketsPaths; this.metaData = metaData; diff --git a/src/main/java/org/elasticsearch/search/aggregations/reducers/ReducerBuilder.java b/src/main/java/org/elasticsearch/search/aggregations/pipeline/PipelineAggregatorBuilder.java similarity index 79% rename from src/main/java/org/elasticsearch/search/aggregations/reducers/ReducerBuilder.java rename to src/main/java/org/elasticsearch/search/aggregations/pipeline/PipelineAggregatorBuilder.java index 4dee8ea96a2..56ae321712f 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/reducers/ReducerBuilder.java +++ b/src/main/java/org/elasticsearch/search/aggregations/pipeline/PipelineAggregatorBuilder.java @@ -17,9 +17,8 @@ * under the License. */ -package org.elasticsearch.search.aggregations.reducers; +package org.elasticsearch.search.aggregations.pipeline; -import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.search.aggregations.AbstractAggregationBuilder; @@ -27,9 +26,9 @@ import java.io.IOException; import java.util.Map; /** - * A base class for all reducer builders. + * A base class for all pipeline aggregator builders. */ -public abstract class ReducerBuilder> extends AbstractAggregationBuilder { +public abstract class PipelineAggregatorBuilder> extends AbstractAggregationBuilder { private String[] bucketsPaths; private Map metaData; @@ -37,12 +36,12 @@ public abstract class ReducerBuilder> extends Abstra /** * Sole constructor, typically used by sub-classes. */ - protected ReducerBuilder(String name, String type) { + protected PipelineAggregatorBuilder(String name, String type) { super(name, type); } /** - * Sets the paths to the buckets to use for this reducer + * Sets the paths to the buckets to use for this pipeline aggregator */ public B setBucketsPaths(String... bucketsPaths) { this.bucketsPaths = bucketsPaths; @@ -50,7 +49,7 @@ public abstract class ReducerBuilder> extends Abstra } /** - * Sets the meta data to be included in the reducer's response + * Sets the meta data to be included in the pipeline aggregator's response */ public B setMetaData(Map metaData) { this.metaData = metaData; @@ -67,7 +66,7 @@ public abstract class ReducerBuilder> extends Abstra builder.startObject(type); if (bucketsPaths != null) { - builder.startArray(Reducer.Parser.BUCKETS_PATH.getPreferredName()); + builder.startArray(PipelineAggregator.Parser.BUCKETS_PATH.getPreferredName()); for (String path : bucketsPaths) { builder.value(path); } diff --git a/src/main/java/org/elasticsearch/search/aggregations/reducers/ReducerBuilders.java b/src/main/java/org/elasticsearch/search/aggregations/pipeline/PipelineAggregatorBuilders.java similarity index 75% rename from src/main/java/org/elasticsearch/search/aggregations/reducers/ReducerBuilders.java rename to src/main/java/org/elasticsearch/search/aggregations/pipeline/PipelineAggregatorBuilders.java index 71481de17ce..0d3bfe1f3fd 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/reducers/ReducerBuilders.java +++ b/src/main/java/org/elasticsearch/search/aggregations/pipeline/PipelineAggregatorBuilders.java @@ -17,18 +17,18 @@ * under the License. */ -package org.elasticsearch.search.aggregations.reducers; +package org.elasticsearch.search.aggregations.pipeline; -import org.elasticsearch.search.aggregations.reducers.bucketmetrics.avg.AvgBucketBuilder; -import org.elasticsearch.search.aggregations.reducers.bucketmetrics.max.MaxBucketBuilder; -import org.elasticsearch.search.aggregations.reducers.bucketmetrics.min.MinBucketBuilder; -import org.elasticsearch.search.aggregations.reducers.bucketmetrics.sum.SumBucketBuilder; -import org.elasticsearch.search.aggregations.reducers.derivative.DerivativeBuilder; -import org.elasticsearch.search.aggregations.reducers.movavg.MovAvgBuilder; +import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.avg.AvgBucketBuilder; +import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.max.MaxBucketBuilder; +import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.min.MinBucketBuilder; +import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.sum.SumBucketBuilder; +import org.elasticsearch.search.aggregations.pipeline.derivative.DerivativeBuilder; +import org.elasticsearch.search.aggregations.pipeline.movavg.MovAvgBuilder; -public final class ReducerBuilders { +public final class PipelineAggregatorBuilders { - private ReducerBuilders() { + private PipelineAggregatorBuilders() { } public static final DerivativeBuilder derivative(String name) { diff --git a/src/main/java/org/elasticsearch/search/aggregations/reducers/ReducerFactory.java b/src/main/java/org/elasticsearch/search/aggregations/pipeline/PipelineAggregatorFactory.java similarity index 72% rename from src/main/java/org/elasticsearch/search/aggregations/reducers/ReducerFactory.java rename to src/main/java/org/elasticsearch/search/aggregations/pipeline/PipelineAggregatorFactory.java index 46ac844808c..5109156af65 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/reducers/ReducerFactory.java +++ b/src/main/java/org/elasticsearch/search/aggregations/pipeline/PipelineAggregatorFactory.java @@ -16,9 +16,8 @@ * specific language governing permissions and limitations * under the License. */ -package org.elasticsearch.search.aggregations.reducers; +package org.elasticsearch.search.aggregations.pipeline; -import org.elasticsearch.search.aggregations.Aggregator; import org.elasticsearch.search.aggregations.AggregatorFactory; import java.io.IOException; @@ -26,9 +25,10 @@ import java.util.List; import java.util.Map; /** - * A factory that knows how to create an {@link Aggregator} of a specific type. + * A factory that knows how to create an {@link PipelineAggregator} of a + * specific type. */ -public abstract class ReducerFactory { +public abstract class PipelineAggregatorFactory { protected String name; protected String type; @@ -36,14 +36,14 @@ public abstract class ReducerFactory { protected Map metaData; /** - * Constructs a new reducer factory. + * Constructs a new pipeline aggregator factory. * * @param name * The aggregation name * @param type * The aggregation type */ - public ReducerFactory(String name, String type, String[] bucketsPaths) { + public PipelineAggregatorFactory(String name, String type, String[] bucketsPaths) { this.name = name; this.type = type; this.bucketsPaths = bucketsPaths; @@ -53,18 +53,19 @@ public abstract class ReducerFactory { * Validates the state of this factory (makes sure the factory is properly * configured) * - * @param reducerFactories + * @param pipelineAggregatorFactories * @param factories * @param parent */ - public final void validate(AggregatorFactory parent, AggregatorFactory[] factories, List reducerFactories) { - doValidate(parent, factories, reducerFactories); + public final void validate(AggregatorFactory parent, AggregatorFactory[] factories, + List pipelineAggregatorFactories) { + doValidate(parent, factories, pipelineAggregatorFactories); } - protected abstract Reducer createInternal(Map metaData) throws IOException; + protected abstract PipelineAggregator createInternal(Map metaData) throws IOException; /** - * Creates the reducer + * Creates the pipeline aggregator * * @param context * The aggregation context @@ -79,12 +80,13 @@ public abstract class ReducerFactory { * * @return The created aggregator */ - public final Reducer create() throws IOException { - Reducer aggregator = createInternal(this.metaData); + public final PipelineAggregator create() throws IOException { + PipelineAggregator aggregator = createInternal(this.metaData); return aggregator; } - public void doValidate(AggregatorFactory parent, AggregatorFactory[] factories, List reducerFactories) { + public void doValidate(AggregatorFactory parent, AggregatorFactory[] factories, + List pipelineAggregatorFactories) { } public void setMetaData(Map metaData) { diff --git a/src/main/java/org/elasticsearch/search/aggregations/reducers/ReducerStreams.java b/src/main/java/org/elasticsearch/search/aggregations/pipeline/PipelineAggregatorStreams.java similarity index 92% rename from src/main/java/org/elasticsearch/search/aggregations/reducers/ReducerStreams.java rename to src/main/java/org/elasticsearch/search/aggregations/pipeline/PipelineAggregatorStreams.java index 7a4319e0a2b..a633a3c25ca 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/reducers/ReducerStreams.java +++ b/src/main/java/org/elasticsearch/search/aggregations/pipeline/PipelineAggregatorStreams.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.elasticsearch.search.aggregations.reducers; +package org.elasticsearch.search.aggregations.pipeline; import com.google.common.collect.ImmutableMap; @@ -30,7 +30,7 @@ import java.io.IOException; * A registry for all the dedicated streams in the aggregation module. This is to support dynamic addAggregation that * know how to stream themselves. */ -public class ReducerStreams { +public class PipelineAggregatorStreams { private static ImmutableMap streams = ImmutableMap.of(); @@ -38,7 +38,7 @@ public class ReducerStreams { * A stream that knows how to read an aggregation from the input. */ public static interface Stream { - Reducer readResult(StreamInput in) throws IOException; + PipelineAggregator readResult(StreamInput in) throws IOException; } /** diff --git a/src/main/java/org/elasticsearch/search/aggregations/reducers/SiblingReducer.java b/src/main/java/org/elasticsearch/search/aggregations/pipeline/SiblingPipelineAggregator.java similarity index 89% rename from src/main/java/org/elasticsearch/search/aggregations/reducers/SiblingReducer.java rename to src/main/java/org/elasticsearch/search/aggregations/pipeline/SiblingPipelineAggregator.java index b0be9634ddc..d68660d4c7d 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/reducers/SiblingReducer.java +++ b/src/main/java/org/elasticsearch/search/aggregations/pipeline/SiblingPipelineAggregator.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.search.aggregations.reducers; +package org.elasticsearch.search.aggregations.pipeline; import com.google.common.collect.Lists; @@ -32,13 +32,13 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -public abstract class SiblingReducer extends Reducer { +public abstract class SiblingPipelineAggregator extends PipelineAggregator { - protected SiblingReducer() { // for Serialisation + protected SiblingPipelineAggregator() { // for Serialisation super(); } - protected SiblingReducer(String name, String[] bucketsPaths, Map metaData) { + protected SiblingPipelineAggregator(String name, String[] bucketsPaths, Map metaData) { super(name, bucketsPaths, metaData); } diff --git a/src/main/java/org/elasticsearch/search/aggregations/reducers/SimpleValue.java b/src/main/java/org/elasticsearch/search/aggregations/pipeline/SimpleValue.java similarity index 94% rename from src/main/java/org/elasticsearch/search/aggregations/reducers/SimpleValue.java rename to src/main/java/org/elasticsearch/search/aggregations/pipeline/SimpleValue.java index e1c510e1a29..82674aa82ff 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/reducers/SimpleValue.java +++ b/src/main/java/org/elasticsearch/search/aggregations/pipeline/SimpleValue.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.search.aggregations.reducers; +package org.elasticsearch.search.aggregations.pipeline; import org.elasticsearch.search.aggregations.metrics.NumericMetricsAggregation; diff --git a/src/main/java/org/elasticsearch/search/aggregations/reducers/bucketmetrics/BucketMetricsBuilder.java b/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/BucketMetricsBuilder.java similarity index 80% rename from src/main/java/org/elasticsearch/search/aggregations/reducers/bucketmetrics/BucketMetricsBuilder.java rename to src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/BucketMetricsBuilder.java index d19363b835d..755655755e7 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/reducers/bucketmetrics/BucketMetricsBuilder.java +++ b/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/BucketMetricsBuilder.java @@ -17,20 +17,20 @@ * under the License. */ -package org.elasticsearch.search.aggregations.reducers.bucketmetrics; +package org.elasticsearch.search.aggregations.pipeline.bucketmetrics; import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.search.aggregations.reducers.BucketHelpers.GapPolicy; -import org.elasticsearch.search.aggregations.reducers.ReducerBuilder; -import org.elasticsearch.search.aggregations.reducers.bucketmetrics.min.MinBucketParser; -import org.elasticsearch.search.aggregations.reducers.derivative.DerivativeParser; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilder; +import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy; +import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.min.MinBucketParser; +import org.elasticsearch.search.aggregations.pipeline.derivative.DerivativeParser; import java.io.IOException; /** - * A builder for building requests for a {@link BucketMetricsReducer} + * A builder for building requests for a {@link BucketMetricsPipelineAggregator} */ -public abstract class BucketMetricsBuilder> extends ReducerBuilder { +public abstract class BucketMetricsBuilder> extends PipelineAggregatorBuilder { private String format; private GapPolicy gapPolicy; diff --git a/src/main/java/org/elasticsearch/search/aggregations/reducers/bucketmetrics/BucketMetricsParser.java b/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/BucketMetricsParser.java similarity index 75% rename from src/main/java/org/elasticsearch/search/aggregations/reducers/bucketmetrics/BucketMetricsParser.java rename to src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/BucketMetricsParser.java index 0ff7dcf2fdd..2eceb2f22d5 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/reducers/bucketmetrics/BucketMetricsParser.java +++ b/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/BucketMetricsParser.java @@ -17,16 +17,16 @@ * under the License. */ -package org.elasticsearch.search.aggregations.reducers.bucketmetrics; +package org.elasticsearch.search.aggregations.pipeline.bucketmetrics; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentParser.Token; import org.elasticsearch.search.SearchParseException; -import org.elasticsearch.search.aggregations.reducers.BucketHelpers.GapPolicy; -import org.elasticsearch.search.aggregations.reducers.Reducer; -import org.elasticsearch.search.aggregations.reducers.ReducerFactory; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorFactory; +import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy; import org.elasticsearch.search.aggregations.support.format.ValueFormat; import org.elasticsearch.search.aggregations.support.format.ValueFormatter; import org.elasticsearch.search.internal.SearchContext; @@ -36,9 +36,9 @@ import java.util.ArrayList; import java.util.List; /** - * A parser for parsing requests for a {@link BucketMetricsReducer} + * A parser for parsing requests for a {@link BucketMetricsPipelineAggregator} */ -public abstract class BucketMetricsParser implements Reducer.Parser { +public abstract class BucketMetricsParser implements PipelineAggregator.Parser { public static final ParseField FORMAT = new ParseField("format"); @@ -47,7 +47,7 @@ public abstract class BucketMetricsParser implements Reducer.Parser { } @Override - public final ReducerFactory parse(String reducerName, XContentParser parser, SearchContext context) throws IOException { + public final PipelineAggregatorFactory parse(String pipelineAggregatorName, XContentParser parser, SearchContext context) throws IOException { XContentParser.Token token; String currentFieldName = null; String[] bucketsPaths = null; @@ -57,7 +57,7 @@ public abstract class BucketMetricsParser implements Reducer.Parser { while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); - } else if (doParse(reducerName, currentFieldName, token, parser, context)) { + } else if (doParse(pipelineAggregatorName, currentFieldName, token, parser, context)) { // Do nothing as subclass has stored the state for this token } else if (token == XContentParser.Token.VALUE_STRING) { if (FORMAT.match(currentFieldName)) { @@ -67,7 +67,7 @@ public abstract class BucketMetricsParser implements Reducer.Parser { } else if (GAP_POLICY.match(currentFieldName)) { gapPolicy = GapPolicy.parse(context, parser.text(), parser.getTokenLocation()); } else { - throw new SearchParseException(context, "Unknown key for a " + token + " in [" + reducerName + "]: [" + throw new SearchParseException(context, "Unknown key for a " + token + " in [" + pipelineAggregatorName + "]: [" + currentFieldName + "].", parser.getTokenLocation()); } } else if (token == XContentParser.Token.START_ARRAY) { @@ -79,18 +79,18 @@ public abstract class BucketMetricsParser implements Reducer.Parser { } bucketsPaths = paths.toArray(new String[paths.size()]); } else { - throw new SearchParseException(context, "Unknown key for a " + token + " in [" + reducerName + "]: [" + throw new SearchParseException(context, "Unknown key for a " + token + " in [" + pipelineAggregatorName + "]: [" + currentFieldName + "].", parser.getTokenLocation()); } } else { - throw new SearchParseException(context, "Unexpected token " + token + " in [" + reducerName + "].", + throw new SearchParseException(context, "Unexpected token " + token + " in [" + pipelineAggregatorName + "].", parser.getTokenLocation()); } } if (bucketsPaths == null) { throw new SearchParseException(context, "Missing required field [" + BUCKETS_PATH.getPreferredName() - + "] for derivative aggregation [" + reducerName + "]", parser.getTokenLocation()); + + "] for derivative aggregation [" + pipelineAggregatorName + "]", parser.getTokenLocation()); } ValueFormatter formatter = null; @@ -98,13 +98,13 @@ public abstract class BucketMetricsParser implements Reducer.Parser { formatter = ValueFormat.Patternable.Number.format(format).formatter(); } - return buildFactory(reducerName, bucketsPaths, gapPolicy, formatter); + return buildFactory(pipelineAggregatorName, bucketsPaths, gapPolicy, formatter); } - protected abstract ReducerFactory buildFactory(String reducerName, String[] bucketsPaths, GapPolicy gapPolicy, + protected abstract PipelineAggregatorFactory buildFactory(String pipelineAggregatorName, String[] bucketsPaths, GapPolicy gapPolicy, @Nullable ValueFormatter formatter); - protected boolean doParse(String reducerName, String currentFieldName, Token token, XContentParser parser, SearchContext context) { + protected boolean doParse(String pipelineAggregatorName, String currentFieldName, Token token, XContentParser parser, SearchContext context) { return false; } diff --git a/src/main/java/org/elasticsearch/search/aggregations/reducers/bucketmetrics/BucketMetricsReducer.java b/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/BucketMetricsPipelineAggregator.java similarity index 82% rename from src/main/java/org/elasticsearch/search/aggregations/reducers/bucketmetrics/BucketMetricsReducer.java rename to src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/BucketMetricsPipelineAggregator.java index bf3d8b47e9e..90e4a8ea551 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/reducers/bucketmetrics/BucketMetricsReducer.java +++ b/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/BucketMetricsPipelineAggregator.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.search.aggregations.reducers.bucketmetrics; +package org.elasticsearch.search.aggregations.pipeline.bucketmetrics; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.io.stream.StreamInput; @@ -28,10 +28,10 @@ import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.InternalAggregation.ReduceContext; import org.elasticsearch.search.aggregations.InternalMultiBucketAggregation; import org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation.Bucket; -import org.elasticsearch.search.aggregations.reducers.BucketHelpers; -import org.elasticsearch.search.aggregations.reducers.BucketHelpers.GapPolicy; -import org.elasticsearch.search.aggregations.reducers.Reducer; -import org.elasticsearch.search.aggregations.reducers.SiblingReducer; +import org.elasticsearch.search.aggregations.pipeline.BucketHelpers; +import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; +import org.elasticsearch.search.aggregations.pipeline.SiblingPipelineAggregator; import org.elasticsearch.search.aggregations.support.AggregationPath; import org.elasticsearch.search.aggregations.support.format.ValueFormatter; import org.elasticsearch.search.aggregations.support.format.ValueFormatterStreams; @@ -42,19 +42,19 @@ import java.util.List; import java.util.Map; /** - * A class of sibling reducers which calculate metrics across the buckets of a - * sibling aggregation + * A class of sibling pipeline aggregations which calculate metrics across the + * buckets of a sibling aggregation */ -public abstract class BucketMetricsReducer extends SiblingReducer { +public abstract class BucketMetricsPipelineAggregator extends SiblingPipelineAggregator { protected ValueFormatter formatter; protected GapPolicy gapPolicy; - public BucketMetricsReducer() { + public BucketMetricsPipelineAggregator() { super(); } - protected BucketMetricsReducer(String name, String[] bucketsPaths, GapPolicy gapPolicy, @Nullable ValueFormatter formatter, + protected BucketMetricsPipelineAggregator(String name, String[] bucketsPaths, GapPolicy gapPolicy, @Nullable ValueFormatter formatter, Map metaData) { super(name, bucketsPaths, metaData); this.gapPolicy = gapPolicy; @@ -92,13 +92,13 @@ public abstract class BucketMetricsReducer extends SiblingReducer { * Called after a collection run is finished to build the aggregation for * the collected state. * - * @param reducers - * the reducers to add to the resulting aggregation + * @param pipelineAggregators + * the pipeline aggregators to add to the resulting aggregation * @param metadata * the metadata to add to the resulting aggregation * @return */ - protected abstract InternalAggregation buildAggregation(List reducers, Map metadata); + protected abstract InternalAggregation buildAggregation(List pipelineAggregators, Map metadata); /** * Called for each bucket with a value so the state can be modified based on diff --git a/src/main/java/org/elasticsearch/search/aggregations/reducers/bucketmetrics/InternalBucketMetricValue.java b/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/InternalBucketMetricValue.java similarity index 93% rename from src/main/java/org/elasticsearch/search/aggregations/reducers/bucketmetrics/InternalBucketMetricValue.java rename to src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/InternalBucketMetricValue.java index 2229dd7baf5..a8eb0d82a9b 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/reducers/bucketmetrics/InternalBucketMetricValue.java +++ b/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/InternalBucketMetricValue.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.search.aggregations.reducers.bucketmetrics; +package org.elasticsearch.search.aggregations.pipeline.bucketmetrics; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.io.stream.StreamInput; @@ -26,7 +26,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.search.aggregations.AggregationStreams; import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.metrics.InternalNumericMetricsAggregation; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.format.ValueFormatter; import org.elasticsearch.search.aggregations.support.format.ValueFormatterStreams; @@ -60,8 +60,8 @@ public class InternalBucketMetricValue extends InternalNumericMetricsAggregation } public InternalBucketMetricValue(String name, String[] keys, double value, @Nullable ValueFormatter formatter, - List reducers, Map metaData) { - super(name, reducers, metaData); + List pipelineAggregators, Map metaData) { + super(name, pipelineAggregators, metaData); this.keys = keys; this.value = value; this.valueFormatter = formatter; diff --git a/src/main/java/org/elasticsearch/search/aggregations/reducers/bucketmetrics/avg/AvgBucketBuilder.java b/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/avg/AvgBucketBuilder.java similarity index 83% rename from src/main/java/org/elasticsearch/search/aggregations/reducers/bucketmetrics/avg/AvgBucketBuilder.java rename to src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/avg/AvgBucketBuilder.java index dff77e73525..627cded5932 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/reducers/bucketmetrics/avg/AvgBucketBuilder.java +++ b/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/avg/AvgBucketBuilder.java @@ -17,14 +17,14 @@ * under the License. */ -package org.elasticsearch.search.aggregations.reducers.bucketmetrics.avg; +package org.elasticsearch.search.aggregations.pipeline.bucketmetrics.avg; -import org.elasticsearch.search.aggregations.reducers.bucketmetrics.BucketMetricsBuilder; +import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsBuilder; public class AvgBucketBuilder extends BucketMetricsBuilder { public AvgBucketBuilder(String name) { - super(name, AvgBucketReducer.TYPE.name()); + super(name, AvgBucketPipelineAggregator.TYPE.name()); } } diff --git a/src/main/java/org/elasticsearch/search/aggregations/reducers/bucketmetrics/avg/AvgBucketParser.java b/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/avg/AvgBucketParser.java similarity index 64% rename from src/main/java/org/elasticsearch/search/aggregations/reducers/bucketmetrics/avg/AvgBucketParser.java rename to src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/avg/AvgBucketParser.java index 9c6e4ce1a87..113ad3e0b28 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/reducers/bucketmetrics/avg/AvgBucketParser.java +++ b/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/avg/AvgBucketParser.java @@ -17,22 +17,22 @@ * under the License. */ -package org.elasticsearch.search.aggregations.reducers.bucketmetrics.avg; +package org.elasticsearch.search.aggregations.pipeline.bucketmetrics.avg; import org.elasticsearch.common.Nullable; -import org.elasticsearch.search.aggregations.reducers.BucketHelpers.GapPolicy; -import org.elasticsearch.search.aggregations.reducers.bucketmetrics.BucketMetricsParser; -import org.elasticsearch.search.aggregations.reducers.ReducerFactory; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorFactory; +import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy; +import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsParser; import org.elasticsearch.search.aggregations.support.format.ValueFormatter; public class AvgBucketParser extends BucketMetricsParser { @Override public String type() { - return AvgBucketReducer.TYPE.name(); + return AvgBucketPipelineAggregator.TYPE.name(); } @Override - protected ReducerFactory buildFactory(String reducerName, String[] bucketsPaths, GapPolicy gapPolicy, @Nullable ValueFormatter formatter) { - return new AvgBucketReducer.Factory(reducerName, bucketsPaths, gapPolicy, formatter); + protected PipelineAggregatorFactory buildFactory(String pipelineAggregatorName, String[] bucketsPaths, GapPolicy gapPolicy, @Nullable ValueFormatter formatter) { + return new AvgBucketPipelineAggregator.Factory(pipelineAggregatorName, bucketsPaths, gapPolicy, formatter); } } diff --git a/src/main/java/org/elasticsearch/search/aggregations/reducers/bucketmetrics/avg/AvgBucketReducer.java b/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/avg/AvgBucketPipelineAggregator.java similarity index 58% rename from src/main/java/org/elasticsearch/search/aggregations/reducers/bucketmetrics/avg/AvgBucketReducer.java rename to src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/avg/AvgBucketPipelineAggregator.java index 7c418007758..1ad1aa3b6e8 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/reducers/bucketmetrics/avg/AvgBucketReducer.java +++ b/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/avg/AvgBucketPipelineAggregator.java @@ -17,49 +17,49 @@ * under the License. */ -package org.elasticsearch.search.aggregations.reducers.bucketmetrics.avg; +package org.elasticsearch.search.aggregations.pipeline.bucketmetrics.avg; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.search.aggregations.AggregatorFactory; import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.InternalAggregation.Type; -import org.elasticsearch.search.aggregations.reducers.BucketHelpers.GapPolicy; -import org.elasticsearch.search.aggregations.reducers.InternalSimpleValue; -import org.elasticsearch.search.aggregations.reducers.Reducer; -import org.elasticsearch.search.aggregations.reducers.ReducerFactory; -import org.elasticsearch.search.aggregations.reducers.ReducerStreams; -import org.elasticsearch.search.aggregations.reducers.bucketmetrics.BucketMetricsReducer; +import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy; +import org.elasticsearch.search.aggregations.pipeline.InternalSimpleValue; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorFactory; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorStreams; +import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsPipelineAggregator; import org.elasticsearch.search.aggregations.support.format.ValueFormatter; import java.io.IOException; import java.util.List; import java.util.Map; -public class AvgBucketReducer extends BucketMetricsReducer { +public class AvgBucketPipelineAggregator extends BucketMetricsPipelineAggregator { public final static Type TYPE = new Type("avg_bucket"); - public final static ReducerStreams.Stream STREAM = new ReducerStreams.Stream() { + public final static PipelineAggregatorStreams.Stream STREAM = new PipelineAggregatorStreams.Stream() { @Override - public AvgBucketReducer readResult(StreamInput in) throws IOException { - AvgBucketReducer result = new AvgBucketReducer(); + public AvgBucketPipelineAggregator readResult(StreamInput in) throws IOException { + AvgBucketPipelineAggregator result = new AvgBucketPipelineAggregator(); result.readFrom(in); return result; } }; public static void registerStreams() { - ReducerStreams.registerStream(STREAM, TYPE.stream()); + PipelineAggregatorStreams.registerStream(STREAM, TYPE.stream()); } private int count = 0; private double sum = 0; - private AvgBucketReducer() { + private AvgBucketPipelineAggregator() { } - protected AvgBucketReducer(String name, String[] bucketsPaths, GapPolicy gapPolicy, @Nullable ValueFormatter formatter, + protected AvgBucketPipelineAggregator(String name, String[] bucketsPaths, GapPolicy gapPolicy, @Nullable ValueFormatter formatter, Map metaData) { super(name, bucketsPaths, gapPolicy, formatter, metaData); } @@ -82,12 +82,12 @@ public class AvgBucketReducer extends BucketMetricsReducer { } @Override - protected InternalAggregation buildAggregation(List reducers, Map metadata) { + protected InternalAggregation buildAggregation(List pipelineAggregators, Map metadata) { double avgValue = count == 0 ? Double.NaN : (sum / count); - return new InternalSimpleValue(name(), avgValue, formatter, reducers, metadata); + return new InternalSimpleValue(name(), avgValue, formatter, pipelineAggregators, metadata); } - public static class Factory extends ReducerFactory { + public static class Factory extends PipelineAggregatorFactory { private final ValueFormatter formatter; private final GapPolicy gapPolicy; @@ -99,15 +99,15 @@ public class AvgBucketReducer extends BucketMetricsReducer { } @Override - protected Reducer createInternal(Map metaData) throws IOException { - return new AvgBucketReducer(name, bucketsPaths, gapPolicy, formatter, metaData); + protected PipelineAggregator createInternal(Map metaData) throws IOException { + return new AvgBucketPipelineAggregator(name, bucketsPaths, gapPolicy, formatter, metaData); } @Override - public void doValidate(AggregatorFactory parent, AggregatorFactory[] aggFactories, List reducerFactories) { + public void doValidate(AggregatorFactory parent, AggregatorFactory[] aggFactories, List pipelineAggregatorFactories) { if (bucketsPaths.length != 1) { - throw new IllegalStateException(Reducer.Parser.BUCKETS_PATH.getPreferredName() - + " must contain a single entry for reducer [" + name + "]"); + throw new IllegalStateException(PipelineAggregator.Parser.BUCKETS_PATH.getPreferredName() + + " must contain a single entry for aggregation [" + name + "]"); } } diff --git a/src/main/java/org/elasticsearch/search/aggregations/reducers/bucketmetrics/max/MaxBucketBuilder.java b/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/max/MaxBucketBuilder.java similarity index 83% rename from src/main/java/org/elasticsearch/search/aggregations/reducers/bucketmetrics/max/MaxBucketBuilder.java rename to src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/max/MaxBucketBuilder.java index 88055660d1b..8b214d35f3e 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/reducers/bucketmetrics/max/MaxBucketBuilder.java +++ b/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/max/MaxBucketBuilder.java @@ -17,14 +17,14 @@ * under the License. */ -package org.elasticsearch.search.aggregations.reducers.bucketmetrics.max; +package org.elasticsearch.search.aggregations.pipeline.bucketmetrics.max; -import org.elasticsearch.search.aggregations.reducers.bucketmetrics.BucketMetricsBuilder; +import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsBuilder; public class MaxBucketBuilder extends BucketMetricsBuilder { public MaxBucketBuilder(String name) { - super(name, MaxBucketReducer.TYPE.name()); + super(name, MaxBucketPipelineAggregator.TYPE.name()); } } diff --git a/src/main/java/org/elasticsearch/search/aggregations/reducers/bucketmetrics/max/MaxBucketParser.java b/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/max/MaxBucketParser.java similarity index 63% rename from src/main/java/org/elasticsearch/search/aggregations/reducers/bucketmetrics/max/MaxBucketParser.java rename to src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/max/MaxBucketParser.java index 2d438fdf9a4..864734b956f 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/reducers/bucketmetrics/max/MaxBucketParser.java +++ b/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/max/MaxBucketParser.java @@ -17,23 +17,23 @@ * under the License. */ -package org.elasticsearch.search.aggregations.reducers.bucketmetrics.max; +package org.elasticsearch.search.aggregations.pipeline.bucketmetrics.max; -import org.elasticsearch.search.aggregations.reducers.BucketHelpers.GapPolicy; -import org.elasticsearch.search.aggregations.reducers.ReducerFactory; -import org.elasticsearch.search.aggregations.reducers.bucketmetrics.BucketMetricsParser; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorFactory; +import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy; +import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsParser; import org.elasticsearch.search.aggregations.support.format.ValueFormatter; public class MaxBucketParser extends BucketMetricsParser { @Override public String type() { - return MaxBucketReducer.TYPE.name(); + return MaxBucketPipelineAggregator.TYPE.name(); } @Override - protected ReducerFactory buildFactory(String reducerName, String[] bucketsPaths, GapPolicy gapPolicy, ValueFormatter formatter) { - return new MaxBucketReducer.Factory(reducerName, bucketsPaths, gapPolicy, formatter); + protected PipelineAggregatorFactory buildFactory(String pipelineAggregatorName, String[] bucketsPaths, GapPolicy gapPolicy, ValueFormatter formatter) { + return new MaxBucketPipelineAggregator.Factory(pipelineAggregatorName, bucketsPaths, gapPolicy, formatter); } } diff --git a/src/main/java/org/elasticsearch/search/aggregations/reducers/bucketmetrics/max/MaxBucketReducer.java b/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/max/MaxBucketPipelineAggregator.java similarity index 62% rename from src/main/java/org/elasticsearch/search/aggregations/reducers/bucketmetrics/max/MaxBucketReducer.java rename to src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/max/MaxBucketPipelineAggregator.java index 079a3c5b40a..bdc59c0f2fd 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/reducers/bucketmetrics/max/MaxBucketReducer.java +++ b/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/max/MaxBucketPipelineAggregator.java @@ -17,19 +17,19 @@ * under the License. */ -package org.elasticsearch.search.aggregations.reducers.bucketmetrics.max; +package org.elasticsearch.search.aggregations.pipeline.bucketmetrics.max; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.search.aggregations.AggregatorFactory; import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.InternalAggregation.Type; -import org.elasticsearch.search.aggregations.reducers.BucketHelpers.GapPolicy; -import org.elasticsearch.search.aggregations.reducers.Reducer; -import org.elasticsearch.search.aggregations.reducers.ReducerFactory; -import org.elasticsearch.search.aggregations.reducers.ReducerStreams; -import org.elasticsearch.search.aggregations.reducers.bucketmetrics.BucketMetricsReducer; -import org.elasticsearch.search.aggregations.reducers.bucketmetrics.InternalBucketMetricValue; +import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorFactory; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorStreams; +import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsPipelineAggregator; +import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.InternalBucketMetricValue; import org.elasticsearch.search.aggregations.support.format.ValueFormatter; import java.io.IOException; @@ -38,30 +38,30 @@ import java.util.Collections; import java.util.List; import java.util.Map; -public class MaxBucketReducer extends BucketMetricsReducer { +public class MaxBucketPipelineAggregator extends BucketMetricsPipelineAggregator { public final static Type TYPE = new Type("max_bucket"); - public final static ReducerStreams.Stream STREAM = new ReducerStreams.Stream() { + public final static PipelineAggregatorStreams.Stream STREAM = new PipelineAggregatorStreams.Stream() { @Override - public MaxBucketReducer readResult(StreamInput in) throws IOException { - MaxBucketReducer result = new MaxBucketReducer(); + public MaxBucketPipelineAggregator readResult(StreamInput in) throws IOException { + MaxBucketPipelineAggregator result = new MaxBucketPipelineAggregator(); result.readFrom(in); return result; } }; public static void registerStreams() { - ReducerStreams.registerStream(STREAM, TYPE.stream()); + PipelineAggregatorStreams.registerStream(STREAM, TYPE.stream()); } private List maxBucketKeys; private double maxValue; - private MaxBucketReducer() { + private MaxBucketPipelineAggregator() { } - protected MaxBucketReducer(String name, String[] bucketsPaths, GapPolicy gapPolicy, @Nullable ValueFormatter formatter, + protected MaxBucketPipelineAggregator(String name, String[] bucketsPaths, GapPolicy gapPolicy, @Nullable ValueFormatter formatter, Map metaData) { super(name, bucketsPaths, gapPolicy, formatter, metaData); } @@ -89,12 +89,12 @@ public class MaxBucketReducer extends BucketMetricsReducer { } @Override - protected InternalAggregation buildAggregation(List reducers, Map metadata) { + protected InternalAggregation buildAggregation(List pipelineAggregators, Map metadata) { String[] keys = maxBucketKeys.toArray(new String[maxBucketKeys.size()]); return new InternalBucketMetricValue(name(), keys, maxValue, formatter, Collections.EMPTY_LIST, metaData()); } - public static class Factory extends ReducerFactory { + public static class Factory extends PipelineAggregatorFactory { private final ValueFormatter formatter; private final GapPolicy gapPolicy; @@ -106,15 +106,16 @@ public class MaxBucketReducer extends BucketMetricsReducer { } @Override - protected Reducer createInternal(Map metaData) throws IOException { - return new MaxBucketReducer(name, bucketsPaths, gapPolicy, formatter, metaData); + protected PipelineAggregator createInternal(Map metaData) throws IOException { + return new MaxBucketPipelineAggregator(name, bucketsPaths, gapPolicy, formatter, metaData); } @Override - public void doValidate(AggregatorFactory parent, AggregatorFactory[] aggFactories, List reducerFactories) { + public void doValidate(AggregatorFactory parent, AggregatorFactory[] aggFactories, + List pipelineAggregatorFactories) { if (bucketsPaths.length != 1) { - throw new IllegalStateException(Reducer.Parser.BUCKETS_PATH.getPreferredName() - + " must contain a single entry for reducer [" + name + "]"); + throw new IllegalStateException(PipelineAggregator.Parser.BUCKETS_PATH.getPreferredName() + + " must contain a single entry for aggregation [" + name + "]"); } } diff --git a/src/main/java/org/elasticsearch/search/aggregations/reducers/bucketmetrics/min/MinBucketBuilder.java b/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/min/MinBucketBuilder.java similarity index 83% rename from src/main/java/org/elasticsearch/search/aggregations/reducers/bucketmetrics/min/MinBucketBuilder.java rename to src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/min/MinBucketBuilder.java index 6160df80732..327bf4e063f 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/reducers/bucketmetrics/min/MinBucketBuilder.java +++ b/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/min/MinBucketBuilder.java @@ -17,15 +17,15 @@ * under the License. */ -package org.elasticsearch.search.aggregations.reducers.bucketmetrics.min; +package org.elasticsearch.search.aggregations.pipeline.bucketmetrics.min; -import org.elasticsearch.search.aggregations.reducers.bucketmetrics.BucketMetricsBuilder; +import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsBuilder; public class MinBucketBuilder extends BucketMetricsBuilder { public MinBucketBuilder(String name) { - super(name, MinBucketReducer.TYPE.name()); + super(name, MinBucketPipelineAggregator.TYPE.name()); } } diff --git a/src/main/java/org/elasticsearch/search/aggregations/reducers/bucketmetrics/min/MinBucketParser.java b/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/min/MinBucketParser.java similarity index 62% rename from src/main/java/org/elasticsearch/search/aggregations/reducers/bucketmetrics/min/MinBucketParser.java rename to src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/min/MinBucketParser.java index aa3fc48a5fa..0a5aa7c1123 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/reducers/bucketmetrics/min/MinBucketParser.java +++ b/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/min/MinBucketParser.java @@ -17,22 +17,23 @@ * under the License. */ -package org.elasticsearch.search.aggregations.reducers.bucketmetrics.min; +package org.elasticsearch.search.aggregations.pipeline.bucketmetrics.min; -import org.elasticsearch.search.aggregations.reducers.BucketHelpers.GapPolicy; -import org.elasticsearch.search.aggregations.reducers.ReducerFactory; -import org.elasticsearch.search.aggregations.reducers.bucketmetrics.BucketMetricsParser; +import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorFactory; +import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsParser; import org.elasticsearch.search.aggregations.support.format.ValueFormatter; public class MinBucketParser extends BucketMetricsParser { @Override public String type() { - return MinBucketReducer.TYPE.name(); + return MinBucketPipelineAggregator.TYPE.name(); } - protected ReducerFactory buildFactory(String reducerName, String[] bucketsPaths, GapPolicy gapPolicy, ValueFormatter formatter) { - return new MinBucketReducer.Factory(reducerName, bucketsPaths, gapPolicy, formatter); + protected PipelineAggregatorFactory buildFactory(String pipelineAggregatorName, String[] bucketsPaths, GapPolicy gapPolicy, + ValueFormatter formatter) { + return new MinBucketPipelineAggregator.Factory(pipelineAggregatorName, bucketsPaths, gapPolicy, formatter); }; } diff --git a/src/main/java/org/elasticsearch/search/aggregations/reducers/bucketmetrics/min/MinBucketReducer.java b/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/min/MinBucketPipelineAggregator.java similarity index 63% rename from src/main/java/org/elasticsearch/search/aggregations/reducers/bucketmetrics/min/MinBucketReducer.java rename to src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/min/MinBucketPipelineAggregator.java index 5e0749e245c..a4ec1d83a8b 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/reducers/bucketmetrics/min/MinBucketReducer.java +++ b/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/min/MinBucketPipelineAggregator.java @@ -17,19 +17,19 @@ * under the License. */ -package org.elasticsearch.search.aggregations.reducers.bucketmetrics.min; +package org.elasticsearch.search.aggregations.pipeline.bucketmetrics.min; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.search.aggregations.AggregatorFactory; import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.InternalAggregation.Type; -import org.elasticsearch.search.aggregations.reducers.BucketHelpers.GapPolicy; -import org.elasticsearch.search.aggregations.reducers.Reducer; -import org.elasticsearch.search.aggregations.reducers.ReducerFactory; -import org.elasticsearch.search.aggregations.reducers.ReducerStreams; -import org.elasticsearch.search.aggregations.reducers.bucketmetrics.BucketMetricsReducer; -import org.elasticsearch.search.aggregations.reducers.bucketmetrics.InternalBucketMetricValue; +import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorFactory; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorStreams; +import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsPipelineAggregator; +import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.InternalBucketMetricValue; import org.elasticsearch.search.aggregations.support.format.ValueFormatter; import java.io.IOException; @@ -38,30 +38,30 @@ import java.util.Collections; import java.util.List; import java.util.Map; -public class MinBucketReducer extends BucketMetricsReducer { +public class MinBucketPipelineAggregator extends BucketMetricsPipelineAggregator { public final static Type TYPE = new Type("min_bucket"); - public final static ReducerStreams.Stream STREAM = new ReducerStreams.Stream() { + public final static PipelineAggregatorStreams.Stream STREAM = new PipelineAggregatorStreams.Stream() { @Override - public MinBucketReducer readResult(StreamInput in) throws IOException { - MinBucketReducer result = new MinBucketReducer(); + public MinBucketPipelineAggregator readResult(StreamInput in) throws IOException { + MinBucketPipelineAggregator result = new MinBucketPipelineAggregator(); result.readFrom(in); return result; } }; public static void registerStreams() { - ReducerStreams.registerStream(STREAM, TYPE.stream()); + PipelineAggregatorStreams.registerStream(STREAM, TYPE.stream()); } private List minBucketKeys; private double minValue; - private MinBucketReducer() { + private MinBucketPipelineAggregator() { } - protected MinBucketReducer(String name, String[] bucketsPaths, GapPolicy gapPolicy, @Nullable ValueFormatter formatter, + protected MinBucketPipelineAggregator(String name, String[] bucketsPaths, GapPolicy gapPolicy, @Nullable ValueFormatter formatter, Map metaData) { super(name, bucketsPaths, gapPolicy, formatter, metaData); } @@ -88,12 +88,13 @@ public class MinBucketReducer extends BucketMetricsReducer { } } - protected InternalAggregation buildAggregation(java.util.List reducers, java.util.Map metadata) { + protected InternalAggregation buildAggregation(java.util.List pipelineAggregators, + java.util.Map metadata) { String[] keys = minBucketKeys.toArray(new String[minBucketKeys.size()]); return new InternalBucketMetricValue(name(), keys, minValue, formatter, Collections.EMPTY_LIST, metaData()); }; - public static class Factory extends ReducerFactory { + public static class Factory extends PipelineAggregatorFactory { private final ValueFormatter formatter; private final GapPolicy gapPolicy; @@ -105,15 +106,16 @@ public class MinBucketReducer extends BucketMetricsReducer { } @Override - protected Reducer createInternal(Map metaData) throws IOException { - return new MinBucketReducer(name, bucketsPaths, gapPolicy, formatter, metaData); + protected PipelineAggregator createInternal(Map metaData) throws IOException { + return new MinBucketPipelineAggregator(name, bucketsPaths, gapPolicy, formatter, metaData); } @Override - public void doValidate(AggregatorFactory parent, AggregatorFactory[] aggFactories, List reducerFactories) { + public void doValidate(AggregatorFactory parent, AggregatorFactory[] aggFactories, + List pipelineAggregatorFactories) { if (bucketsPaths.length != 1) { - throw new IllegalStateException(Reducer.Parser.BUCKETS_PATH.getPreferredName() - + " must contain a single entry for reducer [" + name + "]"); + throw new IllegalStateException(PipelineAggregator.Parser.BUCKETS_PATH.getPreferredName() + + " must contain a single entry for aggregation [" + name + "]"); } } diff --git a/src/main/java/org/elasticsearch/search/aggregations/reducers/bucketmetrics/sum/SumBucketBuilder.java b/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/sum/SumBucketBuilder.java similarity index 83% rename from src/main/java/org/elasticsearch/search/aggregations/reducers/bucketmetrics/sum/SumBucketBuilder.java rename to src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/sum/SumBucketBuilder.java index 6c3f18f6b99..5b2201c3f1e 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/reducers/bucketmetrics/sum/SumBucketBuilder.java +++ b/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/sum/SumBucketBuilder.java @@ -17,14 +17,14 @@ * under the License. */ -package org.elasticsearch.search.aggregations.reducers.bucketmetrics.sum; +package org.elasticsearch.search.aggregations.pipeline.bucketmetrics.sum; -import org.elasticsearch.search.aggregations.reducers.bucketmetrics.BucketMetricsBuilder; +import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsBuilder; public class SumBucketBuilder extends BucketMetricsBuilder { public SumBucketBuilder(String name) { - super(name, SumBucketReducer.TYPE.name()); + super(name, SumBucketPipelineAggregator.TYPE.name()); } } diff --git a/src/main/java/org/elasticsearch/search/aggregations/reducers/bucketmetrics/sum/SumBucketParser.java b/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/sum/SumBucketParser.java similarity index 64% rename from src/main/java/org/elasticsearch/search/aggregations/reducers/bucketmetrics/sum/SumBucketParser.java rename to src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/sum/SumBucketParser.java index 30e8093afd1..fd111857ddc 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/reducers/bucketmetrics/sum/SumBucketParser.java +++ b/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/sum/SumBucketParser.java @@ -17,22 +17,22 @@ * under the License. */ -package org.elasticsearch.search.aggregations.reducers.bucketmetrics.sum; +package org.elasticsearch.search.aggregations.pipeline.bucketmetrics.sum; import org.elasticsearch.common.Nullable; -import org.elasticsearch.search.aggregations.reducers.BucketHelpers.GapPolicy; -import org.elasticsearch.search.aggregations.reducers.bucketmetrics.BucketMetricsParser; -import org.elasticsearch.search.aggregations.reducers.ReducerFactory; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorFactory; +import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy; +import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsParser; import org.elasticsearch.search.aggregations.support.format.ValueFormatter; public class SumBucketParser extends BucketMetricsParser { @Override public String type() { - return SumBucketReducer.TYPE.name(); + return SumBucketPipelineAggregator.TYPE.name(); } @Override - protected ReducerFactory buildFactory(String reducerName, String[] bucketsPaths, GapPolicy gapPolicy, @Nullable ValueFormatter formatter) { - return new SumBucketReducer.Factory(reducerName, bucketsPaths, gapPolicy, formatter); + protected PipelineAggregatorFactory buildFactory(String pipelineAggregatorName, String[] bucketsPaths, GapPolicy gapPolicy, @Nullable ValueFormatter formatter) { + return new SumBucketPipelineAggregator.Factory(pipelineAggregatorName, bucketsPaths, gapPolicy, formatter); } } diff --git a/src/main/java/org/elasticsearch/search/aggregations/reducers/bucketmetrics/sum/SumBucketReducer.java b/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/sum/SumBucketPipelineAggregator.java similarity index 55% rename from src/main/java/org/elasticsearch/search/aggregations/reducers/bucketmetrics/sum/SumBucketReducer.java rename to src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/sum/SumBucketPipelineAggregator.java index 018a87ffa2d..9a5452d4258 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/reducers/bucketmetrics/sum/SumBucketReducer.java +++ b/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/sum/SumBucketPipelineAggregator.java @@ -17,48 +17,48 @@ * under the License. */ -package org.elasticsearch.search.aggregations.reducers.bucketmetrics.sum; +package org.elasticsearch.search.aggregations.pipeline.bucketmetrics.sum; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.search.aggregations.AggregatorFactory; import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.InternalAggregation.Type; -import org.elasticsearch.search.aggregations.reducers.BucketHelpers.GapPolicy; -import org.elasticsearch.search.aggregations.reducers.InternalSimpleValue; -import org.elasticsearch.search.aggregations.reducers.Reducer; -import org.elasticsearch.search.aggregations.reducers.ReducerFactory; -import org.elasticsearch.search.aggregations.reducers.ReducerStreams; -import org.elasticsearch.search.aggregations.reducers.bucketmetrics.BucketMetricsReducer; +import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy; +import org.elasticsearch.search.aggregations.pipeline.InternalSimpleValue; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorFactory; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorStreams; +import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsPipelineAggregator; import org.elasticsearch.search.aggregations.support.format.ValueFormatter; import java.io.IOException; import java.util.List; import java.util.Map; -public class SumBucketReducer extends BucketMetricsReducer { +public class SumBucketPipelineAggregator extends BucketMetricsPipelineAggregator { public final static Type TYPE = new Type("sum_bucket"); - public final static ReducerStreams.Stream STREAM = new ReducerStreams.Stream() { + public final static PipelineAggregatorStreams.Stream STREAM = new PipelineAggregatorStreams.Stream() { @Override - public SumBucketReducer readResult(StreamInput in) throws IOException { - SumBucketReducer result = new SumBucketReducer(); + public SumBucketPipelineAggregator readResult(StreamInput in) throws IOException { + SumBucketPipelineAggregator result = new SumBucketPipelineAggregator(); result.readFrom(in); return result; } }; public static void registerStreams() { - ReducerStreams.registerStream(STREAM, TYPE.stream()); + PipelineAggregatorStreams.registerStream(STREAM, TYPE.stream()); } private double sum = 0; - private SumBucketReducer() { + private SumBucketPipelineAggregator() { } - protected SumBucketReducer(String name, String[] bucketsPaths, GapPolicy gapPolicy, @Nullable ValueFormatter formatter, + protected SumBucketPipelineAggregator(String name, String[] bucketsPaths, GapPolicy gapPolicy, @Nullable ValueFormatter formatter, Map metaData) { super(name, bucketsPaths, gapPolicy, formatter, metaData); } @@ -79,11 +79,11 @@ public class SumBucketReducer extends BucketMetricsReducer { } @Override - protected InternalAggregation buildAggregation(List reducers, Map metadata) { - return new InternalSimpleValue(name(), sum, formatter, reducers, metadata); + protected InternalAggregation buildAggregation(List pipelineAggregators, Map metadata) { + return new InternalSimpleValue(name(), sum, formatter, pipelineAggregators, metadata); } - public static class Factory extends ReducerFactory { + public static class Factory extends PipelineAggregatorFactory { private final ValueFormatter formatter; private final GapPolicy gapPolicy; @@ -95,15 +95,16 @@ public class SumBucketReducer extends BucketMetricsReducer { } @Override - protected Reducer createInternal(Map metaData) throws IOException { - return new SumBucketReducer(name, bucketsPaths, gapPolicy, formatter, metaData); + protected PipelineAggregator createInternal(Map metaData) throws IOException { + return new SumBucketPipelineAggregator(name, bucketsPaths, gapPolicy, formatter, metaData); } @Override - public void doValidate(AggregatorFactory parent, AggregatorFactory[] aggFactories, List reducerFactories) { + public void doValidate(AggregatorFactory parent, AggregatorFactory[] aggFactories, + List pipelineAggregatorFactories) { if (bucketsPaths.length != 1) { - throw new IllegalStateException(Reducer.Parser.BUCKETS_PATH.getPreferredName() - + " must contain a single entry for reducer [" + name + "]"); + throw new IllegalStateException(PipelineAggregator.Parser.BUCKETS_PATH.getPreferredName() + + " must contain a single entry for aggregation [" + name + "]"); } } diff --git a/src/main/java/org/elasticsearch/search/aggregations/reducers/derivative/Derivative.java b/src/main/java/org/elasticsearch/search/aggregations/pipeline/derivative/Derivative.java similarity index 89% rename from src/main/java/org/elasticsearch/search/aggregations/reducers/derivative/Derivative.java rename to src/main/java/org/elasticsearch/search/aggregations/pipeline/derivative/Derivative.java index 432f5e1ca8b..56f12c0876b 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/reducers/derivative/Derivative.java +++ b/src/main/java/org/elasticsearch/search/aggregations/pipeline/derivative/Derivative.java @@ -17,9 +17,9 @@ * under the License. */ -package org.elasticsearch.search.aggregations.reducers.derivative; +package org.elasticsearch.search.aggregations.pipeline.derivative; -import org.elasticsearch.search.aggregations.reducers.SimpleValue; +import org.elasticsearch.search.aggregations.pipeline.SimpleValue; public interface Derivative extends SimpleValue { diff --git a/src/main/java/org/elasticsearch/search/aggregations/reducers/derivative/DerivativeBuilder.java b/src/main/java/org/elasticsearch/search/aggregations/pipeline/derivative/DerivativeBuilder.java similarity index 86% rename from src/main/java/org/elasticsearch/search/aggregations/reducers/derivative/DerivativeBuilder.java rename to src/main/java/org/elasticsearch/search/aggregations/pipeline/derivative/DerivativeBuilder.java index ac08264164b..ab077634222 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/reducers/derivative/DerivativeBuilder.java +++ b/src/main/java/org/elasticsearch/search/aggregations/pipeline/derivative/DerivativeBuilder.java @@ -17,23 +17,23 @@ * under the License. */ -package org.elasticsearch.search.aggregations.reducers.derivative; +package org.elasticsearch.search.aggregations.pipeline.derivative; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramInterval; -import org.elasticsearch.search.aggregations.reducers.BucketHelpers.GapPolicy; -import org.elasticsearch.search.aggregations.reducers.ReducerBuilder; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilder; +import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy; import java.io.IOException; -public class DerivativeBuilder extends ReducerBuilder { +public class DerivativeBuilder extends PipelineAggregatorBuilder { private String format; private GapPolicy gapPolicy; private String unit; public DerivativeBuilder(String name) { - super(name, DerivativeReducer.TYPE.name()); + super(name, DerivativePipelineAggregator.TYPE.name()); } public DerivativeBuilder format(String format) { diff --git a/src/main/java/org/elasticsearch/search/aggregations/reducers/derivative/DerivativeParser.java b/src/main/java/org/elasticsearch/search/aggregations/pipeline/derivative/DerivativeParser.java similarity index 82% rename from src/main/java/org/elasticsearch/search/aggregations/reducers/derivative/DerivativeParser.java rename to src/main/java/org/elasticsearch/search/aggregations/pipeline/derivative/DerivativeParser.java index 0ccd399427c..27da830c3b9 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/reducers/derivative/DerivativeParser.java +++ b/src/main/java/org/elasticsearch/search/aggregations/pipeline/derivative/DerivativeParser.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.search.aggregations.reducers.derivative; +package org.elasticsearch.search.aggregations.pipeline.derivative; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.rounding.DateTimeUnit; @@ -25,9 +25,9 @@ import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.search.SearchParseException; import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramParser; -import org.elasticsearch.search.aggregations.reducers.BucketHelpers.GapPolicy; -import org.elasticsearch.search.aggregations.reducers.Reducer; -import org.elasticsearch.search.aggregations.reducers.ReducerFactory; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorFactory; +import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy; import org.elasticsearch.search.aggregations.support.format.ValueFormat; import org.elasticsearch.search.aggregations.support.format.ValueFormatter; import org.elasticsearch.search.internal.SearchContext; @@ -36,7 +36,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; -public class DerivativeParser implements Reducer.Parser { +public class DerivativeParser implements PipelineAggregator.Parser { public static final ParseField FORMAT = new ParseField("format"); public static final ParseField GAP_POLICY = new ParseField("gap_policy"); @@ -44,11 +44,11 @@ public class DerivativeParser implements Reducer.Parser { @Override public String type() { - return DerivativeReducer.TYPE.name(); + return DerivativePipelineAggregator.TYPE.name(); } @Override - public ReducerFactory parse(String reducerName, XContentParser parser, SearchContext context) throws IOException { + public PipelineAggregatorFactory parse(String pipelineAggregatorName, XContentParser parser, SearchContext context) throws IOException { XContentParser.Token token; String currentFieldName = null; String[] bucketsPaths = null; @@ -69,7 +69,7 @@ public class DerivativeParser implements Reducer.Parser { } else if (UNIT.match(currentFieldName)) { units = parser.text(); } else { - throw new SearchParseException(context, "Unknown key for a " + token + " in [" + reducerName + "]: [" + throw new SearchParseException(context, "Unknown key for a " + token + " in [" + pipelineAggregatorName + "]: [" + currentFieldName + "].", parser.getTokenLocation()); } } else if (token == XContentParser.Token.START_ARRAY) { @@ -81,18 +81,18 @@ public class DerivativeParser implements Reducer.Parser { } bucketsPaths = paths.toArray(new String[paths.size()]); } else { - throw new SearchParseException(context, "Unknown key for a " + token + " in [" + reducerName + "]: [" + throw new SearchParseException(context, "Unknown key for a " + token + " in [" + pipelineAggregatorName + "]: [" + currentFieldName + "].", parser.getTokenLocation()); } } else { - throw new SearchParseException(context, "Unexpected token " + token + " in [" + reducerName + "].", + throw new SearchParseException(context, "Unexpected token " + token + " in [" + pipelineAggregatorName + "].", parser.getTokenLocation()); } } if (bucketsPaths == null) { throw new SearchParseException(context, "Missing required field [" + BUCKETS_PATH.getPreferredName() - + "] for derivative aggregation [" + reducerName + "]", parser.getTokenLocation()); + + "] for derivative aggregation [" + pipelineAggregatorName + "]", parser.getTokenLocation()); } ValueFormatter formatter = null; @@ -113,7 +113,7 @@ public class DerivativeParser implements Reducer.Parser { } } - return new DerivativeReducer.Factory(reducerName, bucketsPaths, formatter, gapPolicy, xAxisUnits); + return new DerivativePipelineAggregator.Factory(pipelineAggregatorName, bucketsPaths, formatter, gapPolicy, xAxisUnits); } } diff --git a/src/main/java/org/elasticsearch/search/aggregations/reducers/derivative/DerivativeReducer.java b/src/main/java/org/elasticsearch/search/aggregations/pipeline/derivative/DerivativePipelineAggregator.java similarity index 78% rename from src/main/java/org/elasticsearch/search/aggregations/reducers/derivative/DerivativeReducer.java rename to src/main/java/org/elasticsearch/search/aggregations/pipeline/derivative/DerivativePipelineAggregator.java index cb99200660e..c6d67d5cb46 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/reducers/derivative/DerivativeReducer.java +++ b/src/main/java/org/elasticsearch/search/aggregations/pipeline/derivative/DerivativePipelineAggregator.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.search.aggregations.reducers.derivative; +package org.elasticsearch.search.aggregations.pipeline.derivative; import com.google.common.collect.Lists; @@ -32,10 +32,10 @@ import org.elasticsearch.search.aggregations.InternalAggregation.Type; import org.elasticsearch.search.aggregations.InternalAggregations; import org.elasticsearch.search.aggregations.bucket.histogram.HistogramAggregator; import org.elasticsearch.search.aggregations.bucket.histogram.InternalHistogram; -import org.elasticsearch.search.aggregations.reducers.BucketHelpers.GapPolicy; -import org.elasticsearch.search.aggregations.reducers.Reducer; -import org.elasticsearch.search.aggregations.reducers.ReducerFactory; -import org.elasticsearch.search.aggregations.reducers.ReducerStreams; +import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorFactory; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorStreams; import org.elasticsearch.search.aggregations.support.format.ValueFormatter; import org.elasticsearch.search.aggregations.support.format.ValueFormatterStreams; import org.joda.time.DateTime; @@ -45,33 +45,33 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -import static org.elasticsearch.search.aggregations.reducers.BucketHelpers.resolveBucketValue; +import static org.elasticsearch.search.aggregations.pipeline.BucketHelpers.resolveBucketValue; -public class DerivativeReducer extends Reducer { +public class DerivativePipelineAggregator extends PipelineAggregator { public final static Type TYPE = new Type("derivative"); - public final static ReducerStreams.Stream STREAM = new ReducerStreams.Stream() { + public final static PipelineAggregatorStreams.Stream STREAM = new PipelineAggregatorStreams.Stream() { @Override - public DerivativeReducer readResult(StreamInput in) throws IOException { - DerivativeReducer result = new DerivativeReducer(); + public DerivativePipelineAggregator readResult(StreamInput in) throws IOException { + DerivativePipelineAggregator result = new DerivativePipelineAggregator(); result.readFrom(in); return result; } }; public static void registerStreams() { - ReducerStreams.registerStream(STREAM, TYPE.stream()); + PipelineAggregatorStreams.registerStream(STREAM, TYPE.stream()); } private ValueFormatter formatter; private GapPolicy gapPolicy; private Double xAxisUnits; - public DerivativeReducer() { + public DerivativePipelineAggregator() { } - public DerivativeReducer(String name, String[] bucketsPaths, @Nullable ValueFormatter formatter, GapPolicy gapPolicy, Long xAxisUnits, + public DerivativePipelineAggregator(String name, String[] bucketsPaths, @Nullable ValueFormatter formatter, GapPolicy gapPolicy, Long xAxisUnits, Map metadata) { super(name, bucketsPaths, metadata); this.formatter = formatter; @@ -104,7 +104,7 @@ public class DerivativeReducer extends Reducer { } List aggs = new ArrayList<>(Lists.transform(bucket.getAggregations().asList(), AGGREGATION_TRANFORM_FUNCTION)); - aggs.add(new InternalDerivative(name(), gradient, xDiff, formatter, new ArrayList(), metaData())); + aggs.add(new InternalDerivative(name(), gradient, xDiff, formatter, new ArrayList(), metaData())); InternalHistogram.Bucket newBucket = factory.createBucket(bucket.getKey(), bucket.getDocCount(), new InternalAggregations( aggs), bucket.getKeyed(), bucket.getFormatter()); newBuckets.add(newBucket); @@ -152,7 +152,7 @@ public class DerivativeReducer extends Reducer { } } - public static class Factory extends ReducerFactory { + public static class Factory extends PipelineAggregatorFactory { private final ValueFormatter formatter; private GapPolicy gapPolicy; @@ -166,23 +166,23 @@ public class DerivativeReducer extends Reducer { } @Override - protected Reducer createInternal(Map metaData) throws IOException { - return new DerivativeReducer(name, bucketsPaths, formatter, gapPolicy, xAxisUnits, metaData); + protected PipelineAggregator createInternal(Map metaData) throws IOException { + return new DerivativePipelineAggregator(name, bucketsPaths, formatter, gapPolicy, xAxisUnits, metaData); } @Override - public void doValidate(AggregatorFactory parent, AggregatorFactory[] aggFactories, List reducerFactories) { + public void doValidate(AggregatorFactory parent, AggregatorFactory[] aggFactories, List pipelineAggregatorFactories) { if (bucketsPaths.length != 1) { - throw new IllegalStateException(Reducer.Parser.BUCKETS_PATH.getPreferredName() - + " must contain a single entry for reducer [" + name + "]"); + throw new IllegalStateException(PipelineAggregator.Parser.BUCKETS_PATH.getPreferredName() + + " must contain a single entry for aggregation [" + name + "]"); } if (!(parent instanceof HistogramAggregator.Factory)) { - throw new IllegalStateException("derivative reducer [" + name + throw new IllegalStateException("derivative aggregation [" + name + "] must have a histogram or date_histogram as parent"); } else { HistogramAggregator.Factory histoParent = (HistogramAggregator.Factory) parent; if (histoParent.minDocCount() != 0) { - throw new IllegalStateException("parent histogram of derivative reducer [" + name + throw new IllegalStateException("parent histogram of derivative aggregation [" + name + "] must have min_doc_count of 0"); } } diff --git a/src/main/java/org/elasticsearch/search/aggregations/reducers/derivative/InternalDerivative.java b/src/main/java/org/elasticsearch/search/aggregations/pipeline/derivative/InternalDerivative.java similarity index 90% rename from src/main/java/org/elasticsearch/search/aggregations/reducers/derivative/InternalDerivative.java rename to src/main/java/org/elasticsearch/search/aggregations/pipeline/derivative/InternalDerivative.java index 5542064f5d3..b331fcb7ed9 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/reducers/derivative/InternalDerivative.java +++ b/src/main/java/org/elasticsearch/search/aggregations/pipeline/derivative/InternalDerivative.java @@ -17,14 +17,14 @@ * under the License. */ -package org.elasticsearch.search.aggregations.reducers.derivative; +package org.elasticsearch.search.aggregations.pipeline.derivative; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.search.aggregations.AggregationStreams; -import org.elasticsearch.search.aggregations.reducers.InternalSimpleValue; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.InternalSimpleValue; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.format.ValueFormatter; import java.io.IOException; @@ -53,9 +53,9 @@ public class InternalDerivative extends InternalSimpleValue implements Derivativ InternalDerivative() { } - public InternalDerivative(String name, double value, double normalizationFactor, ValueFormatter formatter, List reducers, + public InternalDerivative(String name, double value, double normalizationFactor, ValueFormatter formatter, List pipelineAggregators, Map metaData) { - super(name, value, formatter, reducers, metaData); + super(name, value, formatter, pipelineAggregators, metaData); this.normalizationFactor = normalizationFactor; } diff --git a/src/main/java/org/elasticsearch/search/aggregations/reducers/movavg/MovAvgBuilder.java b/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/MovAvgBuilder.java similarity index 88% rename from src/main/java/org/elasticsearch/search/aggregations/reducers/movavg/MovAvgBuilder.java rename to src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/MovAvgBuilder.java index 5fba23957e9..ca9ca2b23ad 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/reducers/movavg/MovAvgBuilder.java +++ b/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/MovAvgBuilder.java @@ -17,20 +17,19 @@ * under the License. */ -package org.elasticsearch.search.aggregations.reducers.movavg; +package org.elasticsearch.search.aggregations.pipeline.movavg; import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.search.aggregations.reducers.ReducerBuilder; -import org.elasticsearch.search.aggregations.reducers.movavg.models.MovAvgModelBuilder; +import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilder; +import org.elasticsearch.search.aggregations.pipeline.movavg.models.MovAvgModelBuilder; import java.io.IOException; -import static org.elasticsearch.search.aggregations.reducers.BucketHelpers.GapPolicy; - /** - * A builder to create MovingAvg reducer aggregations + * A builder to create MovingAvg pipeline aggregations */ -public class MovAvgBuilder extends ReducerBuilder { +public class MovAvgBuilder extends PipelineAggregatorBuilder { private String format; private GapPolicy gapPolicy; @@ -39,7 +38,7 @@ public class MovAvgBuilder extends ReducerBuilder { private Integer predict; public MovAvgBuilder(String name) { - super(name, MovAvgReducer.TYPE.name()); + super(name, MovAvgPipelineAggregator.TYPE.name()); } public MovAvgBuilder format(String format) { diff --git a/src/main/java/org/elasticsearch/search/aggregations/reducers/movavg/MovAvgParser.java b/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/MovAvgParser.java similarity index 77% rename from src/main/java/org/elasticsearch/search/aggregations/reducers/movavg/MovAvgParser.java rename to src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/MovAvgParser.java index 4ebf6e10d32..b4f54fd4957 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/reducers/movavg/MovAvgParser.java +++ b/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/MovAvgParser.java @@ -17,18 +17,18 @@ * under the License. */ -package org.elasticsearch.search.aggregations.reducers.movavg; +package org.elasticsearch.search.aggregations.pipeline.movavg; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.search.SearchParseException; -import org.elasticsearch.search.aggregations.reducers.BucketHelpers.GapPolicy; -import org.elasticsearch.search.aggregations.reducers.Reducer; -import org.elasticsearch.search.aggregations.reducers.ReducerFactory; -import org.elasticsearch.search.aggregations.reducers.movavg.models.MovAvgModel; -import org.elasticsearch.search.aggregations.reducers.movavg.models.MovAvgModelParser; -import org.elasticsearch.search.aggregations.reducers.movavg.models.MovAvgModelParserMapper; +import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorFactory; +import org.elasticsearch.search.aggregations.pipeline.movavg.models.MovAvgModel; +import org.elasticsearch.search.aggregations.pipeline.movavg.models.MovAvgModelParser; +import org.elasticsearch.search.aggregations.pipeline.movavg.models.MovAvgModelParserMapper; import org.elasticsearch.search.aggregations.support.format.ValueFormat; import org.elasticsearch.search.aggregations.support.format.ValueFormatter; import org.elasticsearch.search.internal.SearchContext; @@ -38,7 +38,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -public class MovAvgParser implements Reducer.Parser { +public class MovAvgParser implements PipelineAggregator.Parser { public static final ParseField MODEL = new ParseField("model"); public static final ParseField WINDOW = new ParseField("window"); @@ -54,11 +54,11 @@ public class MovAvgParser implements Reducer.Parser { @Override public String type() { - return MovAvgReducer.TYPE.name(); + return MovAvgPipelineAggregator.TYPE.name(); } @Override - public ReducerFactory parse(String reducerName, XContentParser parser, SearchContext context) throws IOException { + public PipelineAggregatorFactory parse(String pipelineAggregatorName, XContentParser parser, SearchContext context) throws IOException { XContentParser.Token token; String currentFieldName = null; String[] bucketsPaths = null; @@ -77,19 +77,19 @@ public class MovAvgParser implements Reducer.Parser { if (WINDOW.match(currentFieldName)) { window = parser.intValue(); if (window <= 0) { - throw new SearchParseException(context, "[" + currentFieldName + "] value must be a positive, " + - "non-zero integer. Value supplied was [" + predict + "] in [" + reducerName + "].", + throw new SearchParseException(context, "[" + currentFieldName + "] value must be a positive, " + + "non-zero integer. Value supplied was [" + predict + "] in [" + pipelineAggregatorName + "].", parser.getTokenLocation()); } } else if (PREDICT.match(currentFieldName)) { predict = parser.intValue(); if (predict <= 0) { - throw new SearchParseException(context, "[" + currentFieldName + "] value must be a positive, " + - "non-zero integer. Value supplied was [" + predict + "] in [" + reducerName + "].", + throw new SearchParseException(context, "[" + currentFieldName + "] value must be a positive, " + + "non-zero integer. Value supplied was [" + predict + "] in [" + pipelineAggregatorName + "].", parser.getTokenLocation()); } } else { - throw new SearchParseException(context, "Unknown key for a " + token + " in [" + reducerName + "]: [" + throw new SearchParseException(context, "Unknown key for a " + token + " in [" + pipelineAggregatorName + "]: [" + currentFieldName + "].", parser.getTokenLocation()); } } else if (token == XContentParser.Token.VALUE_STRING) { @@ -102,7 +102,7 @@ public class MovAvgParser implements Reducer.Parser { } else if (MODEL.match(currentFieldName)) { model = parser.text(); } else { - throw new SearchParseException(context, "Unknown key for a " + token + " in [" + reducerName + "]: [" + throw new SearchParseException(context, "Unknown key for a " + token + " in [" + pipelineAggregatorName + "]: [" + currentFieldName + "].", parser.getTokenLocation()); } } else if (token == XContentParser.Token.START_ARRAY) { @@ -114,25 +114,25 @@ public class MovAvgParser implements Reducer.Parser { } bucketsPaths = paths.toArray(new String[paths.size()]); } else { - throw new SearchParseException(context, "Unknown key for a " + token + " in [" + reducerName + "]: [" + throw new SearchParseException(context, "Unknown key for a " + token + " in [" + pipelineAggregatorName + "]: [" + currentFieldName + "].", parser.getTokenLocation()); } } else if (token == XContentParser.Token.START_OBJECT) { if (SETTINGS.match(currentFieldName)) { settings = parser.map(); } else { - throw new SearchParseException(context, "Unknown key for a " + token + " in [" + reducerName + "]: [" + throw new SearchParseException(context, "Unknown key for a " + token + " in [" + pipelineAggregatorName + "]: [" + currentFieldName + "].", parser.getTokenLocation()); } } else { - throw new SearchParseException(context, "Unexpected token " + token + " in [" + reducerName + "].", + throw new SearchParseException(context, "Unexpected token " + token + " in [" + pipelineAggregatorName + "].", parser.getTokenLocation()); } } if (bucketsPaths == null) { throw new SearchParseException(context, "Missing required field [" + BUCKETS_PATH.getPreferredName() - + "] for movingAvg aggregation [" + reducerName + "]", parser.getTokenLocation()); + + "] for movingAvg aggregation [" + pipelineAggregatorName + "]", parser.getTokenLocation()); } ValueFormatter formatter = null; @@ -147,8 +147,8 @@ public class MovAvgParser implements Reducer.Parser { } MovAvgModel movAvgModel = modelParser.parse(settings); - - return new MovAvgReducer.Factory(reducerName, bucketsPaths, formatter, gapPolicy, window, predict, movAvgModel); + return new MovAvgPipelineAggregator.Factory(pipelineAggregatorName, bucketsPaths, formatter, gapPolicy, window, predict, + movAvgModel); } diff --git a/src/main/java/org/elasticsearch/search/aggregations/reducers/movavg/MovAvgReducer.java b/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/MovAvgPipelineAggregator.java similarity index 79% rename from src/main/java/org/elasticsearch/search/aggregations/reducers/movavg/MovAvgReducer.java rename to src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/MovAvgPipelineAggregator.java index d9ff1b4173e..c6e3d943bb8 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/reducers/movavg/MovAvgReducer.java +++ b/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/MovAvgPipelineAggregator.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.search.aggregations.reducers.movavg; +package org.elasticsearch.search.aggregations.pipeline.movavg; import com.google.common.base.Function; import com.google.common.collect.EvictingQueue; @@ -35,13 +35,13 @@ import org.elasticsearch.search.aggregations.InternalAggregation.Type; import org.elasticsearch.search.aggregations.InternalAggregations; import org.elasticsearch.search.aggregations.bucket.histogram.HistogramAggregator; import org.elasticsearch.search.aggregations.bucket.histogram.InternalHistogram; -import org.elasticsearch.search.aggregations.reducers.BucketHelpers.GapPolicy; -import org.elasticsearch.search.aggregations.reducers.InternalSimpleValue; -import org.elasticsearch.search.aggregations.reducers.Reducer; -import org.elasticsearch.search.aggregations.reducers.ReducerFactory; -import org.elasticsearch.search.aggregations.reducers.ReducerStreams; -import org.elasticsearch.search.aggregations.reducers.movavg.models.MovAvgModel; -import org.elasticsearch.search.aggregations.reducers.movavg.models.MovAvgModelStreams; +import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy; +import org.elasticsearch.search.aggregations.pipeline.InternalSimpleValue; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorFactory; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorStreams; +import org.elasticsearch.search.aggregations.pipeline.movavg.models.MovAvgModel; +import org.elasticsearch.search.aggregations.pipeline.movavg.models.MovAvgModelStreams; import org.elasticsearch.search.aggregations.support.format.ValueFormatter; import org.elasticsearch.search.aggregations.support.format.ValueFormatterStreams; import org.joda.time.DateTime; @@ -51,23 +51,23 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -import static org.elasticsearch.search.aggregations.reducers.BucketHelpers.resolveBucketValue; +import static org.elasticsearch.search.aggregations.pipeline.BucketHelpers.resolveBucketValue; -public class MovAvgReducer extends Reducer { +public class MovAvgPipelineAggregator extends PipelineAggregator { public final static Type TYPE = new Type("moving_avg"); - public final static ReducerStreams.Stream STREAM = new ReducerStreams.Stream() { + public final static PipelineAggregatorStreams.Stream STREAM = new PipelineAggregatorStreams.Stream() { @Override - public MovAvgReducer readResult(StreamInput in) throws IOException { - MovAvgReducer result = new MovAvgReducer(); + public MovAvgPipelineAggregator readResult(StreamInput in) throws IOException { + MovAvgPipelineAggregator result = new MovAvgPipelineAggregator(); result.readFrom(in); return result; } }; public static void registerStreams() { - ReducerStreams.registerStream(STREAM, TYPE.stream()); + PipelineAggregatorStreams.registerStream(STREAM, TYPE.stream()); } private static final Function FUNCTION = new Function() { @@ -83,10 +83,10 @@ public class MovAvgReducer extends Reducer { private MovAvgModel model; private int predict; - public MovAvgReducer() { + public MovAvgPipelineAggregator() { } - public MovAvgReducer(String name, String[] bucketsPaths, @Nullable ValueFormatter formatter, GapPolicy gapPolicy, + public MovAvgPipelineAggregator(String name, String[] bucketsPaths, @Nullable ValueFormatter formatter, GapPolicy gapPolicy, int window, int predict, MovAvgModel model, Map metadata) { super(name, bucketsPaths, metadata); this.formatter = formatter; @@ -124,7 +124,7 @@ public class MovAvgReducer extends Reducer { double movavg = model.next(values); List aggs = new ArrayList<>(Lists.transform(bucket.getAggregations().asList(), FUNCTION)); - aggs.add(new InternalSimpleValue(name(), movavg, formatter, new ArrayList(), metaData())); + aggs.add(new InternalSimpleValue(name(), movavg, formatter, new ArrayList(), metaData())); InternalHistogram.Bucket newBucket = factory.createBucket(currentKey, bucket.getDocCount(), new InternalAggregations( aggs), bucket.getKeyed(), bucket.getFormatter()); newBuckets.add(newBucket); @@ -158,7 +158,7 @@ public class MovAvgReducer extends Reducer { double[] predictions = model.predict(values, predict); for (int i = 0; i < predictions.length; i++) { List aggs = new ArrayList<>(); - aggs.add(new InternalSimpleValue(name(), predictions[i], formatter, new ArrayList(), metaData())); + aggs.add(new InternalSimpleValue(name(), predictions[i], formatter, new ArrayList(), metaData())); InternalHistogram.Bucket newBucket = factory.createBucket(lastKey + (interval * (i + 1)), 0, new InternalAggregations( aggs), keyed, formatter); newBuckets.add(newBucket); @@ -188,7 +188,7 @@ public class MovAvgReducer extends Reducer { } - public static class Factory extends ReducerFactory { + public static class Factory extends PipelineAggregatorFactory { private final ValueFormatter formatter; private GapPolicy gapPolicy; @@ -207,23 +207,24 @@ public class MovAvgReducer extends Reducer { } @Override - protected Reducer createInternal(Map metaData) throws IOException { - return new MovAvgReducer(name, bucketsPaths, formatter, gapPolicy, window, predict, model, metaData); + protected PipelineAggregator createInternal(Map metaData) throws IOException { + return new MovAvgPipelineAggregator(name, bucketsPaths, formatter, gapPolicy, window, predict, model, metaData); } @Override - public void doValidate(AggregatorFactory parent, AggregatorFactory[] aggFactories, List reducerFactories) { + public void doValidate(AggregatorFactory parent, AggregatorFactory[] aggFactories, + List pipelineAggregatoractories) { if (bucketsPaths.length != 1) { - throw new IllegalStateException(Reducer.Parser.BUCKETS_PATH.getPreferredName() - + " must contain a single entry for reducer [" + name + "]"); + throw new IllegalStateException(PipelineAggregator.Parser.BUCKETS_PATH.getPreferredName() + + " must contain a single entry for aggregation [" + name + "]"); } if (!(parent instanceof HistogramAggregator.Factory)) { - throw new IllegalStateException("derivative reducer [" + name + throw new IllegalStateException("moving average aggregation [" + name + "] must have a histogram or date_histogram as parent"); } else { HistogramAggregator.Factory histoParent = (HistogramAggregator.Factory) parent; if (histoParent.minDocCount() != 0) { - throw new IllegalStateException("parent histogram of derivative reducer [" + name + throw new IllegalStateException("parent histogram of moving average aggregation [" + name + "] must have min_doc_count of 0"); } } diff --git a/src/main/java/org/elasticsearch/search/aggregations/reducers/movavg/models/EwmaModel.java b/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/EwmaModel.java similarity index 97% rename from src/main/java/org/elasticsearch/search/aggregations/reducers/movavg/models/EwmaModel.java rename to src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/EwmaModel.java index 8d563062813..b6ee7f8ddb6 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/reducers/movavg/models/EwmaModel.java +++ b/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/EwmaModel.java @@ -17,14 +17,14 @@ * under the License. */ -package org.elasticsearch.search.aggregations.reducers.movavg.models; +package org.elasticsearch.search.aggregations.pipeline.movavg.models; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.search.aggregations.reducers.movavg.MovAvgParser; +import org.elasticsearch.search.aggregations.pipeline.movavg.MovAvgParser; import java.io.IOException; import java.util.Collection; diff --git a/src/main/java/org/elasticsearch/search/aggregations/reducers/movavg/models/HoltLinearModel.java b/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/HoltLinearModel.java similarity index 98% rename from src/main/java/org/elasticsearch/search/aggregations/reducers/movavg/models/HoltLinearModel.java rename to src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/HoltLinearModel.java index e386de73052..a78a5486460 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/reducers/movavg/models/HoltLinearModel.java +++ b/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/HoltLinearModel.java @@ -17,14 +17,14 @@ * under the License. */ -package org.elasticsearch.search.aggregations.reducers.movavg.models; +package org.elasticsearch.search.aggregations.pipeline.movavg.models; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.search.aggregations.reducers.movavg.MovAvgParser; +import org.elasticsearch.search.aggregations.pipeline.movavg.MovAvgParser; import java.io.IOException; import java.util.*; diff --git a/src/main/java/org/elasticsearch/search/aggregations/reducers/movavg/models/LinearModel.java b/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/LinearModel.java similarity index 95% rename from src/main/java/org/elasticsearch/search/aggregations/reducers/movavg/models/LinearModel.java rename to src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/LinearModel.java index 6c269590d33..24780a345c7 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/reducers/movavg/models/LinearModel.java +++ b/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/LinearModel.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.search.aggregations.reducers.movavg.models; +package org.elasticsearch.search.aggregations.pipeline.movavg.models; import org.elasticsearch.common.Nullable; @@ -25,7 +25,7 @@ import org.elasticsearch.common.ParseField; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.search.aggregations.reducers.movavg.MovAvgParser; +import org.elasticsearch.search.aggregations.pipeline.movavg.MovAvgParser; import java.io.IOException; import java.util.Collection; diff --git a/src/main/java/org/elasticsearch/search/aggregations/reducers/movavg/models/MovAvgModel.java b/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/MovAvgModel.java similarity index 98% rename from src/main/java/org/elasticsearch/search/aggregations/reducers/movavg/models/MovAvgModel.java rename to src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/MovAvgModel.java index 8b8e80cff2f..1fa30811f9c 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/reducers/movavg/models/MovAvgModel.java +++ b/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/MovAvgModel.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.search.aggregations.reducers.movavg.models; +package org.elasticsearch.search.aggregations.pipeline.movavg.models; import com.google.common.collect.EvictingQueue; diff --git a/src/main/java/org/elasticsearch/search/aggregations/reducers/movavg/models/MovAvgModelBuilder.java b/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/MovAvgModelBuilder.java similarity index 81% rename from src/main/java/org/elasticsearch/search/aggregations/reducers/movavg/models/MovAvgModelBuilder.java rename to src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/MovAvgModelBuilder.java index a8f40d474ac..e491d121bcb 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/reducers/movavg/models/MovAvgModelBuilder.java +++ b/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/MovAvgModelBuilder.java @@ -17,16 +17,13 @@ * under the License. */ -package org.elasticsearch.search.aggregations.reducers.movavg.models; +package org.elasticsearch.search.aggregations.pipeline.movavg.models; import org.elasticsearch.common.xcontent.ToXContent; -import org.elasticsearch.common.xcontent.XContentBuilder; - -import java.io.IOException; /** - * Represents the common interface that all moving average models share. Moving - * average models are used by the MovAvg reducer + * Represents the common interface that all moving average models share. Moving + * average models are used by the MovAvg aggregation */ public interface MovAvgModelBuilder extends ToXContent { } diff --git a/src/main/java/org/elasticsearch/search/aggregations/reducers/movavg/models/MovAvgModelModule.java b/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/MovAvgModelModule.java similarity index 96% rename from src/main/java/org/elasticsearch/search/aggregations/reducers/movavg/models/MovAvgModelModule.java rename to src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/MovAvgModelModule.java index a144459ab5d..12a61d42d2a 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/reducers/movavg/models/MovAvgModelModule.java +++ b/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/MovAvgModelModule.java @@ -18,7 +18,7 @@ */ -package org.elasticsearch.search.aggregations.reducers.movavg.models; +package org.elasticsearch.search.aggregations.pipeline.movavg.models; import com.google.common.collect.Lists; import org.elasticsearch.common.inject.AbstractModule; diff --git a/src/main/java/org/elasticsearch/search/aggregations/reducers/movavg/models/MovAvgModelParser.java b/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/MovAvgModelParser.java similarity index 94% rename from src/main/java/org/elasticsearch/search/aggregations/reducers/movavg/models/MovAvgModelParser.java rename to src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/MovAvgModelParser.java index d27e447baa4..43721e37309 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/reducers/movavg/models/MovAvgModelParser.java +++ b/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/MovAvgModelParser.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.search.aggregations.reducers.movavg.models; +package org.elasticsearch.search.aggregations.pipeline.movavg.models; import org.elasticsearch.common.Nullable; diff --git a/src/main/java/org/elasticsearch/search/aggregations/reducers/movavg/models/MovAvgModelParserMapper.java b/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/MovAvgModelParserMapper.java similarity index 96% rename from src/main/java/org/elasticsearch/search/aggregations/reducers/movavg/models/MovAvgModelParserMapper.java rename to src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/MovAvgModelParserMapper.java index 459729d8960..2115f7e047b 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/reducers/movavg/models/MovAvgModelParserMapper.java +++ b/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/MovAvgModelParserMapper.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.search.aggregations.reducers.movavg.models; +package org.elasticsearch.search.aggregations.pipeline.movavg.models; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; diff --git a/src/main/java/org/elasticsearch/search/aggregations/reducers/movavg/models/MovAvgModelStreams.java b/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/MovAvgModelStreams.java similarity index 97% rename from src/main/java/org/elasticsearch/search/aggregations/reducers/movavg/models/MovAvgModelStreams.java rename to src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/MovAvgModelStreams.java index b11a3687021..0985612eacd 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/reducers/movavg/models/MovAvgModelStreams.java +++ b/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/MovAvgModelStreams.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.search.aggregations.reducers.movavg.models; +package org.elasticsearch.search.aggregations.pipeline.movavg.models; import com.google.common.collect.ImmutableMap; import org.elasticsearch.common.collect.MapBuilder; diff --git a/src/main/java/org/elasticsearch/search/aggregations/reducers/movavg/models/SimpleModel.java b/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/SimpleModel.java similarity index 95% rename from src/main/java/org/elasticsearch/search/aggregations/reducers/movavg/models/SimpleModel.java rename to src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/SimpleModel.java index 243b022af2c..68ffc3dd9aa 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/reducers/movavg/models/SimpleModel.java +++ b/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/SimpleModel.java @@ -17,14 +17,14 @@ * under the License. */ -package org.elasticsearch.search.aggregations.reducers.movavg.models; +package org.elasticsearch.search.aggregations.pipeline.movavg.models; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.search.aggregations.reducers.movavg.MovAvgParser; +import org.elasticsearch.search.aggregations.pipeline.movavg.MovAvgParser; import java.io.IOException; import java.util.Collection; diff --git a/src/main/java/org/elasticsearch/search/aggregations/reducers/movavg/models/TransportMovAvgModelModule.java b/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/TransportMovAvgModelModule.java similarity index 96% rename from src/main/java/org/elasticsearch/search/aggregations/reducers/movavg/models/TransportMovAvgModelModule.java rename to src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/TransportMovAvgModelModule.java index a09c8265654..41f90b94d84 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/reducers/movavg/models/TransportMovAvgModelModule.java +++ b/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/models/TransportMovAvgModelModule.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.search.aggregations.reducers.movavg.models; +package org.elasticsearch.search.aggregations.pipeline.movavg.models; import com.google.common.collect.Lists; import org.elasticsearch.common.inject.AbstractModule; diff --git a/src/main/java/org/elasticsearch/search/aggregations/support/ValuesSourceAggregatorFactory.java b/src/main/java/org/elasticsearch/search/aggregations/support/ValuesSourceAggregatorFactory.java index d083ae306cc..d0eaec2d8bc 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/support/ValuesSourceAggregatorFactory.java +++ b/src/main/java/org/elasticsearch/search/aggregations/support/ValuesSourceAggregatorFactory.java @@ -23,7 +23,7 @@ import org.elasticsearch.search.aggregations.AggregationInitializationException; import org.elasticsearch.search.aggregations.Aggregator; import org.elasticsearch.search.aggregations.AggregatorFactories; import org.elasticsearch.search.aggregations.AggregatorFactory; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.aggregations.support.format.ValueFormat; import java.io.IOException; @@ -56,12 +56,12 @@ public abstract class ValuesSourceAggregatorFactory ext @Override public Aggregator createInternal(AggregationContext context, Aggregator parent, boolean collectsFromSingleBucket, - List reducers, Map metaData) throws IOException { + List pipelineAggregators, Map metaData) throws IOException { VS vs = context.valuesSource(config, context.searchContext()); if (vs == null) { - return createUnmapped(context, parent, reducers, metaData); + return createUnmapped(context, parent, pipelineAggregators, metaData); } - return doCreateInternal(vs, context, parent, collectsFromSingleBucket, reducers, metaData); + return doCreateInternal(vs, context, parent, collectsFromSingleBucket, pipelineAggregators, metaData); } @Override @@ -71,11 +71,12 @@ public abstract class ValuesSourceAggregatorFactory ext } } - protected abstract Aggregator createUnmapped(AggregationContext aggregationContext, Aggregator parent, List reducers, - Map metaData) throws IOException; + protected abstract Aggregator createUnmapped(AggregationContext aggregationContext, Aggregator parent, + List pipelineAggregators, Map metaData) throws IOException; protected abstract Aggregator doCreateInternal(VS valuesSource, AggregationContext aggregationContext, Aggregator parent, - boolean collectsFromSingleBucket, List reducers, Map metaData) throws IOException; + boolean collectsFromSingleBucket, List pipelineAggregators, Map metaData) + throws IOException; private void resolveValuesSourceConfigFromAncestors(String aggName, AggregatorFactory parent, Class requiredValuesSourceType) { ValuesSourceConfig config; diff --git a/src/main/java/org/elasticsearch/search/controller/SearchPhaseController.java b/src/main/java/org/elasticsearch/search/controller/SearchPhaseController.java index 63eaf8189c0..7faaea72ef5 100644 --- a/src/main/java/org/elasticsearch/search/controller/SearchPhaseController.java +++ b/src/main/java/org/elasticsearch/search/controller/SearchPhaseController.java @@ -44,8 +44,8 @@ import org.elasticsearch.script.ScriptService; import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.InternalAggregation.ReduceContext; import org.elasticsearch.search.aggregations.InternalAggregations; -import org.elasticsearch.search.aggregations.reducers.Reducer; -import org.elasticsearch.search.aggregations.reducers.SiblingReducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; +import org.elasticsearch.search.aggregations.pipeline.SiblingPipelineAggregator; import org.elasticsearch.search.dfs.AggregatedDfs; import org.elasticsearch.search.dfs.DfsSearchResult; import org.elasticsearch.search.fetch.FetchSearchResult; @@ -409,11 +409,11 @@ public class SearchPhaseController extends AbstractComponent { } if (aggregations != null) { - List reducers = firstResult.reducers(); - if (reducers != null) { - List newAggs = new ArrayList<>(Lists.transform(aggregations.asList(), Reducer.AGGREGATION_TRANFORM_FUNCTION)); - for (SiblingReducer reducer : reducers) { - InternalAggregation newAgg = reducer.doReduce(new InternalAggregations(newAggs), new ReduceContext(bigArrays, + List pipelineAggregators = firstResult.pipelineAggregators(); + if (pipelineAggregators != null) { + List newAggs = new ArrayList<>(Lists.transform(aggregations.asList(), PipelineAggregator.AGGREGATION_TRANFORM_FUNCTION)); + for (SiblingPipelineAggregator pipelineAggregator : pipelineAggregators) { + InternalAggregation newAgg = pipelineAggregator.doReduce(new InternalAggregations(newAggs), new ReduceContext(bigArrays, scriptService)); newAggs.add(newAgg); } diff --git a/src/main/java/org/elasticsearch/search/query/QuerySearchResult.java b/src/main/java/org/elasticsearch/search/query/QuerySearchResult.java index e45006b2c32..7f8d12a9c90 100644 --- a/src/main/java/org/elasticsearch/search/query/QuerySearchResult.java +++ b/src/main/java/org/elasticsearch/search/query/QuerySearchResult.java @@ -26,9 +26,9 @@ import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.search.SearchShardTarget; import org.elasticsearch.search.aggregations.Aggregations; import org.elasticsearch.search.aggregations.InternalAggregations; -import org.elasticsearch.search.aggregations.reducers.Reducer; -import org.elasticsearch.search.aggregations.reducers.ReducerStreams; -import org.elasticsearch.search.aggregations.reducers.SiblingReducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorStreams; +import org.elasticsearch.search.aggregations.pipeline.SiblingPipelineAggregator; import org.elasticsearch.search.suggest.Suggest; import java.io.IOException; @@ -49,7 +49,7 @@ public class QuerySearchResult extends QuerySearchResultProvider { private int size; private TopDocs topDocs; private InternalAggregations aggregations; - private List reducers; + private List pipelineAggregators; private Suggest suggest; private boolean searchTimedOut; private Boolean terminatedEarly = null; @@ -120,12 +120,12 @@ public class QuerySearchResult extends QuerySearchResultProvider { this.aggregations = aggregations; } - public List reducers() { - return reducers; + public List pipelineAggregators() { + return pipelineAggregators; } - public void reducers(List reducers) { - this.reducers = reducers; + public void pipelineAggregators(List pipelineAggregators) { + this.pipelineAggregators = pipelineAggregators; } public Suggest suggest() { @@ -178,13 +178,13 @@ public class QuerySearchResult extends QuerySearchResultProvider { } if (in.readBoolean()) { int size = in.readVInt(); - List reducers = new ArrayList<>(size); + List pipelineAggregators = new ArrayList<>(size); for (int i = 0; i < size; i++) { BytesReference type = in.readBytesReference(); - Reducer reducer = ReducerStreams.stream(type).readResult(in); - reducers.add((SiblingReducer) reducer); + PipelineAggregator pipelineAggregator = PipelineAggregatorStreams.stream(type).readResult(in); + pipelineAggregators.add((SiblingPipelineAggregator) pipelineAggregator); } - this.reducers = reducers; + this.pipelineAggregators = pipelineAggregators; } if (in.readBoolean()) { suggest = Suggest.readSuggest(Suggest.Fields.SUGGEST, in); @@ -211,14 +211,14 @@ public class QuerySearchResult extends QuerySearchResultProvider { out.writeBoolean(true); aggregations.writeTo(out); } - if (reducers == null) { + if (pipelineAggregators == null) { out.writeBoolean(false); } else { out.writeBoolean(true); - out.writeVInt(reducers.size()); - for (Reducer reducer : reducers) { - out.writeBytesReference(reducer.type().stream()); - reducer.writeTo(out); + out.writeVInt(pipelineAggregators.size()); + for (PipelineAggregator pipelineAggregator : pipelineAggregators) { + out.writeBytesReference(pipelineAggregator.type().stream()); + pipelineAggregator.writeTo(out); } } if (suggest == null) { diff --git a/src/test/java/org/elasticsearch/percolator/PercolatorFacetsAndAggregationsTests.java b/src/test/java/org/elasticsearch/percolator/PercolatorFacetsAndAggregationsTests.java index 4540cc75a06..7dbbf6cbf4b 100644 --- a/src/test/java/org/elasticsearch/percolator/PercolatorFacetsAndAggregationsTests.java +++ b/src/test/java/org/elasticsearch/percolator/PercolatorFacetsAndAggregationsTests.java @@ -28,8 +28,8 @@ import org.elasticsearch.search.aggregations.Aggregations; import org.elasticsearch.search.aggregations.Aggregator.SubAggCollectionMode; import org.elasticsearch.search.aggregations.bucket.terms.Terms; import org.elasticsearch.search.aggregations.bucket.terms.Terms.Order; -import org.elasticsearch.search.aggregations.reducers.ReducerBuilders; -import org.elasticsearch.search.aggregations.reducers.bucketmetrics.InternalBucketMetricValue; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilders; +import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.InternalBucketMetricValue; import org.elasticsearch.test.ElasticsearchIntegrationTest; import org.junit.Test; @@ -117,7 +117,7 @@ public class PercolatorFacetsAndAggregationsTests extends ElasticsearchIntegrati @Test // Just test the integration with facets and aggregations, not the facet and aggregation functionality! - public void testAggregationsAndReducers() throws Exception { + public void testAggregationsAndPipelineAggregations() throws Exception { assertAcked(prepareCreate("test").addMapping("type", "field1", "type=string", "field2", "type=string")); ensureGreen(); @@ -162,7 +162,7 @@ public class PercolatorFacetsAndAggregationsTests extends ElasticsearchIntegrati percolateRequestBuilder.setOnlyCount(countOnly); } - percolateRequestBuilder.addAggregation(ReducerBuilders.maxBucket("max_a").setBucketsPaths("a>_count")); + percolateRequestBuilder.addAggregation(PipelineAggregatorBuilders.maxBucket("max_a").setBucketsPaths("a>_count")); PercolateResponse response = percolateRequestBuilder.execute().actionGet(); assertMatchCount(response, expectedCount[i % numUniqueQueries]); @@ -241,7 +241,7 @@ public class PercolatorFacetsAndAggregationsTests extends ElasticsearchIntegrati percolateRequestBuilder.setOnlyCount(countOnly); } - percolateRequestBuilder.addAggregation(ReducerBuilders.maxBucket("max_terms").setBucketsPaths("terms>_count")); + percolateRequestBuilder.addAggregation(PipelineAggregatorBuilders.maxBucket("max_terms").setBucketsPaths("terms>_count")); PercolateResponse response = percolateRequestBuilder.execute().actionGet(); assertMatchCount(response, numQueries); diff --git a/src/test/java/org/elasticsearch/search/aggregations/bucket/significant/SignificanceHeuristicTests.java b/src/test/java/org/elasticsearch/search/aggregations/bucket/significant/SignificanceHeuristicTests.java index eeff6304dd3..83705bf7d73 100644 --- a/src/test/java/org/elasticsearch/search/aggregations/bucket/significant/SignificanceHeuristicTests.java +++ b/src/test/java/org/elasticsearch/search/aggregations/bucket/significant/SignificanceHeuristicTests.java @@ -40,7 +40,7 @@ import org.elasticsearch.search.aggregations.bucket.significant.heuristics.Signi import org.elasticsearch.search.aggregations.bucket.significant.heuristics.SignificanceHeuristicParser; import org.elasticsearch.search.aggregations.bucket.significant.heuristics.SignificanceHeuristicParserMapper; import org.elasticsearch.search.aggregations.bucket.significant.heuristics.SignificanceHeuristicStreams; -import org.elasticsearch.search.aggregations.reducers.Reducer; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import org.elasticsearch.search.internal.SearchContext; import org.elasticsearch.test.ElasticsearchTestCase; import org.elasticsearch.test.TestSearchContext; @@ -114,13 +114,13 @@ public class SignificanceHeuristicTests extends ElasticsearchTestCase { BytesRef term = new BytesRef("123.0"); buckets.add(new SignificantLongTerms.Bucket(1, 2, 3, 4, 123, InternalAggregations.EMPTY, null)); sTerms[0] = new SignificantLongTerms(10, 20, "some_name", null, 1, 1, heuristic, buckets, - (List) Collections.EMPTY_LIST, null); + (List) Collections.EMPTY_LIST, null); sTerms[1] = new SignificantLongTerms(); } else { BytesRef term = new BytesRef("someterm"); buckets.add(new SignificantStringTerms.Bucket(term, 1, 2, 3, 4, InternalAggregations.EMPTY)); - sTerms[0] = new SignificantStringTerms(10, 20, "some_name", 1, 1, heuristic, buckets, (List) Collections.EMPTY_LIST, + sTerms[0] = new SignificantStringTerms(10, 20, "some_name", 1, 1, heuristic, buckets, (List) Collections.EMPTY_LIST, null); sTerms[1] = new SignificantStringTerms(); } diff --git a/src/test/java/org/elasticsearch/search/aggregations/reducers/AvgBucketTests.java b/src/test/java/org/elasticsearch/search/aggregations/pipeline/AvgBucketTests.java similarity index 98% rename from src/test/java/org/elasticsearch/search/aggregations/reducers/AvgBucketTests.java rename to src/test/java/org/elasticsearch/search/aggregations/pipeline/AvgBucketTests.java index 2e5e8258561..abf8629ae20 100644 --- a/src/test/java/org/elasticsearch/search/aggregations/reducers/AvgBucketTests.java +++ b/src/test/java/org/elasticsearch/search/aggregations/pipeline/AvgBucketTests.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.search.aggregations.reducers; +package org.elasticsearch.search.aggregations.pipeline; import org.elasticsearch.action.index.IndexRequestBuilder; import org.elasticsearch.action.search.SearchResponse; @@ -26,18 +26,20 @@ import org.elasticsearch.search.aggregations.bucket.histogram.Histogram.Bucket; import org.elasticsearch.search.aggregations.bucket.terms.Terms; import org.elasticsearch.search.aggregations.bucket.terms.Terms.Order; import org.elasticsearch.search.aggregations.metrics.sum.Sum; -import org.elasticsearch.search.aggregations.reducers.BucketHelpers.GapPolicy; +import org.elasticsearch.search.aggregations.pipeline.InternalSimpleValue; +import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy; import org.elasticsearch.test.ElasticsearchIntegrationTest; import org.junit.Test; import java.util.ArrayList; import java.util.List; +import static org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilders.avgBucket; + import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.search.aggregations.AggregationBuilders.histogram; import static org.elasticsearch.search.aggregations.AggregationBuilders.sum; import static org.elasticsearch.search.aggregations.AggregationBuilders.terms; -import static org.elasticsearch.search.aggregations.reducers.ReducerBuilders.avgBucket; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse; import static org.hamcrest.Matchers.equalTo; diff --git a/src/test/java/org/elasticsearch/search/aggregations/reducers/DateDerivativeTests.java b/src/test/java/org/elasticsearch/search/aggregations/pipeline/DateDerivativeTests.java similarity index 98% rename from src/test/java/org/elasticsearch/search/aggregations/reducers/DateDerivativeTests.java rename to src/test/java/org/elasticsearch/search/aggregations/pipeline/DateDerivativeTests.java index 1125918171b..1bba222387d 100644 --- a/src/test/java/org/elasticsearch/search/aggregations/reducers/DateDerivativeTests.java +++ b/src/test/java/org/elasticsearch/search/aggregations/pipeline/DateDerivativeTests.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.search.aggregations.reducers; +package org.elasticsearch.search.aggregations.pipeline; import org.elasticsearch.action.index.IndexRequestBuilder; import org.elasticsearch.action.search.SearchResponse; @@ -27,7 +27,8 @@ import org.elasticsearch.search.aggregations.bucket.histogram.Histogram; import org.elasticsearch.search.aggregations.bucket.histogram.Histogram.Bucket; import org.elasticsearch.search.aggregations.bucket.histogram.InternalHistogram; import org.elasticsearch.search.aggregations.metrics.sum.Sum; -import org.elasticsearch.search.aggregations.reducers.derivative.Derivative; +import org.elasticsearch.search.aggregations.pipeline.SimpleValue; +import org.elasticsearch.search.aggregations.pipeline.derivative.Derivative; import org.elasticsearch.search.aggregations.support.AggregationPath; import org.elasticsearch.test.ElasticsearchIntegrationTest; import org.joda.time.DateTime; @@ -41,10 +42,10 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import static org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilders.derivative; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.search.aggregations.AggregationBuilders.dateHistogram; import static org.elasticsearch.search.aggregations.AggregationBuilders.sum; -import static org.elasticsearch.search.aggregations.reducers.ReducerBuilders.derivative; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse; import static org.hamcrest.Matchers.closeTo; import static org.hamcrest.Matchers.equalTo; diff --git a/src/test/java/org/elasticsearch/search/aggregations/reducers/DerivativeTests.java b/src/test/java/org/elasticsearch/search/aggregations/pipeline/DerivativeTests.java similarity index 98% rename from src/test/java/org/elasticsearch/search/aggregations/reducers/DerivativeTests.java rename to src/test/java/org/elasticsearch/search/aggregations/pipeline/DerivativeTests.java index 8ad0605d210..78a763ac13e 100644 --- a/src/test/java/org/elasticsearch/search/aggregations/reducers/DerivativeTests.java +++ b/src/test/java/org/elasticsearch/search/aggregations/pipeline/DerivativeTests.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.search.aggregations.reducers; +package org.elasticsearch.search.aggregations.pipeline; import org.elasticsearch.action.index.IndexRequestBuilder; import org.elasticsearch.action.search.SearchResponse; @@ -27,8 +27,9 @@ import org.elasticsearch.search.aggregations.bucket.histogram.InternalHistogram; import org.elasticsearch.search.aggregations.bucket.histogram.InternalHistogram.Bucket; import org.elasticsearch.search.aggregations.metrics.stats.Stats; import org.elasticsearch.search.aggregations.metrics.sum.Sum; -import org.elasticsearch.search.aggregations.reducers.BucketHelpers.GapPolicy; -import org.elasticsearch.search.aggregations.reducers.derivative.Derivative; +import org.elasticsearch.search.aggregations.pipeline.SimpleValue; +import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy; +import org.elasticsearch.search.aggregations.pipeline.derivative.Derivative; import org.elasticsearch.search.aggregations.support.AggregationPath; import org.elasticsearch.test.ElasticsearchIntegrationTest; import org.hamcrest.Matchers; @@ -38,12 +39,12 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; +import static org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilders.derivative; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; import static org.elasticsearch.search.aggregations.AggregationBuilders.histogram; import static org.elasticsearch.search.aggregations.AggregationBuilders.stats; import static org.elasticsearch.search.aggregations.AggregationBuilders.sum; -import static org.elasticsearch.search.aggregations.reducers.ReducerBuilders.derivative; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse; import static org.hamcrest.Matchers.closeTo; diff --git a/src/test/java/org/elasticsearch/search/aggregations/reducers/MaxBucketTests.java b/src/test/java/org/elasticsearch/search/aggregations/pipeline/MaxBucketTests.java similarity index 98% rename from src/test/java/org/elasticsearch/search/aggregations/reducers/MaxBucketTests.java rename to src/test/java/org/elasticsearch/search/aggregations/pipeline/MaxBucketTests.java index 4b91c92fccf..177f3bca51f 100644 --- a/src/test/java/org/elasticsearch/search/aggregations/reducers/MaxBucketTests.java +++ b/src/test/java/org/elasticsearch/search/aggregations/pipeline/MaxBucketTests.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.search.aggregations.reducers; +package org.elasticsearch.search.aggregations.pipeline; import org.elasticsearch.action.index.IndexRequestBuilder; import org.elasticsearch.action.search.SearchResponse; @@ -26,19 +26,19 @@ import org.elasticsearch.search.aggregations.bucket.histogram.Histogram.Bucket; import org.elasticsearch.search.aggregations.bucket.terms.Terms; import org.elasticsearch.search.aggregations.bucket.terms.Terms.Order; import org.elasticsearch.search.aggregations.metrics.sum.Sum; -import org.elasticsearch.search.aggregations.reducers.BucketHelpers.GapPolicy; -import org.elasticsearch.search.aggregations.reducers.bucketmetrics.InternalBucketMetricValue; +import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy; +import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.InternalBucketMetricValue; import org.elasticsearch.test.ElasticsearchIntegrationTest; import org.junit.Test; import java.util.ArrayList; import java.util.List; +import static org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilders.maxBucket; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.search.aggregations.AggregationBuilders.histogram; import static org.elasticsearch.search.aggregations.AggregationBuilders.sum; import static org.elasticsearch.search.aggregations.AggregationBuilders.terms; -import static org.elasticsearch.search.aggregations.reducers.ReducerBuilders.maxBucket; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse; import static org.hamcrest.Matchers.equalTo; diff --git a/src/test/java/org/elasticsearch/search/aggregations/reducers/MinBucketTests.java b/src/test/java/org/elasticsearch/search/aggregations/pipeline/MinBucketTests.java similarity index 98% rename from src/test/java/org/elasticsearch/search/aggregations/reducers/MinBucketTests.java rename to src/test/java/org/elasticsearch/search/aggregations/pipeline/MinBucketTests.java index c34ba920da9..e08138fce47 100644 --- a/src/test/java/org/elasticsearch/search/aggregations/reducers/MinBucketTests.java +++ b/src/test/java/org/elasticsearch/search/aggregations/pipeline/MinBucketTests.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.search.aggregations.reducers; +package org.elasticsearch.search.aggregations.pipeline; import org.elasticsearch.action.index.IndexRequestBuilder; import org.elasticsearch.action.search.SearchResponse; @@ -26,19 +26,19 @@ import org.elasticsearch.search.aggregations.bucket.histogram.Histogram.Bucket; import org.elasticsearch.search.aggregations.bucket.terms.Terms; import org.elasticsearch.search.aggregations.bucket.terms.Terms.Order; import org.elasticsearch.search.aggregations.metrics.sum.Sum; -import org.elasticsearch.search.aggregations.reducers.BucketHelpers.GapPolicy; -import org.elasticsearch.search.aggregations.reducers.bucketmetrics.InternalBucketMetricValue; +import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy; +import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.InternalBucketMetricValue; import org.elasticsearch.test.ElasticsearchIntegrationTest; import org.junit.Test; import java.util.ArrayList; import java.util.List; +import static org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilders.minBucket; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.search.aggregations.AggregationBuilders.histogram; import static org.elasticsearch.search.aggregations.AggregationBuilders.sum; import static org.elasticsearch.search.aggregations.AggregationBuilders.terms; -import static org.elasticsearch.search.aggregations.reducers.ReducerBuilders.minBucket; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse; import static org.hamcrest.Matchers.equalTo; diff --git a/src/test/java/org/elasticsearch/search/aggregations/reducers/ReducerHelperTests.java b/src/test/java/org/elasticsearch/search/aggregations/pipeline/PipelineAggregationHelperTests.java similarity index 94% rename from src/test/java/org/elasticsearch/search/aggregations/reducers/ReducerHelperTests.java rename to src/test/java/org/elasticsearch/search/aggregations/pipeline/PipelineAggregationHelperTests.java index 5e1acdef317..0873ce46651 100644 --- a/src/test/java/org/elasticsearch/search/aggregations/reducers/ReducerHelperTests.java +++ b/src/test/java/org/elasticsearch/search/aggregations/pipeline/PipelineAggregationHelperTests.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.search.aggregations.reducers; +package org.elasticsearch.search.aggregations.pipeline; import org.elasticsearch.search.aggregations.metrics.ValuesSourceMetricsAggregationBuilder; @@ -30,10 +30,10 @@ import org.elasticsearch.test.ElasticsearchTestCase; import java.util.ArrayList; /** - * Provides helper methods and classes for use in Reducer tests, such as creating mock histograms or computing - * simple metrics + * Provides helper methods and classes for use in PipelineAggregation tests, + * such as creating mock histograms or computing simple metrics */ -public class ReducerHelperTests extends ElasticsearchTestCase { +public class PipelineAggregationHelperTests extends ElasticsearchTestCase { /** * Generates a mock histogram to use for testing. Each MockBucket holds a doc count, key and document values diff --git a/src/test/java/org/elasticsearch/search/aggregations/reducers/SumBucketTests.java b/src/test/java/org/elasticsearch/search/aggregations/pipeline/SumBucketTests.java similarity index 98% rename from src/test/java/org/elasticsearch/search/aggregations/reducers/SumBucketTests.java rename to src/test/java/org/elasticsearch/search/aggregations/pipeline/SumBucketTests.java index a4cc26bed79..550625be32e 100644 --- a/src/test/java/org/elasticsearch/search/aggregations/reducers/SumBucketTests.java +++ b/src/test/java/org/elasticsearch/search/aggregations/pipeline/SumBucketTests.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.search.aggregations.reducers; +package org.elasticsearch.search.aggregations.pipeline; import org.elasticsearch.action.index.IndexRequestBuilder; import org.elasticsearch.action.search.SearchResponse; @@ -26,18 +26,20 @@ import org.elasticsearch.search.aggregations.bucket.histogram.Histogram.Bucket; import org.elasticsearch.search.aggregations.bucket.terms.Terms; import org.elasticsearch.search.aggregations.bucket.terms.Terms.Order; import org.elasticsearch.search.aggregations.metrics.sum.Sum; -import org.elasticsearch.search.aggregations.reducers.BucketHelpers.GapPolicy; +import org.elasticsearch.search.aggregations.pipeline.InternalSimpleValue; +import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy; import org.elasticsearch.test.ElasticsearchIntegrationTest; import org.junit.Test; import java.util.ArrayList; import java.util.List; +import static org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilders.sumBucket; + import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.search.aggregations.AggregationBuilders.histogram; import static org.elasticsearch.search.aggregations.AggregationBuilders.sum; import static org.elasticsearch.search.aggregations.AggregationBuilders.terms; -import static org.elasticsearch.search.aggregations.reducers.ReducerBuilders.sumBucket; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse; import static org.hamcrest.Matchers.equalTo; diff --git a/src/test/java/org/elasticsearch/search/aggregations/reducers/moving/avg/MovAvgTests.java b/src/test/java/org/elasticsearch/search/aggregations/pipeline/moving/avg/MovAvgTests.java similarity index 95% rename from src/test/java/org/elasticsearch/search/aggregations/reducers/moving/avg/MovAvgTests.java rename to src/test/java/org/elasticsearch/search/aggregations/pipeline/moving/avg/MovAvgTests.java index 3a330b3b9dd..38da141ad5c 100644 --- a/src/test/java/org/elasticsearch/search/aggregations/reducers/moving/avg/MovAvgTests.java +++ b/src/test/java/org/elasticsearch/search/aggregations/pipeline/moving/avg/MovAvgTests.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.search.aggregations.reducers.moving.avg; +package org.elasticsearch.search.aggregations.pipeline.moving.avg; import com.google.common.collect.EvictingQueue; @@ -32,14 +32,14 @@ import org.elasticsearch.search.aggregations.bucket.histogram.Histogram; import org.elasticsearch.search.aggregations.bucket.histogram.InternalHistogram; import org.elasticsearch.search.aggregations.bucket.histogram.InternalHistogram.Bucket; import org.elasticsearch.search.aggregations.metrics.ValuesSourceMetricsAggregationBuilder; -import org.elasticsearch.search.aggregations.reducers.BucketHelpers; -import org.elasticsearch.search.aggregations.reducers.ReducerHelperTests; -import org.elasticsearch.search.aggregations.reducers.SimpleValue; -import org.elasticsearch.search.aggregations.reducers.movavg.models.HoltLinearModel; -import org.elasticsearch.search.aggregations.reducers.movavg.models.LinearModel; -import org.elasticsearch.search.aggregations.reducers.movavg.models.MovAvgModelBuilder; -import org.elasticsearch.search.aggregations.reducers.movavg.models.SimpleModel; -import org.elasticsearch.search.aggregations.reducers.movavg.models.EwmaModel; +import org.elasticsearch.search.aggregations.pipeline.BucketHelpers; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregationHelperTests; +import org.elasticsearch.search.aggregations.pipeline.SimpleValue; +import org.elasticsearch.search.aggregations.pipeline.movavg.models.EwmaModel; +import org.elasticsearch.search.aggregations.pipeline.movavg.models.HoltLinearModel; +import org.elasticsearch.search.aggregations.pipeline.movavg.models.LinearModel; +import org.elasticsearch.search.aggregations.pipeline.movavg.models.MovAvgModelBuilder; +import org.elasticsearch.search.aggregations.pipeline.movavg.models.SimpleModel; import org.elasticsearch.test.ElasticsearchIntegrationTest; import org.hamcrest.Matchers; import org.junit.Test; @@ -51,6 +51,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map; +import static org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilders.movingAvg; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.search.aggregations.AggregationBuilders.avg; import static org.elasticsearch.search.aggregations.AggregationBuilders.filter; @@ -58,7 +59,6 @@ import static org.elasticsearch.search.aggregations.AggregationBuilders.histogra import static org.elasticsearch.search.aggregations.AggregationBuilders.max; import static org.elasticsearch.search.aggregations.AggregationBuilders.min; import static org.elasticsearch.search.aggregations.AggregationBuilders.range; -import static org.elasticsearch.search.aggregations.reducers.ReducerBuilders.movingAvg; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse; import static org.hamcrest.Matchers.*; import static org.hamcrest.core.IsNull.notNullValue; @@ -78,7 +78,7 @@ public class MovAvgTests extends ElasticsearchIntegrationTest { static double beta; static BucketHelpers.GapPolicy gapPolicy; static ValuesSourceMetricsAggregationBuilder metric; - static List mockHisto; + static List mockHisto; static Map> testValues; @@ -127,7 +127,7 @@ public class MovAvgTests extends ElasticsearchIntegrationTest { gapPolicy = randomBoolean() ? BucketHelpers.GapPolicy.SKIP : BucketHelpers.GapPolicy.INSERT_ZEROS; metric = randomMetric("the_metric", VALUE_FIELD); - mockHisto = ReducerHelperTests.generateHistogram(interval, numBuckets, randomDouble(), randomDouble()); + mockHisto = PipelineAggregationHelperTests.generateHistogram(interval, numBuckets, randomDouble(), randomDouble()); testValues = new HashMap<>(8); @@ -137,7 +137,7 @@ public class MovAvgTests extends ElasticsearchIntegrationTest { } } - for (ReducerHelperTests.MockBucket mockBucket : mockHisto) { + for (PipelineAggregationHelperTests.MockBucket mockBucket : mockHisto) { for (double value : mockBucket.docValues) { builders.add(client().prepareIndex("idx", "type").setSource(jsonBuilder().startObject() .field(INTERVAL_FIELD, mockBucket.key) @@ -169,7 +169,7 @@ public class MovAvgTests extends ElasticsearchIntegrationTest { ArrayList values = new ArrayList<>(numBuckets); EvictingQueue window = EvictingQueue.create(windowSize); - for (ReducerHelperTests.MockBucket mockBucket : mockHisto) { + for (PipelineAggregationHelperTests.MockBucket mockBucket : mockHisto) { double metricValue; double[] docValues = mockBucket.docValues; @@ -183,12 +183,12 @@ public class MovAvgTests extends ElasticsearchIntegrationTest { // otherwise insert a zero instead of the true value metricValue = 0.0; } else { - metricValue = ReducerHelperTests.calculateMetric(docValues, metric); + metricValue = PipelineAggregationHelperTests.calculateMetric(docValues, metric); } } else { // If this isn't a gap, or is a _count, just insert the value - metricValue = target.equals(MetricTarget.VALUE) ? ReducerHelperTests.calculateMetric(docValues, metric) : mockBucket.count; + metricValue = target.equals(MetricTarget.VALUE) ? PipelineAggregationHelperTests.calculateMetric(docValues, metric) : mockBucket.count; } window.offer(metricValue); @@ -339,7 +339,7 @@ public class MovAvgTests extends ElasticsearchIntegrationTest { List expectedValues = testValues.get(MovAvgType.SIMPLE.toString() + "_" + MetricTarget.VALUE.toString()); Iterator actualIter = buckets.iterator(); - Iterator expectedBucketIter = mockHisto.iterator(); + Iterator expectedBucketIter = mockHisto.iterator(); Iterator expectedCountsIter = expectedCounts.iterator(); Iterator expectedValuesIter = expectedValues.iterator(); @@ -347,7 +347,7 @@ public class MovAvgTests extends ElasticsearchIntegrationTest { assertValidIterators(expectedBucketIter, expectedCountsIter, expectedValuesIter); Histogram.Bucket actual = actualIter.next(); - ReducerHelperTests.MockBucket expected = expectedBucketIter.next(); + PipelineAggregationHelperTests.MockBucket expected = expectedBucketIter.next(); Double expectedCount = expectedCountsIter.next(); Double expectedValue = expectedValuesIter.next(); @@ -391,7 +391,7 @@ public class MovAvgTests extends ElasticsearchIntegrationTest { List expectedValues = testValues.get(MovAvgType.LINEAR.toString() + "_" + MetricTarget.VALUE.toString()); Iterator actualIter = buckets.iterator(); - Iterator expectedBucketIter = mockHisto.iterator(); + Iterator expectedBucketIter = mockHisto.iterator(); Iterator expectedCountsIter = expectedCounts.iterator(); Iterator expectedValuesIter = expectedValues.iterator(); @@ -399,7 +399,7 @@ public class MovAvgTests extends ElasticsearchIntegrationTest { assertValidIterators(expectedBucketIter, expectedCountsIter, expectedValuesIter); Histogram.Bucket actual = actualIter.next(); - ReducerHelperTests.MockBucket expected = expectedBucketIter.next(); + PipelineAggregationHelperTests.MockBucket expected = expectedBucketIter.next(); Double expectedCount = expectedCountsIter.next(); Double expectedValue = expectedValuesIter.next(); @@ -443,7 +443,7 @@ public class MovAvgTests extends ElasticsearchIntegrationTest { List expectedValues = testValues.get(MovAvgType.EWMA.toString() + "_" + MetricTarget.VALUE.toString()); Iterator actualIter = buckets.iterator(); - Iterator expectedBucketIter = mockHisto.iterator(); + Iterator expectedBucketIter = mockHisto.iterator(); Iterator expectedCountsIter = expectedCounts.iterator(); Iterator expectedValuesIter = expectedValues.iterator(); @@ -451,7 +451,7 @@ public class MovAvgTests extends ElasticsearchIntegrationTest { assertValidIterators(expectedBucketIter, expectedCountsIter, expectedValuesIter); Histogram.Bucket actual = actualIter.next(); - ReducerHelperTests.MockBucket expected = expectedBucketIter.next(); + PipelineAggregationHelperTests.MockBucket expected = expectedBucketIter.next(); Double expectedCount = expectedCountsIter.next(); Double expectedValue = expectedValuesIter.next(); @@ -495,7 +495,7 @@ public class MovAvgTests extends ElasticsearchIntegrationTest { List expectedValues = testValues.get(MovAvgType.HOLT.toString() + "_" + MetricTarget.VALUE.toString()); Iterator actualIter = buckets.iterator(); - Iterator expectedBucketIter = mockHisto.iterator(); + Iterator expectedBucketIter = mockHisto.iterator(); Iterator expectedCountsIter = expectedCounts.iterator(); Iterator expectedValuesIter = expectedValues.iterator(); @@ -503,7 +503,7 @@ public class MovAvgTests extends ElasticsearchIntegrationTest { assertValidIterators(expectedBucketIter, expectedCountsIter, expectedValuesIter); Histogram.Bucket actual = actualIter.next(); - ReducerHelperTests.MockBucket expected = expectedBucketIter.next(); + PipelineAggregationHelperTests.MockBucket expected = expectedBucketIter.next(); Double expectedCount = expectedCountsIter.next(); Double expectedValue = expectedValuesIter.next(); diff --git a/src/test/java/org/elasticsearch/search/aggregations/reducers/moving/avg/MovAvgUnitTests.java b/src/test/java/org/elasticsearch/search/aggregations/pipeline/moving/avg/MovAvgUnitTests.java similarity index 98% rename from src/test/java/org/elasticsearch/search/aggregations/reducers/moving/avg/MovAvgUnitTests.java rename to src/test/java/org/elasticsearch/search/aggregations/pipeline/moving/avg/MovAvgUnitTests.java index 2a3f862c321..a25f84d1902 100644 --- a/src/test/java/org/elasticsearch/search/aggregations/reducers/moving/avg/MovAvgUnitTests.java +++ b/src/test/java/org/elasticsearch/search/aggregations/pipeline/moving/avg/MovAvgUnitTests.java @@ -17,12 +17,15 @@ * under the License. */ -package org.elasticsearch.search.aggregations.reducers.moving.avg; +package org.elasticsearch.search.aggregations.pipeline.moving.avg; import com.google.common.collect.EvictingQueue; -import org.elasticsearch.search.aggregations.reducers.movavg.models.*; + +import org.elasticsearch.search.aggregations.pipeline.movavg.models.*; import org.elasticsearch.test.ElasticsearchTestCase; + import static org.hamcrest.Matchers.equalTo; + import org.junit.Test; public class MovAvgUnitTests extends ElasticsearchTestCase {