Remove deprecated registration methods

Removes deprecated registration methods from SearchModule and
NamedWriteableRegistry and removes the "shims" used to migrate
aggregations to the new registration methods.

Relates to #17085
This commit is contained in:
Nik Everett 2016-04-18 12:06:56 -04:00
parent bbe03c92c2
commit 7a2b923ad1
52 changed files with 11 additions and 407 deletions

View File

@ -48,17 +48,6 @@ public class NamedWriteableRegistry {
innerRegistry.register(name, reader); innerRegistry.register(name, reader);
} }
/**
* Registers a {@link NamedWriteable} prototype given its category.
* @deprecated Prefer {@link #register(Class, String, org.elasticsearch.common.io.stream.Writeable.Reader)}
*/
@Deprecated
@SuppressWarnings("rawtypes") // TODO remove this method entirely before 5.0.0 GA
public synchronized <T extends NamedWriteable> void registerPrototype(Class<T> categoryClass,
NamedWriteable<? extends T> namedWriteable) {
register(categoryClass, namedWriteable.getWriteableName(), namedWriteable::readFrom);
}
/** /**
* Returns a prototype of the {@link NamedWriteable} object identified by the name provided as argument and its category * Returns a prototype of the {@link NamedWriteable} object identified by the name provided as argument and its category
*/ */

View File

@ -381,18 +381,6 @@ public class SearchModule extends AbstractModule {
namedWriteableRegistry.register(AggregatorBuilder.class, aggregationName.getPreferredName(), reader); namedWriteableRegistry.register(AggregatorBuilder.class, aggregationName.getPreferredName(), reader);
} }
/**
* Register an aggregation.
*
* @deprecated prefer {@link #registerPipelineAggregation(Writeable.Reader, PipelineAggregator.Parser, ParseField)}. Will be removed
* before 5.0.0GA.
*/
@Deprecated // NORELEASE remove this before 5.0.0GA
public void registerAggregatorParser(Aggregator.Parser parser) {
aggregationParserRegistry.register(parser, new ParseField(parser.type()));
namedWriteableRegistry.registerPrototype(AggregatorBuilder.class, parser.getFactoryPrototypes());
}
/** /**
* Register a pipeline aggregation. * Register a pipeline aggregation.
* *
@ -407,18 +395,6 @@ public class SearchModule extends AbstractModule {
namedWriteableRegistry.register(PipelineAggregatorBuilder.class, aggregationName.getPreferredName(), reader); namedWriteableRegistry.register(PipelineAggregatorBuilder.class, aggregationName.getPreferredName(), reader);
} }
/**
* Register a pipeline aggregation.
*
* @deprecated prefer {@link #registerPipelineAggregation(Writeable.Reader, PipelineAggregator.Parser, ParseField)}. Will be removed
* before 5.0.0GA.
*/
@Deprecated // NORELEASE remove this before 5.0.0GA
public void registerPipelineParser(PipelineAggregator.Parser parser) {
pipelineAggregationParserRegistry.register(parser, new ParseField(parser.type()));
namedWriteableRegistry.registerPrototype(PipelineAggregatorBuilder.class, parser.getFactoryPrototype());
}
public AggregatorParsers getAggregatorParsers() { public AggregatorParsers getAggregatorParsers() {
return aggregatorParsers; return aggregatorParsers;
} }

View File

@ -46,14 +46,6 @@ public abstract class Aggregator extends BucketCollector implements Releasable {
*/ */
@FunctionalInterface @FunctionalInterface
public interface Parser { public interface Parser {
/**
* @return The aggregation type this parser is associated with.
*/
default String type() {
throw new UnsupportedOperationException(); // NORELEASE remove before 5.0.0GA
}
/** /**
* Returns the aggregator factory with which this parser is associated, may return {@code null} indicating the * Returns the aggregator factory with which this parser is associated, may return {@code null} indicating the
* aggregation should be skipped (e.g. when trying to aggregate on unmapped fields). * aggregation should be skipped (e.g. when trying to aggregate on unmapped fields).
@ -64,14 +56,6 @@ public abstract class Aggregator extends BucketCollector implements Releasable {
* @throws java.io.IOException When parsing fails * @throws java.io.IOException When parsing fails
*/ */
AggregatorBuilder<?> parse(String aggregationName, QueryParseContext context) throws IOException; AggregatorBuilder<?> parse(String aggregationName, QueryParseContext context) throws IOException;
/**
* @return an empty {@link AggregatorBuilder} instance for this parser
* that can be used for deserialization
*/
default AggregatorBuilder<?> getFactoryPrototypes() {
throw new UnsupportedOperationException(); // NORELEASE remove before 5.0.0GA
}
} }
/** /**

View File

@ -71,39 +71,16 @@ public abstract class AggregatorBuilder<AB extends AggregatorBuilder<AB>> extend
metaData = in.readMap(); metaData = in.readMap();
} }
protected boolean usesNewStyleSerialization() { // NORELEASE remove this before 5.0.0GA, when all the aggregations have been migrated
return false;
}
@Override @Override
public final void writeTo(StreamOutput out) throws IOException { public final void writeTo(StreamOutput out) throws IOException {
out.writeString(name); out.writeString(name);
if (false == usesNewStyleSerialization()) {
doWriteTo(out);
}
factoriesBuilder.writeTo(out); factoriesBuilder.writeTo(out);
out.writeMap(metaData); out.writeMap(metaData);
if (usesNewStyleSerialization()) { doWriteTo(out);
doWriteTo(out);
}
} }
protected abstract void doWriteTo(StreamOutput out) throws IOException; protected abstract void doWriteTo(StreamOutput out) throws IOException;
@Override
public final AB readFrom(StreamInput in) throws IOException {
// NORELEASE remove when all aggregations have StreamInput constructor
String name = in.readString();
AB factory = doReadFrom(name, in);
factory.factoriesBuilder = AggregatorFactories.Builder.PROTOTYPE.readFrom(in);
factory.metaData = in.readMap();
return factory;
}
protected AB doReadFrom(String name, StreamInput in) throws IOException {
throw new UnsupportedOperationException(); // NORELEASE remove before 5.0.0GA
}
/** /**
* Add a sub aggregation to this aggregation. * Add a sub aggregation to this aggregation.
*/ */
@ -188,13 +165,6 @@ public abstract class AggregatorBuilder<AB extends AggregatorBuilder<AB>> extend
protected abstract XContentBuilder internalXContent(XContentBuilder builder, Params params) throws IOException; protected abstract XContentBuilder internalXContent(XContentBuilder builder, Params params) throws IOException;
@Override
public String getWriteableName() {
// NORELEASE remove this before 5.0.0GA - all builders will implement this method on their own.
assert usesNewStyleSerialization() == false: "migrated aggregations should just return their NAME";
return type.stream().toUtf8();
}
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(factoriesBuilder, metaData, name, type, doHashCode()); return Objects.hash(factoriesBuilder, metaData, name, type, doHashCode());

View File

@ -69,7 +69,8 @@ public abstract class InternalAggregation implements Aggregation, ToXContent, St
} }
/** /**
* @return The name of the type (mainly used for registering the parser for the aggregator (see {@link org.elasticsearch.search.aggregations.Aggregator.Parser#type()}). * @return The name of the type of aggregation. This is the key for parsing the aggregation from XContent and is the name of the
* aggregation's builder when serialized.
*/ */
public String name() { public String name() {
return name; return name;

View File

@ -80,11 +80,6 @@ public class ChildrenAggregatorBuilder extends ValuesSourceAggregatorBuilder<Par
out.writeString(childType); out.writeString(childType);
} }
@Override
protected boolean usesNewStyleSerialization() {
return true;
}
@Override @Override
protected ValuesSourceAggregatorFactory<ParentChild, ?> innerBuild(AggregationContext context, protected ValuesSourceAggregatorFactory<ParentChild, ?> innerBuild(AggregationContext context,
ValuesSourceConfig<ParentChild> config, AggregatorFactory<?> parent, Builder subFactoriesBuilder) throws IOException { ValuesSourceConfig<ParentChild> config, AggregatorFactory<?> parent, Builder subFactoriesBuilder) throws IOException {

View File

@ -76,11 +76,6 @@ public class FilterAggregatorBuilder extends AggregatorBuilder<FilterAggregatorB
out.writeQuery(filter); out.writeQuery(filter);
} }
@Override
protected boolean usesNewStyleSerialization() {
return true;
}
@Override @Override
protected AggregatorFactory<?> doBuild(AggregationContext context, AggregatorFactory<?> parent, protected AggregatorFactory<?> doBuild(AggregationContext context, AggregatorFactory<?> parent,
AggregatorFactories.Builder subFactoriesBuilder) throws IOException { AggregatorFactories.Builder subFactoriesBuilder) throws IOException {

View File

@ -128,11 +128,6 @@ public class FiltersAggregatorBuilder extends AggregatorBuilder<FiltersAggregato
out.writeString(otherBucketKey); out.writeString(otherBucketKey);
} }
@Override
protected boolean usesNewStyleSerialization() {
return true;
}
/** /**
* Set whether to include a bucket for documents not matching any filter * Set whether to include a bucket for documents not matching any filter
*/ */

View File

