Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove ValuesSourceType argument to ValuesSourceAggregationBuilder #48638

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public class ChildrenAggregationBuilder
* the type of children documents
*/
public ChildrenAggregationBuilder(String name, String childType) {
super(name, ValuesSourceType.BYTES, ValueType.STRING);
super(name, ValueType.STRING);
if (childType == null) {
throw new IllegalArgumentException("[childType] must not be null: [" + name + "]");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public class ParentAggregationBuilder
* the type of children documents
*/
public ParentAggregationBuilder(String name, String childType) {
super(name, ValuesSourceType.BYTES, ValueType.STRING);
super(name, ValueType.STRING);
if (childType == null) {
throw new IllegalArgumentException("[childType] must not be null: [" + name + "]");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public static ObjectParser<GeoGridAggregationBuilder, Void> createParser(String
}

public GeoGridAggregationBuilder(String name) {
super(name, ValuesSourceType.GEOPOINT, ValueType.GEOPOINT);
super(name, ValueType.GEOPOINT);
}

protected GeoGridAggregationBuilder(GeoGridAggregationBuilder clone, Builder factoriesBuilder, Map<String, Object> metaData) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public AutoDateHistogramAggregationBuilder setMinimumIntervalExpression(String m

/** Create a new builder with the given name. */
public AutoDateHistogramAggregationBuilder(String name) {
super(name, ValuesSourceType.NUMERIC, ValueType.DATE);
super(name, ValueType.DATE);
}

/** Read from a stream, for internal use only. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public static DateHistogramAggregationBuilder parse(String aggregationName, XCon

/** Create a new builder with the given name. */
public DateHistogramAggregationBuilder(String name) {
super(name, ValuesSourceType.ANY, ValueType.DATE);
super(name, ValueType.DATE);
}

protected DateHistogramAggregationBuilder(DateHistogramAggregationBuilder clone,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ protected ValuesSourceType resolveScriptAny(Script script) {

/** Create a new builder with the given name. */
public HistogramAggregationBuilder(String name) {
super(name, ValuesSourceType.ANY, ValueType.NUMERIC);
super(name, ValueType.NUMERIC);
}

protected HistogramAggregationBuilder(HistogramAggregationBuilder clone, Builder factoriesBuilder, Map<String, Object> metaData) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static MissingAggregationBuilder parse(String aggregationName, XContentPa
}

public MissingAggregationBuilder(String name, ValueType targetValueType) {
super(name, ValuesSourceType.ANY, targetValueType);
super(name, targetValueType);
}

protected MissingAggregationBuilder(MissingAggregationBuilder clone, Builder factoriesBuilder, Map<String, Object> metaData) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public abstract class AbstractRangeBuilder<AB extends AbstractRangeBuilder<AB, R
protected boolean keyed = false;

protected AbstractRangeBuilder(String name, InternalRange.Factory<?, ?> rangeFactory) {
super(name, rangeFactory.getValueSourceType(), rangeFactory.getValueType());
super(name, rangeFactory.getValueType());
this.rangeFactory = rangeFactory;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ public GeoDistanceAggregationBuilder(String name, GeoPoint origin) {

private GeoDistanceAggregationBuilder(String name, GeoPoint origin,
InternalRange.Factory<InternalGeoDistance.Bucket, InternalGeoDistance> rangeFactory) {
super(name, rangeFactory.getValueSourceType(), rangeFactory.getValueType());
super(name, rangeFactory.getValueType());
this.origin = origin;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
private List<Range> ranges = new ArrayList<>();

public IpRangeAggregationBuilder(String name) {
super(name, ValuesSourceType.BYTES, ValueType.IP);
super(name, ValueType.IP);
}

protected IpRangeAggregationBuilder(IpRangeAggregationBuilder clone, Builder factoriesBuilder, Map<String, Object> metaData) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static AggregationBuilder parse(String aggregationName, XContentParser pa
private String executionHint = null;

public DiversifiedAggregationBuilder(String name) {
super(name, ValuesSourceType.ANY, null);
super(name, null);
}

protected DiversifiedAggregationBuilder(DiversifiedAggregationBuilder clone, Builder factoriesBuilder, Map<String, Object> metaData) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public AggregationBuilder parse(String aggregationName, XContentParser parser) t
private SignificanceHeuristic significanceHeuristic = DEFAULT_SIGNIFICANCE_HEURISTIC;

public SignificantTermsAggregationBuilder(String name, ValueType valueType) {
super(name, ValuesSourceType.ANY, valueType);
super(name, valueType);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public static AggregationBuilder parse(String aggregationName, XContentParser pa
private double precision = 0.001;

public RareTermsAggregationBuilder(String name, ValueType valueType) {
super(name, ValuesSourceType.ANY, valueType);
super(name, valueType);
}

private RareTermsAggregationBuilder(RareTermsAggregationBuilder clone, Builder factoriesBuilder, Map<String, Object> metaData) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public static AggregationBuilder parse(String aggregationName, XContentParser pa
private boolean showTermDocCountError = false;

public TermsAggregationBuilder(String name, ValueType valueType) {
super(name, ValuesSourceType.ANY, valueType);
super(name, valueType);
}

protected TermsAggregationBuilder(TermsAggregationBuilder clone, Builder factoriesBuilder, Map<String, Object> metaData) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static AggregationBuilder parse(String aggregationName, XContentParser pa
private boolean wrapLongitude = true;

public GeoBoundsAggregationBuilder(String name) {
super(name, ValuesSourceType.GEOPOINT, ValueType.GEOPOINT);
super(name, ValueType.GEOPOINT);
}

protected GeoBoundsAggregationBuilder(GeoBoundsAggregationBuilder clone, Builder factoriesBuilder, Map<String, Object> metaData) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public abstract static class LeafOnly<VS extends ValuesSource, AB extends Values
extends ValuesSourceAggregationBuilder<VS, AB> {

protected LeafOnly(String name, ValuesSourceType valuesSourceType, ValueType targetValueType) {
super(name, valuesSourceType, targetValueType);
super(name, targetValueType);
}

protected LeafOnly(LeafOnly<VS, AB> clone, Builder factoriesBuilder, Map<String, Object> metaData) {
Expand Down Expand Up @@ -74,7 +74,6 @@ public final AB subAggregations(Builder subFactories) {
}
}

private final ValuesSourceType valuesSourceType;
private final ValueType targetValueType;
private String field = null;
private Script script = null;
Expand All @@ -84,19 +83,14 @@ public final AB subAggregations(Builder subFactories) {
private ZoneId timeZone = null;
protected ValuesSourceConfig<VS> config;

protected ValuesSourceAggregationBuilder(String name, ValuesSourceType valuesSourceType, ValueType targetValueType) {
protected ValuesSourceAggregationBuilder(String name, ValueType targetValueType) {
super(name);
if (valuesSourceType == null) {
throw new IllegalArgumentException("[valuesSourceType] must not be null: [" + name + "]");
}
this.valuesSourceType = valuesSourceType;
this.targetValueType = targetValueType;
}

protected ValuesSourceAggregationBuilder(ValuesSourceAggregationBuilder<VS, AB> clone,
Builder factoriesBuilder, Map<String, Object> metaData) {
super(clone, factoriesBuilder, metaData);
this.valuesSourceType = clone.valuesSourceType;
this.targetValueType = clone.targetValueType;
this.field = clone.field;
this.valueType = clone.valueType;
Expand All @@ -116,7 +110,6 @@ protected ValuesSourceAggregationBuilder(ValuesSourceAggregationBuilder<VS, AB>
protected ValuesSourceAggregationBuilder(StreamInput in, ValuesSourceType valuesSourceType, ValueType targetValueType)
throws IOException {
super(in);
this.valuesSourceType = valuesSourceType;
if (serializeTargetValueType(in.getVersion())) {
this.targetValueType = in.readOptionalWriteable(ValueType::readFromStream);
} else {
Expand All @@ -133,7 +126,6 @@ protected ValuesSourceAggregationBuilder(StreamInput in, ValuesSourceType values
super(in);
// TODO: Can we get rid of this constructor and always use the three value version? Does this assert provide any value?
assert serializeTargetValueType(in.getVersion()) : "Wrong read constructor called for subclass that serializes its targetValueType";
this.valuesSourceType = valuesSourceType;
this.targetValueType = in.readOptionalWriteable(ValueType::readFromStream);
read(in);
}
Expand Down Expand Up @@ -377,7 +369,7 @@ public final XContentBuilder internalXContent(XContentBuilder builder, Params pa
@Override
public int hashCode() {
return Objects.hash(super.hashCode(), field, format, missing, script,
targetValueType, timeZone, valueType, valuesSourceType);
targetValueType, timeZone, valueType);
}

@Override
Expand All @@ -386,8 +378,7 @@ public boolean equals(Object obj) {
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
ValuesSourceAggregationBuilder<?, ?> other = (ValuesSourceAggregationBuilder<?, ?>) obj;
return Objects.equals(valuesSourceType, other.valuesSourceType)
&& Objects.equals(field, other.field)
return Objects.equals(field, other.field)
&& Objects.equals(format, other.format)
&& Objects.equals(missing, other.missing)
&& Objects.equals(script, other.script)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.elasticsearch.search.aggregations.support.ValuesSourceAggregationBuilder;
import org.elasticsearch.search.aggregations.support.ValuesSourceAggregatorFactory;
import org.elasticsearch.search.aggregations.support.ValuesSourceConfig;
import org.elasticsearch.search.aggregations.support.ValuesSourceType;

import java.io.IOException;
import java.util.Map;
Expand All @@ -45,7 +44,7 @@ protected AggregationBuilder shallowCopy(Builder factoriesBuilder, Map<String, O
}

public MockDeprecatedAggregationBuilder() {
super(NAME, ValuesSourceType.NUMERIC, ValueType.NUMERIC);
super(NAME, ValueType.NUMERIC);
}

/**
Expand Down