From 3ede7cb2f55c48eb3dcff7f3a74ed8ff8e5a5376 Mon Sep 17 00:00:00 2001 From: Mark Tozzi Date: Tue, 21 Jan 2020 17:05:48 -0500 Subject: [PATCH] CoreValuesSourceType no longer implements Writable --- .../support/CoreValuesSourceType.java | 16 +------- .../support/CoreValuesSourceTypeTests.java | 41 +------------------ 2 files changed, 3 insertions(+), 54 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/support/CoreValuesSourceType.java b/server/src/main/java/org/elasticsearch/search/aggregations/support/CoreValuesSourceType.java index c3a117911796e..90ee2421a6e2e 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/support/CoreValuesSourceType.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/support/CoreValuesSourceType.java @@ -21,9 +21,6 @@ import org.apache.lucene.util.BytesRef; import org.elasticsearch.common.geo.GeoPoint; -import org.elasticsearch.common.io.stream.StreamInput; -import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.common.time.DateFormatter; import org.elasticsearch.index.fielddata.IndexFieldData; import org.elasticsearch.index.fielddata.IndexGeoPointFieldData; @@ -37,7 +34,6 @@ import org.elasticsearch.search.DocValueFormat; import org.elasticsearch.search.aggregations.AggregationExecutionException; -import java.io.IOException; import java.time.ZoneId; import java.time.ZoneOffset; import java.util.Locale; @@ -46,7 +42,7 @@ /** * {@link CoreValuesSourceType} holds the {@link ValuesSourceType} implementations for the core aggregations package. */ -public enum CoreValuesSourceType implements Writeable, ValuesSourceType { +public enum CoreValuesSourceType implements ValuesSourceType { ANY(EquivalenceType.STRING) { // ANY still has a lot of special handling in ValuesSourceConfig, and as such doesn't adhere to this interface yet @Override @@ -342,16 +338,6 @@ public static ValuesSourceType fromString(String name) { return valueOf(name.trim().toUpperCase(Locale.ROOT)); } - public static ValuesSourceType fromStream(StreamInput in) throws IOException { - return in.readEnum(CoreValuesSourceType.class); - } - - @Override - public void writeTo(StreamOutput out) throws IOException { - CoreValuesSourceType state = this; - out.writeEnum(state); - } - public String value() { return name().toLowerCase(Locale.ROOT); } diff --git a/server/src/test/java/org/elasticsearch/search/aggregations/support/CoreValuesSourceTypeTests.java b/server/src/test/java/org/elasticsearch/search/aggregations/support/CoreValuesSourceTypeTests.java index 5f57a8ee9c12e..0059ed6b63e1c 100644 --- a/server/src/test/java/org/elasticsearch/search/aggregations/support/CoreValuesSourceTypeTests.java +++ b/server/src/test/java/org/elasticsearch/search/aggregations/support/CoreValuesSourceTypeTests.java @@ -19,29 +19,12 @@ package org.elasticsearch.search.aggregations.support; -import org.elasticsearch.common.io.stream.AbstractWriteableEnumTestCase; - -import java.io.IOException; +import org.elasticsearch.test.ESTestCase; import static org.hamcrest.Matchers.equalTo; -public class CoreValuesSourceTypeTests extends AbstractWriteableEnumTestCase { - - public CoreValuesSourceTypeTests() { - super(CoreValuesSourceType::fromStream); - } - - @Override - public void testValidOrdinals() { - assertThat(CoreValuesSourceType.ANY.ordinal(), equalTo(0)); - assertThat(CoreValuesSourceType.NUMERIC.ordinal(), equalTo(1)); - assertThat(CoreValuesSourceType.BYTES.ordinal(), equalTo(2)); - assertThat(CoreValuesSourceType.GEOPOINT.ordinal(), equalTo(3)); - assertThat(CoreValuesSourceType.RANGE.ordinal(), equalTo(4)); - assertThat(CoreValuesSourceType.HISTOGRAM.ordinal(), equalTo(5)); - } +public class CoreValuesSourceTypeTests extends ESTestCase { - @Override public void testFromString() { assertThat(CoreValuesSourceType.fromString("any"), equalTo(CoreValuesSourceType.ANY)); assertThat(CoreValuesSourceType.fromString("numeric"), equalTo(CoreValuesSourceType.NUMERIC)); @@ -55,24 +38,4 @@ public void testFromString() { equalTo("No enum constant org.elasticsearch.search.aggregations.support.CoreValuesSourceType.DOES_NOT_EXIST")); expectThrows(NullPointerException.class, () -> CoreValuesSourceType.fromString(null)); } - - @Override - public void testReadFrom() throws IOException { - assertReadFromStream(0, CoreValuesSourceType.ANY); - assertReadFromStream(1, CoreValuesSourceType.NUMERIC); - assertReadFromStream(2, CoreValuesSourceType.BYTES); - assertReadFromStream(3, CoreValuesSourceType.GEOPOINT); - assertReadFromStream(4, CoreValuesSourceType.RANGE); - assertReadFromStream(5, CoreValuesSourceType.HISTOGRAM); - } - - @Override - public void testWriteTo() throws IOException { - assertWriteToStream(CoreValuesSourceType.ANY, 0); - assertWriteToStream(CoreValuesSourceType.NUMERIC, 1); - assertWriteToStream(CoreValuesSourceType.BYTES, 2); - assertWriteToStream(CoreValuesSourceType.GEOPOINT, 3); - assertWriteToStream(CoreValuesSourceType.RANGE, 4); - assertWriteToStream(CoreValuesSourceType.HISTOGRAM, 5); - } }