@ -74,11 +74,6 @@ public class GeoGridAggregatorBuilder extends ValuesSourceAggregatorBuilder<Valu
out.writeVInt(shardSize); out.writeVInt(shardSize);
} }
@Override
protected boolean usesNewStyleSerialization() {
return true;
}
public GeoGridAggregatorBuilder precision(int precision) { public GeoGridAggregatorBuilder precision(int precision) {
this.precision = GeoHashGridParams.checkPrecision(precision); this.precision = GeoHashGridParams.checkPrecision(precision);
return this; return this;

View File

@ -51,11 +51,6 @@ public class GlobalAggregatorBuilder extends AggregatorBuilder<GlobalAggregatorB
// Nothing to write // Nothing to write
} }
@Override
protected boolean usesNewStyleSerialization() {
return true;
}
@Override @Override
protected AggregatorFactory<?> doBuild(AggregationContext context, AggregatorFactory<?> parent, Builder subFactoriesBuilder) protected AggregatorFactory<?> doBuild(AggregationContext context, AggregatorFactory<?> parent, Builder subFactoriesBuilder)
throws IOException { throws IOException {

View File

@ -79,11 +79,6 @@ public abstract class AbstractHistogramBuilder<AB extends AbstractHistogramBuild
} }
} }
@Override
protected boolean usesNewStyleSerialization() {
return true;
}
public long interval() { public long interval() {
return interval; return interval;
} }

View File

@ -55,11 +55,6 @@ public class MissingAggregatorBuilder extends ValuesSourceAggregatorBuilder<Valu
// Do nothing, no extra state to write to stream // Do nothing, no extra state to write to stream
} }
@Override
protected boolean usesNewStyleSerialization() {
return true;
}
@Override @Override
protected boolean serializeTargetValueType() { protected boolean serializeTargetValueType() {
return true; return true;

View File

@ -68,11 +68,6 @@ public class NestedAggregatorBuilder extends AggregatorBuilder<NestedAggregatorB
out.writeString(path); out.writeString(path);
} }
@Override
protected boolean usesNewStyleSerialization() {
return true;
}
/** /**
* Get the path to use for this nested aggregation. * Get the path to use for this nested aggregation.
*/ */

View File

@ -57,11 +57,6 @@ public class ReverseNestedAggregatorBuilder extends AggregatorBuilder<ReverseNes
out.writeOptionalString(path); out.writeOptionalString(path);
} }
@Override
protected boolean usesNewStyleSerialization() {
return true;
}
/** /**
* Set the path to use for this nested aggregation. The path must match * Set the path to use for this nested aggregation. The path must match
* the path to a nested object in the mappings. If it is not specified * the path to a nested object in the mappings. If it is not specified

View File

@ -64,11 +64,6 @@ public abstract class AbstractRangeBuilder<AB extends AbstractRangeBuilder<AB, R
out.writeBoolean(keyed); out.writeBoolean(keyed);
} }
@Override
protected boolean usesNewStyleSerialization() {
return true;
}
public AB addRange(R range) { public AB addRange(R range) {
if (range == null) { if (range == null) {
throw new IllegalArgumentException("[range] must not be null: [" + name + "]"); throw new IllegalArgumentException("[range] must not be null: [" + name + "]");

View File

@ -95,11 +95,6 @@ public class GeoDistanceAggregatorBuilder extends ValuesSourceAggregatorBuilder<
unit.writeTo(out); unit.writeTo(out);
} }
@Override
protected boolean usesNewStyleSerialization() {
return true;
}
public GeoDistanceAggregatorBuilder addRange(Range range) { public GeoDistanceAggregatorBuilder addRange(Range range) {
if (range == null) { if (range == null) {
throw new IllegalArgumentException("[range] must not be null: [" + name + "]"); throw new IllegalArgumentException("[range] must not be null: [" + name + "]");

View File

@ -68,11 +68,6 @@ public class DiversifiedAggregatorBuilder extends ValuesSourceAggregatorBuilder<
out.writeOptionalString(executionHint); out.writeOptionalString(executionHint);
} }
@Override
protected boolean usesNewStyleSerialization() {
return true;
}
/** /**
* Set the max num docs to be returned from each shard. * Set the max num docs to be returned from each shard.
*/ */

View File

@ -59,11 +59,6 @@ public class SamplerAggregatorBuilder extends AggregatorBuilder<SamplerAggregato
out.writeVInt(shardSize); out.writeVInt(shardSize);
} }
@Override
protected boolean usesNewStyleSerialization() {
return true;
}
/** /**
* Set the max num docs to be returned from each shard. * Set the max num docs to be returned from each shard.
*/ */

View File

@ -99,11 +99,6 @@ public class SignificantTermsAggregatorBuilder extends ValuesSourceAggregatorBui
SignificanceHeuristicStreams.writeTo(significanceHeuristic, out); SignificanceHeuristicStreams.writeTo(significanceHeuristic, out);
} }
@Override
protected boolean usesNewStyleSerialization() {
return true;
}
@Override @Override
protected boolean serializeTargetValueType() { protected boolean serializeTargetValueType() {
return true; return true;

View File

@ -99,11 +99,6 @@ public class TermsAggregatorBuilder extends ValuesSourceAggregatorBuilder<Values
out.writeBoolean(showTermDocCountError); out.writeBoolean(showTermDocCountError);
} }
@Override
protected boolean usesNewStyleSerialization() {
return true;
}
public TermsAggregator.BucketCountThresholds bucketCountThresholds() { public TermsAggregator.BucketCountThresholds bucketCountThresholds() {
return bucketCountThresholds; return bucketCountThresholds;
} }

