Aggregations: Remove the logic to optionally sort/dedup values on the fly.

These options are not used anymore. Instead numeric values can now contain dups
and it is the responsibility of the aggregation to deal with it (eg. terms).
And otherwise all values sources are now sorted, which is the contract of the
interfaces that they implement.

Close #7276
This commit is contained in:
Adrien Grand 2014-08-14 12:17:18 +02:00
parent 62ef4a30dc
commit ded30e95de
12 changed files with 3 additions and 39 deletions

View File

@ -77,7 +77,6 @@ public class DateHistogramParser implements Aggregator.Parser {
ValuesSourceParser vsParser = ValuesSourceParser.numeric(aggregationName, InternalDateHistogram.TYPE, context) ValuesSourceParser vsParser = ValuesSourceParser.numeric(aggregationName, InternalDateHistogram.TYPE, context)
.targetValueType(ValueType.DATE) .targetValueType(ValueType.DATE)
.requiresSortedValues(true)
.formattable(true) .formattable(true)
.build(); .build();

View File

@ -47,7 +47,6 @@ public class HistogramParser implements Aggregator.Parser {
public AggregatorFactory parse(String aggregationName, XContentParser parser, SearchContext context) throws IOException { public AggregatorFactory parse(String aggregationName, XContentParser parser, SearchContext context) throws IOException {
ValuesSourceParser vsParser = ValuesSourceParser.numeric(aggregationName, InternalHistogram.TYPE, context) ValuesSourceParser vsParser = ValuesSourceParser.numeric(aggregationName, InternalHistogram.TYPE, context)
.requiresSortedValues(true)
.targetValueType(ValueType.NUMERIC) .targetValueType(ValueType.NUMERIC)
.formattable(true) .formattable(true)
.build(); .build();

View File

@ -47,7 +47,6 @@ public class RangeParser implements Aggregator.Parser {
boolean keyed = false; boolean keyed = false;
ValuesSourceParser<ValuesSource.Numeric> vsParser = ValuesSourceParser.numeric(aggregationName, InternalRange.TYPE, context) ValuesSourceParser<ValuesSource.Numeric> vsParser = ValuesSourceParser.numeric(aggregationName, InternalRange.TYPE, context)
.requiresSortedValues(true)
.formattable(true) .formattable(true)
.build(); .build();

View File

@ -47,7 +47,6 @@ public class DateRangeParser implements Aggregator.Parser {
ValuesSourceParser<ValuesSource.Numeric> vsParser = ValuesSourceParser.numeric(aggregationName, InternalDateRange.TYPE, context) ValuesSourceParser<ValuesSource.Numeric> vsParser = ValuesSourceParser.numeric(aggregationName, InternalDateRange.TYPE, context)
.targetValueType(ValueType.DATE) .targetValueType(ValueType.DATE)
.requiresSortedValues(true)
.formattable(true) .formattable(true)
.build(); .build();

View File

@ -69,9 +69,7 @@ public class GeoDistanceParser implements Aggregator.Parser {
@Override @Override
public AggregatorFactory parse(String aggregationName, XContentParser parser, SearchContext context) throws IOException { public AggregatorFactory parse(String aggregationName, XContentParser parser, SearchContext context) throws IOException {
ValuesSourceParser<ValuesSource.GeoPoint> vsParser = ValuesSourceParser.geoPoint(aggregationName, InternalGeoDistance.TYPE, context) ValuesSourceParser<ValuesSource.GeoPoint> vsParser = ValuesSourceParser.geoPoint(aggregationName, InternalGeoDistance.TYPE, context).build();
.requiresSortedValues(true)
.build();
GeoPointParser geoPointParser = new GeoPointParser(aggregationName, InternalGeoDistance.TYPE, context, ORIGIN_FIELD); GeoPointParser geoPointParser = new GeoPointParser(aggregationName, InternalGeoDistance.TYPE, context, ORIGIN_FIELD);

View File

@ -47,7 +47,6 @@ public class IpRangeParser implements Aggregator.Parser {
ValuesSourceParser<ValuesSource.Numeric> vsParser = ValuesSourceParser.numeric(aggregationName, InternalIPv4Range.TYPE, context) ValuesSourceParser<ValuesSource.Numeric> vsParser = ValuesSourceParser.numeric(aggregationName, InternalIPv4Range.TYPE, context)
.targetValueType(ValueType.IP) .targetValueType(ValueType.IP)
.requiresSortedValues(true)
.formattable(false) .formattable(false)
.build(); .build();

View File

@ -56,8 +56,6 @@ public class SignificantTermsParser implements Aggregator.Parser {
ValuesSourceParser vsParser = ValuesSourceParser.any(aggregationName, SignificantStringTerms.TYPE, context) ValuesSourceParser vsParser = ValuesSourceParser.any(aggregationName, SignificantStringTerms.TYPE, context)
.scriptable(false) .scriptable(false)
.formattable(true) .formattable(true)
.requiresSortedValues(true)
.requiresUniqueValues(true)
.build(); .build();
IncludeExclude.Parser incExcParser = new IncludeExclude.Parser(aggregationName, SignificantStringTerms.TYPE, context); IncludeExclude.Parser incExcParser = new IncludeExclude.Parser(aggregationName, SignificantStringTerms.TYPE, context);
aggParser.parse(aggregationName, parser, context, vsParser, incExcParser); aggParser.parse(aggregationName, parser, context, vsParser, incExcParser);

View File

@ -41,8 +41,7 @@ public class TermsParser implements Aggregator.Parser {
@Override @Override
public AggregatorFactory parse(String aggregationName, XContentParser parser, SearchContext context) throws IOException { public AggregatorFactory parse(String aggregationName, XContentParser parser, SearchContext context) throws IOException {
TermsParametersParser aggParser = new TermsParametersParser(); TermsParametersParser aggParser = new TermsParametersParser();
ValuesSourceParser vsParser = ValuesSourceParser.any(aggregationName, StringTerms.TYPE, context).scriptable(true).formattable(true) ValuesSourceParser vsParser = ValuesSourceParser.any(aggregationName, StringTerms.TYPE, context).scriptable(true).formattable(true).build();
.requiresSortedValues(true).requiresUniqueValues(true).build();
IncludeExclude.Parser incExcParser = new IncludeExclude.Parser(aggregationName, StringTerms.TYPE, context); IncludeExclude.Parser incExcParser = new IncludeExclude.Parser(aggregationName, StringTerms.TYPE, context);
aggParser.parse(aggregationName, parser, context, vsParser, incExcParser); aggParser.parse(aggregationName, parser, context, vsParser, incExcParser);

View File

@ -54,7 +54,6 @@ public abstract class NumericValuesSourceMetricsAggregatorParser<S extends Inter
public AggregatorFactory parse(String aggregationName, XContentParser parser, SearchContext context) throws IOException { public AggregatorFactory parse(String aggregationName, XContentParser parser, SearchContext context) throws IOException {
ValuesSourceParser<ValuesSource.Numeric> vsParser = ValuesSourceParser.numeric(aggregationName, aggType, context) ValuesSourceParser<ValuesSource.Numeric> vsParser = ValuesSourceParser.numeric(aggregationName, aggType, context)
.requiresSortedValues(requiresSortedValues())
.build(); .build();
XContentParser.Token token; XContentParser.Token token;

View File

@ -42,9 +42,7 @@ public abstract class AbstractPercentilesParser implements Aggregator.Parser {
@Override @Override
public AggregatorFactory parse(String aggregationName, XContentParser parser, SearchContext context) throws IOException { public AggregatorFactory parse(String aggregationName, XContentParser parser, SearchContext context) throws IOException {
ValuesSourceParser<ValuesSource.Numeric> vsParser = ValuesSourceParser.numeric(aggregationName, InternalPercentiles.TYPE, context) ValuesSourceParser<ValuesSource.Numeric> vsParser = ValuesSourceParser.numeric(aggregationName, InternalPercentiles.TYPE, context).build();
.requiresSortedValues(true)
.build();
double[] keys = null; double[] keys = null;
boolean keyed = true; boolean keyed = true;

View File

@ -41,7 +41,6 @@ public class ValueCountParser implements Aggregator.Parser {
public AggregatorFactory parse(String aggregationName, XContentParser parser, SearchContext context) throws IOException { public AggregatorFactory parse(String aggregationName, XContentParser parser, SearchContext context) throws IOException {
ValuesSourceParser vsParser = ValuesSourceParser.any(aggregationName, InternalValueCount.TYPE, context) ValuesSourceParser vsParser = ValuesSourceParser.any(aggregationName, InternalValueCount.TYPE, context)
.requiresUniqueValues(true)
.build(); .build();
XContentParser.Token token; XContentParser.Token token;

View File

@ -66,8 +66,6 @@ public class ValuesSourceParser<VS extends ValuesSource> {
String lang = null; String lang = null;
Map<String, Object> params = null; Map<String, Object> params = null;
ValueType valueType = null; ValueType valueType = null;
boolean assumeUnique = false;
boolean assumeSorted = false;
String format = null; String format = null;
} }
@ -125,16 +123,6 @@ public class ValuesSourceParser<VS extends ValuesSource> {
} }
return true; return true;
} }
if (scriptable && token == XContentParser.Token.VALUE_BOOLEAN) {
if ("script_values_unique".equals(currentFieldName) || "scriptValuesUnique".equals(currentFieldName)) {
input.assumeUnique = parser.booleanValue();
} else if ("script_values_sorted".equals(currentFieldName) || "scriptValuesSorted".equals(currentFieldName)) {
input.assumeSorted = parser.booleanValue();
} else {
return false;
}
return true;
}
if (scriptable && token == XContentParser.Token.START_OBJECT) { if (scriptable && token == XContentParser.Token.START_OBJECT) {
if ("params".equals(currentFieldName)) { if ("params".equals(currentFieldName)) {
input.params = parser.map(); input.params = parser.map();
@ -252,16 +240,6 @@ public class ValuesSourceParser<VS extends ValuesSource> {
return this; return this;
} }
public Builder<VS> requiresSortedValues(boolean requiresSortedValues) {
parser.requiresSortedValues = requiresSortedValues;
return this;
}
public Builder<VS> requiresUniqueValues(boolean requiresUniqueValues) {
parser.requiresUniqueValues = requiresUniqueValues;
return this;
}
public ValuesSourceParser<VS> build() { public ValuesSourceParser<VS> build() {
return parser; return parser;
} }