diff --git a/server/src/main/java/org/elasticsearch/index/fielddata/plain/LeafLongFieldData.java b/server/src/main/java/org/elasticsearch/index/fielddata/plain/LeafLongFieldData.java index cf46d51340227..38dede8537b94 100644 --- a/server/src/main/java/org/elasticsearch/index/fielddata/plain/LeafLongFieldData.java +++ b/server/src/main/java/org/elasticsearch/index/fielddata/plain/LeafLongFieldData.java @@ -29,7 +29,7 @@ /** * Specialization of {@link LeafNumericFieldData} for integers. */ -abstract class LeafLongFieldData implements LeafNumericFieldData { +public abstract class LeafLongFieldData implements LeafNumericFieldData { private final long ramBytesUsed; /** @@ -37,7 +37,7 @@ abstract class LeafLongFieldData implements LeafNumericFieldData { */ private final NumericType numericType; - LeafLongFieldData(long ramBytesUsed, NumericType numericType) { + protected LeafLongFieldData(long ramBytesUsed, NumericType numericType) { this.ramBytesUsed = ramBytesUsed; this.numericType = numericType; } diff --git a/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/fielddata/ScriptLongFieldData.java b/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/fielddata/ScriptLongFieldData.java index b4bb942be6bbd..8e18966343d65 100644 --- a/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/fielddata/ScriptLongFieldData.java +++ b/x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/fielddata/ScriptLongFieldData.java @@ -11,15 +11,11 @@ import org.apache.lucene.util.SetOnce; import org.elasticsearch.ExceptionsHelper; import org.elasticsearch.index.IndexSettings; -import org.elasticsearch.index.fielddata.FieldData; import org.elasticsearch.index.fielddata.IndexFieldData; import org.elasticsearch.index.fielddata.IndexFieldDataCache; import org.elasticsearch.index.fielddata.IndexNumericFieldData; -import org.elasticsearch.index.fielddata.LeafNumericFieldData; -import org.elasticsearch.index.fielddata.ScriptDocValues; import org.elasticsearch.index.fielddata.SearchLookupAware; -import org.elasticsearch.index.fielddata.SortedBinaryDocValues; -import org.elasticsearch.index.fielddata.SortedNumericDoubleValues; +import org.elasticsearch.index.fielddata.plain.LeafLongFieldData; import org.elasticsearch.index.mapper.MappedFieldType; import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.indices.breaker.CircuitBreakerService; @@ -108,41 +104,17 @@ protected boolean sortRequiresCustomComparator() { @Override public void clear() {} - public static class ScriptLongLeafFieldData implements LeafNumericFieldData { - private final ScriptLongDocValues scriptBinaryDocValues; + public static class ScriptLongLeafFieldData extends LeafLongFieldData { + private final ScriptLongDocValues scriptLongDocValues; - ScriptLongLeafFieldData(ScriptLongDocValues scriptBinaryDocValues) { - this.scriptBinaryDocValues = scriptBinaryDocValues; - } - - @Override - public ScriptDocValues getScriptValues() { - return new ScriptDocValues.Longs(getLongValues()); - } - - @Override - public SortedBinaryDocValues getBytesValues() { - return FieldData.toString(scriptBinaryDocValues); - } - - @Override - public SortedNumericDoubleValues getDoubleValues() { - return FieldData.castToDouble(getLongValues()); + ScriptLongLeafFieldData(ScriptLongDocValues scriptLongDocValues) { + super(0, NumericType.LONG); + this.scriptLongDocValues = scriptLongDocValues; } @Override public SortedNumericDocValues getLongValues() { - return scriptBinaryDocValues; - } - - @Override - public long ramBytesUsed() { - return 0; - } - - @Override - public void close() { - + return scriptLongDocValues; } } }