View File

@ -55,11 +55,6 @@ public class AvgAggregatorBuilder extends ValuesSourceAggregatorBuilder.LeafOnly
// Do nothing, no extra state to write to stream // Do nothing, no extra state to write to stream
} }
@Override
protected boolean usesNewStyleSerialization() {
return true;
}
@Override @Override
protected AvgAggregatorFactory innerBuild(AggregationContext context, ValuesSourceConfig<Numeric> config, protected AvgAggregatorFactory innerBuild(AggregationContext context, ValuesSourceConfig<Numeric> config,
AggregatorFactory<?> parent, Builder subFactoriesBuilder) throws IOException { AggregatorFactory<?> parent, Builder subFactoriesBuilder) throws IOException {

View File

@ -66,11 +66,6 @@ public final class CardinalityAggregatorBuilder extends ValuesSourceAggregatorBu
} }
} }
@Override
protected boolean usesNewStyleSerialization() {
return true;
}
@Override @Override
protected boolean serializeTargetValueType() { protected boolean serializeTargetValueType() {
return true; return true;

View File

@ -58,11 +58,6 @@ public class GeoBoundsAggregatorBuilder extends ValuesSourceAggregatorBuilder<Va
out.writeBoolean(wrapLongitude); out.writeBoolean(wrapLongitude);
} }
@Override
protected boolean usesNewStyleSerialization() {
return true;
}
/** /**
* Set whether to wrap longitudes. Defaults to true. * Set whether to wrap longitudes. Defaults to true.
*/ */

View File

@ -55,11 +55,6 @@ public class GeoCentroidAggregatorBuilder
// Do nothing, no extra state to write to stream // Do nothing, no extra state to write to stream
} }
@Override
protected boolean usesNewStyleSerialization() {
return true;
}
@Override @Override
protected GeoCentroidAggregatorFactory innerBuild(AggregationContext context, ValuesSourceConfig<ValuesSource.GeoPoint> config, protected GeoCentroidAggregatorFactory innerBuild(AggregationContext context, ValuesSourceConfig<ValuesSource.GeoPoint> config,
AggregatorFactory<?> parent, Builder subFactoriesBuilder) throws IOException { AggregatorFactory<?> parent, Builder subFactoriesBuilder) throws IOException {

View File

@ -55,11 +55,6 @@ public class MaxAggregatorBuilder extends ValuesSourceAggregatorBuilder.LeafOnly
// Do nothing, no extra state to write to stream // Do nothing, no extra state to write to stream
} }
@Override
protected boolean usesNewStyleSerialization() {
return true;
}
@Override @Override
protected MaxAggregatorFactory innerBuild(AggregationContext context, ValuesSourceConfig<Numeric> config, protected MaxAggregatorFactory innerBuild(AggregationContext context, ValuesSourceConfig<Numeric> config,
AggregatorFactory<?> parent, Builder subFactoriesBuilder) throws IOException { AggregatorFactory<?> parent, Builder subFactoriesBuilder) throws IOException {

View File

@ -55,11 +55,6 @@ public class MinAggregatorBuilder extends ValuesSourceAggregatorBuilder.LeafOnly
// Do nothing, no extra state to write to stream // Do nothing, no extra state to write to stream
} }
@Override
protected boolean usesNewStyleSerialization() {
return true;
}
@Override @Override
protected MinAggregatorFactory innerBuild(AggregationContext context, ValuesSourceConfig<Numeric> config, protected MinAggregatorFactory innerBuild(AggregationContext context, ValuesSourceConfig<Numeric> config,
AggregatorFactory<?> parent, Builder subFactoriesBuilder) throws IOException { AggregatorFactory<?> parent, Builder subFactoriesBuilder) throws IOException {

View File

@ -76,11 +76,6 @@ public class PercentileRanksAggregatorBuilder extends LeafOnly<ValuesSource.Nume
method.writeTo(out); method.writeTo(out);
} }
@Override
protected boolean usesNewStyleSerialization() {
return true;
}
/** /**
* Set the values to compute percentiles from. * Set the values to compute percentiles from.
*/ */

View File

@ -76,11 +76,6 @@ public class PercentilesAggregatorBuilder extends LeafOnly<ValuesSource.Numeric,
method.writeTo(out); method.writeTo(out);
} }
@Override
protected boolean usesNewStyleSerialization() {
return true;
}
/** /**
* Set the values to compute percentiles from. * Set the values to compute percentiles from.
*/ */

View File

@ -89,11 +89,6 @@ public class ScriptedMetricAggregatorBuilder extends AggregatorBuilder<ScriptedM
} }
} }
@Override
protected boolean usesNewStyleSerialization() {
return true;
}
/** /**
* Set the <tt>init</tt> script. * Set the <tt>init</tt> script.
*/ */

