Renames PipelineAggregatorFactory to PipelineAggregatorBuilder

Also renames all the implementations appropriately
This commit is contained in:
Colin Goodheart-Smithe 2016-02-09 17:28:45 +00:00
parent 2d1f97beae
commit 37ce7406d7
55 changed files with 422 additions and 384 deletions

View File

@ -27,7 +27,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.search.aggregations.AggregatorBuilder;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorFactory;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilder;
import org.elasticsearch.search.highlight.HighlightBuilder;
import org.elasticsearch.search.sort.SortBuilder;
@ -163,9 +163,9 @@ public class PercolateRequestBuilder extends BroadcastOperationRequestBuilder<Pe
/**
* Delegates to
* {@link PercolateSourceBuilder#addAggregation(PipelineAggregatorFactory)}
* {@link PercolateSourceBuilder#addAggregation(PipelineAggregatorBuilder)}
*/
public PercolateRequestBuilder addAggregation(PipelineAggregatorFactory aggregationBuilder) {
public PercolateRequestBuilder addAggregation(PipelineAggregatorBuilder aggregationBuilder) {
sourceBuilder().addAggregation(aggregationBuilder);
return this;
}

View File

@ -30,7 +30,7 @@ import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.search.aggregations.AggregatorBuilder;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorFactory;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilder;
import org.elasticsearch.search.highlight.HighlightBuilder;
import org.elasticsearch.search.sort.ScoreSortBuilder;
import org.elasticsearch.search.sort.SortBuilder;
@ -53,7 +53,7 @@ public class PercolateSourceBuilder extends ToXContentToBytes {
private Boolean trackScores;
private HighlightBuilder highlightBuilder;
private List<AggregatorBuilder<?>> aggregationFactorys;
private List<PipelineAggregatorFactory> pipelineAggregationFactorys;
private List<PipelineAggregatorBuilder> pipelineAggregationFactorys;
/**
* Sets the document to run the percolate queries against.
@ -136,7 +136,7 @@ public class PercolateSourceBuilder extends ToXContentToBytes {
/**
* Add an aggregation definition.
*/
public PercolateSourceBuilder addAggregation(PipelineAggregatorFactory aggregationBuilder) {
public PercolateSourceBuilder addAggregation(PipelineAggregatorBuilder aggregationBuilder) {
if (pipelineAggregationFactorys == null) {
pipelineAggregationFactorys = new ArrayList<>();
}
@ -181,7 +181,7 @@ public class PercolateSourceBuilder extends ToXContentToBytes {
}
}
if (pipelineAggregationFactorys != null) {
for (PipelineAggregatorFactory aggregation : pipelineAggregationFactorys) {
for (PipelineAggregatorBuilder aggregation : pipelineAggregationFactorys) {
aggregation.toXContent(builder, params);
}
}

View File

@ -29,7 +29,7 @@ import org.elasticsearch.script.Script;
import org.elasticsearch.script.Template;
import org.elasticsearch.search.Scroll;
import org.elasticsearch.search.aggregations.AggregatorBuilder;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorFactory;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilder;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.elasticsearch.search.fetch.innerhits.InnerHitsBuilder;
import org.elasticsearch.search.highlight.HighlightBuilder;
@ -382,7 +382,7 @@ public class SearchRequestBuilder extends ActionRequestBuilder<SearchRequest, Se
/**
* Adds an aggregation to the search operation.
*/
public SearchRequestBuilder addAggregation(PipelineAggregatorFactory aggregation) {
public SearchRequestBuilder addAggregation(PipelineAggregatorBuilder aggregation) {
sourceBuilder().aggregation(aggregation);
return this;
}

View File

@ -40,7 +40,7 @@ import org.elasticsearch.index.query.functionscore.ScoreFunctionBuilder;
import org.elasticsearch.search.rescore.RescoreBuilder;
import org.elasticsearch.tasks.Task;
import org.elasticsearch.search.aggregations.AggregatorBuilder;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorFactory;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilder;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
@ -673,10 +673,10 @@ public abstract class StreamInput extends InputStream {
}
/**
* Reads a {@link PipelineAggregatorFactory} from the current stream
* Reads a {@link PipelineAggregatorBuilder} from the current stream
*/
public PipelineAggregatorFactory readPipelineAggregatorFactory() throws IOException {
return readNamedWriteable(PipelineAggregatorFactory.class);
public PipelineAggregatorBuilder readPipelineAggregatorFactory() throws IOException {
return readNamedWriteable(PipelineAggregatorBuilder.class);
}
/**

View File

@ -39,7 +39,7 @@ import org.elasticsearch.index.query.functionscore.ScoreFunctionBuilder;
import org.elasticsearch.search.rescore.RescoreBuilder;
import org.elasticsearch.tasks.Task;
import org.elasticsearch.search.aggregations.AggregatorBuilder;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorFactory;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilder;
import org.joda.time.ReadableInstant;
import java.io.EOFException;
@ -650,9 +650,9 @@ public abstract class StreamOutput extends OutputStream {
}
/**
* Writes a {@link PipelineAggregatorFactory} to the current stream
* Writes a {@link PipelineAggregatorBuilder} to the current stream
*/
public void writePipelineAggregatorFactory(PipelineAggregatorFactory factory) throws IOException {
public void writePipelineAggregatorFactory(PipelineAggregatorBuilder factory) throws IOException {
writeNamedWriteable(factory);
}

View File

@ -26,7 +26,7 @@ import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.search.aggregations.InternalAggregation.Type;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorFactory;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilder;
import org.elasticsearch.search.aggregations.support.AggregationContext;
import java.io.IOException;
@ -68,7 +68,7 @@ public abstract class AggregatorBuilder<AB extends AggregatorBuilder<AB>> extend
* Add a sub aggregation to this aggregation.
*/
@SuppressWarnings("unchecked")
public AB subAggregation(PipelineAggregatorFactory aggregation) {
public AB subAggregation(PipelineAggregatorBuilder aggregation) {
factoriesBuilder.addPipelineAggregator(aggregation);
return (AB) this;
}

View File

@ -24,7 +24,7 @@ import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorFactory;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilder;
import org.elasticsearch.search.aggregations.support.AggregationContext;
import org.elasticsearch.search.aggregations.support.AggregationPath;
import org.elasticsearch.search.aggregations.support.AggregationPath.PathElement;
@ -45,18 +45,18 @@ import java.util.Set;
public class AggregatorFactories {
public static final AggregatorFactories EMPTY = new AggregatorFactories(null, new AggregatorFactory<?>[0],
new ArrayList<PipelineAggregatorFactory>());
new ArrayList<PipelineAggregatorBuilder>());
private AggregatorFactory<?> parent;
private AggregatorFactory<?>[] factories;
private List<PipelineAggregatorFactory> pipelineAggregatorFactories;
private List<PipelineAggregatorBuilder> pipelineAggregatorFactories;
public static Builder builder() {
return new Builder();
}
private AggregatorFactories(AggregatorFactory<?> parent, AggregatorFactory<?>[] factories,
List<PipelineAggregatorFactory> pipelineAggregators) {
List<PipelineAggregatorBuilder> pipelineAggregators) {
this.parent = parent;
this.factories = factories;
this.pipelineAggregatorFactories = pipelineAggregators;
@ -64,7 +64,7 @@ public class AggregatorFactories {
public List<PipelineAggregator> createPipelineAggregators() throws IOException {
List<PipelineAggregator> pipelineAggregators = new ArrayList<>();
for (PipelineAggregatorFactory factory : this.pipelineAggregatorFactories) {
for (PipelineAggregatorBuilder factory : this.pipelineAggregatorFactories) {
pipelineAggregators.add(factory.create());
}
return pipelineAggregators;
@ -117,7 +117,7 @@ public class AggregatorFactories {
for (AggregatorFactory<?> factory : factories) {
factory.validate();
}
for (PipelineAggregatorFactory factory : pipelineAggregatorFactories) {
for (PipelineAggregatorBuilder factory : pipelineAggregatorFactories) {
factory.validate(parent, factories, pipelineAggregatorFactories);
}
}
@ -128,7 +128,7 @@ public class AggregatorFactories {
private final Set<String> names = new HashSet<>();
private final List<AggregatorBuilder<?>> aggregatorBuilders = new ArrayList<>();
private final List<PipelineAggregatorFactory> pipelineAggregatorFactories = new ArrayList<>();
private final List<PipelineAggregatorBuilder> pipelineAggregatorFactories = new ArrayList<>();
private boolean skipResolveOrder;
public Builder addAggregators(AggregatorFactories factories) {
@ -143,7 +143,7 @@ public class AggregatorFactories {
return this;
}
public Builder addPipelineAggregator(PipelineAggregatorFactory pipelineAggregatorFactory) {
public Builder addPipelineAggregator(PipelineAggregatorBuilder pipelineAggregatorFactory) {
this.pipelineAggregatorFactories.add(pipelineAggregatorFactory);
return this;
}
@ -160,7 +160,7 @@ public class AggregatorFactories {
if (aggregatorBuilders.isEmpty() && pipelineAggregatorFactories.isEmpty()) {
return EMPTY;
}
List<PipelineAggregatorFactory> orderedpipelineAggregators = null;
List<PipelineAggregatorBuilder> orderedpipelineAggregators = null;
if (skipResolveOrder) {
orderedpipelineAggregators = new ArrayList<>(pipelineAggregatorFactories);
} else {
@ -173,21 +173,21 @@ public class AggregatorFactories {
return new AggregatorFactories(parent, aggFactories, orderedpipelineAggregators);
}
private List<PipelineAggregatorFactory> resolvePipelineAggregatorOrder(List<PipelineAggregatorFactory> pipelineAggregatorFactories,
private List<PipelineAggregatorBuilder> resolvePipelineAggregatorOrder(List<PipelineAggregatorBuilder> pipelineAggregatorFactories,
List<AggregatorBuilder<?>> aggFactories) {
Map<String, PipelineAggregatorFactory> pipelineAggregatorFactoriesMap = new HashMap<>();
for (PipelineAggregatorFactory factory : pipelineAggregatorFactories) {
Map<String, PipelineAggregatorBuilder> pipelineAggregatorFactoriesMap = new HashMap<>();
for (PipelineAggregatorBuilder factory : pipelineAggregatorFactories) {
pipelineAggregatorFactoriesMap.put(factory.getName(), factory);
}
Map<String, AggregatorBuilder<?>> aggFactoriesMap = new HashMap<>();
for (AggregatorBuilder<?> aggFactory : aggFactories) {
aggFactoriesMap.put(aggFactory.name, aggFactory);
}
List<PipelineAggregatorFactory> orderedPipelineAggregatorrs = new LinkedList<>();
List<PipelineAggregatorFactory> unmarkedFactories = new ArrayList<PipelineAggregatorFactory>(pipelineAggregatorFactories);
Set<PipelineAggregatorFactory> temporarilyMarked = new HashSet<PipelineAggregatorFactory>();
List<PipelineAggregatorBuilder> orderedPipelineAggregatorrs = new LinkedList<>();
List<PipelineAggregatorBuilder> unmarkedFactories = new ArrayList<PipelineAggregatorBuilder>(pipelineAggregatorFactories);
Set<PipelineAggregatorBuilder> temporarilyMarked = new HashSet<PipelineAggregatorBuilder>();
while (!unmarkedFactories.isEmpty()) {
PipelineAggregatorFactory factory = unmarkedFactories.get(0);
PipelineAggregatorBuilder factory = unmarkedFactories.get(0);
resolvePipelineAggregatorOrder(aggFactoriesMap, pipelineAggregatorFactoriesMap, orderedPipelineAggregatorrs,
unmarkedFactories, temporarilyMarked, factory);
}
@ -195,9 +195,9 @@ public class AggregatorFactories {
}
private void resolvePipelineAggregatorOrder(Map<String, AggregatorBuilder<?>> aggFactoriesMap,
Map<String, PipelineAggregatorFactory> pipelineAggregatorFactoriesMap,
List<PipelineAggregatorFactory> orderedPipelineAggregators, List<PipelineAggregatorFactory> unmarkedFactories, Set<PipelineAggregatorFactory> temporarilyMarked,
PipelineAggregatorFactory factory) {
Map<String, PipelineAggregatorBuilder> pipelineAggregatorFactoriesMap,
List<PipelineAggregatorBuilder> orderedPipelineAggregators, List<PipelineAggregatorBuilder> unmarkedFactories, Set<PipelineAggregatorBuilder> temporarilyMarked,
PipelineAggregatorBuilder factory) {
if (temporarilyMarked.contains(factory)) {
throw new IllegalArgumentException("Cyclical dependancy found with pipeline aggregator [" + factory.getName() + "]");
} else if (unmarkedFactories.contains(factory)) {
@ -229,8 +229,8 @@ public class AggregatorFactories {
}
// Check the pipeline sub-aggregator factories
if (!foundSubFactory && (i == bucketsPathElements.size() - 1)) {
List<PipelineAggregatorFactory> subPipelineFactories = aggFactory.factoriesBuilder.pipelineAggregatorFactories;
for (PipelineAggregatorFactory subFactory : subPipelineFactories) {
List<PipelineAggregatorBuilder> subPipelineFactories = aggFactory.factoriesBuilder.pipelineAggregatorFactories;
for (PipelineAggregatorBuilder subFactory : subPipelineFactories) {
if (aggName.equals(subFactory.name())) {
foundSubFactory = true;
break;
@ -245,7 +245,7 @@ public class AggregatorFactories {
}
continue;
} else {
PipelineAggregatorFactory matchingFactory = pipelineAggregatorFactoriesMap.get(firstAggName);
PipelineAggregatorBuilder matchingFactory = pipelineAggregatorFactoriesMap.get(firstAggName);
if (matchingFactory != null) {
resolvePipelineAggregatorOrder(aggFactoriesMap, pipelineAggregatorFactoriesMap, orderedPipelineAggregators,
unmarkedFactories,
@ -265,7 +265,7 @@ public class AggregatorFactories {
return this.aggregatorBuilders.toArray(new AggregatorBuilder<?>[this.aggregatorBuilders.size()]);
}
List<PipelineAggregatorFactory> getPipelineAggregatorFactories() {
List<PipelineAggregatorBuilder> getPipelineAggregatorFactories() {
return this.pipelineAggregatorFactories;
}
@ -283,7 +283,7 @@ public class AggregatorFactories {
}
int pipelineFactoriesSize = in.readVInt();
for (int i = 0; i < pipelineFactoriesSize; i++) {
PipelineAggregatorFactory factory = in.readPipelineAggregatorFactory();
PipelineAggregatorBuilder factory = in.readPipelineAggregatorFactory();
builder.addPipelineAggregator(factory);
}
return builder;
@ -296,7 +296,7 @@ public class AggregatorFactories {
out.writeAggregatorFactory(factory);
}
out.writeVInt(this.pipelineAggregatorFactories.size());
for (PipelineAggregatorFactory factory : pipelineAggregatorFactories) {
for (PipelineAggregatorBuilder factory : pipelineAggregatorFactories) {
out.writePipelineAggregatorFactory(factory);
}
}
@ -310,7 +310,7 @@ public class AggregatorFactories {
}
}
if (pipelineAggregatorFactories != null) {
for (PipelineAggregatorFactory subAgg : pipelineAggregatorFactories) {
for (PipelineAggregatorBuilder subAgg : pipelineAggregatorFactories) {
subAgg.toXContent(builder, params);
}
}

View File

@ -25,7 +25,7 @@ import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.index.query.QueryParseContext;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorFactory;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilder;
import java.io.IOException;
import java.util.HashMap;
@ -67,8 +67,8 @@ public class AggregatorParsers {
Map<String, PipelineAggregator.Parser> pipelineAggregatorParsersBuilder = new HashMap<>(pipelineAggregatorParsers.size());
for (PipelineAggregator.Parser parser : pipelineAggregatorParsers) {
pipelineAggregatorParsersBuilder.put(parser.type(), parser);
PipelineAggregatorFactory factoryPrototype = parser.getFactoryPrototype();
namedWriteableRegistry.registerPrototype(PipelineAggregatorFactory.class, factoryPrototype);
PipelineAggregatorBuilder factoryPrototype = parser.getFactoryPrototype();
namedWriteableRegistry.registerPrototype(PipelineAggregatorBuilder.class, factoryPrototype);
}
this.pipelineAggregatorParsers = unmodifiableMap(pipelineAggregatorParsersBuilder);
}
@ -134,7 +134,7 @@ public class AggregatorParsers {
}
AggregatorBuilder<?> aggFactory = null;
PipelineAggregatorFactory pipelineAggregatorFactory = null;
PipelineAggregatorBuilder pipelineAggregatorFactory = null;
AggregatorFactories.Builder subFactories = null;
Map<String, Object> metaData = null;

View File

@ -39,7 +39,7 @@ public abstract class PipelineAggregator implements Streamable {
* Parses the pipeline aggregation request and creates the appropriate
* pipeline aggregator factory for it.
*
* @see PipelineAggregatorFactory
* @see PipelineAggregatorBuilder
*/
public static interface Parser {
@ -67,13 +67,13 @@ public abstract class PipelineAggregator implements Streamable {
* @throws java.io.IOException
* When parsing fails
*/
PipelineAggregatorFactory parse(String pipelineAggregatorName, XContentParser parser, QueryParseContext context) throws IOException;
PipelineAggregatorBuilder parse(String pipelineAggregatorName, XContentParser parser, QueryParseContext context) throws IOException;
/**
* @return an empty {@link PipelineAggregatorFactory} instance for this
* @return an empty {@link PipelineAggregatorBuilder} instance for this
* parser that can be used for deserialization
*/
PipelineAggregatorFactory getFactoryPrototype();
PipelineAggregatorBuilder getFactoryPrototype();
}

View File

@ -36,7 +36,7 @@ import java.util.Objects;
* A factory that knows how to create an {@link PipelineAggregator} of a
* specific type.
*/
public abstract class PipelineAggregatorFactory extends ToXContentToBytes implements NamedWriteable<PipelineAggregatorFactory>, ToXContent {
public abstract class PipelineAggregatorBuilder extends ToXContentToBytes implements NamedWriteable<PipelineAggregatorBuilder>, ToXContent {
protected String name;
protected String type;
@ -51,7 +51,7 @@ public abstract class PipelineAggregatorFactory extends ToXContentToBytes implem
* @param type
* The aggregation type
*/
public PipelineAggregatorFactory(String name, String type, String[] bucketsPaths) {
public PipelineAggregatorBuilder(String name, String type, String[] bucketsPaths) {
this.name = name;
this.type = type;
this.bucketsPaths = bucketsPaths;
@ -70,7 +70,7 @@ public abstract class PipelineAggregatorFactory extends ToXContentToBytes implem
* configured)
*/
public final void validate(AggregatorFactory<?> parent, AggregatorFactory<?>[] factories,
List<PipelineAggregatorFactory> pipelineAggregatorFactories) {
List<PipelineAggregatorBuilder> pipelineAggregatorFactories) {
doValidate(parent, factories, pipelineAggregatorFactories);
}
@ -87,7 +87,7 @@ public abstract class PipelineAggregatorFactory extends ToXContentToBytes implem
}
public void doValidate(AggregatorFactory<?> parent, AggregatorFactory<?>[] factories,
List<PipelineAggregatorFactory> pipelineAggregatorFactories) {
List<PipelineAggregatorBuilder> pipelineAggregatorFactories) {
}
public void setMetaData(Map<String, Object> metaData) {
@ -118,15 +118,15 @@ public abstract class PipelineAggregatorFactory extends ToXContentToBytes implem
}
@Override
public PipelineAggregatorFactory readFrom(StreamInput in) throws IOException {
public PipelineAggregatorBuilder readFrom(StreamInput in) throws IOException {
String name = in.readString();
String[] bucketsPaths = in.readStringArray();
PipelineAggregatorFactory factory = doReadFrom(name, bucketsPaths, in);
PipelineAggregatorBuilder factory = doReadFrom(name, bucketsPaths, in);
factory.metaData = in.readMap();
return factory;
}
protected abstract PipelineAggregatorFactory doReadFrom(String name, String[] bucketsPaths, StreamInput in) throws IOException;
protected abstract PipelineAggregatorBuilder doReadFrom(String name, String[] bucketsPaths, StreamInput in) throws IOException;
@Override
public final XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
@ -153,7 +153,7 @@ public abstract class PipelineAggregatorFactory extends ToXContentToBytes implem
}
/**
* @return <code>true</code> if the {@link PipelineAggregatorFactory}
* @return <code>true</code> if the {@link PipelineAggregatorBuilder}
* overrides the XContent rendering of the bucketPath option.
*/
protected boolean overrideBucketsPath() {
@ -175,7 +175,7 @@ public abstract class PipelineAggregatorFactory extends ToXContentToBytes implem
return false;
if (getClass() != obj.getClass())
return false;
PipelineAggregatorFactory other = (PipelineAggregatorFactory) obj;
PipelineAggregatorBuilder other = (PipelineAggregatorBuilder) obj;
if (!Objects.equals(name, other.name))
return false;
if (!Objects.equals(type, other.type))

View File

@ -41,65 +41,70 @@ public final class PipelineAggregatorBuilders {
private PipelineAggregatorBuilders() {
}
public static final DerivativePipelineAggregator.Factory derivative(String name, String bucketsPath) {
return new DerivativePipelineAggregator.Factory(name, bucketsPath);
public static final DerivativePipelineAggregator.DerivativePipelineAggregatorBuilder derivative(String name, String bucketsPath) {
return new DerivativePipelineAggregator.DerivativePipelineAggregatorBuilder(name, bucketsPath);
}
public static final MaxBucketPipelineAggregator.Factory maxBucket(String name, String bucketsPath) {
return new MaxBucketPipelineAggregator.Factory(name, bucketsPath);
public static final MaxBucketPipelineAggregator.MaxBucketPipelineAggregatorBuilder maxBucket(String name, String bucketsPath) {
return new MaxBucketPipelineAggregator.MaxBucketPipelineAggregatorBuilder(name, bucketsPath);
}
public static final MinBucketPipelineAggregator.Factory minBucket(String name, String bucketsPath) {
return new MinBucketPipelineAggregator.Factory(name, bucketsPath);
public static final MinBucketPipelineAggregator.MinBucketPipelineAggregatorBuilder minBucket(String name, String bucketsPath) {
return new MinBucketPipelineAggregator.MinBucketPipelineAggregatorBuilder(name, bucketsPath);
}
public static final AvgBucketPipelineAggregator.Factory avgBucket(String name, String bucketsPath) {
return new AvgBucketPipelineAggregator.Factory(name, bucketsPath);
public static final AvgBucketPipelineAggregator.AvgBucketPipelineAggregatorBuilder avgBucket(String name, String bucketsPath) {
return new AvgBucketPipelineAggregator.AvgBucketPipelineAggregatorBuilder(name, bucketsPath);
}
public static final SumBucketPipelineAggregator.Factory sumBucket(String name, String bucketsPath) {
return new SumBucketPipelineAggregator.Factory(name, bucketsPath);
public static final SumBucketPipelineAggregator.SumBucketPipelineAggregatorBuilder sumBucket(String name, String bucketsPath) {
return new SumBucketPipelineAggregator.SumBucketPipelineAggregatorBuilder(name, bucketsPath);
}
public static final StatsBucketPipelineAggregator.Factory statsBucket(String name, String bucketsPath) {
return new StatsBucketPipelineAggregator.Factory(name, bucketsPath);
public static final StatsBucketPipelineAggregator.StatsBucketPipelineAggregatorBuilder statsBucket(String name, String bucketsPath) {
return new StatsBucketPipelineAggregator.StatsBucketPipelineAggregatorBuilder(name, bucketsPath);
}
public static final ExtendedStatsBucketPipelineAggregator.Factory extendedStatsBucket(String name, String bucketsPath) {
return new ExtendedStatsBucketPipelineAggregator.Factory(name, bucketsPath);
public static final ExtendedStatsBucketPipelineAggregator.ExtendedStatsBucketPipelineAggregatorBuilder extendedStatsBucket(String name,
String bucketsPath) {
return new ExtendedStatsBucketPipelineAggregator.ExtendedStatsBucketPipelineAggregatorBuilder(name, bucketsPath);
}
public static final PercentilesBucketPipelineAggregator.Factory percentilesBucket(String name, String bucketsPath) {
return new PercentilesBucketPipelineAggregator.Factory(name, bucketsPath);
public static final PercentilesBucketPipelineAggregator.PercentilesBucketPipelineAggregatorBuilder percentilesBucket(String name,
String bucketsPath) {
return new PercentilesBucketPipelineAggregator.PercentilesBucketPipelineAggregatorBuilder(name, bucketsPath);
}
public static final MovAvgPipelineAggregator.Factory movingAvg(String name, String bucketsPath) {
return new MovAvgPipelineAggregator.Factory(name, bucketsPath);
public static final MovAvgPipelineAggregator.MovAvgPipelineAggregatorBuilder movingAvg(String name, String bucketsPath) {
return new MovAvgPipelineAggregator.MovAvgPipelineAggregatorBuilder(name, bucketsPath);
}
public static final BucketScriptPipelineAggregator.Factory bucketScript(String name, Map<String, String> bucketsPathsMap,
Script script) {
return new BucketScriptPipelineAggregator.Factory(name, bucketsPathsMap, script);
public static final BucketScriptPipelineAggregator.BucketScriptPipelineAggregatorBuilder bucketScript(String name,
Map<String, String> bucketsPathsMap, Script script) {
return new BucketScriptPipelineAggregator.BucketScriptPipelineAggregatorBuilder(name, bucketsPathsMap, script);
}
public static final BucketScriptPipelineAggregator.Factory bucketScript(String name, Script script, String... bucketsPaths) {
return new BucketScriptPipelineAggregator.Factory(name, script, bucketsPaths);
public static final BucketScriptPipelineAggregator.BucketScriptPipelineAggregatorBuilder bucketScript(String name, Script script,
String... bucketsPaths) {
return new BucketScriptPipelineAggregator.BucketScriptPipelineAggregatorBuilder(name, script, bucketsPaths);
}
public static final BucketSelectorPipelineAggregator.Factory bucketSelector(String name, Map<String, String> bucketsPathsMap,
Script script) {
return new BucketSelectorPipelineAggregator.Factory(name, bucketsPathsMap, script);
public static final BucketSelectorPipelineAggregator.BucketSelectorPipelineAggregatorBuilder bucketSelector(String name,
Map<String, String> bucketsPathsMap, Script script) {
return new BucketSelectorPipelineAggregator.BucketSelectorPipelineAggregatorBuilder(name, bucketsPathsMap, script);
}
public static final BucketSelectorPipelineAggregator.Factory bucketSelector(String name, Script script, String... bucketsPaths) {
return new BucketSelectorPipelineAggregator.Factory(name, script, bucketsPaths);
public static final BucketSelectorPipelineAggregator.BucketSelectorPipelineAggregatorBuilder bucketSelector(String name, Script script,
String... bucketsPaths) {
return new BucketSelectorPipelineAggregator.BucketSelectorPipelineAggregatorBuilder(name, script, bucketsPaths);
}
public static final CumulativeSumPipelineAggregator.Factory cumulativeSum(String name, String bucketsPath) {
return new CumulativeSumPipelineAggregator.Factory(name, bucketsPath);
public static final CumulativeSumPipelineAggregator.CumulativeSumPipelineAggregatorBuilder cumulativeSum(String name,
String bucketsPath) {
return new CumulativeSumPipelineAggregator.CumulativeSumPipelineAggregatorBuilder(name, bucketsPath);
}
public static final SerialDiffPipelineAggregator.Factory diff(String name, String bucketsPath) {
return new SerialDiffPipelineAggregator.Factory(name, bucketsPath);
public static final SerialDiffPipelineAggregator.SerialDiffPipelineAggregatorBuilder diff(String name, String bucketsPath) {
return new SerialDiffPipelineAggregator.SerialDiffPipelineAggregatorBuilder(name, bucketsPath);
}
}

View File

@ -25,7 +25,7 @@ import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.index.query.QueryParseContext;
import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorFactory;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilder;
import java.io.IOException;
import java.text.ParseException;
@ -46,7 +46,7 @@ public abstract class BucketMetricsParser implements PipelineAggregator.Parser {
}
@Override
public final PipelineAggregatorFactory parse(String pipelineAggregatorName, XContentParser parser, QueryParseContext context)
public final PipelineAggregatorBuilder parse(String pipelineAggregatorName, XContentParser parser, QueryParseContext context)
throws IOException {
XContentParser.Token token;
String currentFieldName = null;
@ -89,7 +89,7 @@ public abstract class BucketMetricsParser implements PipelineAggregator.Parser {
"Missing required field [" + BUCKETS_PATH.getPreferredName() + "] for aggregation [" + pipelineAggregatorName + "]");
}
BucketMetricsFactory factory = null;
BucketMetricsPipelineAggregatorBuilder factory = null;
try {
factory = buildFactory(pipelineAggregatorName, bucketsPaths[0], leftover);
if (format != null) {
@ -112,7 +112,7 @@ public abstract class BucketMetricsParser implements PipelineAggregator.Parser {
return factory;
}
protected abstract BucketMetricsFactory buildFactory(String pipelineAggregatorName, String bucketsPaths,
protected abstract BucketMetricsPipelineAggregatorBuilder buildFactory(String pipelineAggregatorName, String bucketsPaths,
Map<String, Object> unparsedParams) throws ParseException;
}

View File

@ -25,7 +25,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.search.aggregations.AggregatorFactory;
import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorFactory;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilder;
import org.elasticsearch.search.aggregations.support.format.ValueFormat;
import org.elasticsearch.search.aggregations.support.format.ValueFormatter;
@ -34,12 +34,13 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
public abstract class BucketMetricsFactory<AF extends BucketMetricsFactory<AF>> extends PipelineAggregatorFactory {
public abstract class BucketMetricsPipelineAggregatorBuilder<AF extends BucketMetricsPipelineAggregatorBuilder<AF>>
extends PipelineAggregatorBuilder {
private String format = null;
private GapPolicy gapPolicy = GapPolicy.SKIP;
public BucketMetricsFactory(String name, String type, String[] bucketsPaths) {
public BucketMetricsPipelineAggregatorBuilder(String name, String type, String[] bucketsPaths) {
super(name, type, bucketsPaths);
}
@ -86,7 +87,7 @@ public abstract class BucketMetricsFactory<AF extends BucketMetricsFactory<AF>>
@Override
public void doValidate(AggregatorFactory<?> parent, AggregatorFactory<?>[] aggFactories,
List<PipelineAggregatorFactory> pipelineAggregatorFactories) {
List<PipelineAggregatorBuilder> pipelineAggregatorFactories) {
if (bucketsPaths.length != 1) {
throw new IllegalStateException(PipelineAggregator.Parser.BUCKETS_PATH.getPreferredName()
+ " must contain a single entry for aggregation [" + name + "]");
@ -108,14 +109,15 @@ public abstract class BucketMetricsFactory<AF extends BucketMetricsFactory<AF>>
protected abstract XContentBuilder doXContentBody(XContentBuilder builder, Params params) throws IOException;
@Override
protected final PipelineAggregatorFactory doReadFrom(String name, String[] bucketsPaths, StreamInput in) throws IOException {
BucketMetricsFactory factory = innerReadFrom(name, bucketsPaths, in);
protected final PipelineAggregatorBuilder doReadFrom(String name, String[] bucketsPaths, StreamInput in) throws IOException {
BucketMetricsPipelineAggregatorBuilder factory = innerReadFrom(name, bucketsPaths, in);
factory.format = in.readOptionalString();
factory.gapPolicy = GapPolicy.readFrom(in);
return factory;
}
protected abstract BucketMetricsFactory innerReadFrom(String name, String[] bucketsPaths, StreamInput in) throws IOException;
protected abstract BucketMetricsPipelineAggregatorBuilder innerReadFrom(String name, String[] bucketsPaths, StreamInput in)
throws IOException;
@Override
protected final void doWriteTo(StreamOutput out) throws IOException {
@ -135,12 +137,12 @@ public abstract class BucketMetricsFactory<AF extends BucketMetricsFactory<AF>>
@Override
protected final boolean doEquals(Object obj) {
BucketMetricsFactory other = (BucketMetricsFactory) obj;
BucketMetricsPipelineAggregatorBuilder other = (BucketMetricsPipelineAggregatorBuilder) obj;
return Objects.equals(format, other.format)
&& Objects.equals(gapPolicy, other.gapPolicy)
&& innerEquals(other);
}
protected abstract boolean innerEquals(BucketMetricsFactory other);
protected abstract boolean innerEquals(BucketMetricsPipelineAggregatorBuilder other);
}

View File

@ -19,8 +19,8 @@
package org.elasticsearch.search.aggregations.pipeline.bucketmetrics.avg;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorFactory;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsFactory;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilder;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsPipelineAggregatorBuilder;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsParser;
import java.util.Map;
@ -32,11 +32,13 @@ public class AvgBucketParser extends BucketMetricsParser {
}
@Override
protected BucketMetricsFactory buildFactory(String pipelineAggregatorName, String bucketsPath, Map<String, Object> unparsedParams) {
return new AvgBucketPipelineAggregator.Factory(pipelineAggregatorName, bucketsPath);
protected BucketMetricsPipelineAggregatorBuilder buildFactory(String pipelineAggregatorName, String bucketsPath,
Map<String, Object> unparsedParams) {
return new AvgBucketPipelineAggregator.AvgBucketPipelineAggregatorBuilder(pipelineAggregatorName, bucketsPath);
}
@Override
public PipelineAggregatorFactory getFactoryPrototype() {
return new AvgBucketPipelineAggregator.Factory(null, null);
public PipelineAggregatorBuilder getFactoryPrototype() {
return new AvgBucketPipelineAggregator.AvgBucketPipelineAggregatorBuilder(null, null);
}
}

View File

@ -28,9 +28,9 @@ import org.elasticsearch.search.aggregations.InternalAggregation.Type;
import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy;
import org.elasticsearch.search.aggregations.pipeline.InternalSimpleValue;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorFactory;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilder;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorStreams;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsFactory;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsPipelineAggregatorBuilder;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsPipelineAggregator;
import org.elasticsearch.search.aggregations.support.format.ValueFormatter;
@ -89,13 +89,13 @@ public class AvgBucketPipelineAggregator extends BucketMetricsPipelineAggregator
return new InternalSimpleValue(name(), avgValue, formatter, pipelineAggregators, metadata);
}
public static class Factory extends BucketMetricsFactory<Factory> {
public static class AvgBucketPipelineAggregatorBuilder extends BucketMetricsPipelineAggregatorBuilder<AvgBucketPipelineAggregatorBuilder> {
public Factory(String name, String bucketsPath) {
public AvgBucketPipelineAggregatorBuilder(String name, String bucketsPath) {
this(name, new String[] { bucketsPath });
}
private Factory(String name, String[] bucketsPaths) {
private AvgBucketPipelineAggregatorBuilder(String name, String[] bucketsPaths) {
super(name, TYPE.name(), bucketsPaths);
}
@ -106,7 +106,7 @@ public class AvgBucketPipelineAggregator extends BucketMetricsPipelineAggregator
@Override
public void doValidate(AggregatorFactory<?> parent, AggregatorFactory<?>[] aggFactories,
List<PipelineAggregatorFactory> pipelineAggregatorFactories) {
List<PipelineAggregatorBuilder> pipelineAggregatorFactories) {
if (bucketsPaths.length != 1) {
throw new IllegalStateException(PipelineAggregator.Parser.BUCKETS_PATH.getPreferredName()
+ " must contain a single entry for aggregation [" + name + "]");
@ -119,8 +119,8 @@ public class AvgBucketPipelineAggregator extends BucketMetricsPipelineAggregator
}
@Override
protected BucketMetricsFactory innerReadFrom(String name, String[] bucketsPaths, StreamInput in) throws IOException {
return new Factory(name, bucketsPaths);
protected BucketMetricsPipelineAggregatorBuilder innerReadFrom(String name, String[] bucketsPaths, StreamInput in) throws IOException {
return new AvgBucketPipelineAggregatorBuilder(name, bucketsPaths);
}
@Override
@ -134,7 +134,7 @@ public class AvgBucketPipelineAggregator extends BucketMetricsPipelineAggregator
}
@Override
protected boolean innerEquals(BucketMetricsFactory other) {
protected boolean innerEquals(BucketMetricsPipelineAggregatorBuilder other) {
return true;
}

View File

@ -19,8 +19,8 @@
package org.elasticsearch.search.aggregations.pipeline.bucketmetrics.max;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorFactory;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsFactory;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilder;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsPipelineAggregatorBuilder;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsParser;
import java.util.Map;
@ -33,13 +33,14 @@ public class MaxBucketParser extends BucketMetricsParser {
}
@Override
protected BucketMetricsFactory buildFactory(String pipelineAggregatorName, String bucketsPath, Map<String, Object> unparsedParams) {
return new MaxBucketPipelineAggregator.Factory(pipelineAggregatorName, bucketsPath);
protected BucketMetricsPipelineAggregatorBuilder buildFactory(String pipelineAggregatorName, String bucketsPath,
Map<String, Object> unparsedParams) {
return new MaxBucketPipelineAggregator.MaxBucketPipelineAggregatorBuilder(pipelineAggregatorName, bucketsPath);
}
@Override
public PipelineAggregatorFactory getFactoryPrototype() {
return new MaxBucketPipelineAggregator.Factory(null, null);
public PipelineAggregatorBuilder getFactoryPrototype() {
return new MaxBucketPipelineAggregator.MaxBucketPipelineAggregatorBuilder(null, null);
}
}

View File

@ -27,9 +27,9 @@ import org.elasticsearch.search.aggregations.InternalAggregation;
import org.elasticsearch.search.aggregations.InternalAggregation.Type;
import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorFactory;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilder;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorStreams;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsFactory;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsPipelineAggregatorBuilder;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsPipelineAggregator;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.InternalBucketMetricValue;
import org.elasticsearch.search.aggregations.support.format.ValueFormatter;
@ -96,13 +96,14 @@ public class MaxBucketPipelineAggregator extends BucketMetricsPipelineAggregator
return new InternalBucketMetricValue(name(), keys, maxValue, formatter, Collections.emptyList(), metaData());
}
public static class Factory extends BucketMetricsFactory<Factory> {
public static class MaxBucketPipelineAggregatorBuilder
extends BucketMetricsPipelineAggregatorBuilder<MaxBucketPipelineAggregatorBuilder> {
public Factory(String name, String bucketsPath) {
public MaxBucketPipelineAggregatorBuilder(String name, String bucketsPath) {
this(name, new String[] { bucketsPath });
}
private Factory(String name, String[] bucketsPaths) {
private MaxBucketPipelineAggregatorBuilder(String name, String[] bucketsPaths) {
super(name, TYPE.name(), bucketsPaths);
}
@ -113,7 +114,7 @@ public class MaxBucketPipelineAggregator extends BucketMetricsPipelineAggregator
@Override
public void doValidate(AggregatorFactory<?> parent, AggregatorFactory<?>[] aggFactories,
List<PipelineAggregatorFactory> pipelineAggregatorFactories) {
List<PipelineAggregatorBuilder> pipelineAggregatorFactories) {
if (bucketsPaths.length != 1) {
throw new IllegalStateException(PipelineAggregator.Parser.BUCKETS_PATH.getPreferredName()
+ " must contain a single entry for aggregation [" + name + "]");
@ -126,8 +127,9 @@ public class MaxBucketPipelineAggregator extends BucketMetricsPipelineAggregator
}
@Override
protected BucketMetricsFactory innerReadFrom(String name, String[] bucketsPaths, StreamInput in) throws IOException {
return new Factory(name, bucketsPaths);
protected BucketMetricsPipelineAggregatorBuilder innerReadFrom(String name, String[] bucketsPaths, StreamInput in)
throws IOException {
return new MaxBucketPipelineAggregatorBuilder(name, bucketsPaths);
}
@Override
@ -141,7 +143,7 @@ public class MaxBucketPipelineAggregator extends BucketMetricsPipelineAggregator
}
@Override
protected boolean innerEquals(BucketMetricsFactory other) {
protected boolean innerEquals(BucketMetricsPipelineAggregatorBuilder other) {
return true;
}

View File

@ -19,8 +19,8 @@
package org.elasticsearch.search.aggregations.pipeline.bucketmetrics.min;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorFactory;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsFactory;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilder;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsPipelineAggregatorBuilder;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsParser;
import java.util.Map;
@ -33,13 +33,14 @@ public class MinBucketParser extends BucketMetricsParser {
}
@Override
protected BucketMetricsFactory buildFactory(String pipelineAggregatorName, String bucketsPath, Map<String, Object> unparsedParams) {
return new MinBucketPipelineAggregator.Factory(pipelineAggregatorName, bucketsPath);
protected BucketMetricsPipelineAggregatorBuilder buildFactory(String pipelineAggregatorName, String bucketsPath,
Map<String, Object> unparsedParams) {
return new MinBucketPipelineAggregator.MinBucketPipelineAggregatorBuilder(pipelineAggregatorName, bucketsPath);
}
@Override
public PipelineAggregatorFactory getFactoryPrototype() {
return new MinBucketPipelineAggregator.Factory(null, null);
public PipelineAggregatorBuilder getFactoryPrototype() {
return new MinBucketPipelineAggregator.MinBucketPipelineAggregatorBuilder(null, null);
}
}

View File

@ -27,9 +27,9 @@ import org.elasticsearch.search.aggregations.InternalAggregation;
import org.elasticsearch.search.aggregations.InternalAggregation.Type;
import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorFactory;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilder;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorStreams;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsFactory;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsPipelineAggregatorBuilder;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsPipelineAggregator;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.InternalBucketMetricValue;
import org.elasticsearch.search.aggregations.support.format.ValueFormatter;
@ -97,13 +97,14 @@ public class MinBucketPipelineAggregator extends BucketMetricsPipelineAggregator
return new InternalBucketMetricValue(name(), keys, minValue, formatter, Collections.emptyList(), metaData());
};
public static class Factory extends BucketMetricsFactory<Factory> {
public static class MinBucketPipelineAggregatorBuilder
extends BucketMetricsPipelineAggregatorBuilder<MinBucketPipelineAggregatorBuilder> {
public Factory(String name, String bucketsPath) {
public MinBucketPipelineAggregatorBuilder(String name, String bucketsPath) {
this(name, new String[] { bucketsPath });
}
private Factory(String name, String[] bucketsPaths) {
private MinBucketPipelineAggregatorBuilder(String name, String[] bucketsPaths) {
super(name, TYPE.name(), bucketsPaths);
}
@ -114,7 +115,7 @@ public class MinBucketPipelineAggregator extends BucketMetricsPipelineAggregator
@Override
public void doValidate(AggregatorFactory<?> parent, AggregatorFactory<?>[] aggFactories,
List<PipelineAggregatorFactory> pipelineAggregatorFactories) {
List<PipelineAggregatorBuilder> pipelineAggregatorFactories) {
if (bucketsPaths.length != 1) {
throw new IllegalStateException(PipelineAggregator.Parser.BUCKETS_PATH.getPreferredName()
+ " must contain a single entry for aggregation [" + name + "]");
@ -127,8 +128,9 @@ public class MinBucketPipelineAggregator extends BucketMetricsPipelineAggregator
}
@Override
protected BucketMetricsFactory innerReadFrom(String name, String[] bucketsPaths, StreamInput in) throws IOException {
return new Factory(name, bucketsPaths);
protected BucketMetricsPipelineAggregatorBuilder innerReadFrom(String name, String[] bucketsPaths, StreamInput in)
throws IOException {
return new MinBucketPipelineAggregatorBuilder(name, bucketsPaths);
}
@Override
@ -142,7 +144,7 @@ public class MinBucketPipelineAggregator extends BucketMetricsPipelineAggregator
}
@Override
protected boolean innerEquals(BucketMetricsFactory other) {
protected boolean innerEquals(BucketMetricsPipelineAggregatorBuilder other) {
return true;
}

View File

@ -20,8 +20,8 @@
package org.elasticsearch.search.aggregations.pipeline.bucketmetrics.percentile;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorFactory;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsFactory;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilder;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsPipelineAggregatorBuilder;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsParser;
import java.text.ParseException;
@ -39,8 +39,8 @@ public class PercentilesBucketParser extends BucketMetricsParser {
}
@Override
protected BucketMetricsFactory buildFactory(String pipelineAggregatorName, String bucketsPath, Map<String, Object> unparsedParams)
throws ParseException {
protected BucketMetricsPipelineAggregatorBuilder buildFactory(String pipelineAggregatorName, String bucketsPath,
Map<String, Object> unparsedParams) throws ParseException {
double[] percents = null;
int counter = 0;
@ -65,8 +65,8 @@ public class PercentilesBucketParser extends BucketMetricsParser {
}
}
PercentilesBucketPipelineAggregator.Factory factory = new PercentilesBucketPipelineAggregator.Factory(pipelineAggregatorName,
bucketsPath);
PercentilesBucketPipelineAggregator.PercentilesBucketPipelineAggregatorBuilder factory = new
PercentilesBucketPipelineAggregator.PercentilesBucketPipelineAggregatorBuilder(pipelineAggregatorName, bucketsPath);
if (percents != null) {
factory.percents(percents);
}
@ -74,7 +74,7 @@ public class PercentilesBucketParser extends BucketMetricsParser {
}
@Override
public PipelineAggregatorFactory getFactoryPrototype() {
return new PercentilesBucketPipelineAggregator.Factory(null, null);
public PipelineAggregatorBuilder getFactoryPrototype() {
return new PercentilesBucketPipelineAggregator.PercentilesBucketPipelineAggregatorBuilder(null, null);
}
}

View File

@ -28,9 +28,9 @@ import org.elasticsearch.search.aggregations.InternalAggregation;
import org.elasticsearch.search.aggregations.InternalAggregation.Type;
import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorFactory;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilder;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorStreams;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsFactory;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsPipelineAggregatorBuilder;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsPipelineAggregator;
import org.elasticsearch.search.aggregations.support.format.ValueFormatter;
@ -124,15 +124,16 @@ public class PercentilesBucketPipelineAggregator extends BucketMetricsPipelineAg
out.writeDoubleArray(percents);
}
public static class Factory extends BucketMetricsFactory<Factory> {
public static class PercentilesBucketPipelineAggregatorBuilder
extends BucketMetricsPipelineAggregatorBuilder<PercentilesBucketPipelineAggregatorBuilder> {
private double[] percents = new double[] { 1.0, 5.0, 25.0, 50.0, 75.0, 95.0, 99.0 };
public Factory(String name, String bucketsPath) {
public PercentilesBucketPipelineAggregatorBuilder(String name, String bucketsPath) {
this(name, new String[] { bucketsPath });
}
private Factory(String name, String[] bucketsPaths) {
private PercentilesBucketPipelineAggregatorBuilder(String name, String[] bucketsPaths) {
super(name, TYPE.name(), bucketsPaths);
}
@ -146,7 +147,7 @@ public class PercentilesBucketPipelineAggregator extends BucketMetricsPipelineAg
/**
* Set the percentages to calculate percentiles for in this aggregation
*/
public Factory percents(double[] percents) {
public PercentilesBucketPipelineAggregatorBuilder percents(double[] percents) {
for (Double p : percents) {
if (p == null || p < 0.0 || p > 100.0) {
throw new IllegalArgumentException(PercentilesBucketParser.PERCENTS.getPreferredName()
@ -164,7 +165,7 @@ public class PercentilesBucketPipelineAggregator extends BucketMetricsPipelineAg
@Override
public void doValidate(AggregatorFactory<?> parent, AggregatorFactory<?>[] aggFactories,
List<PipelineAggregatorFactory> pipelineAggregatorFactories) {
List<PipelineAggregatorBuilder> pipelineAggregatorFactories) {
if (bucketsPaths.length != 1) {
throw new IllegalStateException(PipelineAggregator.Parser.BUCKETS_PATH.getPreferredName()
+ " must contain a single entry for aggregation [" + name + "]");
@ -187,8 +188,9 @@ public class PercentilesBucketPipelineAggregator extends BucketMetricsPipelineAg
}
@Override
protected BucketMetricsFactory innerReadFrom(String name, String[] bucketsPaths, StreamInput in) throws IOException {
Factory factory = new Factory(name, bucketsPaths);
protected BucketMetricsPipelineAggregatorBuilder innerReadFrom(String name, String[] bucketsPaths, StreamInput in)
throws IOException {
PercentilesBucketPipelineAggregatorBuilder factory = new PercentilesBucketPipelineAggregatorBuilder(name, bucketsPaths);
factory.percents = in.readDoubleArray();
return factory;
}
@ -204,8 +206,8 @@ public class PercentilesBucketPipelineAggregator extends BucketMetricsPipelineAg
}
@Override
protected boolean innerEquals(BucketMetricsFactory obj) {
Factory other = (Factory) obj;
protected boolean innerEquals(BucketMetricsPipelineAggregatorBuilder obj) {
PercentilesBucketPipelineAggregatorBuilder other = (PercentilesBucketPipelineAggregatorBuilder) obj;
return Objects.deepEquals(percents, other.percents);
}

View File

@ -19,8 +19,8 @@
package org.elasticsearch.search.aggregations.pipeline.bucketmetrics.stats;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorFactory;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsFactory;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilder;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsPipelineAggregatorBuilder;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsParser;
import java.util.Map;
@ -32,12 +32,13 @@ public class StatsBucketParser extends BucketMetricsParser {
}
@Override
protected BucketMetricsFactory buildFactory(String pipelineAggregatorName, String bucketsPath, Map<String, Object> unparsedParams) {
return new StatsBucketPipelineAggregator.Factory(pipelineAggregatorName, bucketsPath);
protected BucketMetricsPipelineAggregatorBuilder buildFactory(String pipelineAggregatorName, String bucketsPath,
Map<String, Object> unparsedParams) {
return new StatsBucketPipelineAggregator.StatsBucketPipelineAggregatorBuilder(pipelineAggregatorName, bucketsPath);
}
@Override
public PipelineAggregatorFactory getFactoryPrototype() {
return new StatsBucketPipelineAggregator.Factory(null, null);
public PipelineAggregatorBuilder getFactoryPrototype() {
return new StatsBucketPipelineAggregator.StatsBucketPipelineAggregatorBuilder(null, null);
}
}

View File

@ -27,9 +27,9 @@ import org.elasticsearch.search.aggregations.InternalAggregation;
import org.elasticsearch.search.aggregations.InternalAggregation.Type;
import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorFactory;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilder;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorStreams;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsFactory;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsPipelineAggregatorBuilder;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsPipelineAggregator;
import org.elasticsearch.search.aggregations.support.format.ValueFormatter;
@ -95,13 +95,14 @@ public class StatsBucketPipelineAggregator extends BucketMetricsPipelineAggregat
return new InternalStatsBucket(name(), count, sum, min, max, formatter, pipelineAggregators, metadata);
}
public static class Factory extends BucketMetricsFactory<Factory> {
public static class StatsBucketPipelineAggregatorBuilder
extends BucketMetricsPipelineAggregatorBuilder<StatsBucketPipelineAggregatorBuilder> {
public Factory(String name, String bucketsPath) {
public StatsBucketPipelineAggregatorBuilder(String name, String bucketsPath) {
this(name, new String[] { bucketsPath });
}
private Factory(String name, String[] bucketsPaths) {
private StatsBucketPipelineAggregatorBuilder(String name, String[] bucketsPaths) {
super(name, TYPE.name(), bucketsPaths);
}
@ -112,7 +113,7 @@ public class StatsBucketPipelineAggregator extends BucketMetricsPipelineAggregat
@Override
public void doValidate(AggregatorFactory<?> parent, AggregatorFactory<?>[] aggFactories,
List<PipelineAggregatorFactory> pipelineAggregatorFactories) {
List<PipelineAggregatorBuilder> pipelineAggregatorFactories) {
if (bucketsPaths.length != 1) {
throw new IllegalStateException(Parser.BUCKETS_PATH.getPreferredName()
+ " must contain a single entry for aggregation [" + name + "]");
@ -125,8 +126,9 @@ public class StatsBucketPipelineAggregator extends BucketMetricsPipelineAggregat
}
@Override
protected BucketMetricsFactory innerReadFrom(String name, String[] bucketsPaths, StreamInput in) throws IOException {
return new Factory(name, bucketsPaths);
protected BucketMetricsPipelineAggregatorBuilder innerReadFrom(String name, String[] bucketsPaths, StreamInput in)
throws IOException {
return new StatsBucketPipelineAggregatorBuilder(name, bucketsPaths);
}
@Override
@ -140,7 +142,7 @@ public class StatsBucketPipelineAggregator extends BucketMetricsPipelineAggregat
}
@Override
protected boolean innerEquals(BucketMetricsFactory other) {
protected boolean innerEquals(BucketMetricsPipelineAggregatorBuilder other) {
return true;
}

View File

@ -20,8 +20,8 @@
package org.elasticsearch.search.aggregations.pipeline.bucketmetrics.stats.extended;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorFactory;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsFactory;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilder;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsPipelineAggregatorBuilder;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsParser;
import java.text.ParseException;
@ -36,8 +36,8 @@ public class ExtendedStatsBucketParser extends BucketMetricsParser {
}
@Override
protected BucketMetricsFactory buildFactory(String pipelineAggregatorName, String bucketsPath, Map<String, Object> unparsedParams)
throws ParseException {
protected BucketMetricsPipelineAggregatorBuilder buildFactory(String pipelineAggregatorName, String bucketsPath,
Map<String, Object> unparsedParams) throws ParseException {
Double sigma = null;
Object param = unparsedParams.get(SIGMA.getPreferredName());
@ -51,8 +51,8 @@ public class ExtendedStatsBucketParser extends BucketMetricsParser {
+ param.getClass().getSimpleName() + "` provided instead", 0);
}
}
ExtendedStatsBucketPipelineAggregator.Factory factory = new ExtendedStatsBucketPipelineAggregator.Factory(pipelineAggregatorName,
bucketsPath);
ExtendedStatsBucketPipelineAggregator.ExtendedStatsBucketPipelineAggregatorBuilder factory =
new ExtendedStatsBucketPipelineAggregator.ExtendedStatsBucketPipelineAggregatorBuilder(pipelineAggregatorName, bucketsPath);
if (sigma != null) {
factory.sigma(sigma);
}
@ -60,7 +60,7 @@ public class ExtendedStatsBucketParser extends BucketMetricsParser {
}
@Override
public PipelineAggregatorFactory getFactoryPrototype() {
return new ExtendedStatsBucketPipelineAggregator.Factory(null, null);
public PipelineAggregatorBuilder getFactoryPrototype() {
return new ExtendedStatsBucketPipelineAggregator.ExtendedStatsBucketPipelineAggregatorBuilder(null, null);
}
}

View File

@ -27,9 +27,9 @@ import org.elasticsearch.search.aggregations.InternalAggregation;
import org.elasticsearch.search.aggregations.InternalAggregation.Type;
import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorFactory;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilder;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorStreams;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsFactory;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsPipelineAggregatorBuilder;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsPipelineAggregator;
import org.elasticsearch.search.aggregations.support.format.ValueFormatter;
@ -101,15 +101,16 @@ public class ExtendedStatsBucketPipelineAggregator extends BucketMetricsPipeline
return new InternalExtendedStatsBucket(name(), count, sum, min, max, sumOfSqrs, sigma, formatter, pipelineAggregators, metadata);
}
public static class Factory extends BucketMetricsFactory<Factory> {
public static class ExtendedStatsBucketPipelineAggregatorBuilder
extends BucketMetricsPipelineAggregatorBuilder<ExtendedStatsBucketPipelineAggregatorBuilder> {
private double sigma = 2.0;
public Factory(String name, String bucketsPath) {
public ExtendedStatsBucketPipelineAggregatorBuilder(String name, String bucketsPath) {
this(name, new String[] { bucketsPath });
}
private Factory(String name, String[] bucketsPaths) {
private ExtendedStatsBucketPipelineAggregatorBuilder(String name, String[] bucketsPaths) {
super(name, TYPE.name(), bucketsPaths);
}
@ -117,7 +118,7 @@ public class ExtendedStatsBucketPipelineAggregator extends BucketMetricsPipeline
* Set the value of sigma to use when calculating the standard deviation
* bounds
*/
public Factory sigma(double sigma) {
public ExtendedStatsBucketPipelineAggregatorBuilder sigma(double sigma) {
if (sigma < 0.0) {
throw new IllegalArgumentException(ExtendedStatsBucketParser.SIGMA.getPreferredName() + " must be a non-negative double");
}
@ -140,7 +141,7 @@ public class ExtendedStatsBucketPipelineAggregator extends BucketMetricsPipeline
@Override
public void doValidate(AggregatorFactory<?> parent, AggregatorFactory<?>[] aggFactories,
List<PipelineAggregatorFactory> pipelineAggregatorFactories) {
List<PipelineAggregatorBuilder> pipelineAggregatorFactories) {
if (bucketsPaths.length != 1) {
throw new IllegalStateException(Parser.BUCKETS_PATH.getPreferredName()
+ " must contain a single entry for aggregation [" + name + "]");
@ -159,8 +160,9 @@ public class ExtendedStatsBucketPipelineAggregator extends BucketMetricsPipeline
}
@Override
protected BucketMetricsFactory innerReadFrom(String name, String[] bucketsPaths, StreamInput in) throws IOException {
Factory factory = new Factory(name, bucketsPaths);
protected BucketMetricsPipelineAggregatorBuilder innerReadFrom(String name, String[] bucketsPaths, StreamInput in)
throws IOException {
ExtendedStatsBucketPipelineAggregatorBuilder factory = new ExtendedStatsBucketPipelineAggregatorBuilder(name, bucketsPaths);
factory.sigma = in.readDouble();
return factory;
}
@ -176,8 +178,8 @@ public class ExtendedStatsBucketPipelineAggregator extends BucketMetricsPipeline
}
@Override
protected boolean innerEquals(BucketMetricsFactory obj) {
Factory other = (Factory) obj;
protected boolean innerEquals(BucketMetricsPipelineAggregatorBuilder obj) {
ExtendedStatsBucketPipelineAggregatorBuilder other = (ExtendedStatsBucketPipelineAggregatorBuilder) obj;
return Objects.equals(sigma, other.sigma);
}

View File

@ -19,8 +19,8 @@
package org.elasticsearch.search.aggregations.pipeline.bucketmetrics.sum;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorFactory;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsFactory;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilder;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsPipelineAggregatorBuilder;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsParser;
import java.util.Map;
@ -32,12 +32,13 @@ public class SumBucketParser extends BucketMetricsParser {
}
@Override
protected BucketMetricsFactory buildFactory(String pipelineAggregatorName, String bucketsPath, Map<String, Object> unparsedParams) {
return new SumBucketPipelineAggregator.Factory(pipelineAggregatorName, bucketsPath);
protected BucketMetricsPipelineAggregatorBuilder buildFactory(String pipelineAggregatorName, String bucketsPath,
Map<String, Object> unparsedParams) {
return new SumBucketPipelineAggregator.SumBucketPipelineAggregatorBuilder(pipelineAggregatorName, bucketsPath);
}
@Override
public PipelineAggregatorFactory getFactoryPrototype() {
return new SumBucketPipelineAggregator.Factory(null, null);
public PipelineAggregatorBuilder getFactoryPrototype() {
return new SumBucketPipelineAggregator.SumBucketPipelineAggregatorBuilder(null, null);
}
}

View File

@ -28,9 +28,9 @@ import org.elasticsearch.search.aggregations.InternalAggregation.Type;
import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy;
import org.elasticsearch.search.aggregations.pipeline.InternalSimpleValue;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorFactory;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilder;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorStreams;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsFactory;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsPipelineAggregatorBuilder;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsPipelineAggregator;
import org.elasticsearch.search.aggregations.support.format.ValueFormatter;
@ -85,13 +85,14 @@ public class SumBucketPipelineAggregator extends BucketMetricsPipelineAggregator
return new InternalSimpleValue(name(), sum, formatter, pipelineAggregators, metadata);
}
public static class Factory extends BucketMetricsFactory<Factory> {
public static class SumBucketPipelineAggregatorBuilder
extends BucketMetricsPipelineAggregatorBuilder<SumBucketPipelineAggregatorBuilder> {
public Factory(String name, String bucketsPath) {
public SumBucketPipelineAggregatorBuilder(String name, String bucketsPath) {
this(name, new String[] { bucketsPath });
}
private Factory(String name, String[] bucketsPaths) {
private SumBucketPipelineAggregatorBuilder(String name, String[] bucketsPaths) {
super(name, TYPE.name(), bucketsPaths);
}
@ -102,7 +103,7 @@ public class SumBucketPipelineAggregator extends BucketMetricsPipelineAggregator
@Override
public void doValidate(AggregatorFactory<?> parent, AggregatorFactory<?>[] aggFactories,
List<PipelineAggregatorFactory> pipelineAggregatorFactories) {
List<PipelineAggregatorBuilder> pipelineAggregatorFactories) {
if (bucketsPaths.length != 1) {
throw new IllegalStateException(PipelineAggregator.Parser.BUCKETS_PATH.getPreferredName()
+ " must contain a single entry for aggregation [" + name + "]");
@ -115,8 +116,9 @@ public class SumBucketPipelineAggregator extends BucketMetricsPipelineAggregator
}
@Override
protected BucketMetricsFactory innerReadFrom(String name, String[] bucketsPaths, StreamInput in) throws IOException {
return new Factory(name, bucketsPaths);
protected BucketMetricsPipelineAggregatorBuilder innerReadFrom(String name, String[] bucketsPaths, StreamInput in)
throws IOException {
return new SumBucketPipelineAggregatorBuilder(name, bucketsPaths);
}
@Override
@ -130,7 +132,7 @@ public class SumBucketPipelineAggregator extends BucketMetricsPipelineAggregator
}
@Override
protected boolean innerEquals(BucketMetricsFactory other) {
protected boolean innerEquals(BucketMetricsPipelineAggregatorBuilder other) {
return true;
}

View File

@ -27,7 +27,7 @@ import org.elasticsearch.script.Script;
import org.elasticsearch.script.Script.ScriptField;
import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorFactory;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilder;
import java.io.IOException;
import java.util.ArrayList;
@ -48,7 +48,7 @@ public class BucketScriptParser implements PipelineAggregator.Parser {
}
@Override
public PipelineAggregatorFactory parse(String reducerName, XContentParser parser, QueryParseContext context) throws IOException {
public PipelineAggregatorBuilder parse(String reducerName, XContentParser parser, QueryParseContext context) throws IOException {
XContentParser.Token token;
Script script = null;
String currentFieldName = null;
@ -116,7 +116,8 @@ public class BucketScriptParser implements PipelineAggregator.Parser {
+ "] for series_arithmetic aggregation [" + reducerName + "]");
}
BucketScriptPipelineAggregator.Factory factory = new BucketScriptPipelineAggregator.Factory(reducerName, bucketsPathsMap, script);
BucketScriptPipelineAggregator.BucketScriptPipelineAggregatorBuilder factory =
new BucketScriptPipelineAggregator.BucketScriptPipelineAggregatorBuilder(reducerName, bucketsPathsMap, script);
if (format != null) {
factory.format(format);
}
@ -127,8 +128,8 @@ public class BucketScriptParser implements PipelineAggregator.Parser {
}
@Override
public PipelineAggregatorFactory getFactoryPrototype() {
return new BucketScriptPipelineAggregator.Factory(null, Collections.emptyMap(), null);
public PipelineAggregatorBuilder getFactoryPrototype() {
return new BucketScriptPipelineAggregator.BucketScriptPipelineAggregatorBuilder(null, Collections.emptyMap(), null);
}
}

View File

@ -37,7 +37,7 @@ import org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation.Buck
import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy;
import org.elasticsearch.search.aggregations.pipeline.InternalSimpleValue;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorFactory;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilder;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorStreams;
import org.elasticsearch.search.aggregations.support.format.ValueFormat;
import org.elasticsearch.search.aggregations.support.format.ValueFormatter;
@ -160,20 +160,20 @@ public class BucketScriptPipelineAggregator extends PipelineAggregator {
bucketsPathsMap = (Map<String, String>) in.readGenericValue();
}
public static class Factory extends PipelineAggregatorFactory {
public static class BucketScriptPipelineAggregatorBuilder extends PipelineAggregatorBuilder {
private final Script script;
private final Map<String, String> bucketsPathsMap;
private String format = null;
private GapPolicy gapPolicy = GapPolicy.SKIP;
public Factory(String name, Map<String, String> bucketsPathsMap, Script script) {
public BucketScriptPipelineAggregatorBuilder(String name, Map<String, String> bucketsPathsMap, Script script) {
super(name, TYPE.name(), bucketsPathsMap.values().toArray(new String[bucketsPathsMap.size()]));
this.bucketsPathsMap = bucketsPathsMap;
this.script = script;
}
public Factory(String name, Script script, String... bucketsPaths) {
public BucketScriptPipelineAggregatorBuilder(String name, Script script, String... bucketsPaths) {
this(name, convertToBucketsPathMap(bucketsPaths), script);
}
@ -188,7 +188,7 @@ public class BucketScriptPipelineAggregator extends PipelineAggregator {
/**
* Sets the format to use on the output of this aggregation.
*/
public Factory format(String format) {
public BucketScriptPipelineAggregatorBuilder format(String format) {
this.format = format;
return this;
}
@ -211,7 +211,7 @@ public class BucketScriptPipelineAggregator extends PipelineAggregator {
/**
* Sets the gap policy to use for this aggregation.
*/
public Factory gapPolicy(GapPolicy gapPolicy) {
public BucketScriptPipelineAggregatorBuilder gapPolicy(GapPolicy gapPolicy) {
this.gapPolicy = gapPolicy;
return this;
}
@ -245,14 +245,14 @@ public class BucketScriptPipelineAggregator extends PipelineAggregator {
}
@Override
protected PipelineAggregatorFactory doReadFrom(String name, String[] bucketsPaths, StreamInput in) throws IOException {
protected PipelineAggregatorBuilder 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++) {
bucketsPathsMap.put(in.readString(), in.readString());
}
Script script = Script.readScript(in);
Factory factory = new Factory(name, bucketsPathsMap, script);
BucketScriptPipelineAggregatorBuilder factory = new BucketScriptPipelineAggregatorBuilder(name, bucketsPathsMap, script);
factory.format = in.readOptionalString();
factory.gapPolicy = GapPolicy.readFrom(in);
return factory;
@ -277,7 +277,7 @@ public class BucketScriptPipelineAggregator extends PipelineAggregator {
@Override
protected boolean doEquals(Object obj) {
Factory other = (Factory) obj;
BucketScriptPipelineAggregatorBuilder other = (BucketScriptPipelineAggregatorBuilder) obj;
return Objects.equals(bucketsPathsMap, other.bucketsPathsMap) && Objects.equals(script, other.script)
&& Objects.equals(format, other.format) && Objects.equals(gapPolicy, other.gapPolicy);
}

View File

@ -24,7 +24,7 @@ import org.elasticsearch.common.ParsingException;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.index.query.QueryParseContext;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorFactory;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilder;
import java.io.IOException;
import java.util.ArrayList;
@ -42,7 +42,7 @@ public class CumulativeSumParser implements PipelineAggregator.Parser {
}
@Override
public PipelineAggregatorFactory parse(String pipelineAggregatorName, XContentParser parser, QueryParseContext context)
public PipelineAggregatorBuilder parse(String pipelineAggregatorName, XContentParser parser, QueryParseContext context)
throws IOException {
XContentParser.Token token;
String currentFieldName = null;
@ -84,8 +84,8 @@ public class CumulativeSumParser implements PipelineAggregator.Parser {
+ "] for derivative aggregation [" + pipelineAggregatorName + "]");
}
CumulativeSumPipelineAggregator.Factory factory = new CumulativeSumPipelineAggregator.Factory(pipelineAggregatorName,
bucketsPaths[0]);
CumulativeSumPipelineAggregator.CumulativeSumPipelineAggregatorBuilder factory =
new CumulativeSumPipelineAggregator.CumulativeSumPipelineAggregatorBuilder(pipelineAggregatorName, bucketsPaths[0]);
if (format != null) {
factory.format(format);
}
@ -93,8 +93,8 @@ public class CumulativeSumParser implements PipelineAggregator.Parser {
}
@Override
public PipelineAggregatorFactory getFactoryPrototype() {
return new CumulativeSumPipelineAggregator.Factory(null, null);
public PipelineAggregatorBuilder getFactoryPrototype() {
return new CumulativeSumPipelineAggregator.CumulativeSumPipelineAggregatorBuilder(null, null);
}
}

View File

@ -32,7 +32,7 @@ import org.elasticsearch.search.aggregations.bucket.histogram.InternalHistogram;
import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy;
import org.elasticsearch.search.aggregations.pipeline.InternalSimpleValue;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorFactory;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilder;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorStreams;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsParser;
import org.elasticsearch.search.aggregations.support.format.ValueFormat;
@ -111,22 +111,22 @@ public class CumulativeSumPipelineAggregator extends PipelineAggregator {
ValueFormatterStreams.writeOptional(formatter, out);
}
public static class Factory extends PipelineAggregatorFactory {
public static class CumulativeSumPipelineAggregatorBuilder extends PipelineAggregatorBuilder {
private String format;
public Factory(String name, String bucketsPath) {
public CumulativeSumPipelineAggregatorBuilder(String name, String bucketsPath) {
this(name, new String[] { bucketsPath });
}
private Factory(String name, String[] bucketsPaths) {
private CumulativeSumPipelineAggregatorBuilder(String name, String[] bucketsPaths) {
super(name, TYPE.name(), bucketsPaths);
}
/**
* Sets the format to use on the output of this aggregation.
*/
public Factory format(String format) {
public CumulativeSumPipelineAggregatorBuilder format(String format) {
this.format = format;
return this;
}
@ -152,7 +152,7 @@ public class CumulativeSumPipelineAggregator extends PipelineAggregator {
}
@Override
public void doValidate(AggregatorFactory<?> parent, AggregatorFactory<?>[] aggFactories, List<PipelineAggregatorFactory> 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 + "]");
@ -178,8 +178,8 @@ public class CumulativeSumPipelineAggregator extends PipelineAggregator {
}
@Override
protected final PipelineAggregatorFactory doReadFrom(String name, String[] bucketsPaths, StreamInput in) throws IOException {
Factory factory = new Factory(name, bucketsPaths);
protected final PipelineAggregatorBuilder doReadFrom(String name, String[] bucketsPaths, StreamInput in) throws IOException {
CumulativeSumPipelineAggregatorBuilder factory = new CumulativeSumPipelineAggregatorBuilder(name, bucketsPaths);
factory.format = in.readOptionalString();
return factory;
}
@ -196,7 +196,7 @@ public class CumulativeSumPipelineAggregator extends PipelineAggregator {
@Override
protected boolean doEquals(Object obj) {
Factory other = (Factory) obj;
CumulativeSumPipelineAggregatorBuilder other = (CumulativeSumPipelineAggregatorBuilder) obj;
return Objects.equals(format, other.format);
}
}

View File

@ -25,7 +25,7 @@ import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.index.query.QueryParseContext;
import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorFactory;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilder;
import java.io.IOException;
import java.util.ArrayList;
@ -43,7 +43,7 @@ public class DerivativeParser implements PipelineAggregator.Parser {
}
@Override
public PipelineAggregatorFactory parse(String pipelineAggregatorName, XContentParser parser, QueryParseContext context)
public PipelineAggregatorBuilder parse(String pipelineAggregatorName, XContentParser parser, QueryParseContext context)
throws IOException {
XContentParser.Token token;
String currentFieldName = null;
@ -91,7 +91,8 @@ public class DerivativeParser implements PipelineAggregator.Parser {
+ "] for derivative aggregation [" + pipelineAggregatorName + "]");
}
DerivativePipelineAggregator.Factory factory = new DerivativePipelineAggregator.Factory(pipelineAggregatorName, bucketsPaths[0]);
DerivativePipelineAggregator.DerivativePipelineAggregatorBuilder factory =
new DerivativePipelineAggregator.DerivativePipelineAggregatorBuilder(pipelineAggregatorName, bucketsPaths[0]);
if (format != null) {
factory.format(format);
}
@ -105,8 +106,8 @@ public class DerivativeParser implements PipelineAggregator.Parser {
}
@Override
public PipelineAggregatorFactory getFactoryPrototype() {
return new DerivativePipelineAggregator.Factory(null, null);
public PipelineAggregatorBuilder getFactoryPrototype() {
return new DerivativePipelineAggregator.DerivativePipelineAggregatorBuilder(null, null);
}
}

View File

@ -36,7 +36,7 @@ import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramInter
import org.elasticsearch.search.aggregations.bucket.histogram.InternalHistogram;
import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorFactory;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilder;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorStreams;
import org.elasticsearch.search.aggregations.support.format.ValueFormat;
import org.elasticsearch.search.aggregations.support.format.ValueFormatter;
@ -159,21 +159,21 @@ public class DerivativePipelineAggregator extends PipelineAggregator {
}
}
public static class Factory extends PipelineAggregatorFactory {
public static class DerivativePipelineAggregatorBuilder extends PipelineAggregatorBuilder {
private String format;
private GapPolicy gapPolicy = GapPolicy.SKIP;
private String units;
public Factory(String name, String bucketsPath) {
public DerivativePipelineAggregatorBuilder(String name, String bucketsPath) {
this(name, new String[] { bucketsPath });
}
private Factory(String name, String[] bucketsPaths) {
private DerivativePipelineAggregatorBuilder(String name, String[] bucketsPaths) {
super(name, TYPE.name(), bucketsPaths);
}
public Factory format(String format) {
public DerivativePipelineAggregatorBuilder format(String format) {
this.format = format;
return this;
}
@ -182,7 +182,7 @@ public class DerivativePipelineAggregator extends PipelineAggregator {
return format;
}
public Factory gapPolicy(GapPolicy gapPolicy) {
public DerivativePipelineAggregatorBuilder gapPolicy(GapPolicy gapPolicy) {
this.gapPolicy = gapPolicy;
return this;
}
@ -191,12 +191,12 @@ public class DerivativePipelineAggregator extends PipelineAggregator {
return gapPolicy;
}
public Factory unit(String units) {
public DerivativePipelineAggregatorBuilder unit(String units) {
this.units = units;
return this;
}
public Factory unit(DateHistogramInterval units) {
public DerivativePipelineAggregatorBuilder unit(DateHistogramInterval units) {
this.units = units.toString();
return this;
}
@ -229,7 +229,7 @@ public class DerivativePipelineAggregator extends PipelineAggregator {
}
@Override
public void doValidate(AggregatorFactory<?> parent, AggregatorFactory<?>[] aggFactories, List<PipelineAggregatorFactory> 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 + "]");
@ -247,8 +247,8 @@ public class DerivativePipelineAggregator extends PipelineAggregator {
}
@Override
protected PipelineAggregatorFactory doReadFrom(String name, String[] bucketsPaths, StreamInput in) throws IOException {
Factory factory = new Factory(name, bucketsPaths);
protected PipelineAggregatorBuilder doReadFrom(String name, String[] bucketsPaths, StreamInput in) throws IOException {
DerivativePipelineAggregatorBuilder factory = new DerivativePipelineAggregatorBuilder(name, bucketsPaths);
factory.format = in.readOptionalString();
if (in.readBoolean()) {
factory.gapPolicy = GapPolicy.readFrom(in);
@ -284,7 +284,7 @@ public class DerivativePipelineAggregator extends PipelineAggregator {
@Override
protected boolean doEquals(Object obj) {
Factory other = (Factory) obj;
DerivativePipelineAggregatorBuilder other = (DerivativePipelineAggregatorBuilder) obj;
if (!Objects.equals(format, other.format)) {
return false;
}

View File

@ -27,7 +27,7 @@ import org.elasticsearch.script.Script;
import org.elasticsearch.script.Script.ScriptField;
import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorFactory;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilder;
import java.io.IOException;
import java.util.ArrayList;
@ -48,7 +48,7 @@ public class BucketSelectorParser implements PipelineAggregator.Parser {
}
@Override
public PipelineAggregatorFactory parse(String reducerName, XContentParser parser, QueryParseContext context) throws IOException {
public PipelineAggregatorBuilder parse(String reducerName, XContentParser parser, QueryParseContext context) throws IOException {
XContentParser.Token token;
Script script = null;
String currentFieldName = null;
@ -113,8 +113,8 @@ public class BucketSelectorParser implements PipelineAggregator.Parser {
+ "] for bucket_selector aggregation [" + reducerName + "]");
}
BucketSelectorPipelineAggregator.Factory factory = new BucketSelectorPipelineAggregator.Factory(reducerName, bucketsPathsMap,
script);
BucketSelectorPipelineAggregator.BucketSelectorPipelineAggregatorBuilder factory =
new BucketSelectorPipelineAggregator.BucketSelectorPipelineAggregatorBuilder(reducerName, bucketsPathsMap, script);
if (gapPolicy != null) {
factory.gapPolicy(gapPolicy);
}
@ -123,8 +123,8 @@ public class BucketSelectorParser implements PipelineAggregator.Parser {
}
@Override
public PipelineAggregatorFactory getFactoryPrototype() {
return new BucketSelectorPipelineAggregator.Factory(null, Collections.emptyMap(), null);
public PipelineAggregatorBuilder getFactoryPrototype() {
return new BucketSelectorPipelineAggregator.BucketSelectorPipelineAggregatorBuilder(null, Collections.emptyMap(), null);
}
}

View File

@ -35,7 +35,7 @@ import org.elasticsearch.search.aggregations.InternalMultiBucketAggregation;
import org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation.Bucket;
import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorFactory;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilder;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorStreams;
import org.elasticsearch.search.aggregations.pipeline.bucketscript.BucketScriptParser;
@ -139,19 +139,19 @@ public class BucketSelectorPipelineAggregator extends PipelineAggregator {
bucketsPathsMap = (Map<String, String>) in.readGenericValue();
}
public static class Factory extends PipelineAggregatorFactory {
public static class BucketSelectorPipelineAggregatorBuilder extends PipelineAggregatorBuilder {
private Script script;
private GapPolicy gapPolicy = GapPolicy.SKIP;
private Map<String, String> bucketsPathsMap;
public Factory(String name, Map<String, String> bucketsPathsMap, Script script) {
public BucketSelectorPipelineAggregatorBuilder(String name, Map<String, String> bucketsPathsMap, Script script) {
super(name, TYPE.name(), bucketsPathsMap.values().toArray(new String[bucketsPathsMap.size()]));
this.bucketsPathsMap = bucketsPathsMap;
this.script = script;
}
public Factory(String name, Script script, String... bucketsPaths) {
public BucketSelectorPipelineAggregatorBuilder(String name, Script script, String... bucketsPaths) {
this(name, convertToBucketsPathMap(bucketsPaths), script);
}
@ -166,7 +166,7 @@ public class BucketSelectorPipelineAggregator extends PipelineAggregator {
/**
* Sets the gap policy to use for this aggregation.
*/
public Factory gapPolicy(GapPolicy gapPolicy) {
public BucketSelectorPipelineAggregatorBuilder gapPolicy(GapPolicy gapPolicy) {
this.gapPolicy = gapPolicy;
return this;
}
@ -197,14 +197,14 @@ public class BucketSelectorPipelineAggregator extends PipelineAggregator {
}
@Override
protected PipelineAggregatorFactory doReadFrom(String name, String[] bucketsPaths, StreamInput in) throws IOException {
protected PipelineAggregatorBuilder 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++) {
bucketsPathsMap.put(in.readString(), in.readString());
}
Script script = Script.readScript(in);
Factory factory = new Factory(name, bucketsPathsMap, script);
BucketSelectorPipelineAggregatorBuilder factory = new BucketSelectorPipelineAggregatorBuilder(name, bucketsPathsMap, script);
factory.gapPolicy = GapPolicy.readFrom(in);
return factory;
}
@ -227,7 +227,7 @@ public class BucketSelectorPipelineAggregator extends PipelineAggregator {
@Override
protected boolean doEquals(Object obj) {
Factory other = (Factory) obj;
BucketSelectorPipelineAggregatorBuilder other = (BucketSelectorPipelineAggregatorBuilder) obj;
return Objects.equals(bucketsPathsMap, other.bucketsPathsMap) && Objects.equals(script, other.script)
&& Objects.equals(gapPolicy, other.gapPolicy);
}

View File

@ -26,7 +26,7 @@ import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.index.query.QueryParseContext;
import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorFactory;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilder;
import org.elasticsearch.search.aggregations.pipeline.movavg.models.MovAvgModel;
import org.elasticsearch.search.aggregations.pipeline.movavg.models.MovAvgModelParserMapper;
@ -57,7 +57,7 @@ public class MovAvgParser implements PipelineAggregator.Parser {
}
@Override
public PipelineAggregatorFactory parse(String pipelineAggregatorName, XContentParser parser, QueryParseContext context)
public PipelineAggregatorBuilder parse(String pipelineAggregatorName, XContentParser parser, QueryParseContext context)
throws IOException {
XContentParser.Token token;
String currentFieldName = null;
@ -141,7 +141,8 @@ public class MovAvgParser implements PipelineAggregator.Parser {
+ "] for movingAvg aggregation [" + pipelineAggregatorName + "]");
}
MovAvgPipelineAggregator.Factory factory = new MovAvgPipelineAggregator.Factory(pipelineAggregatorName, bucketsPaths[0]);
MovAvgPipelineAggregator.MovAvgPipelineAggregatorBuilder factory =
new MovAvgPipelineAggregator.MovAvgPipelineAggregatorBuilder(pipelineAggregatorName, bucketsPaths[0]);
if (format != null) {
factory.format(format);
}
@ -176,8 +177,8 @@ public class MovAvgParser implements PipelineAggregator.Parser {
}
@Override
public PipelineAggregatorFactory getFactoryPrototype() {
return new MovAvgPipelineAggregator.Factory(null, null);
public PipelineAggregatorBuilder getFactoryPrototype() {
return new MovAvgPipelineAggregator.MovAvgPipelineAggregatorBuilder(null, null);
}
}

View File

@ -34,7 +34,7 @@ import org.elasticsearch.search.aggregations.bucket.histogram.InternalHistogram;
import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy;
import org.elasticsearch.search.aggregations.pipeline.InternalSimpleValue;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorFactory;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilder;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorStreams;
import org.elasticsearch.search.aggregations.pipeline.movavg.models.MovAvgModel;
import org.elasticsearch.search.aggregations.pipeline.movavg.models.MovAvgModelBuilder;
@ -279,7 +279,7 @@ public class MovAvgPipelineAggregator extends PipelineAggregator {
}
public static class Factory extends PipelineAggregatorFactory {
public static class MovAvgPipelineAggregatorBuilder extends PipelineAggregatorBuilder {
private String format;
private GapPolicy gapPolicy = GapPolicy.SKIP;
@ -288,18 +288,18 @@ public class MovAvgPipelineAggregator extends PipelineAggregator {
private int predict = 0;
private Boolean minimize;
public Factory(String name, String bucketsPath) {
public MovAvgPipelineAggregatorBuilder(String name, String bucketsPath) {
this(name, new String[] { bucketsPath });
}
private Factory(String name, String[] bucketsPaths) {
private MovAvgPipelineAggregatorBuilder(String name, String[] bucketsPaths) {
super(name, TYPE.name(), bucketsPaths);
}
/**
* Sets the format to use on the output of this aggregation.
*/
public Factory format(String format) {
public MovAvgPipelineAggregatorBuilder format(String format) {
this.format = format;
return this;
}
@ -314,7 +314,7 @@ public class MovAvgPipelineAggregator extends PipelineAggregator {
/**
* Sets the GapPolicy to use on the output of this aggregation.
*/
public Factory gapPolicy(GapPolicy gapPolicy) {
public MovAvgPipelineAggregatorBuilder gapPolicy(GapPolicy gapPolicy) {
this.gapPolicy = gapPolicy;
return this;
}
@ -342,7 +342,7 @@ public class MovAvgPipelineAggregator extends PipelineAggregator {
* @param window
* Size of window
*/
public Factory window(int window) {
public MovAvgPipelineAggregatorBuilder window(int window) {
if (window <= 0) {
throw new IllegalArgumentException("[window] must be a positive integer: [" + name + "]");
}
@ -366,7 +366,7 @@ public class MovAvgPipelineAggregator extends PipelineAggregator {
* @param model
* A MovAvgModel which has been prepopulated with settings
*/
public Factory modelBuilder(MovAvgModelBuilder model) {
public MovAvgPipelineAggregatorBuilder modelBuilder(MovAvgModelBuilder model) {
this.model = model.build();
return this;
}
@ -378,7 +378,7 @@ public class MovAvgPipelineAggregator extends PipelineAggregator {
* @param model
* A MovAvgModel which has been prepopulated with settings
*/
public Factory model(MovAvgModel model) {
public MovAvgPipelineAggregatorBuilder model(MovAvgModel model) {
this.model = model;
return this;
}
@ -400,7 +400,7 @@ public class MovAvgPipelineAggregator extends PipelineAggregator {
* @param predict
* Number of predictions to make
*/
public Factory predict(int predict) {
public MovAvgPipelineAggregatorBuilder predict(int predict) {
if (predict <= 0) {
throw new IllegalArgumentException("predict must be greater than 0. Found [" + predict + "] in [" + name + "]");
}
@ -425,7 +425,7 @@ public class MovAvgPipelineAggregator extends PipelineAggregator {
* @param minimize
* If the model should be fit to the underlying data
*/
public Factory minimize(boolean minimize) {
public MovAvgPipelineAggregatorBuilder minimize(boolean minimize) {
this.minimize = minimize;
return this;
}
@ -448,7 +448,7 @@ public class MovAvgPipelineAggregator extends PipelineAggregator {
@Override
public void doValidate(AggregatorFactory<?> parent, AggregatorFactory<?>[] aggFactories,
List<PipelineAggregatorFactory> 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
@ -488,8 +488,8 @@ public class MovAvgPipelineAggregator extends PipelineAggregator {
}
@Override
protected PipelineAggregatorFactory doReadFrom(String name, String[] bucketsPaths, StreamInput in) throws IOException {
Factory factory = new Factory(name, bucketsPaths);
protected PipelineAggregatorBuilder doReadFrom(String name, String[] bucketsPaths, StreamInput in) throws IOException {
MovAvgPipelineAggregatorBuilder factory = new MovAvgPipelineAggregatorBuilder(name, bucketsPaths);
factory.format = in.readOptionalString();
factory.gapPolicy = GapPolicy.readFrom(in);
factory.window = in.readVInt();
@ -516,7 +516,7 @@ public class MovAvgPipelineAggregator extends PipelineAggregator {
@Override
protected boolean doEquals(Object obj) {
Factory other = (Factory) obj;
MovAvgPipelineAggregatorBuilder other = (MovAvgPipelineAggregatorBuilder) obj;
return Objects.equals(format, other.format)
&& Objects.equals(gapPolicy, other.gapPolicy)
&& Objects.equals(window, other.window)

View File

@ -25,7 +25,7 @@ import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.index.query.QueryParseContext;
import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorFactory;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilder;
import java.io.IOException;
import java.util.ArrayList;
@ -43,7 +43,7 @@ public class SerialDiffParser implements PipelineAggregator.Parser {
}
@Override
public PipelineAggregatorFactory parse(String reducerName, XContentParser parser, QueryParseContext context) throws IOException {
public PipelineAggregatorBuilder parse(String reducerName, XContentParser parser, QueryParseContext context) throws IOException {
XContentParser.Token token;
String currentFieldName = null;
String[] bucketsPaths = null;
@ -101,7 +101,8 @@ public class SerialDiffParser implements PipelineAggregator.Parser {
"Missing required field [" + BUCKETS_PATH.getPreferredName() + "] for derivative aggregation [" + reducerName + "]");
}
SerialDiffPipelineAggregator.Factory factory = new SerialDiffPipelineAggregator.Factory(reducerName, bucketsPaths[0]);
SerialDiffPipelineAggregator.SerialDiffPipelineAggregatorBuilder factory =
new SerialDiffPipelineAggregator.SerialDiffPipelineAggregatorBuilder(reducerName, bucketsPaths[0]);
if (lag != null) {
factory.lag(lag);
}
@ -115,8 +116,8 @@ public class SerialDiffParser implements PipelineAggregator.Parser {
}
@Override
public PipelineAggregatorFactory getFactoryPrototype() {
return new SerialDiffPipelineAggregator.Factory(null, null);
public PipelineAggregatorBuilder getFactoryPrototype() {
return new SerialDiffPipelineAggregator.SerialDiffPipelineAggregatorBuilder(null, null);
}
}

View File

@ -32,7 +32,7 @@ import org.elasticsearch.search.aggregations.bucket.histogram.InternalHistogram;
import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy;
import org.elasticsearch.search.aggregations.pipeline.InternalSimpleValue;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorFactory;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilder;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorStreams;
import org.elasticsearch.search.aggregations.support.format.ValueFormat;
import org.elasticsearch.search.aggregations.support.format.ValueFormatter;
@ -145,24 +145,24 @@ public class SerialDiffPipelineAggregator extends PipelineAggregator {
out.writeVInt(lag);
}
public static class Factory extends PipelineAggregatorFactory {
public static class SerialDiffPipelineAggregatorBuilder extends PipelineAggregatorBuilder {
private String format;
private GapPolicy gapPolicy = GapPolicy.SKIP;
private int lag = 1;
public Factory(String name, String bucketsPath) {
public SerialDiffPipelineAggregatorBuilder(String name, String bucketsPath) {
this(name, new String[] { bucketsPath });
}
private Factory(String name, String[] bucketsPaths) {
private SerialDiffPipelineAggregatorBuilder(String name, String[] bucketsPaths) {
super(name, TYPE.name(), bucketsPaths);
}
/**
* Sets the lag to use when calculating the serial difference.
*/
public Factory lag(int lag) {
public SerialDiffPipelineAggregatorBuilder lag(int lag) {
if (lag <= 0) {
throw new IllegalArgumentException("[lag] must be a positive integer: [" + name + "]");
}
@ -180,7 +180,7 @@ public class SerialDiffPipelineAggregator extends PipelineAggregator {
/**
* Sets the format to use on the output of this aggregation.
*/
public Factory format(String format) {
public SerialDiffPipelineAggregatorBuilder format(String format) {
this.format = format;
return this;
}
@ -195,7 +195,7 @@ public class SerialDiffPipelineAggregator extends PipelineAggregator {
/**
* Sets the GapPolicy to use on the output of this aggregation.
*/
public Factory gapPolicy(GapPolicy gapPolicy) {
public SerialDiffPipelineAggregatorBuilder gapPolicy(GapPolicy gapPolicy) {
this.gapPolicy = gapPolicy;
return this;
}
@ -231,8 +231,8 @@ public class SerialDiffPipelineAggregator extends PipelineAggregator {
}
@Override
protected PipelineAggregatorFactory doReadFrom(String name, String[] bucketsPaths, StreamInput in) throws IOException {
Factory factory = new Factory(name, bucketsPaths);
protected PipelineAggregatorBuilder doReadFrom(String name, String[] bucketsPaths, StreamInput in) throws IOException {
SerialDiffPipelineAggregatorBuilder factory = new SerialDiffPipelineAggregatorBuilder(name, bucketsPaths);
factory.format = in.readOptionalString();
factory.gapPolicy = GapPolicy.readFrom(in);
factory.lag = in.readVInt();
@ -252,7 +252,7 @@ public class SerialDiffPipelineAggregator extends PipelineAggregator {
}
@Override
protected boolean doEquals(Object obj) {
Factory other = (Factory) obj;
SerialDiffPipelineAggregatorBuilder other = (SerialDiffPipelineAggregatorBuilder) obj;
return Objects.equals(format, other.format)
&& Objects.equals(gapPolicy, other.gapPolicy)
&& Objects.equals(lag, other.lag);

View File

@ -43,9 +43,9 @@ import org.elasticsearch.index.query.QueryParseContext;
import org.elasticsearch.script.Script;
import org.elasticsearch.search.searchafter.SearchAfterBuilder;
import org.elasticsearch.search.aggregations.AggregatorBuilder;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilder;
import org.elasticsearch.search.aggregations.AggregatorFactories;
import org.elasticsearch.search.aggregations.AggregatorParsers;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorFactory;
import org.elasticsearch.search.fetch.innerhits.InnerHitsBuilder;
import org.elasticsearch.search.fetch.source.FetchSourceContext;
import org.elasticsearch.search.highlight.HighlightBuilder;
@ -414,23 +414,23 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ
* Add an aggregation to perform as part of the search.
*/
public SearchSourceBuilder aggregation(AggregatorBuilder<?> aggregation) {
if (aggregations == null) {
if (aggregations == null) {
aggregations = AggregatorFactories.builder();
}
}
aggregations.addAggregator(aggregation);
return this;
return this;
}
/**
* Add an aggregation to perform as part of the search.
*/
public SearchSourceBuilder aggregation(PipelineAggregatorFactory aggregation) {
if (aggregations == null) {
public SearchSourceBuilder aggregation(PipelineAggregatorBuilder aggregation) {
if (aggregations == null) {
aggregations = AggregatorFactories.builder();
}
}
aggregations.addPipelineAggregator(aggregation);
return this;
}
return this;
}
/**
* Gets the bytes representing the aggregation builders for this request.
@ -1034,7 +1034,7 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ
if (aggregations != null) {
builder.field(AGGREGATIONS_FIELD.getPreferredName(), aggregations);
}
}
if (highlightBuilder != null) {
this.highlightBuilder.toXContent(builder, params);
@ -1150,7 +1150,7 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ
SearchSourceBuilder builder = new SearchSourceBuilder();
if (in.readBoolean()) {
builder.aggregations = AggregatorFactories.Builder.PROTOTYPE.readFrom(in);
}
}
builder.explain = in.readOptionalBoolean();
builder.fetchSourceContext = FetchSourceContext.optionalReadFromStream(in);
boolean hasFieldDataFields = in.readBoolean();

View File

@ -56,7 +56,7 @@ import org.elasticsearch.script.ScriptModule;
import org.elasticsearch.script.ScriptService;
import org.elasticsearch.script.ScriptSettings;
import org.elasticsearch.search.SearchModule;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorFactory;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilder;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.IndexSettingsModule;
import org.elasticsearch.test.InternalSettingsPlugin;
@ -76,7 +76,7 @@ import java.util.Set;
import static org.hamcrest.Matchers.equalTo;
public abstract class BasePipelineAggregationTestCase<AF extends PipelineAggregatorFactory> extends ESTestCase {
public abstract class BasePipelineAggregationTestCase<AF extends PipelineAggregatorBuilder> extends ESTestCase {
protected static final String STRING_FIELD_NAME = "mapped_string";
protected static final String INT_FIELD_NAME = "mapped_int";
@ -230,7 +230,7 @@ public abstract class BasePipelineAggregationTestCase<AF extends PipelineAggrega
assertSame(XContentParser.Token.FIELD_NAME, parser.nextToken());
assertEquals(testAgg.type(), parser.currentName());
assertSame(XContentParser.Token.START_OBJECT, parser.nextToken());
PipelineAggregatorFactory newAgg = aggParsers.pipelineAggregator(testAgg.getWriteableName()).parse(testAgg.name(), parser,
PipelineAggregatorBuilder newAgg = aggParsers.pipelineAggregator(testAgg.getWriteableName()).parse(testAgg.name(), parser,
parseContext);
assertSame(XContentParser.Token.END_OBJECT, parser.currentToken());
assertSame(XContentParser.Token.END_OBJECT, parser.nextToken());
@ -251,8 +251,8 @@ public abstract class BasePipelineAggregationTestCase<AF extends PipelineAggrega
try (BytesStreamOutput output = new BytesStreamOutput()) {
testAgg.writeTo(output);
try (StreamInput in = new NamedWriteableAwareStreamInput(StreamInput.wrap(output.bytes()), namedWriteableRegistry)) {
PipelineAggregatorFactory prototype = aggParsers.pipelineAggregator(testAgg.getWriteableName()).getFactoryPrototype();
PipelineAggregatorFactory deserializedQuery = prototype.readFrom(in);
PipelineAggregatorBuilder prototype = aggParsers.pipelineAggregator(testAgg.getWriteableName()).getFactoryPrototype();
PipelineAggregatorBuilder deserializedQuery = prototype.readFrom(in);
assertEquals(deserializedQuery, testAgg);
assertEquals(deserializedQuery.hashCode(), testAgg.hashCode());
assertNotSame(deserializedQuery, testAgg);
@ -292,7 +292,7 @@ public abstract class BasePipelineAggregationTestCase<AF extends PipelineAggrega
try (BytesStreamOutput output = new BytesStreamOutput()) {
agg.writeTo(output);
try (StreamInput in = new NamedWriteableAwareStreamInput(StreamInput.wrap(output.bytes()), namedWriteableRegistry)) {
PipelineAggregatorFactory prototype = aggParsers.pipelineAggregator(agg.getWriteableName()).getFactoryPrototype();
PipelineAggregatorBuilder prototype = aggParsers.pipelineAggregator(agg.getWriteableName()).getFactoryPrototype();
@SuppressWarnings("unchecked")
AF secondAgg = (AF) prototype.readFrom(in);
return secondAgg;

View File

@ -24,15 +24,16 @@ import org.elasticsearch.script.ScriptService.ScriptType;
import org.elasticsearch.search.aggregations.BasePipelineAggregationTestCase;
import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy;
import org.elasticsearch.search.aggregations.pipeline.bucketscript.BucketScriptPipelineAggregator;
import org.elasticsearch.search.aggregations.pipeline.bucketscript.BucketScriptPipelineAggregator.Factory;
import org.elasticsearch.search.aggregations.pipeline.bucketscript.BucketScriptPipelineAggregator.BucketScriptPipelineAggregatorBuilder;
import java.util.HashMap;
import java.util.Map;
public class BucketScriptTests extends BasePipelineAggregationTestCase<BucketScriptPipelineAggregator.Factory> {
public class BucketScriptTests
extends BasePipelineAggregationTestCase<BucketScriptPipelineAggregator.BucketScriptPipelineAggregatorBuilder> {
@Override
protected Factory createTestAggregatorFactory() {
protected BucketScriptPipelineAggregatorBuilder createTestAggregatorFactory() {
String name = randomAsciiOfLengthBetween(3, 20);
Map<String, String> bucketsPaths = new HashMap<>();
int numBucketPaths = randomIntBetween(1, 10);
@ -50,7 +51,7 @@ public class BucketScriptTests extends BasePipelineAggregationTestCase<BucketScr
}
script = new Script("script", randomFrom(ScriptType.values()), randomFrom("my_lang", null), params);
}
Factory factory = new Factory(name, bucketsPaths, script);
BucketScriptPipelineAggregatorBuilder factory = new BucketScriptPipelineAggregatorBuilder(name, bucketsPaths, script);
if (randomBoolean()) {
factory.format(randomAsciiOfLengthBetween(1, 10));
}

View File

@ -24,15 +24,16 @@ import org.elasticsearch.script.ScriptService.ScriptType;
import org.elasticsearch.search.aggregations.BasePipelineAggregationTestCase;
import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy;
import org.elasticsearch.search.aggregations.pipeline.having.BucketSelectorPipelineAggregator;
import org.elasticsearch.search.aggregations.pipeline.having.BucketSelectorPipelineAggregator.Factory;
import org.elasticsearch.search.aggregations.pipeline.having.BucketSelectorPipelineAggregator.BucketSelectorPipelineAggregatorBuilder;
import java.util.HashMap;
import java.util.Map;
public class BucketSelectorTests extends BasePipelineAggregationTestCase<BucketSelectorPipelineAggregator.Factory> {
public class BucketSelectorTests
extends BasePipelineAggregationTestCase<BucketSelectorPipelineAggregator.BucketSelectorPipelineAggregatorBuilder> {
@Override
protected Factory createTestAggregatorFactory() {
protected BucketSelectorPipelineAggregatorBuilder createTestAggregatorFactory() {
String name = randomAsciiOfLengthBetween(3, 20);
Map<String, String> bucketsPaths = new HashMap<>();
int numBucketPaths = randomIntBetween(1, 10);
@ -50,7 +51,7 @@ public class BucketSelectorTests extends BasePipelineAggregationTestCase<BucketS
}
script = new Script("script", randomFrom(ScriptType.values()), randomFrom("my_lang", null), params);
}
Factory factory = new Factory(name, bucketsPaths, script);
BucketSelectorPipelineAggregatorBuilder factory = new BucketSelectorPipelineAggregatorBuilder(name, bucketsPaths, script);
if (randomBoolean()) {
factory.gapPolicy(randomFrom(GapPolicy.values()));
}

View File

@ -21,15 +21,16 @@ package org.elasticsearch.search.aggregations.pipeline;
import org.elasticsearch.search.aggregations.BasePipelineAggregationTestCase;
import org.elasticsearch.search.aggregations.pipeline.cumulativesum.CumulativeSumPipelineAggregator;
import org.elasticsearch.search.aggregations.pipeline.cumulativesum.CumulativeSumPipelineAggregator.Factory;
import org.elasticsearch.search.aggregations.pipeline.cumulativesum.CumulativeSumPipelineAggregator.CumulativeSumPipelineAggregatorBuilder;
public class CumulativeSumTests extends BasePipelineAggregationTestCase<CumulativeSumPipelineAggregator.Factory> {
public class CumulativeSumTests
extends BasePipelineAggregationTestCase<CumulativeSumPipelineAggregator.CumulativeSumPipelineAggregatorBuilder> {
@Override
protected Factory createTestAggregatorFactory() {
protected CumulativeSumPipelineAggregatorBuilder createTestAggregatorFactory() {
String name = randomAsciiOfLengthBetween(3, 20);
String bucketsPath = randomAsciiOfLengthBetween(3, 20);
Factory factory = new Factory(name, bucketsPath);
CumulativeSumPipelineAggregatorBuilder factory = new CumulativeSumPipelineAggregatorBuilder(name, bucketsPath);
if (randomBoolean()) {
factory.format(randomAsciiOfLengthBetween(1, 10));
}

View File

@ -22,15 +22,15 @@ package org.elasticsearch.search.aggregations.pipeline;
import org.elasticsearch.search.aggregations.BasePipelineAggregationTestCase;
import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy;
import org.elasticsearch.search.aggregations.pipeline.derivative.DerivativePipelineAggregator;
import org.elasticsearch.search.aggregations.pipeline.derivative.DerivativePipelineAggregator.Factory;
import org.elasticsearch.search.aggregations.pipeline.derivative.DerivativePipelineAggregator.DerivativePipelineAggregatorBuilder;
public class DerivativeTests extends BasePipelineAggregationTestCase<DerivativePipelineAggregator.Factory> {
public class DerivativeTests extends BasePipelineAggregationTestCase<DerivativePipelineAggregator.DerivativePipelineAggregatorBuilder> {
@Override
protected Factory createTestAggregatorFactory() {
protected DerivativePipelineAggregatorBuilder createTestAggregatorFactory() {
String name = randomAsciiOfLengthBetween(3, 20);
String bucketsPath = randomAsciiOfLengthBetween(3, 20);
Factory factory = new Factory(name, bucketsPath);
DerivativePipelineAggregatorBuilder factory = new DerivativePipelineAggregatorBuilder(name, bucketsPath);
if (randomBoolean()) {
factory.format(randomAsciiOfLengthBetween(1, 10));
}

View File

@ -22,15 +22,16 @@ package org.elasticsearch.search.aggregations.pipeline;
import org.elasticsearch.search.aggregations.BasePipelineAggregationTestCase;
import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy;
import org.elasticsearch.search.aggregations.pipeline.serialdiff.SerialDiffPipelineAggregator;
import org.elasticsearch.search.aggregations.pipeline.serialdiff.SerialDiffPipelineAggregator.Factory;
import org.elasticsearch.search.aggregations.pipeline.serialdiff.SerialDiffPipelineAggregator.SerialDiffPipelineAggregatorBuilder;
public class SerialDifferenceTests extends BasePipelineAggregationTestCase<SerialDiffPipelineAggregator.Factory> {
public class SerialDifferenceTests
extends BasePipelineAggregationTestCase<SerialDiffPipelineAggregator.SerialDiffPipelineAggregatorBuilder> {
@Override
protected Factory createTestAggregatorFactory() {
protected SerialDiffPipelineAggregatorBuilder createTestAggregatorFactory() {
String name = randomAsciiOfLengthBetween(3, 20);
String bucketsPath = randomAsciiOfLengthBetween(3, 20);
Factory factory = new Factory(name, bucketsPath);
SerialDiffPipelineAggregatorBuilder factory = new SerialDiffPipelineAggregatorBuilder(name, bucketsPath);
if (randomBoolean()) {
factory.format(randomAsciiOfLengthBetween(1, 10));
}

View File

@ -22,7 +22,8 @@ package org.elasticsearch.search.aggregations.pipeline.bucketmetrics;
import org.elasticsearch.search.aggregations.BasePipelineAggregationTestCase;
import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy;
public abstract class AbstractBucketMetricsTestCase<PAF extends BucketMetricsFactory> extends BasePipelineAggregationTestCase<PAF> {
public abstract class AbstractBucketMetricsTestCase<PAF extends BucketMetricsPipelineAggregatorBuilder>
extends BasePipelineAggregationTestCase<PAF> {
@Override
protected final PAF createTestAggregatorFactory() {

View File

@ -20,13 +20,13 @@
package org.elasticsearch.search.aggregations.pipeline.bucketmetrics;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.avg.AvgBucketPipelineAggregator;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.avg.AvgBucketPipelineAggregator.Factory;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.avg.AvgBucketPipelineAggregator.AvgBucketPipelineAggregatorBuilder;
public class AvgBucketTests extends AbstractBucketMetricsTestCase<AvgBucketPipelineAggregator.Factory> {
public class AvgBucketTests extends AbstractBucketMetricsTestCase<AvgBucketPipelineAggregator.AvgBucketPipelineAggregatorBuilder> {
@Override
protected Factory doCreateTestAggregatorFactory(String name, String bucketsPath) {
return new Factory(name, bucketsPath);
protected AvgBucketPipelineAggregatorBuilder doCreateTestAggregatorFactory(String name, String bucketsPath) {
return new AvgBucketPipelineAggregatorBuilder(name, bucketsPath);
}

View File

@ -20,13 +20,15 @@
package org.elasticsearch.search.aggregations.pipeline.bucketmetrics;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.stats.extended.ExtendedStatsBucketPipelineAggregator;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.stats.extended.ExtendedStatsBucketPipelineAggregator.Factory;
public class ExtendedStatsBucketTests extends AbstractBucketMetricsTestCase<ExtendedStatsBucketPipelineAggregator.Factory> {
public class ExtendedStatsBucketTests
extends AbstractBucketMetricsTestCase<ExtendedStatsBucketPipelineAggregator.ExtendedStatsBucketPipelineAggregatorBuilder> {
@Override
protected Factory doCreateTestAggregatorFactory(String name, String bucketsPath) {
Factory factory = new Factory(name, bucketsPath);
protected ExtendedStatsBucketPipelineAggregator.ExtendedStatsBucketPipelineAggregatorBuilder doCreateTestAggregatorFactory(String name,
String bucketsPath) {
ExtendedStatsBucketPipelineAggregator.ExtendedStatsBucketPipelineAggregatorBuilder factory =
new ExtendedStatsBucketPipelineAggregator.ExtendedStatsBucketPipelineAggregatorBuilder(name, bucketsPath);
if (randomBoolean()) {
factory.sigma(randomDoubleBetween(0.0, 10.0, false));
}

View File

@ -20,13 +20,13 @@
package org.elasticsearch.search.aggregations.pipeline.bucketmetrics;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.max.MaxBucketPipelineAggregator;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.max.MaxBucketPipelineAggregator.Factory;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.max.MaxBucketPipelineAggregator.MaxBucketPipelineAggregatorBuilder;
public class MaxBucketTests extends AbstractBucketMetricsTestCase<MaxBucketPipelineAggregator.Factory> {
public class MaxBucketTests extends AbstractBucketMetricsTestCase<MaxBucketPipelineAggregator.MaxBucketPipelineAggregatorBuilder> {
@Override
protected Factory doCreateTestAggregatorFactory(String name, String bucketsPath) {
return new Factory(name, bucketsPath);
protected MaxBucketPipelineAggregatorBuilder doCreateTestAggregatorFactory(String name, String bucketsPath) {
return new MaxBucketPipelineAggregatorBuilder(name, bucketsPath);
}

View File

@ -20,13 +20,13 @@
package org.elasticsearch.search.aggregations.pipeline.bucketmetrics;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.min.MinBucketPipelineAggregator;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.min.MinBucketPipelineAggregator.Factory;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.min.MinBucketPipelineAggregator.MinBucketPipelineAggregatorBuilder;
public class MinBucketTests extends AbstractBucketMetricsTestCase<MinBucketPipelineAggregator.Factory> {
public class MinBucketTests extends AbstractBucketMetricsTestCase<MinBucketPipelineAggregator.MinBucketPipelineAggregatorBuilder> {
@Override
protected Factory doCreateTestAggregatorFactory(String name, String bucketsPath) {
return new Factory(name, bucketsPath);
protected MinBucketPipelineAggregatorBuilder doCreateTestAggregatorFactory(String name, String bucketsPath) {
return new MinBucketPipelineAggregatorBuilder(name, bucketsPath);
}

View File

@ -20,13 +20,15 @@
package org.elasticsearch.search.aggregations.pipeline.bucketmetrics;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.percentile.PercentilesBucketPipelineAggregator;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.percentile.PercentilesBucketPipelineAggregator.Factory;
public class PercentilesBucketTests extends AbstractBucketMetricsTestCase<PercentilesBucketPipelineAggregator.Factory> {
public class PercentilesBucketTests
extends AbstractBucketMetricsTestCase<PercentilesBucketPipelineAggregator.PercentilesBucketPipelineAggregatorBuilder> {
@Override
protected Factory doCreateTestAggregatorFactory(String name, String bucketsPath) {
Factory factory = new Factory(name, bucketsPath);
protected PercentilesBucketPipelineAggregator.PercentilesBucketPipelineAggregatorBuilder doCreateTestAggregatorFactory(String name,
String bucketsPath) {
PercentilesBucketPipelineAggregator.PercentilesBucketPipelineAggregatorBuilder factory =
new PercentilesBucketPipelineAggregator.PercentilesBucketPipelineAggregatorBuilder(name, bucketsPath);
if (randomBoolean()) {
int numPercents = randomIntBetween(1, 20);
double[] percents = new double[numPercents];

View File

@ -20,13 +20,13 @@
package org.elasticsearch.search.aggregations.pipeline.bucketmetrics;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.stats.StatsBucketPipelineAggregator;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.stats.StatsBucketPipelineAggregator.Factory;
public class StatsBucketTests extends AbstractBucketMetricsTestCase<StatsBucketPipelineAggregator.Factory> {
public class StatsBucketTests extends AbstractBucketMetricsTestCase<StatsBucketPipelineAggregator.StatsBucketPipelineAggregatorBuilder> {
@Override
protected Factory doCreateTestAggregatorFactory(String name, String bucketsPath) {
return new Factory(name, bucketsPath);
protected StatsBucketPipelineAggregator.StatsBucketPipelineAggregatorBuilder doCreateTestAggregatorFactory(String name,
String bucketsPath) {
return new StatsBucketPipelineAggregator.StatsBucketPipelineAggregatorBuilder(name, bucketsPath);
}

View File

@ -20,13 +20,13 @@
package org.elasticsearch.search.aggregations.pipeline.bucketmetrics;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.sum.SumBucketPipelineAggregator;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.sum.SumBucketPipelineAggregator.Factory;
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.sum.SumBucketPipelineAggregator.SumBucketPipelineAggregatorBuilder;
public class SumBucketTests extends AbstractBucketMetricsTestCase<SumBucketPipelineAggregator.Factory> {
public class SumBucketTests extends AbstractBucketMetricsTestCase<SumBucketPipelineAggregator.SumBucketPipelineAggregatorBuilder> {
@Override
protected Factory doCreateTestAggregatorFactory(String name, String bucketsPath) {
return new Factory(name, bucketsPath);
protected SumBucketPipelineAggregatorBuilder doCreateTestAggregatorFactory(String name, String bucketsPath) {
return new SumBucketPipelineAggregatorBuilder(name, bucketsPath);
}

View File

@ -22,7 +22,7 @@ package org.elasticsearch.search.aggregations.pipeline.moving.avg;
import org.elasticsearch.search.aggregations.BasePipelineAggregationTestCase;
import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy;
import org.elasticsearch.search.aggregations.pipeline.movavg.MovAvgPipelineAggregator;
import org.elasticsearch.search.aggregations.pipeline.movavg.MovAvgPipelineAggregator.Factory;
import org.elasticsearch.search.aggregations.pipeline.movavg.MovAvgPipelineAggregator.MovAvgPipelineAggregatorBuilder;
import org.elasticsearch.search.aggregations.pipeline.movavg.models.EwmaModel;
import org.elasticsearch.search.aggregations.pipeline.movavg.models.HoltLinearModel;
import org.elasticsearch.search.aggregations.pipeline.movavg.models.HoltWintersModel;
@ -30,13 +30,13 @@ import org.elasticsearch.search.aggregations.pipeline.movavg.models.HoltWintersM
import org.elasticsearch.search.aggregations.pipeline.movavg.models.LinearModel;
import org.elasticsearch.search.aggregations.pipeline.movavg.models.SimpleModel;;
public class MovAvgTests extends BasePipelineAggregationTestCase<MovAvgPipelineAggregator.Factory> {
public class MovAvgTests extends BasePipelineAggregationTestCase<MovAvgPipelineAggregator.MovAvgPipelineAggregatorBuilder> {
@Override
protected Factory createTestAggregatorFactory() {
protected MovAvgPipelineAggregatorBuilder createTestAggregatorFactory() {
String name = randomAsciiOfLengthBetween(3, 20);
String bucketsPath = randomAsciiOfLengthBetween(3, 20);
Factory factory = new Factory(name, bucketsPath);
MovAvgPipelineAggregatorBuilder factory = new MovAvgPipelineAggregatorBuilder(name, bucketsPath);
if (randomBoolean()) {
factory.format(randomAsciiOfLengthBetween(1, 10));
}