Skip to content

Commit a0ef1ea

Browse files
authored
ScriptLongFieldData to extend LeafLongFieldData (#59884)
Relates to #59332
1 parent 0589d2e commit a0ef1ea

File tree

2 files changed

+9
-37
lines changed

2 files changed

+9
-37
lines changed

server/src/main/java/org/elasticsearch/index/fielddata/plain/LeafLongFieldData.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@
2929
/**
3030
* Specialization of {@link LeafNumericFieldData} for integers.
3131
*/
32-
abstract class LeafLongFieldData implements LeafNumericFieldData {
32+
public abstract class LeafLongFieldData implements LeafNumericFieldData {
3333

3434
private final long ramBytesUsed;
3535
/**
3636
* Type of this field. Used to expose appropriate types in {@link #getScriptValues()}.
3737
*/
3838
private final NumericType numericType;
3939

40-
LeafLongFieldData(long ramBytesUsed, NumericType numericType) {
40+
protected LeafLongFieldData(long ramBytesUsed, NumericType numericType) {
4141
this.ramBytesUsed = ramBytesUsed;
4242
this.numericType = numericType;
4343
}

x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/fielddata/ScriptLongFieldData.java

+7-35
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,11 @@
1111
import org.apache.lucene.util.SetOnce;
1212
import org.elasticsearch.ExceptionsHelper;
1313
import org.elasticsearch.index.IndexSettings;
14-
import org.elasticsearch.index.fielddata.FieldData;
1514
import org.elasticsearch.index.fielddata.IndexFieldData;
1615
import org.elasticsearch.index.fielddata.IndexFieldDataCache;
1716
import org.elasticsearch.index.fielddata.IndexNumericFieldData;
18-
import org.elasticsearch.index.fielddata.LeafNumericFieldData;
19-
import org.elasticsearch.index.fielddata.ScriptDocValues;
2017
import org.elasticsearch.index.fielddata.SearchLookupAware;
21-
import org.elasticsearch.index.fielddata.SortedBinaryDocValues;
22-
import org.elasticsearch.index.fielddata.SortedNumericDoubleValues;
18+
import org.elasticsearch.index.fielddata.plain.LeafLongFieldData;
2319
import org.elasticsearch.index.mapper.MappedFieldType;
2420
import org.elasticsearch.index.mapper.MapperService;
2521
import org.elasticsearch.indices.breaker.CircuitBreakerService;
@@ -108,41 +104,17 @@ protected boolean sortRequiresCustomComparator() {
108104
@Override
109105
public void clear() {}
110106

111-
public static class ScriptLongLeafFieldData implements LeafNumericFieldData {
112-
private final ScriptLongDocValues scriptBinaryDocValues;
107+
public static class ScriptLongLeafFieldData extends LeafLongFieldData {
108+
private final ScriptLongDocValues scriptLongDocValues;
113109

114-
ScriptLongLeafFieldData(ScriptLongDocValues scriptBinaryDocValues) {
115-
this.scriptBinaryDocValues = scriptBinaryDocValues;
116-
}
117-
118-
@Override
119-
public ScriptDocValues<?> getScriptValues() {
120-
return new ScriptDocValues.Longs(getLongValues());
121-
}
122-
123-
@Override
124-
public SortedBinaryDocValues getBytesValues() {
125-
return FieldData.toString(scriptBinaryDocValues);
126-
}
127-
128-
@Override
129-
public SortedNumericDoubleValues getDoubleValues() {
130-
return FieldData.castToDouble(getLongValues());
110+
ScriptLongLeafFieldData(ScriptLongDocValues scriptLongDocValues) {
111+
super(0, NumericType.LONG);
112+
this.scriptLongDocValues = scriptLongDocValues;
131113
}
132114

133115
@Override
134116
public SortedNumericDocValues getLongValues() {
135-
return scriptBinaryDocValues;
136-
}
137-
138-
@Override
139-
public long ramBytesUsed() {
140-
return 0;
141-
}
142-
143-
@Override
144-
public void close() {
145-
117+
return scriptLongDocValues;
146118
}
147119
}
148120
}

0 commit comments

Comments
 (0)