View File

@ -61,11 +61,6 @@ public class StatsAggregatorBuilder extends ValuesSourceAggregatorBuilder.LeafOn
return new StatsAggregatorFactory(name, type, config, context, parent, subFactoriesBuilder, metaData); return new StatsAggregatorFactory(name, type, config, context, parent, subFactoriesBuilder, metaData);
} }
@Override
protected boolean usesNewStyleSerialization() {
return true;
}
@Override @Override
public XContentBuilder doXContentBody(XContentBuilder builder, Params params) throws IOException { public XContentBuilder doXContentBody(XContentBuilder builder, Params params) throws IOException {
return builder; return builder;

View File

@ -60,11 +60,6 @@ public class ExtendedStatsAggregatorBuilder
out.writeDouble(sigma); out.writeDouble(sigma);
} }
@Override
protected boolean usesNewStyleSerialization() {
return true;
}
public ExtendedStatsAggregatorBuilder sigma(double sigma) { public ExtendedStatsAggregatorBuilder sigma(double sigma) {
if (sigma < 0.0) { if (sigma < 0.0) {
throw new IllegalArgumentException("[sigma] must be greater than or equal to 0. Found [" + sigma + "] in [" + name + "]"); throw new IllegalArgumentException("[sigma] must be greater than or equal to 0. Found [" + sigma + "] in [" + name + "]");

View File

@ -55,11 +55,6 @@ public class SumAggregatorBuilder extends ValuesSourceAggregatorBuilder.LeafOnly
// Do nothing, no extra state to write to stream // Do nothing, no extra state to write to stream
} }
@Override
protected boolean usesNewStyleSerialization() {
return true;
}
@Override @Override
protected SumAggregatorFactory innerBuild(AggregationContext context, ValuesSourceConfig<Numeric> config, protected SumAggregatorFactory innerBuild(AggregationContext context, ValuesSourceConfig<Numeric> config,
AggregatorFactory<?> parent, Builder subFactoriesBuilder) throws IOException { AggregatorFactory<?> parent, Builder subFactoriesBuilder) throws IOException {

View File

@ -156,11 +156,6 @@ public class TopHitsAggregatorBuilder extends AggregatorBuilder<TopHitsAggregato
out.writeBoolean(version); out.writeBoolean(version);
} }
@Override
protected boolean usesNewStyleSerialization() {
return true;
}
/** /**
* From index to start the search from. Defaults to <tt>0</tt>. * From index to start the search from. Defaults to <tt>0</tt>.
*/ */

View File

@ -54,11 +54,6 @@ public class ValueCountAggregatorBuilder extends ValuesSourceAggregatorBuilder.L
// Do nothing, no extra state to write to stream // Do nothing, no extra state to write to stream
} }
@Override
protected boolean usesNewStyleSerialization() {
return true;
}
@Override @Override
protected boolean serializeTargetValueType() { protected boolean serializeTargetValueType() {
return true; return true;

View File

@ -39,19 +39,10 @@ public abstract class PipelineAggregator implements Streamable {
*/ */
@FunctionalInterface @FunctionalInterface
public static interface Parser { public static interface Parser {
public static final ParseField BUCKETS_PATH = new ParseField("buckets_path"); public static final ParseField BUCKETS_PATH = new ParseField("buckets_path");
public static final ParseField FORMAT = new ParseField("format"); public static final ParseField FORMAT = new ParseField("format");
public static final ParseField GAP_POLICY = new ParseField("gap_policy"); public static final ParseField GAP_POLICY = new ParseField("gap_policy");
/**
* @return The aggregation type this parser is associated with.
*/
default String type() {
throw new UnsupportedOperationException(); // NORELEASE remove before 5.0.0GA
}
/** /**
* Returns the pipeline aggregator factory with which this parser is * Returns the pipeline aggregator factory with which this parser is
* associated. * associated.
@ -66,15 +57,6 @@ public abstract class PipelineAggregator implements Streamable {
*/ */
PipelineAggregatorBuilder<?> parse(String pipelineAggregatorName, QueryParseContext context) PipelineAggregatorBuilder<?> parse(String pipelineAggregatorName, QueryParseContext context)
throws IOException; throws IOException;
/**
* @return an empty {@link PipelineAggregatorBuilder} instance for this
* parser that can be used for deserialization
*/
default PipelineAggregatorBuilder<?> getFactoryPrototype() {
throw new UnsupportedOperationException(); // NORELEASE remove before 5.0.0GA
}
} }
private String name; private String name;

View File

@ -86,34 +86,12 @@ public abstract class PipelineAggregatorBuilder<PAB extends PipelineAggregatorBu
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
out.writeString(name); out.writeString(name);
out.writeStringArray(bucketsPaths); out.writeStringArray(bucketsPaths);
if (usesNewStyleSerialization()) { out.writeMap(metaData);
out.writeMap(metaData); doWriteTo(out);
doWriteTo(out);
} else {
doWriteTo(out);
out.writeMap(metaData);
}
} }
protected abstract void doWriteTo(StreamOutput out) throws IOException; protected abstract void doWriteTo(StreamOutput out) throws IOException;
protected boolean usesNewStyleSerialization() {
return false; // NORELEASE remove this before 5.0.0GA, when all the aggregations have been migrated
}
@Override
public PipelineAggregatorBuilder<PAB> readFrom(StreamInput in) throws IOException {
String name = in.readString();
String[] bucketsPaths = in.readStringArray();
PipelineAggregatorBuilder<PAB> factory = doReadFrom(name, bucketsPaths, in);
factory.metaData = in.readMap();
return factory;
}
protected PipelineAggregatorBuilder<PAB> doReadFrom(String name, String[] bucketsPaths, StreamInput in) throws IOException {
throw new UnsupportedOperationException(); // NORELEASE remove this before 5.0.0GA, when all the aggregations have been migrated
}
public String name() { public String name() {
return name; return name;
} }
@ -161,12 +139,6 @@ public abstract class PipelineAggregatorBuilder<PAB extends PipelineAggregatorBu
return bucketsPaths; return bucketsPaths;
} }
@Override
public String getWriteableName() {
assert false == usesNewStyleSerialization() : "Migrated aggregations should just return NAME";
return type;
}
@Override @Override
public final XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { public final XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject(getName()); builder.startObject(getName());

View File

@ -54,32 +54,13 @@ public abstract class BucketMetricsPipelineAggregatorBuilder<AF extends BucketMe
@Override @Override
protected final void doWriteTo(StreamOutput out) throws IOException { protected final void doWriteTo(StreamOutput out) throws IOException {
if (false == usesNewStyleSerialization()) {
innerWriteTo(out);
}
out.writeOptionalString(format); out.writeOptionalString(format);
gapPolicy.writeTo(out); gapPolicy.writeTo(out);
if (usesNewStyleSerialization()) { innerWriteTo(out);
innerWriteTo(out);
}
} }
protected abstract void innerWriteTo(StreamOutput out) throws IOException; protected abstract void innerWriteTo(StreamOutput out) throws IOException;
@Override
protected final PipelineAggregatorBuilder<AF> doReadFrom(String name, String[] bucketsPaths, StreamInput in) throws IOException {
BucketMetricsPipelineAggregatorBuilder<AF> factory = innerReadFrom(name, bucketsPaths, in);
factory.format = in.readOptionalString();
factory.gapPolicy = GapPolicy.readFrom(in);
return factory;
}
protected BucketMetricsPipelineAggregatorBuilder<AF> innerReadFrom(String name, String[] bucketsPaths, StreamInput in)
throws IOException {
throw new UnsupportedOperationException(); // NORELEASE remove before 5.0.0 GA
}
/** /**
* Sets the format to use on the output of this aggregation. * Sets the format to use on the output of this aggregation.
*/ */

View File

@ -53,11 +53,6 @@ public class AvgBucketPipelineAggregatorBuilder extends BucketMetricsPipelineAgg
// Do nothing, no extra state to write to stream // Do nothing, no extra state to write to stream
} }
@Override
protected boolean usesNewStyleSerialization() {
return true;
}
@Override @Override
protected PipelineAggregator createInternal(Map<String, Object> metaData) throws IOException { protected PipelineAggregator createInternal(Map<String, Object> metaData) throws IOException {
return new AvgBucketPipelineAggregator(name, bucketsPaths, gapPolicy(), formatter(), metaData); return new AvgBucketPipelineAggregator(name, bucketsPaths, gapPolicy(), formatter(), metaData);

View File

@ -53,11 +53,6 @@ public class MaxBucketPipelineAggregatorBuilder extends BucketMetricsPipelineAgg
// Do nothing, no extra state to write to stream // Do nothing, no extra state to write to stream
} }
@Override
protected boolean usesNewStyleSerialization() {
return true;
}
@Override @Override
protected PipelineAggregator createInternal(Map<String, Object> metaData) throws IOException { protected PipelineAggregator createInternal(Map<String, Object> metaData) throws IOException {
return new MaxBucketPipelineAggregator(name, bucketsPaths, gapPolicy(), formatter(), metaData); return new MaxBucketPipelineAggregator(name, bucketsPaths, gapPolicy(), formatter(), metaData);

View File

@ -53,11 +53,6 @@ public class MinBucketPipelineAggregatorBuilder extends BucketMetricsPipelineAgg
// Do nothing, no extra state to write to stream // Do nothing, no extra state to write to stream
} }
@Override
protected boolean usesNewStyleSerialization() {
return true;
}
@Override @Override
protected PipelineAggregator createInternal(Map<String, Object> metaData) throws IOException { protected PipelineAggregator createInternal(Map<String, Object> metaData) throws IOException {
return new MinBucketPipelineAggregator(name, bucketsPaths, gapPolicy(), formatter(), metaData); return new MinBucketPipelineAggregator(name, bucketsPaths, gapPolicy(), formatter(), metaData);

View File

@ -63,11 +63,6 @@ public class PercentilesBucketPipelineAggregatorBuilder
out.writeDoubleArray(percents); out.writeDoubleArray(percents);
} }
@Override
protected boolean usesNewStyleSerialization() {
return true;
}
/** /**
* Get the percentages to calculate percentiles for in this aggregation * Get the percentages to calculate percentiles for in this aggregation
*/ */

