From 8b1b152e919f1a67313b4fff82b506c6eef63423 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20B=C3=BCscher?= Date: Thu, 23 Feb 2017 18:03:40 +0100 Subject: [PATCH] Remove abstract InternalMetricsAggregation class (#23326) This class doesn't seem to do much other than to group together certain types of aggregations. --- .../metrics/InternalMetricsAggregation.java | 42 ------------------- .../InternalNumericMetricsAggregation.java | 5 ++- .../metrics/geobounds/InternalGeoBounds.java | 3 +- .../geocentroid/InternalGeoCentroid.java | 3 +- .../scripted/InternalScriptedMetric.java | 3 +- .../metrics/tophits/InternalTopHits.java | 7 ++-- .../matrix/stats/InternalMatrixStats.java | 3 +- 7 files changed, 10 insertions(+), 56 deletions(-) delete mode 100644 core/src/main/java/org/elasticsearch/search/aggregations/metrics/InternalMetricsAggregation.java diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/metrics/InternalMetricsAggregation.java b/core/src/main/java/org/elasticsearch/search/aggregations/metrics/InternalMetricsAggregation.java deleted file mode 100644 index ded69d9f75b..00000000000 --- a/core/src/main/java/org/elasticsearch/search/aggregations/metrics/InternalMetricsAggregation.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.search.aggregations.metrics; - -import org.elasticsearch.common.io.stream.StreamInput; -import org.elasticsearch.search.aggregations.InternalAggregation; -import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; - -import java.io.IOException; -import java.util.List; -import java.util.Map; - -public abstract class InternalMetricsAggregation extends InternalAggregation { - protected InternalMetricsAggregation(String name, List pipelineAggregators, Map metaData) { - super(name, pipelineAggregators, metaData); - } - - /** - * Read from a stream. - */ - protected InternalMetricsAggregation(StreamInput in) throws IOException { - super(in); - } - -} diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/metrics/InternalNumericMetricsAggregation.java b/core/src/main/java/org/elasticsearch/search/aggregations/metrics/InternalNumericMetricsAggregation.java index 010e24346bf..dba16397fc0 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/metrics/InternalNumericMetricsAggregation.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/metrics/InternalNumericMetricsAggregation.java @@ -20,6 +20,7 @@ package org.elasticsearch.search.aggregations.metrics; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.search.DocValueFormat; +import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import java.io.IOException; @@ -27,7 +28,7 @@ import java.util.List; import java.util.Map; import java.util.Objects; -public abstract class InternalNumericMetricsAggregation extends InternalMetricsAggregation { +public abstract class InternalNumericMetricsAggregation extends InternalAggregation { private static final DocValueFormat DEFAULT_FORMAT = DocValueFormat.RAW; @@ -118,7 +119,7 @@ public abstract class InternalNumericMetricsAggregation extends InternalMetricsA return false; } InternalNumericMetricsAggregation other = (InternalNumericMetricsAggregation) obj; - return super.equals(obj) && + return super.equals(obj) && Objects.equals(format, other.format); } } diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/metrics/geobounds/InternalGeoBounds.java b/core/src/main/java/org/elasticsearch/search/aggregations/metrics/geobounds/InternalGeoBounds.java index bdb9acd91ab..2a3d03e43e6 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/metrics/geobounds/InternalGeoBounds.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/metrics/geobounds/InternalGeoBounds.java @@ -24,7 +24,6 @@ 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.InternalAggregation; -import org.elasticsearch.search.aggregations.metrics.InternalMetricsAggregation; import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import java.io.IOException; @@ -32,7 +31,7 @@ import java.util.List; import java.util.Map; import java.util.Objects; -public class InternalGeoBounds extends InternalMetricsAggregation implements GeoBounds { +public class InternalGeoBounds extends InternalAggregation implements GeoBounds { final double top; final double bottom; final double posLeft; diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/metrics/geocentroid/InternalGeoCentroid.java b/core/src/main/java/org/elasticsearch/search/aggregations/metrics/geocentroid/InternalGeoCentroid.java index 06d9d369029..a5a8058ed28 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/metrics/geocentroid/InternalGeoCentroid.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/metrics/geocentroid/InternalGeoCentroid.java @@ -25,7 +25,6 @@ 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.InternalAggregation; -import org.elasticsearch.search.aggregations.metrics.InternalMetricsAggregation; import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import java.io.IOException; @@ -35,7 +34,7 @@ import java.util.Map; /** * Serialization and merge logic for {@link GeoCentroidAggregator}. */ -public class InternalGeoCentroid extends InternalMetricsAggregation implements GeoCentroid { +public class InternalGeoCentroid extends InternalAggregation implements GeoCentroid { protected final GeoPoint centroid; protected final long count; diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/metrics/scripted/InternalScriptedMetric.java b/core/src/main/java/org/elasticsearch/search/aggregations/metrics/scripted/InternalScriptedMetric.java index 174ff8ca28d..bb8e1ac48d3 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/metrics/scripted/InternalScriptedMetric.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/metrics/scripted/InternalScriptedMetric.java @@ -27,7 +27,6 @@ import org.elasticsearch.script.ExecutableScript; import org.elasticsearch.script.Script; import org.elasticsearch.script.ScriptContext; import org.elasticsearch.search.aggregations.InternalAggregation; -import org.elasticsearch.search.aggregations.metrics.InternalMetricsAggregation; import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import java.io.IOException; @@ -37,7 +36,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -public class InternalScriptedMetric extends InternalMetricsAggregation implements ScriptedMetric { +public class InternalScriptedMetric extends InternalAggregation implements ScriptedMetric { private final Script reduceScript; private final List aggregation; diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/metrics/tophits/InternalTopHits.java b/core/src/main/java/org/elasticsearch/search/aggregations/metrics/tophits/InternalTopHits.java index de37e1a62d1..1b32e6e9dee 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/metrics/tophits/InternalTopHits.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/metrics/tophits/InternalTopHits.java @@ -27,11 +27,10 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.lucene.Lucene; import org.elasticsearch.common.xcontent.XContentBuilder; +import org.elasticsearch.search.SearchHit; import org.elasticsearch.search.SearchHits; import org.elasticsearch.search.aggregations.InternalAggregation; -import org.elasticsearch.search.aggregations.metrics.InternalMetricsAggregation; import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; -import org.elasticsearch.search.SearchHit; import java.io.IOException; import java.util.Arrays; @@ -41,7 +40,7 @@ import java.util.Map; /** * Results of the {@link TopHitsAggregator}. */ -public class InternalTopHits extends InternalMetricsAggregation implements TopHits { +public class InternalTopHits extends InternalAggregation implements TopHits { private int from; private int size; private TopDocs topDocs; @@ -117,7 +116,7 @@ public class InternalTopHits extends InternalMetricsAggregation implements TopHi shardDocs = new TopFieldDocs[aggregations.size()]; for (int i = 0; i < shardDocs.length; i++) { InternalTopHits topHitsAgg = (InternalTopHits) aggregations.get(i); - shardDocs[i] = (TopFieldDocs) topHitsAgg.topDocs; + shardDocs[i] = topHitsAgg.topDocs; shardHits[i] = topHitsAgg.searchHits; } reducedTopDocs = TopDocs.merge(sort, from, size, (TopFieldDocs[]) shardDocs); diff --git a/modules/aggs-matrix-stats/src/main/java/org/elasticsearch/search/aggregations/matrix/stats/InternalMatrixStats.java b/modules/aggs-matrix-stats/src/main/java/org/elasticsearch/search/aggregations/matrix/stats/InternalMatrixStats.java index d97fb64a16d..0914ea2910c 100644 --- a/modules/aggs-matrix-stats/src/main/java/org/elasticsearch/search/aggregations/matrix/stats/InternalMatrixStats.java +++ b/modules/aggs-matrix-stats/src/main/java/org/elasticsearch/search/aggregations/matrix/stats/InternalMatrixStats.java @@ -22,7 +22,6 @@ 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.InternalAggregation; -import org.elasticsearch.search.aggregations.metrics.InternalMetricsAggregation; import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator; import java.io.IOException; @@ -35,7 +34,7 @@ import static java.util.Collections.emptyMap; /** * Computes distribution statistics over multiple fields */ -public class InternalMatrixStats extends InternalMetricsAggregation implements MatrixStats { +public class InternalMatrixStats extends InternalAggregation implements MatrixStats { /** per shard stats needed to compute stats */ private final RunningStats stats; /** final result */