Skip to content

Commit

Permalink
Aggregations: Remove the logic to optionally sort/dedup values on the…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
jpountz committed Aug 21, 2014
1 parent 50daf2b commit 1f5e244
Show file tree
Hide file tree
Showing 12 changed files with 3 additions and 39 deletions.
Expand Up @@ -77,7 +77,6 @@ public AggregatorFactory parse(String aggregationName, XContentParser parser, Se

ValuesSourceParser vsParser = ValuesSourceParser.numeric(aggregationName, InternalDateHistogram.TYPE, context)
.targetValueType(ValueType.DATE)
.requiresSortedValues(true)
.formattable(true)
.build();

Expand Down
Expand Up @@ -47,7 +47,6 @@ public String type() {
public AggregatorFactory parse(String aggregationName, XContentParser parser, SearchContext context) throws IOException {

ValuesSourceParser vsParser = ValuesSourceParser.numeric(aggregationName, InternalHistogram.TYPE, context)
.requiresSortedValues(true)
.targetValueType(ValueType.NUMERIC)
.formattable(true)
.build();
Expand Down
Expand Up @@ -47,7 +47,6 @@ public AggregatorFactory parse(String aggregationName, XContentParser parser, Se
boolean keyed = false;

ValuesSourceParser<ValuesSource.Numeric> vsParser = ValuesSourceParser.numeric(aggregationName, InternalRange.TYPE, context)
.requiresSortedValues(true)
.formattable(true)
.build();

Expand Down
Expand Up @@ -47,7 +47,6 @@ public AggregatorFactory parse(String aggregationName, XContentParser parser, Se

ValuesSourceParser<ValuesSource.Numeric> vsParser = ValuesSourceParser.numeric(aggregationName, InternalDateRange.TYPE, context)
.targetValueType(ValueType.DATE)
.requiresSortedValues(true)
.formattable(true)
.build();

Expand Down
Expand Up @@ -69,9 +69,7 @@ private static String key(String key, double from, double to) {
@Override
public AggregatorFactory parse(String aggregationName, XContentParser parser, SearchContext context) throws IOException {

ValuesSourceParser<ValuesSource.GeoPoint> vsParser = ValuesSourceParser.geoPoint(aggregationName, InternalGeoDistance.TYPE, context)
.requiresSortedValues(true)
.build();
ValuesSourceParser<ValuesSource.GeoPoint> vsParser = ValuesSourceParser.geoPoint(aggregationName, InternalGeoDistance.TYPE, context).build();

GeoPointParser geoPointParser = new GeoPointParser(aggregationName, InternalGeoDistance.TYPE, context, ORIGIN_FIELD);

Expand Down
Expand Up @@ -47,7 +47,6 @@ public AggregatorFactory parse(String aggregationName, XContentParser parser, Se

ValuesSourceParser<ValuesSource.Numeric> vsParser = ValuesSourceParser.numeric(aggregationName, InternalIPv4Range.TYPE, context)
.targetValueType(ValueType.IP)
.requiresSortedValues(true)
.formattable(false)
.build();

Expand Down
Expand Up @@ -56,8 +56,6 @@ public AggregatorFactory parse(String aggregationName, XContentParser parser, Se
ValuesSourceParser vsParser = ValuesSourceParser.any(aggregationName, SignificantStringTerms.TYPE, context)
.scriptable(false)
.formattable(true)
.requiresSortedValues(true)
.requiresUniqueValues(true)
.build();
IncludeExclude.Parser incExcParser = new IncludeExclude.Parser(aggregationName, SignificantStringTerms.TYPE, context);
aggParser.parse(aggregationName, parser, context, vsParser, incExcParser);
Expand Down
Expand Up @@ -41,8 +41,7 @@ public String type() {
@Override
public AggregatorFactory parse(String aggregationName, XContentParser parser, SearchContext context) throws IOException {
TermsParametersParser aggParser = new TermsParametersParser();
ValuesSourceParser vsParser = ValuesSourceParser.any(aggregationName, StringTerms.TYPE, context).scriptable(true).formattable(true)
.requiresSortedValues(true).requiresUniqueValues(true).build();
ValuesSourceParser vsParser = ValuesSourceParser.any(aggregationName, StringTerms.TYPE, context).scriptable(true).formattable(true).build();
IncludeExclude.Parser incExcParser = new IncludeExclude.Parser(aggregationName, StringTerms.TYPE, context);
aggParser.parse(aggregationName, parser, context, vsParser, incExcParser);

Expand Down
Expand Up @@ -54,7 +54,6 @@ protected boolean requiresSortedValues() {
public AggregatorFactory parse(String aggregationName, XContentParser parser, SearchContext context) throws IOException {

ValuesSourceParser<ValuesSource.Numeric> vsParser = ValuesSourceParser.numeric(aggregationName, aggType, context)
.requiresSortedValues(requiresSortedValues())
.build();

XContentParser.Token token;
Expand Down
Expand Up @@ -42,9 +42,7 @@ public AbstractPercentilesParser() {
@Override
public AggregatorFactory parse(String aggregationName, XContentParser parser, SearchContext context) throws IOException {

ValuesSourceParser<ValuesSource.Numeric> vsParser = ValuesSourceParser.numeric(aggregationName, InternalPercentiles.TYPE, context)
.requiresSortedValues(true)
.build();
ValuesSourceParser<ValuesSource.Numeric> vsParser = ValuesSourceParser.numeric(aggregationName, InternalPercentiles.TYPE, context).build();

double[] keys = null;
boolean keyed = true;
Expand Down
Expand Up @@ -41,7 +41,6 @@ public String type() {
public AggregatorFactory parse(String aggregationName, XContentParser parser, SearchContext context) throws IOException {

ValuesSourceParser vsParser = ValuesSourceParser.any(aggregationName, InternalValueCount.TYPE, context)
.requiresUniqueValues(true)
.build();

XContentParser.Token token;
Expand Down
Expand Up @@ -66,8 +66,6 @@ private static class Input {
String lang = null;
Map<String, Object> params = null;
ValueType valueType = null;
boolean assumeUnique = false;
boolean assumeSorted = false;
String format = null;
}

Expand Down Expand Up @@ -125,16 +123,6 @@ public boolean token(String currentFieldName, XContentParser.Token token, XConte
}
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 ("params".equals(currentFieldName)) {
input.params = parser.map();
Expand Down Expand Up @@ -252,16 +240,6 @@ public Builder<VS> targetValueType(ValueType valueType) {
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() {
return parser;
}
Expand Down

0 comments on commit 1f5e244

Please sign in to comment.