View File

@ -55,11 +55,6 @@ public class StatsBucketPipelineAggregatorBuilder extends BucketMetricsPipelineA
// Do nothing, no extra state to write to stream // Do nothing, no extra state to write to stream
} }
@Override
protected boolean usesNewStyleSerialization() {
return true;
}
@Override @Override
protected PipelineAggregator createInternal(Map<String, Object> metaData) throws IOException { protected PipelineAggregator createInternal(Map<String, Object> metaData) throws IOException {
return new StatsBucketPipelineAggregator(name, bucketsPaths, gapPolicy(), formatter(), metaData); return new StatsBucketPipelineAggregator(name, bucketsPaths, gapPolicy(), formatter(), metaData);

View File

@ -58,11 +58,6 @@ public class ExtendedStatsBucketPipelineAggregatorBuilder
out.writeDouble(sigma); out.writeDouble(sigma);
} }
@Override
protected boolean usesNewStyleSerialization() {
return true;
}
/** /**
* Set the value of sigma to use when calculating the standard deviation * Set the value of sigma to use when calculating the standard deviation
* bounds * bounds

View File

@ -53,11 +53,6 @@ public class SumBucketPipelineAggregatorBuilder extends BucketMetricsPipelineAgg
// Do nothing, no extra state to write to stream // Do nothing, no extra state to write to stream
} }
@Override
protected boolean usesNewStyleSerialization() {
return true;
}
@Override @Override
protected PipelineAggregator createInternal(Map<String, Object> metaData) throws IOException { protected PipelineAggregator createInternal(Map<String, Object> metaData) throws IOException {
return new SumBucketPipelineAggregator(name, bucketsPaths, gapPolicy(), formatter(), metaData); return new SumBucketPipelineAggregator(name, bucketsPaths, gapPolicy(), formatter(), metaData);

View File

@ -93,11 +93,6 @@ public class BucketScriptPipelineAggregatorBuilder extends PipelineAggregatorBui
gapPolicy.writeTo(out); gapPolicy.writeTo(out);
} }
@Override
protected boolean usesNewStyleSerialization() {
return true;
}
private static Map<String, String> convertToBucketsPathMap(String[] bucketsPaths) { private static Map<String, String> convertToBucketsPathMap(String[] bucketsPaths) {
Map<String, String> bucketsPathsMap = new HashMap<>(); Map<String, String> bucketsPathsMap = new HashMap<>();
for (int i = 0; i < bucketsPaths.length; i++) { for (int i = 0; i < bucketsPaths.length; i++) {

View File

@ -88,11 +88,6 @@ public class BucketSelectorPipelineAggregatorBuilder extends PipelineAggregatorB
gapPolicy.writeTo(out); gapPolicy.writeTo(out);
} }
@Override
protected boolean usesNewStyleSerialization() {
return true;
}
private static Map<String, String> convertToBucketsPathMap(String[] bucketsPaths) { private static Map<String, String> convertToBucketsPathMap(String[] bucketsPaths) {
Map<String, String> bucketsPathsMap = new HashMap<>(); Map<String, String> bucketsPathsMap = new HashMap<>();
for (int i = 0; i < bucketsPaths.length; i++) { for (int i = 0; i < bucketsPaths.length; i++) {

View File

@ -65,11 +65,6 @@ public class CumulativeSumPipelineAggregatorBuilder extends PipelineAggregatorBu
out.writeOptionalString(format); out.writeOptionalString(format);
} }
@Override
protected boolean usesNewStyleSerialization() {
return true;
}
/** /**
* Sets the format to use on the output of this aggregation. * Sets the format to use on the output of this aggregation.
*/ */

