From 38721ecf7baab522bf943334149cffbe03311368 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Mon, 18 Apr 2016 19:49:27 -0400 Subject: [PATCH] Remove writeAllocationCommand and writeValueFormat Replace with writeNamedWriteable. s/write/read/g --- .../allocation/RerouteExplanation.java | 4 ++-- .../command/AllocationCommands.java | 4 ++-- .../common/io/stream/StreamInput.java | 18 -------------- .../common/io/stream/StreamOutput.java | 18 -------------- .../bucket/BucketStreamContext.java | 4 ++-- .../bucket/histogram/InternalHistogram.java | 4 ++-- .../bucket/range/InternalRange.java | 4 ++-- .../significant/SignificantLongTerms.java | 4 ++-- .../bucket/terms/DoubleTerms.java | 4 ++-- .../aggregations/bucket/terms/LongTerms.java | 4 ++-- .../bucket/terms/StringTerms.java | 4 ++-- .../aggregations/metrics/avg/InternalAvg.java | 4 ++-- .../cardinality/InternalCardinality.java | 5 ++-- .../aggregations/metrics/max/InternalMax.java | 4 ++-- .../aggregations/metrics/min/InternalMin.java | 4 ++-- .../hdr/AbstractInternalHDRPercentiles.java | 4 ++-- .../AbstractInternalTDigestPercentiles.java | 4 ++-- .../metrics/stats/InternalStats.java | 4 ++-- .../aggregations/metrics/sum/InternalSum.java | 4 ++-- .../pipeline/InternalSimpleValue.java | 4 ++-- .../BucketMetricsPipelineAggregator.java | 4 ++-- .../InternalBucketMetricValue.java | 4 ++-- .../percentile/InternalPercentilesBucket.java | 4 ++-- .../BucketScriptPipelineAggregator.java | 4 ++-- .../CumulativeSumPipelineAggregator.java | 4 ++-- .../DerivativePipelineAggregator.java | 4 ++-- .../movavg/MovAvgPipelineAggregator.java | 4 ++-- .../SerialDiffPipelineAggregator.java | 4 ++-- .../search/DocValueFormatTests.java | 24 +++++++++---------- 29 files changed, 65 insertions(+), 100 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/cluster/routing/allocation/RerouteExplanation.java b/core/src/main/java/org/elasticsearch/cluster/routing/allocation/RerouteExplanation.java index fc4dbe447af..d591cc131b5 100644 --- a/core/src/main/java/org/elasticsearch/cluster/routing/allocation/RerouteExplanation.java +++ b/core/src/main/java/org/elasticsearch/cluster/routing/allocation/RerouteExplanation.java @@ -52,13 +52,13 @@ public class RerouteExplanation implements ToXContent { } public static RerouteExplanation readFrom(StreamInput in) throws IOException { - AllocationCommand command = in.readAllocationCommand(); + AllocationCommand command = in.readNamedWriteable(AllocationCommand.class); Decision decisions = Decision.readFrom(in); return new RerouteExplanation(command, decisions); } public static void writeTo(RerouteExplanation explanation, StreamOutput out) throws IOException { - out.writeAllocationCommand(explanation.command); + out.writeNamedWriteable(explanation.command); Decision.writeTo(explanation.decisions, out); } diff --git a/core/src/main/java/org/elasticsearch/cluster/routing/allocation/command/AllocationCommands.java b/core/src/main/java/org/elasticsearch/cluster/routing/allocation/command/AllocationCommands.java index 10c43fac7d7..50a23d3e793 100644 --- a/core/src/main/java/org/elasticsearch/cluster/routing/allocation/command/AllocationCommands.java +++ b/core/src/main/java/org/elasticsearch/cluster/routing/allocation/command/AllocationCommands.java @@ -96,7 +96,7 @@ public class AllocationCommands { AllocationCommands commands = new AllocationCommands(); int size = in.readVInt(); for (int i = 0; i < size; i++) { - commands.add(in.readAllocationCommand()); + commands.add(in.readNamedWriteable(AllocationCommand.class)); } return commands; } @@ -111,7 +111,7 @@ public class AllocationCommands { public static void writeTo(AllocationCommands commands, StreamOutput out) throws IOException { out.writeVInt(commands.commands.size()); for (AllocationCommand command : commands.commands) { - out.writeAllocationCommand(command); + out.writeNamedWriteable(command); } } diff --git a/core/src/main/java/org/elasticsearch/common/io/stream/StreamInput.java b/core/src/main/java/org/elasticsearch/common/io/stream/StreamInput.java index 5469ced526f..a0cfca3bfd4 100644 --- a/core/src/main/java/org/elasticsearch/common/io/stream/StreamInput.java +++ b/core/src/main/java/org/elasticsearch/common/io/stream/StreamInput.java @@ -790,24 +790,6 @@ public abstract class StreamInput extends InputStream { return readNamedWriteable(Task.Status.class); } - /** - * Reads a {@link DocValueFormat} from the current stream. - * @deprecated prefer {@link #readNamedWriteable(Class)} passing {@link DocValueFormat}. - */ - @Deprecated - public DocValueFormat readValueFormat() throws IOException { - return readNamedWriteable(DocValueFormat.class); - } - - /** - * Reads an {@link AllocationCommand} from the stream. - * @deprecated prefer {@link #readNamedWriteable(Class)} passing {@link AllocationCommand}. - */ - @Deprecated - public AllocationCommand readAllocationCommand() throws IOException { - return readNamedWriteable(AllocationCommand.class); - } - /** * Reads a list of objects */ diff --git a/core/src/main/java/org/elasticsearch/common/io/stream/StreamOutput.java b/core/src/main/java/org/elasticsearch/common/io/stream/StreamOutput.java index fac66d42265..23a70af8689 100644 --- a/core/src/main/java/org/elasticsearch/common/io/stream/StreamOutput.java +++ b/core/src/main/java/org/elasticsearch/common/io/stream/StreamOutput.java @@ -790,22 +790,4 @@ public abstract class StreamOutput extends OutputStream { public void writeSortBuilder(SortBuilder sort) throws IOException { writeNamedWriteable(sort); } - - /** - * Writes a {@link DocValueFormat}. - * @deprecated prefer {@link #writeNamedWriteable(NamedWriteable)} - */ - @Deprecated - public void writeValueFormat(DocValueFormat format) throws IOException { - writeNamedWriteable(format); - } - - /** - * Writes an {@link AllocationCommand} to the stream. - * @deprecated prefer {@link #writeNamedWriteable(NamedWriteable)} - */ - @Deprecated - public void writeAllocationCommand(AllocationCommand command) throws IOException { - writeNamedWriteable(command); - } } diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/BucketStreamContext.java b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/BucketStreamContext.java index 794383e8d70..5916baa3f8e 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/BucketStreamContext.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/BucketStreamContext.java @@ -62,14 +62,14 @@ public class BucketStreamContext implements Streamable { @Override public void readFrom(StreamInput in) throws IOException { - format = in.readValueFormat(); + format = in.readNamedWriteable(DocValueFormat.class); keyed = in.readBoolean(); attributes = in.readMap(); } @Override public void writeTo(StreamOutput out) throws IOException { - out.writeValueFormat(format); + out.writeNamedWriteable(format); out.writeBoolean(keyed); out.writeMap(attributes); } diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/InternalHistogram.java b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/InternalHistogram.java index 92e61c85bb9..a5ee0728b4a 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/InternalHistogram.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/InternalHistogram.java @@ -497,7 +497,7 @@ public class InternalHistogram extends Inter if (minDocCount == 0) { emptyBucketInfo = EmptyBucketInfo.readFrom(in); } - format = in.readValueFormat(); + format = in.readNamedWriteable(DocValueFormat.class); keyed = in.readBoolean(); int size = in.readVInt(); List buckets = new ArrayList<>(size); @@ -528,7 +528,7 @@ public class InternalHistogram extends Inter if (minDocCount == 0) { EmptyBucketInfo.writeTo(emptyBucketInfo, out); } - out.writeValueFormat(format); + out.writeNamedWriteable(format); out.writeBoolean(keyed); out.writeVInt(buckets.size()); for (B bucket : buckets) { diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/range/InternalRange.java b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/range/InternalRange.java index ce4e0ba60f1..0eebd6df150 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/range/InternalRange.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/range/InternalRange.java @@ -324,7 +324,7 @@ public class InternalRange ranges = new ArrayList<>(size); @@ -338,7 +338,7 @@ public class InternalRange protected void doReadFrom(StreamInput in) throws IOException { this.docCountError = in.readLong(); this.order = InternalOrder.Streams.readOrder(in); - this.format = in.readValueFormat(); + this.format = in.readNamedWriteable(DocValueFormat.class); this.requiredSize = readSize(in); this.shardSize = readSize(in); this.showTermDocCountError = in.readBoolean(); @@ -211,7 +211,7 @@ public class DoubleTerms extends InternalTerms protected void doWriteTo(StreamOutput out) throws IOException { out.writeLong(docCountError); InternalOrder.Streams.writeOrder(order, out); - out.writeValueFormat(format); + out.writeNamedWriteable(format); writeSize(requiredSize, out); writeSize(shardSize, out); out.writeBoolean(showTermDocCountError); diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/LongTerms.java b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/LongTerms.java index 69fe5203173..91aec24529e 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/LongTerms.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/LongTerms.java @@ -189,7 +189,7 @@ public class LongTerms extends InternalTerms { protected void doReadFrom(StreamInput in) throws IOException { this.docCountError = in.readLong(); this.order = InternalOrder.Streams.readOrder(in); - this.format = in.readValueFormat(); + this.format = in.readNamedWriteable(DocValueFormat.class); this.requiredSize = readSize(in); this.shardSize = readSize(in); this.showTermDocCountError = in.readBoolean(); @@ -210,7 +210,7 @@ public class LongTerms extends InternalTerms { protected void doWriteTo(StreamOutput out) throws IOException { out.writeLong(docCountError); InternalOrder.Streams.writeOrder(order, out); - out.writeValueFormat(format); + out.writeNamedWriteable(format); writeSize(requiredSize, out); writeSize(shardSize, out); out.writeBoolean(showTermDocCountError); diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/StringTerms.java b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/StringTerms.java index 0f5c3d6e70a..9c7c85ef855 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/StringTerms.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/StringTerms.java @@ -189,7 +189,7 @@ public class StringTerms extends InternalTerms protected void doReadFrom(StreamInput in) throws IOException { this.docCountError = in.readLong(); this.order = InternalOrder.Streams.readOrder(in); - this.format = in.readValueFormat(); + this.format = in.readNamedWriteable(DocValueFormat.class); this.requiredSize = readSize(in); this.shardSize = readSize(in); this.showTermDocCountError = in.readBoolean(); @@ -210,7 +210,7 @@ public class StringTerms extends InternalTerms protected void doWriteTo(StreamOutput out) throws IOException { out.writeLong(docCountError); InternalOrder.Streams.writeOrder(order, out); - out.writeValueFormat(format); + out.writeNamedWriteable(format); writeSize(requiredSize, out); writeSize(shardSize, out); out.writeBoolean(showTermDocCountError); diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/metrics/avg/InternalAvg.java b/core/src/main/java/org/elasticsearch/search/aggregations/metrics/avg/InternalAvg.java index 5148e602aae..bb4260b8189 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/metrics/avg/InternalAvg.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/metrics/avg/InternalAvg.java @@ -92,14 +92,14 @@ public class InternalAvg extends InternalNumericMetricsAggregation.SingleValue i @Override protected void doReadFrom(StreamInput in) throws IOException { - format = in.readValueFormat(); + format = in.readNamedWriteable(DocValueFormat.class); sum = in.readDouble(); count = in.readVLong(); } @Override protected void doWriteTo(StreamOutput out) throws IOException { - out.writeValueFormat(format); + out.writeNamedWriteable(format); out.writeDouble(sum); out.writeVLong(count); } diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/metrics/cardinality/InternalCardinality.java b/core/src/main/java/org/elasticsearch/search/aggregations/metrics/cardinality/InternalCardinality.java index f4e9e3acd1f..2d320eda818 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/metrics/cardinality/InternalCardinality.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/metrics/cardinality/InternalCardinality.java @@ -23,6 +23,7 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.util.BigArrays; import org.elasticsearch.common.xcontent.XContentBuilder; +import org.elasticsearch.search.DocValueFormat; import org.elasticsearch.search.aggregations.AggregationStreams; import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.metrics.InternalNumericMetricsAggregation; @@ -77,7 +78,7 @@ public final class InternalCardinality extends InternalNumericMetricsAggregation @Override protected void doReadFrom(StreamInput in) throws IOException { - format = in.readValueFormat(); + format = in.readNamedWriteable(DocValueFormat.class); if (in.readBoolean()) { counts = HyperLogLogPlusPlus.readFrom(in, BigArrays.NON_RECYCLING_INSTANCE); } else { @@ -87,7 +88,7 @@ public final class InternalCardinality extends InternalNumericMetricsAggregation @Override protected void doWriteTo(StreamOutput out) throws IOException { - out.writeValueFormat(format); + out.writeNamedWriteable(format); if (counts != null) { out.writeBoolean(true); counts.writeTo(0, out); diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/metrics/max/InternalMax.java b/core/src/main/java/org/elasticsearch/search/aggregations/metrics/max/InternalMax.java index c72a3a4ed0a..7047f28947e 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/metrics/max/InternalMax.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/metrics/max/InternalMax.java @@ -88,13 +88,13 @@ public class InternalMax extends InternalNumericMetricsAggregation.SingleValue i @Override protected void doReadFrom(StreamInput in) throws IOException { - format = in.readValueFormat(); + format = in.readNamedWriteable(DocValueFormat.class); max = in.readDouble(); } @Override protected void doWriteTo(StreamOutput out) throws IOException { - out.writeValueFormat(format); + out.writeNamedWriteable(format); out.writeDouble(max); } diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/metrics/min/InternalMin.java b/core/src/main/java/org/elasticsearch/search/aggregations/metrics/min/InternalMin.java index 8ebd985a6e6..d729002e4d1 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/metrics/min/InternalMin.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/metrics/min/InternalMin.java @@ -89,13 +89,13 @@ public class InternalMin extends InternalNumericMetricsAggregation.SingleValue i @Override protected void doReadFrom(StreamInput in) throws IOException { - format = in.readValueFormat(); + format = in.readNamedWriteable(DocValueFormat.class); min = in.readDouble(); } @Override protected void doWriteTo(StreamOutput out) throws IOException { - out.writeValueFormat(format); + out.writeNamedWriteable(format); out.writeDouble(min); } diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/metrics/percentiles/hdr/AbstractInternalHDRPercentiles.java b/core/src/main/java/org/elasticsearch/search/aggregations/metrics/percentiles/hdr/AbstractInternalHDRPercentiles.java index 4168e227101..7d4ea18afcd 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/metrics/percentiles/hdr/AbstractInternalHDRPercentiles.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/metrics/percentiles/hdr/AbstractInternalHDRPercentiles.java @@ -82,7 +82,7 @@ abstract class AbstractInternalHDRPercentiles extends InternalNumericMetricsAggr @Override protected void doReadFrom(StreamInput in) throws IOException { - format = in.readValueFormat(); + format = in.readNamedWriteable(DocValueFormat.class); keys = new double[in.readInt()]; for (int i = 0; i < keys.length; ++i) { keys[i] = in.readDouble(); @@ -102,7 +102,7 @@ abstract class AbstractInternalHDRPercentiles extends InternalNumericMetricsAggr @Override protected void doWriteTo(StreamOutput out) throws IOException { - out.writeValueFormat(format); + out.writeNamedWriteable(format); out.writeInt(keys.length); for (int i = 0 ; i < keys.length; ++i) { out.writeDouble(keys[i]); diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/metrics/percentiles/tdigest/AbstractInternalTDigestPercentiles.java b/core/src/main/java/org/elasticsearch/search/aggregations/metrics/percentiles/tdigest/AbstractInternalTDigestPercentiles.java index 6af7cb9b291..b55efcde92d 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/metrics/percentiles/tdigest/AbstractInternalTDigestPercentiles.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/metrics/percentiles/tdigest/AbstractInternalTDigestPercentiles.java @@ -78,7 +78,7 @@ abstract class AbstractInternalTDigestPercentiles extends InternalNumericMetrics @Override protected void doReadFrom(StreamInput in) throws IOException { - format = in.readValueFormat(); + format = in.readNamedWriteable(DocValueFormat.class); keys = new double[in.readInt()]; for (int i = 0; i < keys.length; ++i) { keys[i] = in.readDouble(); @@ -89,7 +89,7 @@ abstract class AbstractInternalTDigestPercentiles extends InternalNumericMetrics @Override protected void doWriteTo(StreamOutput out) throws IOException { - out.writeValueFormat(format); + out.writeNamedWriteable(format); out.writeInt(keys.length); for (int i = 0 ; i < keys.length; ++i) { out.writeDouble(keys[i]); diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/metrics/stats/InternalStats.java b/core/src/main/java/org/elasticsearch/search/aggregations/metrics/stats/InternalStats.java index 6b98201898b..cbbb3493100 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/metrics/stats/InternalStats.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/metrics/stats/InternalStats.java @@ -165,7 +165,7 @@ public class InternalStats extends InternalNumericMetricsAggregation.MultiValue @Override protected void doReadFrom(StreamInput in) throws IOException { - format = in.readValueFormat(); + format = in.readNamedWriteable(DocValueFormat.class); count = in.readVLong(); min = in.readDouble(); max = in.readDouble(); @@ -178,7 +178,7 @@ public class InternalStats extends InternalNumericMetricsAggregation.MultiValue @Override protected void doWriteTo(StreamOutput out) throws IOException { - out.writeValueFormat(format); + out.writeNamedWriteable(format); out.writeVLong(count); out.writeDouble(min); out.writeDouble(max); diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/metrics/sum/InternalSum.java b/core/src/main/java/org/elasticsearch/search/aggregations/metrics/sum/InternalSum.java index ee6851c94cb..0b76e39d208 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/metrics/sum/InternalSum.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/metrics/sum/InternalSum.java @@ -88,13 +88,13 @@ public class InternalSum extends InternalNumericMetricsAggregation.SingleValue i @Override protected void doReadFrom(StreamInput in) throws IOException { - format = in.readValueFormat(); + format = in.readNamedWriteable(DocValueFormat.class); sum = in.readDouble(); } @Override protected void doWriteTo(StreamOutput out) throws IOException { - out.writeValueFormat(format); + out.writeNamedWriteable(format); out.writeDouble(sum); } diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/InternalSimpleValue.java b/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/InternalSimpleValue.java index 9f6bec782c0..13cfd9487cd 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/InternalSimpleValue.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/InternalSimpleValue.java @@ -82,13 +82,13 @@ public class InternalSimpleValue extends InternalNumericMetricsAggregation.Singl @Override protected void doReadFrom(StreamInput in) throws IOException { - format = in.readValueFormat(); + format = in.readNamedWriteable(DocValueFormat.class); value = in.readDouble(); } @Override protected void doWriteTo(StreamOutput out) throws IOException { - out.writeValueFormat(format); + out.writeNamedWriteable(format); out.writeDouble(value); } diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/BucketMetricsPipelineAggregator.java b/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/BucketMetricsPipelineAggregator.java index f934e17a62e..06b093a4736 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/BucketMetricsPipelineAggregator.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/BucketMetricsPipelineAggregator.java @@ -112,7 +112,7 @@ public abstract class BucketMetricsPipelineAggregator extends SiblingPipelineAgg @Override public final void doReadFrom(StreamInput in) throws IOException { - format = in.readValueFormat(); + format = in.readNamedWriteable(DocValueFormat.class); gapPolicy = GapPolicy.readFrom(in); innerReadFrom(in); } @@ -122,7 +122,7 @@ public abstract class BucketMetricsPipelineAggregator extends SiblingPipelineAgg @Override public final void doWriteTo(StreamOutput out) throws IOException { - out.writeValueFormat(format); + out.writeNamedWriteable(format); gapPolicy.writeTo(out); innerWriteTo(out); } diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/InternalBucketMetricValue.java b/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/InternalBucketMetricValue.java index 0c905136f5f..dab7235e9d1 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/InternalBucketMetricValue.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/InternalBucketMetricValue.java @@ -99,14 +99,14 @@ public class InternalBucketMetricValue extends InternalNumericMetricsAggregation @Override protected void doReadFrom(StreamInput in) throws IOException { - format = in.readValueFormat(); + format = in.readNamedWriteable(DocValueFormat.class); value = in.readDouble(); keys = in.readStringArray(); } @Override protected void doWriteTo(StreamOutput out) throws IOException { - out.writeValueFormat(format); + out.writeNamedWriteable(format); out.writeDouble(value); out.writeStringArray(keys); } diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/percentile/InternalPercentilesBucket.java b/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/percentile/InternalPercentilesBucket.java index 00b4b5ba90a..65d04ee12ad 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/percentile/InternalPercentilesBucket.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketmetrics/percentile/InternalPercentilesBucket.java @@ -106,14 +106,14 @@ public class InternalPercentilesBucket extends InternalNumericMetricsAggregation @Override protected void doReadFrom(StreamInput in) throws IOException { - format = in.readValueFormat(); + format = in.readNamedWriteable(DocValueFormat.class); percentiles = in.readDoubleArray(); percents = in.readDoubleArray(); } @Override protected void doWriteTo(StreamOutput out) throws IOException { - out.writeValueFormat(format); + out.writeNamedWriteable(format); out.writeDoubleArray(percentiles); out.writeDoubleArray(percents); } diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketscript/BucketScriptPipelineAggregator.java b/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketscript/BucketScriptPipelineAggregator.java index 83cf5cbbf83..f8271655e20 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketscript/BucketScriptPipelineAggregator.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/bucketscript/BucketScriptPipelineAggregator.java @@ -139,7 +139,7 @@ public class BucketScriptPipelineAggregator extends PipelineAggregator { @Override protected void doWriteTo(StreamOutput out) throws IOException { script.writeTo(out); - out.writeValueFormat(formatter); + out.writeNamedWriteable(formatter); gapPolicy.writeTo(out); out.writeGenericValue(bucketsPathsMap); } @@ -148,7 +148,7 @@ public class BucketScriptPipelineAggregator extends PipelineAggregator { @Override protected void doReadFrom(StreamInput in) throws IOException { script = Script.readScript(in); - formatter = in.readValueFormat(); + formatter = in.readNamedWriteable(DocValueFormat.class); gapPolicy = GapPolicy.readFrom(in); bucketsPathsMap = (Map) in.readGenericValue(); } diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/cumulativesum/CumulativeSumPipelineAggregator.java b/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/cumulativesum/CumulativeSumPipelineAggregator.java index e7f68338a1d..5f003481f17 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/cumulativesum/CumulativeSumPipelineAggregator.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/cumulativesum/CumulativeSumPipelineAggregator.java @@ -95,11 +95,11 @@ public class CumulativeSumPipelineAggregator extends PipelineAggregator { @Override public void doReadFrom(StreamInput in) throws IOException { - formatter = in.readValueFormat(); + formatter = in.readNamedWriteable(DocValueFormat.class); } @Override public void doWriteTo(StreamOutput out) throws IOException { - out.writeValueFormat(formatter); + out.writeNamedWriteable(formatter); } } diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/derivative/DerivativePipelineAggregator.java b/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/derivative/DerivativePipelineAggregator.java index ff0b1d97d0d..964c82a4d94 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/derivative/DerivativePipelineAggregator.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/derivative/DerivativePipelineAggregator.java @@ -127,7 +127,7 @@ public class DerivativePipelineAggregator extends PipelineAggregator { @Override public void doReadFrom(StreamInput in) throws IOException { - formatter = in.readValueFormat(); + formatter = in.readNamedWriteable(DocValueFormat.class); gapPolicy = GapPolicy.readFrom(in); if (in.readBoolean()) { xAxisUnits = in.readDouble(); @@ -139,7 +139,7 @@ public class DerivativePipelineAggregator extends PipelineAggregator { @Override public void doWriteTo(StreamOutput out) throws IOException { - out.writeValueFormat(formatter); + out.writeNamedWriteable(formatter); gapPolicy.writeTo(out); boolean hasXAxisUnitsValue = xAxisUnits != null; out.writeBoolean(hasXAxisUnitsValue); diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/MovAvgPipelineAggregator.java b/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/MovAvgPipelineAggregator.java index 08c7ee64680..537e40cd2d2 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/MovAvgPipelineAggregator.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/movavg/MovAvgPipelineAggregator.java @@ -250,7 +250,7 @@ public class MovAvgPipelineAggregator extends PipelineAggregator { @Override public void doReadFrom(StreamInput in) throws IOException { - formatter = in.readValueFormat(); + formatter = in.readNamedWriteable(DocValueFormat.class); gapPolicy = GapPolicy.readFrom(in); window = in.readVInt(); predict = in.readVInt(); @@ -261,7 +261,7 @@ public class MovAvgPipelineAggregator extends PipelineAggregator { @Override public void doWriteTo(StreamOutput out) throws IOException { - out.writeValueFormat(formatter); + out.writeNamedWriteable(formatter); gapPolicy.writeTo(out); out.writeVInt(window); out.writeVInt(predict); diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/serialdiff/SerialDiffPipelineAggregator.java b/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/serialdiff/SerialDiffPipelineAggregator.java index 4df1e326036..2ebf740bb6f 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/serialdiff/SerialDiffPipelineAggregator.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/pipeline/serialdiff/SerialDiffPipelineAggregator.java @@ -128,14 +128,14 @@ public class SerialDiffPipelineAggregator extends PipelineAggregator { @Override public void doReadFrom(StreamInput in) throws IOException { - formatter = in.readValueFormat(); + formatter = in.readNamedWriteable(DocValueFormat.class); gapPolicy = GapPolicy.readFrom(in); lag = in.readVInt(); } @Override public void doWriteTo(StreamOutput out) throws IOException { - out.writeValueFormat(formatter); + out.writeNamedWriteable(formatter); gapPolicy.writeTo(out); out.writeVInt(lag); } diff --git a/core/src/test/java/org/elasticsearch/search/DocValueFormatTests.java b/core/src/test/java/org/elasticsearch/search/DocValueFormatTests.java index 218ccc4f20c..a936a315b1e 100644 --- a/core/src/test/java/org/elasticsearch/search/DocValueFormatTests.java +++ b/core/src/test/java/org/elasticsearch/search/DocValueFormatTests.java @@ -39,41 +39,41 @@ public class DocValueFormatTests extends ESTestCase { registry.register(DocValueFormat.class, DocValueFormat.RAW.getWriteableName(), in -> DocValueFormat.RAW); BytesStreamOutput out = new BytesStreamOutput(); - out.writeValueFormat(DocValueFormat.BOOLEAN); + out.writeNamedWriteable(DocValueFormat.BOOLEAN); StreamInput in = new NamedWriteableAwareStreamInput(StreamInput.wrap(out.bytes()), registry); - assertSame(DocValueFormat.BOOLEAN, in.readValueFormat()); + assertSame(DocValueFormat.BOOLEAN, in.readNamedWriteable(DocValueFormat.class)); DocValueFormat.Decimal decimalFormat = new DocValueFormat.Decimal("###.##"); out = new BytesStreamOutput(); - out.writeValueFormat(decimalFormat); + out.writeNamedWriteable(decimalFormat); in = new NamedWriteableAwareStreamInput(StreamInput.wrap(out.bytes()), registry); - DocValueFormat vf = in.readValueFormat(); + DocValueFormat vf = in.readNamedWriteable(DocValueFormat.class); assertEquals(DocValueFormat.Decimal.class, vf.getClass()); assertEquals("###.##", ((DocValueFormat.Decimal) vf).pattern); DocValueFormat.DateTime dateFormat = new DocValueFormat.DateTime(Joda.forPattern("epoch_second"), DateTimeZone.forOffsetHours(1)); out = new BytesStreamOutput(); - out.writeValueFormat(dateFormat); + out.writeNamedWriteable(dateFormat); in = new NamedWriteableAwareStreamInput(StreamInput.wrap(out.bytes()), registry); - vf = in.readValueFormat(); + vf = in.readNamedWriteable(DocValueFormat.class); assertEquals(DocValueFormat.DateTime.class, vf.getClass()); assertEquals("epoch_second", ((DocValueFormat.DateTime) vf).formatter.format()); assertEquals(DateTimeZone.forOffsetHours(1), ((DocValueFormat.DateTime) vf).timeZone); out = new BytesStreamOutput(); - out.writeValueFormat(DocValueFormat.GEOHASH); + out.writeNamedWriteable(DocValueFormat.GEOHASH); in = new NamedWriteableAwareStreamInput(StreamInput.wrap(out.bytes()), registry); - assertSame(DocValueFormat.GEOHASH, in.readValueFormat()); + assertSame(DocValueFormat.GEOHASH, in.readNamedWriteable(DocValueFormat.class)); out = new BytesStreamOutput(); - out.writeValueFormat(DocValueFormat.IP); + out.writeNamedWriteable(DocValueFormat.IP); in = new NamedWriteableAwareStreamInput(StreamInput.wrap(out.bytes()), registry); - assertSame(DocValueFormat.IP, in.readValueFormat()); + assertSame(DocValueFormat.IP, in.readNamedWriteable(DocValueFormat.class)); out = new BytesStreamOutput(); - out.writeValueFormat(DocValueFormat.RAW); + out.writeNamedWriteable(DocValueFormat.RAW); in = new NamedWriteableAwareStreamInput(StreamInput.wrap(out.bytes()), registry); - assertSame(DocValueFormat.RAW, in.readValueFormat()); + assertSame(DocValueFormat.RAW, in.readNamedWriteable(DocValueFormat.class)); } }