diff options
author | Adrien Grand <jpountz@gmail.com> | 2016-12-13 09:09:40 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-13 09:09:40 +0100 |
commit | 049fd3991cb22384c24e7d4bafed7b05bd3c9d8e (patch) | |
tree | 8ad77fe0aeca776882d65d662c18b52d48c7419e /modules/aggs-matrix-stats/src/main/java/org/elasticsearch/search | |
parent | a4e8b5d952aa58665b7a09e548ecad1c0f00e8df (diff) |
Remove `AggregationContext`. (#22124)
This class is just a wrapper around `SearchContext`, so let's use
`SearchContext` directly. The change is mechanical, except the
`ValuesSourceConfig` class, where I moved the logic to get a `ValuesSource`
given a config.
Diffstat (limited to 'modules/aggs-matrix-stats/src/main/java/org/elasticsearch/search')
5 files changed, 17 insertions, 15 deletions
diff --git a/modules/aggs-matrix-stats/src/main/java/org/elasticsearch/search/aggregations/matrix/stats/MatrixStatsAggregationBuilder.java b/modules/aggs-matrix-stats/src/main/java/org/elasticsearch/search/aggregations/matrix/stats/MatrixStatsAggregationBuilder.java index 867bcdbdfa..95374069b1 100644 --- a/modules/aggs-matrix-stats/src/main/java/org/elasticsearch/search/aggregations/matrix/stats/MatrixStatsAggregationBuilder.java +++ b/modules/aggs-matrix-stats/src/main/java/org/elasticsearch/search/aggregations/matrix/stats/MatrixStatsAggregationBuilder.java @@ -26,13 +26,13 @@ import org.elasticsearch.search.MultiValueMode; import org.elasticsearch.search.aggregations.AggregatorFactories; import org.elasticsearch.search.aggregations.AggregatorFactory; import org.elasticsearch.search.aggregations.InternalAggregation.Type; -import org.elasticsearch.search.aggregations.support.AggregationContext; import org.elasticsearch.search.aggregations.support.MultiValuesSourceAggregationBuilder; import org.elasticsearch.search.aggregations.support.ValueType; import org.elasticsearch.search.aggregations.support.ValuesSource; import org.elasticsearch.search.aggregations.support.ValuesSource.Numeric; import org.elasticsearch.search.aggregations.support.ValuesSourceConfig; import org.elasticsearch.search.aggregations.support.ValuesSourceType; +import org.elasticsearch.search.internal.SearchContext; import java.io.IOException; import java.util.Map; @@ -70,7 +70,7 @@ public class MatrixStatsAggregationBuilder } @Override - protected MatrixStatsAggregatorFactory innerBuild(AggregationContext context, Map<String, ValuesSourceConfig<Numeric>> configs, + protected MatrixStatsAggregatorFactory innerBuild(SearchContext context, Map<String, ValuesSourceConfig<Numeric>> configs, AggregatorFactory<?> parent, AggregatorFactories.Builder subFactoriesBuilder) throws IOException { return new MatrixStatsAggregatorFactory(name, type, configs, multiValueMode, context, parent, subFactoriesBuilder, metaData); } diff --git a/modules/aggs-matrix-stats/src/main/java/org/elasticsearch/search/aggregations/matrix/stats/MatrixStatsAggregator.java b/modules/aggs-matrix-stats/src/main/java/org/elasticsearch/search/aggregations/matrix/stats/MatrixStatsAggregator.java index 75f0c37d89..4665e74daa 100644 --- a/modules/aggs-matrix-stats/src/main/java/org/elasticsearch/search/aggregations/matrix/stats/MatrixStatsAggregator.java +++ b/modules/aggs-matrix-stats/src/main/java/org/elasticsearch/search/aggregations/matrix/stats/MatrixStatsAggregator.java @@ -30,9 +30,9 @@ import org.elasticsearch.search.aggregations.LeafBucketCollector; import org.elasticsearch.search.aggregations.LeafBucketCollectorBase; import org.elasticsearch.search.aggregations.metrics.MetricsAggregator; import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; -import org.elasticsearch.search.aggregations.support.AggregationContext; import org.elasticsearch.search.aggregations.support.MultiValuesSource.NumericMultiValuesSource; import org.elasticsearch.search.aggregations.support.ValuesSource; +import org.elasticsearch.search.internal.SearchContext; import java.io.IOException; import java.util.List; @@ -48,7 +48,7 @@ public class MatrixStatsAggregator extends MetricsAggregator { /** array of descriptive stats, per shard, needed to compute the correlation */ ObjectArray<RunningStats> stats; - public MatrixStatsAggregator(String name, Map<String, ValuesSource.Numeric> valuesSources, AggregationContext context, + public MatrixStatsAggregator(String name, Map<String, ValuesSource.Numeric> valuesSources, SearchContext context, Aggregator parent, MultiValueMode multiValueMode, List<PipelineAggregator> pipelineAggregators, Map<String,Object> metaData) throws IOException { super(name, context, parent, pipelineAggregators, metaData); diff --git a/modules/aggs-matrix-stats/src/main/java/org/elasticsearch/search/aggregations/matrix/stats/MatrixStatsAggregatorFactory.java b/modules/aggs-matrix-stats/src/main/java/org/elasticsearch/search/aggregations/matrix/stats/MatrixStatsAggregatorFactory.java index 2ad2341795..94b0b37dc3 100644 --- a/modules/aggs-matrix-stats/src/main/java/org/elasticsearch/search/aggregations/matrix/stats/MatrixStatsAggregatorFactory.java +++ b/modules/aggs-matrix-stats/src/main/java/org/elasticsearch/search/aggregations/matrix/stats/MatrixStatsAggregatorFactory.java @@ -24,10 +24,10 @@ import org.elasticsearch.search.aggregations.AggregatorFactories; import org.elasticsearch.search.aggregations.AggregatorFactory; import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; -import org.elasticsearch.search.aggregations.support.AggregationContext; import org.elasticsearch.search.aggregations.support.MultiValuesSourceAggregatorFactory; import org.elasticsearch.search.aggregations.support.ValuesSource; import org.elasticsearch.search.aggregations.support.ValuesSourceConfig; +import org.elasticsearch.search.internal.SearchContext; import java.io.IOException; import java.util.List; @@ -40,7 +40,7 @@ public class MatrixStatsAggregatorFactory public MatrixStatsAggregatorFactory(String name, InternalAggregation.Type type, Map<String, ValuesSourceConfig<ValuesSource.Numeric>> configs, MultiValueMode multiValueMode, - AggregationContext context, AggregatorFactory<?> parent, AggregatorFactories.Builder subFactoriesBuilder, + SearchContext context, AggregatorFactory<?> parent, AggregatorFactories.Builder subFactoriesBuilder, Map<String, Object> metaData) throws IOException { super(name, type, configs, context, parent, subFactoriesBuilder, metaData); this.multiValueMode = multiValueMode; diff --git a/modules/aggs-matrix-stats/src/main/java/org/elasticsearch/search/aggregations/support/MultiValuesSourceAggregationBuilder.java b/modules/aggs-matrix-stats/src/main/java/org/elasticsearch/search/aggregations/support/MultiValuesSourceAggregationBuilder.java index 8524f7d79b..fde3d24792 100644 --- a/modules/aggs-matrix-stats/src/main/java/org/elasticsearch/search/aggregations/support/MultiValuesSourceAggregationBuilder.java +++ b/modules/aggs-matrix-stats/src/main/java/org/elasticsearch/search/aggregations/support/MultiValuesSourceAggregationBuilder.java @@ -35,6 +35,7 @@ import org.elasticsearch.search.aggregations.AggregatorFactories; import org.elasticsearch.search.aggregations.AggregatorFactories.Builder; import org.elasticsearch.search.aggregations.AggregatorFactory; import org.elasticsearch.search.aggregations.InternalAggregation.Type; +import org.elasticsearch.search.internal.SearchContext; import java.io.IOException; import java.util.ArrayList; @@ -219,14 +220,14 @@ public abstract class MultiValuesSourceAggregationBuilder<VS extends ValuesSourc } @Override - protected final MultiValuesSourceAggregatorFactory<VS, ?> doBuild(AggregationContext context, AggregatorFactory<?> parent, + protected final MultiValuesSourceAggregatorFactory<VS, ?> doBuild(SearchContext context, AggregatorFactory<?> parent, AggregatorFactories.Builder subFactoriesBuilder) throws IOException { Map<String, ValuesSourceConfig<VS>> configs = resolveConfig(context); MultiValuesSourceAggregatorFactory<VS, ?> factory = innerBuild(context, configs, parent, subFactoriesBuilder); return factory; } - protected Map<String, ValuesSourceConfig<VS>> resolveConfig(AggregationContext context) { + protected Map<String, ValuesSourceConfig<VS>> resolveConfig(SearchContext context) { HashMap<String, ValuesSourceConfig<VS>> configs = new HashMap<>(); for (String field : fields) { ValuesSourceConfig<VS> config = config(context, field, null); @@ -235,11 +236,11 @@ public abstract class MultiValuesSourceAggregationBuilder<VS extends ValuesSourc return configs; } - protected abstract MultiValuesSourceAggregatorFactory<VS, ?> innerBuild(AggregationContext context, + protected abstract MultiValuesSourceAggregatorFactory<VS, ?> innerBuild(SearchContext context, Map<String, ValuesSourceConfig<VS>> configs, AggregatorFactory<?> parent, AggregatorFactories.Builder subFactoriesBuilder) throws IOException; - public ValuesSourceConfig<VS> config(AggregationContext context, String field, Script script) { + public ValuesSourceConfig<VS> config(SearchContext context, String field, Script script) { ValueType valueType = this.valueType != null ? this.valueType : targetValueType; @@ -262,7 +263,7 @@ public abstract class MultiValuesSourceAggregationBuilder<VS extends ValuesSourc return config.format(resolveFormat(format, valueType)); } - MappedFieldType fieldType = context.searchContext().smartNameFieldType(field); + MappedFieldType fieldType = context.smartNameFieldType(field); if (fieldType == null) { ValuesSourceType valuesSourceType = valueType != null ? valueType.getValuesSourceType() : this.valuesSourceType; ValuesSourceConfig<VS> config = new ValuesSourceConfig<>(valuesSourceType); @@ -271,7 +272,7 @@ public abstract class MultiValuesSourceAggregationBuilder<VS extends ValuesSourc return config.unmapped(true); } - IndexFieldData<?> indexFieldData = context.searchContext().fieldData().getForField(fieldType); + IndexFieldData<?> indexFieldData = context.fieldData().getForField(fieldType); ValuesSourceConfig<VS> config; if (valuesSourceType == ValuesSourceType.ANY) { diff --git a/modules/aggs-matrix-stats/src/main/java/org/elasticsearch/search/aggregations/support/MultiValuesSourceAggregatorFactory.java b/modules/aggs-matrix-stats/src/main/java/org/elasticsearch/search/aggregations/support/MultiValuesSourceAggregatorFactory.java index 956f953da1..dd469e2131 100644 --- a/modules/aggs-matrix-stats/src/main/java/org/elasticsearch/search/aggregations/support/MultiValuesSourceAggregatorFactory.java +++ b/modules/aggs-matrix-stats/src/main/java/org/elasticsearch/search/aggregations/support/MultiValuesSourceAggregatorFactory.java @@ -24,6 +24,7 @@ import org.elasticsearch.search.aggregations.AggregatorFactories; import org.elasticsearch.search.aggregations.AggregatorFactory; import org.elasticsearch.search.aggregations.InternalAggregation.Type; import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; +import org.elasticsearch.search.internal.SearchContext; import java.io.IOException; import java.util.HashMap; @@ -36,8 +37,8 @@ public abstract class MultiValuesSourceAggregatorFactory<VS extends ValuesSource protected Map<String, ValuesSourceConfig<VS>> configs; public MultiValuesSourceAggregatorFactory(String name, Type type, Map<String, ValuesSourceConfig<VS>> configs, - AggregationContext context, AggregatorFactory<?> parent, AggregatorFactories.Builder subFactoriesBuilder, - Map<String, Object> metaData) throws IOException { + SearchContext context, AggregatorFactory<?> parent, AggregatorFactories.Builder subFactoriesBuilder, + Map<String, Object> metaData) throws IOException { super(name, type, context, parent, subFactoriesBuilder, metaData); this.configs = configs; } @@ -48,7 +49,7 @@ public abstract class MultiValuesSourceAggregatorFactory<VS extends ValuesSource HashMap<String, VS> valuesSources = new HashMap<>(); for (Map.Entry<String, ValuesSourceConfig<VS>> config : configs.entrySet()) { - VS vs = context.valuesSource(config.getValue(), context.searchContext()); + VS vs = config.getValue().toValuesSource(context); if (vs != null) { valuesSources.put(config.getKey(), vs); } |