View File

@ -86,11 +86,6 @@ public class DerivativePipelineAggregatorBuilder extends PipelineAggregatorBuild
out.writeOptionalString(units); out.writeOptionalString(units);
} }
@Override
protected boolean usesNewStyleSerialization() {
return true;
}
public DerivativePipelineAggregatorBuilder format(String format) { public DerivativePipelineAggregatorBuilder format(String format) {
if (format == null) { if (format == null) {
throw new IllegalArgumentException("[format] must not be null: [" + name + "]"); throw new IllegalArgumentException("[format] must not be null: [" + name + "]");

View File

@ -93,11 +93,6 @@ public class MovAvgPipelineAggregatorBuilder extends PipelineAggregatorBuilder<M
out.writeOptionalBoolean(minimize); out.writeOptionalBoolean(minimize);
} }
@Override
protected boolean usesNewStyleSerialization() {
return true;
}
/** /**
* Sets the format to use on the output of this aggregation. * Sets the format to use on the output of this aggregation.
*/ */

View File

@ -72,11 +72,6 @@ public class SerialDiffPipelineAggregatorBuilder extends PipelineAggregatorBuild
out.writeVInt(lag); out.writeVInt(lag);
} }
@Override
protected boolean usesNewStyleSerialization() {
return true;
}
/** /**
* Sets the lag to use when calculating the serial difference. * Sets the lag to use when calculating the serial difference.
*/ */

View File

@ -122,8 +122,8 @@ public abstract class AbstractValuesSourceParser<VS extends ValuesSource>
valueType = ValueType.resolveForScript(parser.text()); valueType = ValueType.resolveForScript(parser.text());
if (targetValueType != null && valueType.isNotA(targetValueType)) { if (targetValueType != null && valueType.isNotA(targetValueType)) {
throw new ParsingException(parser.getTokenLocation(), throw new ParsingException(parser.getTokenLocation(),
type() + " aggregation [" + aggregationName + "] was configured with an incompatible value type [" "Aggregation [" + aggregationName + "] was configured with an incompatible value type ["
+ valueType + "]. [" + type() + "] aggregation can only work on value of type [" + valueType + "]. It can only work on value of type ["
+ targetValueType + "]"); + targetValueType + "]");
} }
} else if (!token(aggregationName, currentFieldName, token, parser, context.getParseFieldMatcher(), otherOptions)) { } else if (!token(aggregationName, currentFieldName, token, parser, context.getParseFieldMatcher(), otherOptions)) {

View File

@ -140,18 +140,8 @@ public abstract class ValuesSourceAggregatorBuilder<VS extends ValuesSource, AB
@Override @Override
protected final void doWriteTo(StreamOutput out) throws IOException { protected final void doWriteTo(StreamOutput out) throws IOException {
if (usesNewStyleSerialization()) { if (serializeTargetValueType()) {
if (serializeTargetValueType()) { out.writeOptionalWriteable(targetValueType);
out.writeOptionalWriteable(targetValueType);
}
} else {
valuesSourceType.writeTo(out);
boolean hasTargetValueType = targetValueType != null;
out.writeBoolean(hasTargetValueType);
if (hasTargetValueType) {
targetValueType.writeTo(out);
}
innerWriteTo(out);
} }
out.writeOptionalString(field); out.writeOptionalString(field);
boolean hasScript = script != null; boolean hasScript = script != null;
@ -171,9 +161,7 @@ public abstract class ValuesSourceAggregatorBuilder<VS extends ValuesSource, AB
if (hasTimeZone) { if (hasTimeZone) {
out.writeString(timeZone.getID()); out.writeString(timeZone.getID());
} }
if (usesNewStyleSerialization()) { innerWriteTo(out);
innerWriteTo(out);
}
} }
/** /**
@ -181,35 +169,6 @@ public abstract class ValuesSourceAggregatorBuilder<VS extends ValuesSource, AB
*/ */
protected abstract void innerWriteTo(StreamOutput out) throws IOException; protected abstract void innerWriteTo(StreamOutput out) throws IOException;
@SuppressWarnings("unchecked")
@Override
protected final AB doReadFrom(String name, StreamInput in) throws IOException {
ValuesSourceType valuesSourceType = ValuesSourceType.ANY.readFrom(in);
ValueType targetValueType = null;
if (in.readBoolean()) {
targetValueType = ValueType.readFromStream(in);
}
ValuesSourceAggregatorBuilder<VS, AB> factory = innerReadFrom(name, valuesSourceType, targetValueType, in);
factory.field = in.readOptionalString();
if (in.readBoolean()) {
factory.script = Script.readScript(in);
}
if (in.readBoolean()) {
factory.valueType = ValueType.readFromStream(in);
}
factory.format = in.readOptionalString();
factory.missing = in.readGenericValue();
if (in.readBoolean()) {
factory.timeZone = DateTimeZone.forID(in.readString());
}
return (AB) factory;
}
protected ValuesSourceAggregatorBuilder<VS, AB> innerReadFrom(String name, ValuesSourceType valuesSourceType,
ValueType targetValueType, StreamInput in) throws IOException {
throw new UnsupportedOperationException(); // NORELEASE remove when no longer overridden
}
/** /**
* Should this builder serialize its targetValueType? Defaults to false. All subclasses that override this to true should use the three * Should this builder serialize its targetValueType? Defaults to false. All subclasses that override this to true should use the three
* argument read constructor rather than the four argument version. * argument read constructor rather than the four argument version.