summaryrefslogtreecommitdiff
path: root/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/BucketMetricsPipelineAggregatorBuilder.java
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/BucketMetricsPipelineAggregatorBuilder.java')
-rw-r--r--core/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/BucketMetricsPipelineAggregatorBuilder.java59
1 files changed, 38 insertions, 21 deletions
diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/BucketMetricsPipelineAggregatorBuilder.java b/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/BucketMetricsPipelineAggregatorBuilder.java
index c28ebed7a7..a3eeed6b5d 100644
--- a/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/BucketMetricsPipelineAggregatorBuilder.java
+++ b/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/BucketMetricsPipelineAggregatorBuilder.java
@@ -39,11 +39,48 @@ public abstract class BucketMetricsPipelineAggregatorBuilder<AF extends BucketMe
private String format = null;
private GapPolicy gapPolicy = GapPolicy.SKIP;
- public BucketMetricsPipelineAggregatorBuilder(String name, String type, String[] bucketsPaths) {
+ protected BucketMetricsPipelineAggregatorBuilder(String name, String type, String[] bucketsPaths) {
super(name, type, bucketsPaths);
}
/**
+ * Read from a stream.
+ */
+ protected BucketMetricsPipelineAggregatorBuilder(StreamInput in, String type) throws IOException {
+ super(in, type);
+ format = in.readOptionalString();
+ gapPolicy = GapPolicy.readFrom(in);
+ }
+
+ @Override
+ protected final void doWriteTo(StreamOutput out) throws IOException {
+ if (false == usesNewStyleSerialization()) {
+ innerWriteTo(out);
+ }
+ out.writeOptionalString(format);
+ gapPolicy.writeTo(out);
+ if (usesNewStyleSerialization()) {
+ innerWriteTo(out);
+ }
+ }
+
+ protected abstract void innerWriteTo(StreamOutput out) throws IOException;
+
+ @Override
+ protected final PipelineAggregatorBuilder<AF> doReadFrom(String name, String[] bucketsPaths, StreamInput in) throws IOException {
+ BucketMetricsPipelineAggregatorBuilder<AF> factory = innerReadFrom(name, bucketsPaths, in);
+ factory.format = in.readOptionalString();
+ factory.gapPolicy = GapPolicy.readFrom(in);
+ return factory;
+ }
+
+ protected BucketMetricsPipelineAggregatorBuilder<AF> innerReadFrom(String name, String[] bucketsPaths, StreamInput in)
+ throws IOException {
+ throw new UnsupportedOperationException(); // NORELEASE remove before 5.0.0 GA
+ }
+
+
+ /**
* Sets the format to use on the output of this aggregation.
*/
@SuppressWarnings("unchecked")
@@ -110,26 +147,6 @@ public abstract class BucketMetricsPipelineAggregatorBuilder<AF extends BucketMe
protected abstract XContentBuilder doXContentBody(XContentBuilder builder, Params params) throws IOException;
@Override
- protected final PipelineAggregatorBuilder<AF> doReadFrom(String name, String[] bucketsPaths, StreamInput in) throws IOException {
- BucketMetricsPipelineAggregatorBuilder<AF> factory = innerReadFrom(name, bucketsPaths, in);
- factory.format = in.readOptionalString();
- factory.gapPolicy = GapPolicy.readFrom(in);
- return factory;
- }
-
- protected abstract BucketMetricsPipelineAggregatorBuilder<AF> innerReadFrom(String name, String[] bucketsPaths, StreamInput in)
- throws IOException;
-
- @Override
- protected final void doWriteTo(StreamOutput out) throws IOException {
- innerWriteTo(out);
- out.writeOptionalString(format);
- gapPolicy.writeTo(out);
- }
-
- protected abstract void innerWriteTo(StreamOutput out) throws IOException;
-
- @Override
protected final int doHashCode() {
return Objects.hash(format, gapPolicy, innerHashCode());
}