PipelineAggregatorBuilder.setMetaData is now chain able
This commit is contained in:
parent
ed3f7903f4
commit
d9c1e88ba9
|
@ -36,7 +36,8 @@ import java.util.Objects;
|
|||
* A factory that knows how to create an {@link PipelineAggregator} of a
|
||||
* specific type.
|
||||
*/
|
||||
public abstract class PipelineAggregatorBuilder extends ToXContentToBytes implements NamedWriteable<PipelineAggregatorBuilder>, ToXContent {
|
||||
public abstract class PipelineAggregatorBuilder<PAB extends PipelineAggregatorBuilder<PAB>> extends ToXContentToBytes
|
||||
implements NamedWriteable<PipelineAggregatorBuilder<PAB>>, ToXContent {
|
||||
|
||||
protected String name;
|
||||
protected String type;
|
||||
|
@ -79,7 +80,7 @@ public abstract class PipelineAggregatorBuilder extends ToXContentToBytes implem
|
|||
* configured)
|
||||
*/
|
||||
public final void validate(AggregatorFactory<?> parent, AggregatorFactory<?>[] factories,
|
||||
List<PipelineAggregatorBuilder> pipelineAggregatorFactories) {
|
||||
List<PipelineAggregatorBuilder<?>> pipelineAggregatorFactories) {
|
||||
doValidate(parent, factories, pipelineAggregatorFactories);
|
||||
}
|
||||
|
||||
|
@ -96,11 +97,13 @@ public abstract class PipelineAggregatorBuilder extends ToXContentToBytes implem
|
|||
}
|
||||
|
||||
public void doValidate(AggregatorFactory<?> parent, AggregatorFactory<?>[] factories,
|
||||
List<PipelineAggregatorBuilder> pipelineAggregatorFactories) {
|
||||
List<PipelineAggregatorBuilder<?>> pipelineAggregatorFactories) {
|
||||
}
|
||||
|
||||
public void setMetaData(Map<String, Object> metaData) {
|
||||
@SuppressWarnings("unchecked")
|
||||
public PAB setMetaData(Map<String, Object> metaData) {
|
||||
this.metaData = metaData;
|
||||
return (PAB) this;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
|
@ -127,15 +130,15 @@ public abstract class PipelineAggregatorBuilder extends ToXContentToBytes implem
|
|||
}
|
||||
|
||||
@Override
|
||||
public PipelineAggregatorBuilder readFrom(StreamInput in) throws IOException {
|
||||
public PipelineAggregatorBuilder<PAB> readFrom(StreamInput in) throws IOException {
|
||||
String name = in.readString();
|
||||
String[] bucketsPaths = in.readStringArray();
|
||||
PipelineAggregatorBuilder factory = doReadFrom(name, bucketsPaths, in);
|
||||
PipelineAggregatorBuilder<PAB> factory = doReadFrom(name, bucketsPaths, in);
|
||||
factory.metaData = in.readMap();
|
||||
return factory;
|
||||
}
|
||||
|
||||
protected abstract PipelineAggregatorBuilder doReadFrom(String name, String[] bucketsPaths, StreamInput in) throws IOException;
|
||||
protected abstract PipelineAggregatorBuilder<PAB> doReadFrom(String name, String[] bucketsPaths, StreamInput in) throws IOException;
|
||||
|
||||
@Override
|
||||
public final XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
|
@ -184,7 +187,8 @@ public abstract class PipelineAggregatorBuilder extends ToXContentToBytes implem
|
|||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
PipelineAggregatorBuilder other = (PipelineAggregatorBuilder) obj;
|
||||
@SuppressWarnings("unchecked")
|
||||
PipelineAggregatorBuilder<PAB> other = (PipelineAggregatorBuilder<PAB>) obj;
|
||||
if (!Objects.equals(name, other.name))
|
||||
return false;
|
||||
if (!Objects.equals(type, other.type))
|
||||
|
|
|
@ -35,7 +35,7 @@ import java.util.Map;
|
|||
import java.util.Objects;
|
||||
|
||||
public abstract class BucketMetricsPipelineAggregatorBuilder<AF extends BucketMetricsPipelineAggregatorBuilder<AF>>
|
||||
extends PipelineAggregatorBuilder {
|
||||
extends PipelineAggregatorBuilder<AF> {
|
||||
|
||||
private String format = null;
|
||||
private GapPolicy gapPolicy = GapPolicy.SKIP;
|
||||
|
@ -47,6 +47,7 @@ public abstract class BucketMetricsPipelineAggregatorBuilder<AF extends BucketMe
|
|||
/**
|
||||
* Sets the format to use on the output of this aggregation.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public AF format(String format) {
|
||||
this.format = format;
|
||||
return (AF) this;
|
||||
|
@ -70,6 +71,7 @@ public abstract class BucketMetricsPipelineAggregatorBuilder<AF extends BucketMe
|
|||
/**
|
||||
* Sets the gap policy to use for this aggregation.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public AF gapPolicy(GapPolicy gapPolicy) {
|
||||
this.gapPolicy = gapPolicy;
|
||||
return (AF) this;
|
||||
|
@ -87,7 +89,7 @@ public abstract class BucketMetricsPipelineAggregatorBuilder<AF extends BucketMe
|
|||
|
||||
@Override
|
||||
public void doValidate(AggregatorFactory<?> parent, AggregatorFactory<?>[] aggFactories,
|
||||
List<PipelineAggregatorBuilder> pipelineAggregatorFactories) {
|
||||
List<PipelineAggregatorBuilder<?>> pipelineAggregatorFactories) {
|
||||
if (bucketsPaths.length != 1) {
|
||||
throw new IllegalStateException(PipelineAggregator.Parser.BUCKETS_PATH.getPreferredName()
|
||||
+ " must contain a single entry for aggregation [" + name + "]");
|
||||
|
@ -109,14 +111,14 @@ public abstract class BucketMetricsPipelineAggregatorBuilder<AF extends BucketMe
|
|||
protected abstract XContentBuilder doXContentBody(XContentBuilder builder, Params params) throws IOException;
|
||||
|
||||
@Override
|
||||
protected final PipelineAggregatorBuilder doReadFrom(String name, String[] bucketsPaths, StreamInput in) throws IOException {
|
||||
BucketMetricsPipelineAggregatorBuilder factory = innerReadFrom(name, bucketsPaths, in);
|
||||
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 abstract BucketMetricsPipelineAggregatorBuilder innerReadFrom(String name, String[] bucketsPaths, StreamInput in)
|
||||
protected abstract BucketMetricsPipelineAggregatorBuilder<AF> innerReadFrom(String name, String[] bucketsPaths, StreamInput in)
|
||||
throws IOException;
|
||||
|
||||
@Override
|
||||
|
@ -137,12 +139,13 @@ public abstract class BucketMetricsPipelineAggregatorBuilder<AF extends BucketMe
|
|||
|
||||
@Override
|
||||
protected final boolean doEquals(Object obj) {
|
||||
BucketMetricsPipelineAggregatorBuilder other = (BucketMetricsPipelineAggregatorBuilder) obj;
|
||||
@SuppressWarnings("unchecked")
|
||||
BucketMetricsPipelineAggregatorBuilder<AF> other = (BucketMetricsPipelineAggregatorBuilder<AF>) obj;
|
||||
return Objects.equals(format, other.format)
|
||||
&& Objects.equals(gapPolicy, other.gapPolicy)
|
||||
&& innerEquals(other);
|
||||
}
|
||||
|
||||
protected abstract boolean innerEquals(BucketMetricsPipelineAggregatorBuilder other);
|
||||
protected abstract boolean innerEquals(BucketMetricsPipelineAggregatorBuilder<AF> other);
|
||||
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@ public class AvgBucketPipelineAggregator extends BucketMetricsPipelineAggregator
|
|||
|
||||
@Override
|
||||
public void doValidate(AggregatorFactory<?> parent, AggregatorFactory<?>[] aggFactories,
|
||||
List<PipelineAggregatorBuilder> pipelineAggregatorFactories) {
|
||||
List<PipelineAggregatorBuilder<?>> pipelineAggregatorFactories) {
|
||||
if (bucketsPaths.length != 1) {
|
||||
throw new IllegalStateException(PipelineAggregator.Parser.BUCKETS_PATH.getPreferredName()
|
||||
+ " must contain a single entry for aggregation [" + name + "]");
|
||||
|
@ -121,7 +121,7 @@ public class AvgBucketPipelineAggregator extends BucketMetricsPipelineAggregator
|
|||
}
|
||||
|
||||
@Override
|
||||
protected BucketMetricsPipelineAggregatorBuilder innerReadFrom(String name, String[] bucketsPaths, StreamInput in) throws IOException {
|
||||
protected AvgBucketPipelineAggregatorBuilder innerReadFrom(String name, String[] bucketsPaths, StreamInput in) throws IOException {
|
||||
return new AvgBucketPipelineAggregatorBuilder(name, bucketsPaths);
|
||||
}
|
||||
|
||||
|
@ -136,7 +136,7 @@ public class AvgBucketPipelineAggregator extends BucketMetricsPipelineAggregator
|
|||
}
|
||||
|
||||
@Override
|
||||
protected boolean innerEquals(BucketMetricsPipelineAggregatorBuilder other) {
|
||||
protected boolean innerEquals(BucketMetricsPipelineAggregatorBuilder<AvgBucketPipelineAggregatorBuilder> other) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -116,7 +116,7 @@ public class MaxBucketPipelineAggregator extends BucketMetricsPipelineAggregator
|
|||
|
||||
@Override
|
||||
public void doValidate(AggregatorFactory<?> parent, AggregatorFactory<?>[] aggFactories,
|
||||
List<PipelineAggregatorBuilder> pipelineAggregatorFactories) {
|
||||
List<PipelineAggregatorBuilder<?>> pipelineAggregatorFactories) {
|
||||
if (bucketsPaths.length != 1) {
|
||||
throw new IllegalStateException(PipelineAggregator.Parser.BUCKETS_PATH.getPreferredName()
|
||||
+ " must contain a single entry for aggregation [" + name + "]");
|
||||
|
@ -129,7 +129,7 @@ public class MaxBucketPipelineAggregator extends BucketMetricsPipelineAggregator
|
|||
}
|
||||
|
||||
@Override
|
||||
protected BucketMetricsPipelineAggregatorBuilder innerReadFrom(String name, String[] bucketsPaths, StreamInput in)
|
||||
protected MaxBucketPipelineAggregatorBuilder innerReadFrom(String name, String[] bucketsPaths, StreamInput in)
|
||||
throws IOException {
|
||||
return new MaxBucketPipelineAggregatorBuilder(name, bucketsPaths);
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ public class MaxBucketPipelineAggregator extends BucketMetricsPipelineAggregator
|
|||
}
|
||||
|
||||
@Override
|
||||
protected boolean innerEquals(BucketMetricsPipelineAggregatorBuilder other) {
|
||||
protected boolean innerEquals(BucketMetricsPipelineAggregatorBuilder<MaxBucketPipelineAggregatorBuilder> other) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -117,7 +117,7 @@ public class MinBucketPipelineAggregator extends BucketMetricsPipelineAggregator
|
|||
|
||||
@Override
|
||||
public void doValidate(AggregatorFactory<?> parent, AggregatorFactory<?>[] aggFactories,
|
||||
List<PipelineAggregatorBuilder> pipelineAggregatorFactories) {
|
||||
List<PipelineAggregatorBuilder<?>> pipelineAggregatorFactories) {
|
||||
if (bucketsPaths.length != 1) {
|
||||
throw new IllegalStateException(PipelineAggregator.Parser.BUCKETS_PATH.getPreferredName()
|
||||
+ " must contain a single entry for aggregation [" + name + "]");
|
||||
|
@ -130,7 +130,7 @@ public class MinBucketPipelineAggregator extends BucketMetricsPipelineAggregator
|
|||
}
|
||||
|
||||
@Override
|
||||
protected BucketMetricsPipelineAggregatorBuilder innerReadFrom(String name, String[] bucketsPaths, StreamInput in)
|
||||
protected MinBucketPipelineAggregatorBuilder innerReadFrom(String name, String[] bucketsPaths, StreamInput in)
|
||||
throws IOException {
|
||||
return new MinBucketPipelineAggregatorBuilder(name, bucketsPaths);
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ public class MinBucketPipelineAggregator extends BucketMetricsPipelineAggregator
|
|||
}
|
||||
|
||||
@Override
|
||||
protected boolean innerEquals(BucketMetricsPipelineAggregatorBuilder other) {
|
||||
protected boolean innerEquals(BucketMetricsPipelineAggregatorBuilder<MinBucketPipelineAggregatorBuilder> other) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -170,7 +170,7 @@ public class PercentilesBucketPipelineAggregator extends BucketMetricsPipelineAg
|
|||
|
||||
@Override
|
||||
public void doValidate(AggregatorFactory<?> parent, AggregatorFactory<?>[] aggFactories,
|
||||
List<PipelineAggregatorBuilder> pipelineAggregatorFactories) {
|
||||
List<PipelineAggregatorBuilder<?>> pipelineAggregatorFactories) {
|
||||
if (bucketsPaths.length != 1) {
|
||||
throw new IllegalStateException(PipelineAggregator.Parser.BUCKETS_PATH.getPreferredName()
|
||||
+ " must contain a single entry for aggregation [" + name + "]");
|
||||
|
@ -193,7 +193,7 @@ public class PercentilesBucketPipelineAggregator extends BucketMetricsPipelineAg
|
|||
}
|
||||
|
||||
@Override
|
||||
protected BucketMetricsPipelineAggregatorBuilder innerReadFrom(String name, String[] bucketsPaths, StreamInput in)
|
||||
protected PercentilesBucketPipelineAggregatorBuilder innerReadFrom(String name, String[] bucketsPaths, StreamInput in)
|
||||
throws IOException {
|
||||
PercentilesBucketPipelineAggregatorBuilder factory = new PercentilesBucketPipelineAggregatorBuilder(name, bucketsPaths);
|
||||
factory.percents = in.readDoubleArray();
|
||||
|
@ -211,7 +211,7 @@ public class PercentilesBucketPipelineAggregator extends BucketMetricsPipelineAg
|
|||
}
|
||||
|
||||
@Override
|
||||
protected boolean innerEquals(BucketMetricsPipelineAggregatorBuilder obj) {
|
||||
protected boolean innerEquals(BucketMetricsPipelineAggregatorBuilder<PercentilesBucketPipelineAggregatorBuilder> obj) {
|
||||
PercentilesBucketPipelineAggregatorBuilder other = (PercentilesBucketPipelineAggregatorBuilder) obj;
|
||||
return Objects.deepEquals(percents, other.percents);
|
||||
}
|
||||
|
|
|
@ -115,7 +115,7 @@ public class StatsBucketPipelineAggregator extends BucketMetricsPipelineAggregat
|
|||
|
||||
@Override
|
||||
public void doValidate(AggregatorFactory<?> parent, AggregatorFactory<?>[] aggFactories,
|
||||
List<PipelineAggregatorBuilder> pipelineAggregatorFactories) {
|
||||
List<PipelineAggregatorBuilder<?>> pipelineAggregatorFactories) {
|
||||
if (bucketsPaths.length != 1) {
|
||||
throw new IllegalStateException(Parser.BUCKETS_PATH.getPreferredName()
|
||||
+ " must contain a single entry for aggregation [" + name + "]");
|
||||
|
@ -128,7 +128,7 @@ public class StatsBucketPipelineAggregator extends BucketMetricsPipelineAggregat
|
|||
}
|
||||
|
||||
@Override
|
||||
protected BucketMetricsPipelineAggregatorBuilder innerReadFrom(String name, String[] bucketsPaths, StreamInput in)
|
||||
protected StatsBucketPipelineAggregatorBuilder innerReadFrom(String name, String[] bucketsPaths, StreamInput in)
|
||||
throws IOException {
|
||||
return new StatsBucketPipelineAggregatorBuilder(name, bucketsPaths);
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ public class StatsBucketPipelineAggregator extends BucketMetricsPipelineAggregat
|
|||
}
|
||||
|
||||
@Override
|
||||
protected boolean innerEquals(BucketMetricsPipelineAggregatorBuilder other) {
|
||||
protected boolean innerEquals(BucketMetricsPipelineAggregatorBuilder<StatsBucketPipelineAggregatorBuilder> other) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -143,7 +143,7 @@ public class ExtendedStatsBucketPipelineAggregator extends BucketMetricsPipeline
|
|||
|
||||
@Override
|
||||
public void doValidate(AggregatorFactory<?> parent, AggregatorFactory<?>[] aggFactories,
|
||||
List<PipelineAggregatorBuilder> pipelineAggregatorFactories) {
|
||||
List<PipelineAggregatorBuilder<?>> pipelineAggregatorFactories) {
|
||||
if (bucketsPaths.length != 1) {
|
||||
throw new IllegalStateException(Parser.BUCKETS_PATH.getPreferredName()
|
||||
+ " must contain a single entry for aggregation [" + name + "]");
|
||||
|
@ -162,7 +162,7 @@ public class ExtendedStatsBucketPipelineAggregator extends BucketMetricsPipeline
|
|||
}
|
||||
|
||||
@Override
|
||||
protected BucketMetricsPipelineAggregatorBuilder innerReadFrom(String name, String[] bucketsPaths, StreamInput in)
|
||||
protected ExtendedStatsBucketPipelineAggregatorBuilder innerReadFrom(String name, String[] bucketsPaths, StreamInput in)
|
||||
throws IOException {
|
||||
ExtendedStatsBucketPipelineAggregatorBuilder factory = new ExtendedStatsBucketPipelineAggregatorBuilder(name, bucketsPaths);
|
||||
factory.sigma = in.readDouble();
|
||||
|
@ -180,7 +180,7 @@ public class ExtendedStatsBucketPipelineAggregator extends BucketMetricsPipeline
|
|||
}
|
||||
|
||||
@Override
|
||||
protected boolean innerEquals(BucketMetricsPipelineAggregatorBuilder obj) {
|
||||
protected boolean innerEquals(BucketMetricsPipelineAggregatorBuilder<ExtendedStatsBucketPipelineAggregatorBuilder> obj) {
|
||||
ExtendedStatsBucketPipelineAggregatorBuilder other = (ExtendedStatsBucketPipelineAggregatorBuilder) obj;
|
||||
return Objects.equals(sigma, other.sigma);
|
||||
}
|
||||
|
|
|
@ -105,7 +105,7 @@ public class SumBucketPipelineAggregator extends BucketMetricsPipelineAggregator
|
|||
|
||||
@Override
|
||||
public void doValidate(AggregatorFactory<?> parent, AggregatorFactory<?>[] aggFactories,
|
||||
List<PipelineAggregatorBuilder> pipelineAggregatorFactories) {
|
||||
List<PipelineAggregatorBuilder<?>> pipelineAggregatorFactories) {
|
||||
if (bucketsPaths.length != 1) {
|
||||
throw new IllegalStateException(PipelineAggregator.Parser.BUCKETS_PATH.getPreferredName()
|
||||
+ " must contain a single entry for aggregation [" + name + "]");
|
||||
|
@ -118,7 +118,7 @@ public class SumBucketPipelineAggregator extends BucketMetricsPipelineAggregator
|
|||
}
|
||||
|
||||
@Override
|
||||
protected BucketMetricsPipelineAggregatorBuilder innerReadFrom(String name, String[] bucketsPaths, StreamInput in)
|
||||
protected SumBucketPipelineAggregatorBuilder innerReadFrom(String name, String[] bucketsPaths, StreamInput in)
|
||||
throws IOException {
|
||||
return new SumBucketPipelineAggregatorBuilder(name, bucketsPaths);
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ public class SumBucketPipelineAggregator extends BucketMetricsPipelineAggregator
|
|||
}
|
||||
|
||||
@Override
|
||||
protected boolean innerEquals(BucketMetricsPipelineAggregatorBuilder other) {
|
||||
protected boolean innerEquals(BucketMetricsPipelineAggregatorBuilder<SumBucketPipelineAggregatorBuilder> other) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -160,7 +160,7 @@ public class BucketScriptPipelineAggregator extends PipelineAggregator {
|
|||
bucketsPathsMap = (Map<String, String>) in.readGenericValue();
|
||||
}
|
||||
|
||||
public static class BucketScriptPipelineAggregatorBuilder extends PipelineAggregatorBuilder {
|
||||
public static class BucketScriptPipelineAggregatorBuilder extends PipelineAggregatorBuilder<BucketScriptPipelineAggregatorBuilder> {
|
||||
|
||||
static final BucketScriptPipelineAggregatorBuilder PROTOTYPE = new BucketScriptPipelineAggregatorBuilder("", Collections.emptyMap(),
|
||||
new Script(""));
|
||||
|
@ -254,7 +254,7 @@ public class BucketScriptPipelineAggregator extends PipelineAggregator {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected PipelineAggregatorBuilder doReadFrom(String name, String[] bucketsPaths, StreamInput in) throws IOException {
|
||||
protected BucketScriptPipelineAggregatorBuilder doReadFrom(String name, String[] bucketsPaths, StreamInput in) throws IOException {
|
||||
Map<String, String> bucketsPathsMap = new HashMap<String, String>();
|
||||
int mapSize = in.readVInt();
|
||||
for (int i = 0; i < mapSize; i++) {
|
||||
|
|
|
@ -111,7 +111,7 @@ public class CumulativeSumPipelineAggregator extends PipelineAggregator {
|
|||
ValueFormatterStreams.writeOptional(formatter, out);
|
||||
}
|
||||
|
||||
public static class CumulativeSumPipelineAggregatorBuilder extends PipelineAggregatorBuilder {
|
||||
public static class CumulativeSumPipelineAggregatorBuilder extends PipelineAggregatorBuilder<CumulativeSumPipelineAggregatorBuilder> {
|
||||
|
||||
static final CumulativeSumPipelineAggregatorBuilder PROTOTYPE = new CumulativeSumPipelineAggregatorBuilder("", "");
|
||||
|
||||
|
@ -157,7 +157,8 @@ public class CumulativeSumPipelineAggregator extends PipelineAggregator {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void doValidate(AggregatorFactory<?> parent, AggregatorFactory<?>[] aggFactories, List<PipelineAggregatorBuilder> pipelineAggregatorFactories) {
|
||||
public void doValidate(AggregatorFactory<?> parent, AggregatorFactory<?>[] aggFactories,
|
||||
List<PipelineAggregatorBuilder<?>> pipelineAggregatorFactories) {
|
||||
if (bucketsPaths.length != 1) {
|
||||
throw new IllegalStateException(PipelineAggregator.Parser.BUCKETS_PATH.getPreferredName()
|
||||
+ " must contain a single entry for aggregation [" + name + "]");
|
||||
|
@ -183,7 +184,8 @@ public class CumulativeSumPipelineAggregator extends PipelineAggregator {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected final PipelineAggregatorBuilder doReadFrom(String name, String[] bucketsPaths, StreamInput in) throws IOException {
|
||||
protected final CumulativeSumPipelineAggregatorBuilder doReadFrom(String name, String[] bucketsPaths, StreamInput in)
|
||||
throws IOException {
|
||||
CumulativeSumPipelineAggregatorBuilder factory = new CumulativeSumPipelineAggregatorBuilder(name, bucketsPaths);
|
||||
factory.format = in.readOptionalString();
|
||||
return factory;
|
||||
|
|
|
@ -159,7 +159,7 @@ public class DerivativePipelineAggregator extends PipelineAggregator {
|
|||
}
|
||||
}
|
||||
|
||||
public static class DerivativePipelineAggregatorBuilder extends PipelineAggregatorBuilder {
|
||||
public static class DerivativePipelineAggregatorBuilder extends PipelineAggregatorBuilder<DerivativePipelineAggregatorBuilder> {
|
||||
|
||||
static final DerivativePipelineAggregatorBuilder PROTOTYPE = new DerivativePipelineAggregatorBuilder("", "");
|
||||
|
||||
|
@ -243,7 +243,8 @@ public class DerivativePipelineAggregator extends PipelineAggregator {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void doValidate(AggregatorFactory<?> parent, AggregatorFactory<?>[] aggFactories, List<PipelineAggregatorBuilder> pipelineAggregatoractories) {
|
||||
public void doValidate(AggregatorFactory<?> parent, AggregatorFactory<?>[] aggFactories,
|
||||
List<PipelineAggregatorBuilder<?>> pipelineAggregatoractories) {
|
||||
if (bucketsPaths.length != 1) {
|
||||
throw new IllegalStateException(PipelineAggregator.Parser.BUCKETS_PATH.getPreferredName()
|
||||
+ " must contain a single entry for aggregation [" + name + "]");
|
||||
|
@ -261,7 +262,7 @@ public class DerivativePipelineAggregator extends PipelineAggregator {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected PipelineAggregatorBuilder doReadFrom(String name, String[] bucketsPaths, StreamInput in) throws IOException {
|
||||
protected DerivativePipelineAggregatorBuilder doReadFrom(String name, String[] bucketsPaths, StreamInput in) throws IOException {
|
||||
DerivativePipelineAggregatorBuilder factory = new DerivativePipelineAggregatorBuilder(name, bucketsPaths);
|
||||
factory.format = in.readOptionalString();
|
||||
if (in.readBoolean()) {
|
||||
|
|
|
@ -138,7 +138,7 @@ public class BucketSelectorPipelineAggregator extends PipelineAggregator {
|
|||
bucketsPathsMap = (Map<String, String>) in.readGenericValue();
|
||||
}
|
||||
|
||||
public static class BucketSelectorPipelineAggregatorBuilder extends PipelineAggregatorBuilder {
|
||||
public static class BucketSelectorPipelineAggregatorBuilder extends PipelineAggregatorBuilder<BucketSelectorPipelineAggregatorBuilder> {
|
||||
|
||||
static final BucketSelectorPipelineAggregatorBuilder PROTOTYPE = new BucketSelectorPipelineAggregatorBuilder("",
|
||||
Collections.emptyMap(), new Script(""));
|
||||
|
@ -202,7 +202,8 @@ public class BucketSelectorPipelineAggregator extends PipelineAggregator {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected PipelineAggregatorBuilder doReadFrom(String name, String[] bucketsPaths, StreamInput in) throws IOException {
|
||||
protected BucketSelectorPipelineAggregatorBuilder doReadFrom(String name, String[] bucketsPaths, StreamInput in)
|
||||
throws IOException {
|
||||
Map<String, String> bucketsPathsMap = new HashMap<String, String>();
|
||||
int mapSize = in.readVInt();
|
||||
for (int i = 0; i < mapSize; i++) {
|
||||
|
|
|
@ -279,7 +279,7 @@ public class MovAvgPipelineAggregator extends PipelineAggregator {
|
|||
|
||||
}
|
||||
|
||||
public static class MovAvgPipelineAggregatorBuilder extends PipelineAggregatorBuilder {
|
||||
public static class MovAvgPipelineAggregatorBuilder extends PipelineAggregatorBuilder<MovAvgPipelineAggregatorBuilder> {
|
||||
|
||||
static final MovAvgPipelineAggregatorBuilder PROTOTYPE = new MovAvgPipelineAggregatorBuilder("", "");
|
||||
|
||||
|
@ -462,7 +462,7 @@ public class MovAvgPipelineAggregator extends PipelineAggregator {
|
|||
|
||||
@Override
|
||||
public void doValidate(AggregatorFactory<?> parent, AggregatorFactory<?>[] aggFactories,
|
||||
List<PipelineAggregatorBuilder> pipelineAggregatoractories) {
|
||||
List<PipelineAggregatorBuilder<?>> pipelineAggregatoractories) {
|
||||
if (minimize != null && minimize && !model.canBeMinimized()) {
|
||||
// If the user asks to minimize, but this model doesn't support
|
||||
// it, throw exception
|
||||
|
@ -502,7 +502,7 @@ public class MovAvgPipelineAggregator extends PipelineAggregator {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected PipelineAggregatorBuilder doReadFrom(String name, String[] bucketsPaths, StreamInput in) throws IOException {
|
||||
protected MovAvgPipelineAggregatorBuilder doReadFrom(String name, String[] bucketsPaths, StreamInput in) throws IOException {
|
||||
MovAvgPipelineAggregatorBuilder factory = new MovAvgPipelineAggregatorBuilder(name, bucketsPaths);
|
||||
factory.format = in.readOptionalString();
|
||||
factory.gapPolicy = GapPolicy.readFrom(in);
|
||||
|
|
|
@ -145,7 +145,7 @@ public class SerialDiffPipelineAggregator extends PipelineAggregator {
|
|||
out.writeVInt(lag);
|
||||
}
|
||||
|
||||
public static class SerialDiffPipelineAggregatorBuilder extends PipelineAggregatorBuilder {
|
||||
public static class SerialDiffPipelineAggregatorBuilder extends PipelineAggregatorBuilder<SerialDiffPipelineAggregatorBuilder> {
|
||||
|
||||
static final SerialDiffPipelineAggregatorBuilder PROTOTYPE = new SerialDiffPipelineAggregatorBuilder("", "");
|
||||
|
||||
|
@ -239,7 +239,7 @@ public class SerialDiffPipelineAggregator extends PipelineAggregator {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected PipelineAggregatorBuilder doReadFrom(String name, String[] bucketsPaths, StreamInput in) throws IOException {
|
||||
protected SerialDiffPipelineAggregatorBuilder doReadFrom(String name, String[] bucketsPaths, StreamInput in) throws IOException {
|
||||
SerialDiffPipelineAggregatorBuilder factory = new SerialDiffPipelineAggregatorBuilder(name, bucketsPaths);
|
||||
factory.format = in.readOptionalString();
|
||||
factory.gapPolicy = GapPolicy.readFrom(in);
|
||||
|
|
|
@ -24,7 +24,6 @@ import org.elasticsearch.action.search.SearchResponse;
|
|||
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
||||
import org.elasticsearch.search.aggregations.metrics.sum.Sum;
|
||||
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.InternalBucketMetricValue;
|
||||
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.max.MaxBucketPipelineAggregator.MaxBucketPipelineAggregatorBuilder;
|
||||
import org.elasticsearch.test.ESIntegTestCase;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
@ -65,9 +64,6 @@ public class MetaDataIT extends ESIntegTestCase {
|
|||
put("complex", nestedMetaData);
|
||||
}};
|
||||
|
||||
// NORELEASE make setMetadata return the builder so it can be chained
|
||||
MaxBucketPipelineAggregatorBuilder maxBucketBuilder = maxBucket("the_max_bucket", "the_terms>the_sum");
|
||||
maxBucketBuilder.setMetaData(metaData);
|
||||
SearchResponse response = client().prepareSearch("idx")
|
||||
.addAggregation(
|
||||
terms("the_terms")
|
||||
|
@ -79,7 +75,7 @@ public class MetaDataIT extends ESIntegTestCase {
|
|||
.field("value")
|
||||
)
|
||||
)
|
||||
.addAggregation(maxBucketBuilder)
|
||||
.addAggregation(maxBucket("the_max_bucket", "the_terms>the_sum").setMetaData(metaData))
|
||||
.execute().actionGet();
|
||||
|
||||
assertSearchResponse(response);
|
||||
|
|
Loading…
Reference in New Issue