Cut remaining pipeline aggregations registerPipelineAggregation
Relates to #17085
This commit is contained in:
parent
36622ecb59
commit
c5bad1d93f
|
@ -193,21 +193,21 @@ import org.elasticsearch.search.aggregations.pipeline.InternalSimpleValue;
|
|||
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator;
|
||||
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilder;
|
||||
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.InternalBucketMetricValue;
|
||||
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.avg.AvgBucketParser;
|
||||
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.avg.AvgBucketPipelineAggregator;
|
||||
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.max.MaxBucketParser;
|
||||
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.avg.AvgBucketPipelineAggregatorBuilder;
|
||||
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.max.MaxBucketPipelineAggregator;
|
||||
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.min.MinBucketParser;
|
||||
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.max.MaxBucketPipelineAggregatorBuilder;
|
||||
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.min.MinBucketPipelineAggregator;
|
||||
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.percentile.PercentilesBucketParser;
|
||||
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.min.MinBucketPipelineAggregatorBuilder;
|
||||
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.percentile.PercentilesBucketPipelineAggregator;
|
||||
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.percentile.PercentilesBucketPipelineAggregatorBuilder;
|
||||
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.stats.StatsBucketPipelineAggregator;
|
||||
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.stats.StatsBucketPipelineAggregatorBuilder;
|
||||
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.stats.extended.ExtendedStatsBucketParser;
|
||||
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.stats.extended.ExtendedStatsBucketPipelineAggregator;
|
||||
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.stats.extended.ExtendedStatsBucketPipelineAggregatorBuilder;
|
||||
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.sum.SumBucketParser;
|
||||
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.sum.SumBucketPipelineAggregator;
|
||||
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.sum.SumBucketPipelineAggregatorBuilder;
|
||||
import org.elasticsearch.search.aggregations.pipeline.bucketscript.BucketScriptPipelineAggregator;
|
||||
import org.elasticsearch.search.aggregations.pipeline.bucketscript.BucketScriptPipelineAggregatorBuilder;
|
||||
import org.elasticsearch.search.aggregations.pipeline.bucketselector.BucketSelectorPipelineAggregator;
|
||||
|
@ -502,15 +502,20 @@ public class SearchModule extends AbstractModule {
|
|||
|
||||
registerPipelineAggregation(DerivativePipelineAggregatorBuilder::new, DerivativePipelineAggregatorBuilder::parse,
|
||||
DerivativePipelineAggregatorBuilder.AGGREGATION_NAME_FIELD);
|
||||
registerPipelineParser(new MaxBucketParser());
|
||||
registerPipelineParser(new MinBucketParser());
|
||||
registerPipelineParser(new AvgBucketParser());
|
||||
registerPipelineParser(new SumBucketParser());
|
||||
registerPipelineAggregation(MaxBucketPipelineAggregatorBuilder::new, MaxBucketPipelineAggregatorBuilder.PARSER,
|
||||
MaxBucketPipelineAggregatorBuilder.AGGREGATION_NAME_FIELD);
|
||||
registerPipelineAggregation(MinBucketPipelineAggregatorBuilder::new, MinBucketPipelineAggregatorBuilder.PARSER,
|
||||
MinBucketPipelineAggregatorBuilder.AGGREGATION_FIELD_NAME);
|
||||
registerPipelineAggregation(AvgBucketPipelineAggregatorBuilder::new, AvgBucketPipelineAggregatorBuilder.PARSER,
|
||||
AvgBucketPipelineAggregatorBuilder.AGGREGATION_NAME_FIELD);
|
||||
registerPipelineAggregation(SumBucketPipelineAggregatorBuilder::new, SumBucketPipelineAggregatorBuilder.PARSER,
|
||||
SumBucketPipelineAggregatorBuilder.AGGREGATION_NAME_FIELD);
|
||||
registerPipelineAggregation(StatsBucketPipelineAggregatorBuilder::new, StatsBucketPipelineAggregatorBuilder.PARSER,
|
||||
StatsBucketPipelineAggregatorBuilder.AGGREGATION_NAME_FIELD);
|
||||
registerPipelineAggregation(ExtendedStatsBucketPipelineAggregatorBuilder::new, new ExtendedStatsBucketParser(),
|
||||
ExtendedStatsBucketPipelineAggregatorBuilder.AGGREGATION_NAME_FIELD);
|
||||
registerPipelineParser(new PercentilesBucketParser());
|
||||
registerPipelineAggregation(PercentilesBucketPipelineAggregatorBuilder::new, PercentilesBucketPipelineAggregatorBuilder.PARSER,
|
||||
PercentilesBucketPipelineAggregatorBuilder.AGGREGATION_NAME_FIELD);
|
||||
registerPipelineAggregation(MovAvgPipelineAggregatorBuilder::new,
|
||||
(n, c) -> MovAvgPipelineAggregatorBuilder.parse(movAvgModelParserMapper, n, c),
|
||||
MovAvgPipelineAggregatorBuilder.AGGREGATION_FIELD_NAME);
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.search.aggregations.pipeline.bucketmetrics.avg;
|
||||
|
||||
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsParser;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class AvgBucketParser extends BucketMetricsParser {
|
||||
@Override
|
||||
public String type() {
|
||||
return AvgBucketPipelineAggregator.TYPE.name();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AvgBucketPipelineAggregatorBuilder buildFactory(String pipelineAggregatorName, String bucketsPath,
|
||||
Map<String, Object> unparsedParams) {
|
||||
return new AvgBucketPipelineAggregatorBuilder(pipelineAggregatorName, bucketsPath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AvgBucketPipelineAggregatorBuilder getFactoryPrototype() {
|
||||
return AvgBucketPipelineAggregatorBuilder.PROTOTYPE;
|
||||
}
|
||||
}
|
|
@ -19,12 +19,14 @@
|
|||
|
||||
package org.elasticsearch.search.aggregations.pipeline.bucketmetrics.avg;
|
||||
|
||||
import org.elasticsearch.common.ParseField;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactory;
|
||||
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator;
|
||||
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilder;
|
||||
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsParser;
|
||||
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsPipelineAggregatorBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -32,15 +34,28 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
public class AvgBucketPipelineAggregatorBuilder extends BucketMetricsPipelineAggregatorBuilder<AvgBucketPipelineAggregatorBuilder> {
|
||||
|
||||
static final AvgBucketPipelineAggregatorBuilder PROTOTYPE = new AvgBucketPipelineAggregatorBuilder("", "");
|
||||
public static final String NAME = AvgBucketPipelineAggregator.TYPE.name();
|
||||
public static final ParseField AGGREGATION_NAME_FIELD = new ParseField(NAME);
|
||||
|
||||
public AvgBucketPipelineAggregatorBuilder(String name, String bucketsPath) {
|
||||
this(name, new String[] { bucketsPath });
|
||||
super(name, AvgBucketPipelineAggregator.TYPE.name(), new String[] { bucketsPath });
|
||||
}
|
||||
|
||||
private AvgBucketPipelineAggregatorBuilder(String name, String[] bucketsPaths) {
|
||||
super(name, AvgBucketPipelineAggregator.TYPE.name(), bucketsPaths);
|
||||
/**
|
||||
* Read from a stream.
|
||||
*/
|
||||
public AvgBucketPipelineAggregatorBuilder(StreamInput in) throws IOException {
|
||||
super(in, NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void innerWriteTo(StreamOutput out) throws IOException {
|
||||
// Do nothing, no extra state to write to stream
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean usesNewStyleSerialization() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -62,15 +77,13 @@ public class AvgBucketPipelineAggregatorBuilder extends BucketMetricsPipelineAgg
|
|||
return builder;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AvgBucketPipelineAggregatorBuilder innerReadFrom(String name, String[] bucketsPaths, StreamInput in) throws IOException {
|
||||
return new AvgBucketPipelineAggregatorBuilder(name, bucketsPaths);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void innerWriteTo(StreamOutput out) throws IOException {
|
||||
// Do nothing, no extra state to write to stream
|
||||
}
|
||||
public static final PipelineAggregator.Parser PARSER = new BucketMetricsParser() {
|
||||
@Override
|
||||
protected AvgBucketPipelineAggregatorBuilder buildFactory(String pipelineAggregatorName,
|
||||
String bucketsPath, Map<String, Object> unparsedParams) {
|
||||
return new AvgBucketPipelineAggregatorBuilder(pipelineAggregatorName, bucketsPath);
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected int innerHashCode() {
|
||||
|
@ -82,4 +95,8 @@ public class AvgBucketPipelineAggregatorBuilder extends BucketMetricsPipelineAgg
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWriteableName() {
|
||||
return NAME;
|
||||
}
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.search.aggregations.pipeline.bucketmetrics.max;
|
||||
|
||||
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsParser;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class MaxBucketParser extends BucketMetricsParser {
|
||||
|
||||
@Override
|
||||
public String type() {
|
||||
return MaxBucketPipelineAggregator.TYPE.name();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MaxBucketPipelineAggregatorBuilder buildFactory(String pipelineAggregatorName, String bucketsPath,
|
||||
Map<String, Object> unparsedParams) {
|
||||
return new MaxBucketPipelineAggregatorBuilder(pipelineAggregatorName, bucketsPath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MaxBucketPipelineAggregatorBuilder getFactoryPrototype() {
|
||||
return MaxBucketPipelineAggregatorBuilder.PROTOTYPE;
|
||||
}
|
||||
|
||||
}
|
|
@ -19,29 +19,43 @@
|
|||
|
||||
package org.elasticsearch.search.aggregations.pipeline.bucketmetrics.max;
|
||||
|
||||
import org.elasticsearch.common.ParseField;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactory;
|
||||
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator;
|
||||
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilder;
|
||||
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsParser;
|
||||
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsPipelineAggregatorBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class MaxBucketPipelineAggregatorBuilder
|
||||
extends BucketMetricsPipelineAggregatorBuilder<MaxBucketPipelineAggregatorBuilder> {
|
||||
|
||||
static final MaxBucketPipelineAggregatorBuilder PROTOTYPE = new MaxBucketPipelineAggregatorBuilder("", "");
|
||||
public class MaxBucketPipelineAggregatorBuilder extends BucketMetricsPipelineAggregatorBuilder<MaxBucketPipelineAggregatorBuilder> {
|
||||
public static final String NAME = MaxBucketPipelineAggregator.TYPE.name();
|
||||
public static final ParseField AGGREGATION_NAME_FIELD = new ParseField(NAME);
|
||||
|
||||
public MaxBucketPipelineAggregatorBuilder(String name, String bucketsPath) {
|
||||
this(name, new String[] { bucketsPath });
|
||||
super(name, MaxBucketPipelineAggregator.TYPE.name(), new String[] { bucketsPath });
|
||||
}
|
||||
|
||||
private MaxBucketPipelineAggregatorBuilder(String name, String[] bucketsPaths) {
|
||||
super(name, MaxBucketPipelineAggregator.TYPE.name(), bucketsPaths);
|
||||
/**
|
||||
* Read from a stream.
|
||||
*/
|
||||
public MaxBucketPipelineAggregatorBuilder(StreamInput in) throws IOException {
|
||||
super(in, NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void innerWriteTo(StreamOutput out) throws IOException {
|
||||
// Do nothing, no extra state to write to stream
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean usesNewStyleSerialization() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -63,16 +77,13 @@ public class MaxBucketPipelineAggregatorBuilder
|
|||
return builder;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MaxBucketPipelineAggregatorBuilder innerReadFrom(String name, String[] bucketsPaths, StreamInput in)
|
||||
throws IOException {
|
||||
return new MaxBucketPipelineAggregatorBuilder(name, bucketsPaths);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void innerWriteTo(StreamOutput out) throws IOException {
|
||||
// Do nothing, no extra state to write to stream
|
||||
}
|
||||
public static final PipelineAggregator.Parser PARSER = new BucketMetricsParser() {
|
||||
@Override
|
||||
protected MaxBucketPipelineAggregatorBuilder buildFactory(String pipelineAggregatorName,
|
||||
String bucketsPath, Map<String, Object> unparsedParams) {
|
||||
return new MaxBucketPipelineAggregatorBuilder(pipelineAggregatorName, bucketsPath);
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected int innerHashCode() {
|
||||
|
@ -84,4 +95,8 @@ public class MaxBucketPipelineAggregatorBuilder
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWriteableName() {
|
||||
return NAME;
|
||||
}
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.search.aggregations.pipeline.bucketmetrics.min;
|
||||
|
||||
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsParser;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class MinBucketParser extends BucketMetricsParser {
|
||||
|
||||
@Override
|
||||
public String type() {
|
||||
return MinBucketPipelineAggregator.TYPE.name();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MinBucketPipelineAggregatorBuilder buildFactory(String pipelineAggregatorName, String bucketsPath,
|
||||
Map<String, Object> unparsedParams) {
|
||||
return new MinBucketPipelineAggregatorBuilder(pipelineAggregatorName, bucketsPath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MinBucketPipelineAggregatorBuilder getFactoryPrototype() {
|
||||
return MinBucketPipelineAggregatorBuilder.PROTOTYPE;
|
||||
}
|
||||
|
||||
}
|
|
@ -19,29 +19,43 @@
|
|||
|
||||
package org.elasticsearch.search.aggregations.pipeline.bucketmetrics.min;
|
||||
|
||||
import org.elasticsearch.common.ParseField;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactory;
|
||||
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator;
|
||||
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilder;
|
||||
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsParser;
|
||||
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsPipelineAggregatorBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class MinBucketPipelineAggregatorBuilder
|
||||
extends BucketMetricsPipelineAggregatorBuilder<MinBucketPipelineAggregatorBuilder> {
|
||||
|
||||
static final MinBucketPipelineAggregatorBuilder PROTOTYPE = new MinBucketPipelineAggregatorBuilder("", "");
|
||||
public class MinBucketPipelineAggregatorBuilder extends BucketMetricsPipelineAggregatorBuilder<MinBucketPipelineAggregatorBuilder> {
|
||||
public static final String NAME = MinBucketPipelineAggregator.TYPE.name();
|
||||
public static final ParseField AGGREGATION_FIELD_NAME = new ParseField(NAME);
|
||||
|
||||
public MinBucketPipelineAggregatorBuilder(String name, String bucketsPath) {
|
||||
this(name, new String[] { bucketsPath });
|
||||
super(name, MinBucketPipelineAggregator.TYPE.name(), new String[] { bucketsPath });
|
||||
}
|
||||
|
||||
private MinBucketPipelineAggregatorBuilder(String name, String[] bucketsPaths) {
|
||||
super(name, MinBucketPipelineAggregator.TYPE.name(), bucketsPaths);
|
||||
/**
|
||||
* Read from a stream.
|
||||
*/
|
||||
public MinBucketPipelineAggregatorBuilder(StreamInput in) throws IOException {
|
||||
super(in, NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void innerWriteTo(StreamOutput out) throws IOException {
|
||||
// Do nothing, no extra state to write to stream
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean usesNewStyleSerialization() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -63,16 +77,13 @@ public class MinBucketPipelineAggregatorBuilder
|
|||
return builder;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MinBucketPipelineAggregatorBuilder innerReadFrom(String name, String[] bucketsPaths, StreamInput in)
|
||||
throws IOException {
|
||||
return new MinBucketPipelineAggregatorBuilder(name, bucketsPaths);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void innerWriteTo(StreamOutput out) throws IOException {
|
||||
// Do nothing, no extra state to write to stream
|
||||
}
|
||||
public static final PipelineAggregator.Parser PARSER = new BucketMetricsParser() {
|
||||
@Override
|
||||
protected MinBucketPipelineAggregatorBuilder buildFactory(String pipelineAggregatorName,
|
||||
String bucketsPath, Map<String, Object> unparsedParams) {
|
||||
return new MinBucketPipelineAggregatorBuilder(pipelineAggregatorName, bucketsPath);
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected int innerHashCode() {
|
||||
|
@ -84,4 +95,8 @@ public class MinBucketPipelineAggregatorBuilder
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWriteableName() {
|
||||
return NAME;
|
||||
}
|
||||
}
|
|
@ -1,78 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.search.aggregations.pipeline.bucketmetrics.percentile;
|
||||
|
||||
import org.elasticsearch.common.ParseField;
|
||||
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsParser;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public class PercentilesBucketParser extends BucketMetricsParser {
|
||||
|
||||
public static final ParseField PERCENTS = new ParseField("percents");
|
||||
|
||||
@Override
|
||||
public String type() {
|
||||
return PercentilesBucketPipelineAggregator.TYPE.name();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PercentilesBucketPipelineAggregatorBuilder buildFactory(String pipelineAggregatorName,
|
||||
String bucketsPath, Map<String, Object> unparsedParams) throws ParseException {
|
||||
|
||||
double[] percents = null;
|
||||
int counter = 0;
|
||||
Object percentParam = unparsedParams.get(PERCENTS.getPreferredName());
|
||||
|
||||
if (percentParam != null) {
|
||||
if (percentParam instanceof List) {
|
||||
percents = new double[((List<?>) percentParam).size()];
|
||||
for (Object p : (List<?>) percentParam) {
|
||||
if (p instanceof Double) {
|
||||
percents[counter] = (Double) p;
|
||||
counter += 1;
|
||||
} else {
|
||||
throw new ParseException("Parameter [" + PERCENTS.getPreferredName() + "] must be an array of doubles, type `"
|
||||
+ percentParam.getClass().getSimpleName() + "` provided instead", 0);
|
||||
}
|
||||
}
|
||||
unparsedParams.remove(PERCENTS.getPreferredName());
|
||||
} else {
|
||||
throw new ParseException("Parameter [" + PERCENTS.getPreferredName() + "] must be an array of doubles, type `"
|
||||
+ percentParam.getClass().getSimpleName() + "` provided instead", 0);
|
||||
}
|
||||
}
|
||||
|
||||
PercentilesBucketPipelineAggregatorBuilder factory = new
|
||||
PercentilesBucketPipelineAggregatorBuilder(pipelineAggregatorName, bucketsPath);
|
||||
if (percents != null) {
|
||||
factory.percents(percents);
|
||||
}
|
||||
return factory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PercentilesBucketPipelineAggregatorBuilder getFactoryPrototype() {
|
||||
return PercentilesBucketPipelineAggregatorBuilder.PROTOTYPE;
|
||||
}
|
||||
}
|
|
@ -19,15 +19,18 @@
|
|||
|
||||
package org.elasticsearch.search.aggregations.pipeline.bucketmetrics.percentile;
|
||||
|
||||
import org.elasticsearch.common.ParseField;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactory;
|
||||
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator;
|
||||
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilder;
|
||||
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsParser;
|
||||
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsPipelineAggregatorBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -35,17 +38,34 @@ import java.util.Objects;
|
|||
|
||||
public class PercentilesBucketPipelineAggregatorBuilder
|
||||
extends BucketMetricsPipelineAggregatorBuilder<PercentilesBucketPipelineAggregatorBuilder> {
|
||||
public static final String NAME = PercentilesBucketPipelineAggregator.TYPE.name();
|
||||
public static final ParseField AGGREGATION_NAME_FIELD = new ParseField(NAME);
|
||||
|
||||
static final PercentilesBucketPipelineAggregatorBuilder PROTOTYPE = new PercentilesBucketPipelineAggregatorBuilder("", "");
|
||||
private static final ParseField PERCENTS_FIELD = new ParseField("percents");
|
||||
|
||||
private double[] percents = new double[] { 1.0, 5.0, 25.0, 50.0, 75.0, 95.0, 99.0 };
|
||||
|
||||
public PercentilesBucketPipelineAggregatorBuilder(String name, String bucketsPath) {
|
||||
this(name, new String[] { bucketsPath });
|
||||
super(name, PercentilesBucketPipelineAggregator.TYPE.name(), new String[] { bucketsPath });
|
||||
}
|
||||
|
||||
private PercentilesBucketPipelineAggregatorBuilder(String name, String[] bucketsPaths) {
|
||||
super(name, PercentilesBucketPipelineAggregator.TYPE.name(), bucketsPaths);
|
||||
/**
|
||||
* Read from a stream.
|
||||
*/
|
||||
public PercentilesBucketPipelineAggregatorBuilder(StreamInput in)
|
||||
throws IOException {
|
||||
super(in, NAME);
|
||||
percents = in.readDoubleArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void innerWriteTo(StreamOutput out) throws IOException {
|
||||
out.writeDoubleArray(percents);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean usesNewStyleSerialization() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -64,7 +84,7 @@ public class PercentilesBucketPipelineAggregatorBuilder
|
|||
}
|
||||
for (Double p : percents) {
|
||||
if (p == null || p < 0.0 || p > 100.0) {
|
||||
throw new IllegalArgumentException(PercentilesBucketParser.PERCENTS.getPreferredName()
|
||||
throw new IllegalArgumentException(PERCENTS_FIELD.getPreferredName()
|
||||
+ " must only contain non-null doubles from 0.0-100.0 inclusive");
|
||||
}
|
||||
}
|
||||
|
@ -87,7 +107,7 @@ public class PercentilesBucketPipelineAggregatorBuilder
|
|||
|
||||
for (Double p : percents) {
|
||||
if (p == null || p < 0.0 || p > 100.0) {
|
||||
throw new IllegalStateException(PercentilesBucketParser.PERCENTS.getPreferredName()
|
||||
throw new IllegalStateException(PERCENTS_FIELD.getPreferredName()
|
||||
+ " must only contain non-null doubles from 0.0-100.0 inclusive");
|
||||
}
|
||||
}
|
||||
|
@ -96,23 +116,48 @@ public class PercentilesBucketPipelineAggregatorBuilder
|
|||
@Override
|
||||
protected XContentBuilder doXContentBody(XContentBuilder builder, Params params) throws IOException {
|
||||
if (percents != null) {
|
||||
builder.field(PercentilesBucketParser.PERCENTS.getPreferredName(), percents);
|
||||
builder.field(PERCENTS_FIELD.getPreferredName(), percents);
|
||||
}
|
||||
return builder;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PercentilesBucketPipelineAggregatorBuilder innerReadFrom(String name, String[] bucketsPaths, StreamInput in)
|
||||
throws IOException {
|
||||
PercentilesBucketPipelineAggregatorBuilder factory = new PercentilesBucketPipelineAggregatorBuilder(name, bucketsPaths);
|
||||
factory.percents = in.readDoubleArray();
|
||||
return factory;
|
||||
}
|
||||
public static final PipelineAggregator.Parser PARSER = new BucketMetricsParser() {
|
||||
@Override
|
||||
protected PercentilesBucketPipelineAggregatorBuilder buildFactory(String pipelineAggregatorName,
|
||||
String bucketsPath, Map<String, Object> unparsedParams) throws ParseException {
|
||||
double[] percents = null;
|
||||
int counter = 0;
|
||||
Object percentParam = unparsedParams.get(PERCENTS_FIELD.getPreferredName());
|
||||
|
||||
@Override
|
||||
protected void innerWriteTo(StreamOutput out) throws IOException {
|
||||
out.writeDoubleArray(percents);
|
||||
}
|
||||
if (percentParam != null) {
|
||||
if (percentParam instanceof List) {
|
||||
percents = new double[((List<?>) percentParam).size()];
|
||||
for (Object p : (List<?>) percentParam) {
|
||||
if (p instanceof Double) {
|
||||
percents[counter] = (Double) p;
|
||||
counter += 1;
|
||||
} else {
|
||||
throw new ParseException(
|
||||
"Parameter [" + PERCENTS_FIELD.getPreferredName() + "] must be an array of doubles, type `"
|
||||
+ percentParam.getClass().getSimpleName() + "` provided instead",
|
||||
0);
|
||||
}
|
||||
}
|
||||
unparsedParams.remove(PERCENTS_FIELD.getPreferredName());
|
||||
} else {
|
||||
throw new ParseException("Parameter [" + PERCENTS_FIELD.getPreferredName() + "] must be an array of doubles, type `"
|
||||
+ percentParam.getClass().getSimpleName() + "` provided instead", 0);
|
||||
}
|
||||
}
|
||||
|
||||
PercentilesBucketPipelineAggregatorBuilder factory = new
|
||||
PercentilesBucketPipelineAggregatorBuilder(pipelineAggregatorName, bucketsPath);
|
||||
if (percents != null) {
|
||||
factory.percents(percents);
|
||||
}
|
||||
return factory;
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected int innerHashCode() {
|
||||
|
@ -125,4 +170,8 @@ public class PercentilesBucketPipelineAggregatorBuilder
|
|||
return Objects.deepEquals(percents, other.percents);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWriteableName() {
|
||||
return NAME;
|
||||
}
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.search.aggregations.pipeline.bucketmetrics.sum;
|
||||
|
||||
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsParser;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class SumBucketParser extends BucketMetricsParser {
|
||||
@Override
|
||||
public String type() {
|
||||
return SumBucketPipelineAggregator.TYPE.name();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SumBucketPipelineAggregatorBuilder buildFactory(String pipelineAggregatorName, String bucketsPath,
|
||||
Map<String, Object> unparsedParams) {
|
||||
return new SumBucketPipelineAggregatorBuilder(pipelineAggregatorName, bucketsPath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SumBucketPipelineAggregatorBuilder getFactoryPrototype() {
|
||||
return SumBucketPipelineAggregatorBuilder.PROTOTYPE;
|
||||
}
|
||||
}
|
|
@ -19,29 +19,43 @@
|
|||
|
||||
package org.elasticsearch.search.aggregations.pipeline.bucketmetrics.sum;
|
||||
|
||||
import org.elasticsearch.common.ParseField;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactory;
|
||||
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator;
|
||||
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilder;
|
||||
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsParser;
|
||||
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.BucketMetricsPipelineAggregatorBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class SumBucketPipelineAggregatorBuilder
|
||||
extends BucketMetricsPipelineAggregatorBuilder<SumBucketPipelineAggregatorBuilder> {
|
||||
|
||||
static final SumBucketPipelineAggregatorBuilder PROTOTYPE = new SumBucketPipelineAggregatorBuilder("", "");
|
||||
public class SumBucketPipelineAggregatorBuilder extends BucketMetricsPipelineAggregatorBuilder<SumBucketPipelineAggregatorBuilder> {
|
||||
public static final String NAME = SumBucketPipelineAggregator.TYPE.name();
|
||||
public static final ParseField AGGREGATION_NAME_FIELD = new ParseField(NAME);
|
||||
|
||||
public SumBucketPipelineAggregatorBuilder(String name, String bucketsPath) {
|
||||
this(name, new String[] { bucketsPath });
|
||||
super(name, SumBucketPipelineAggregator.TYPE.name(), new String[] { bucketsPath });
|
||||
}
|
||||
|
||||
private SumBucketPipelineAggregatorBuilder(String name, String[] bucketsPaths) {
|
||||
super(name, SumBucketPipelineAggregator.TYPE.name(), bucketsPaths);
|
||||
/**
|
||||
* Read from a stream.
|
||||
*/
|
||||
public SumBucketPipelineAggregatorBuilder(StreamInput in) throws IOException {
|
||||
super(in, NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void innerWriteTo(StreamOutput out) throws IOException {
|
||||
// Do nothing, no extra state to write to stream
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean usesNewStyleSerialization() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -63,16 +77,13 @@ public class SumBucketPipelineAggregatorBuilder
|
|||
return builder;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SumBucketPipelineAggregatorBuilder innerReadFrom(String name, String[] bucketsPaths, StreamInput in)
|
||||
throws IOException {
|
||||
return new SumBucketPipelineAggregatorBuilder(name, bucketsPaths);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void innerWriteTo(StreamOutput out) throws IOException {
|
||||
// Do nothing, no extra state to write to stream
|
||||
}
|
||||
public static final PipelineAggregator.Parser PARSER = new BucketMetricsParser() {
|
||||
@Override
|
||||
protected SumBucketPipelineAggregatorBuilder buildFactory(String pipelineAggregatorName,
|
||||
String bucketsPath, Map<String, Object> unparsedParams) {
|
||||
return new SumBucketPipelineAggregatorBuilder(pipelineAggregatorName, bucketsPath);
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected int innerHashCode() {
|
||||
|
@ -84,4 +95,8 @@ public class SumBucketPipelineAggregatorBuilder
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWriteableName() {
|
||||
return NAME;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue