Skip to content

Commit

Permalink
ScriptLongFieldData to extend LeafLongFieldData (#59884)
Browse files Browse the repository at this point in the history
Relates to #59332
  • Loading branch information
javanna authored Jul 21, 2020
1 parent 0589d2e commit a0ef1ea
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@
/**
* Specialization of {@link LeafNumericFieldData} for integers.
*/
abstract class LeafLongFieldData implements LeafNumericFieldData {
public abstract class LeafLongFieldData implements LeafNumericFieldData {

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

LeafLongFieldData(long ramBytesUsed, NumericType numericType) {
protected LeafLongFieldData(long ramBytesUsed, NumericType numericType) {
this.ramBytesUsed = ramBytesUsed;
this.numericType = numericType;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}
}

0 comments on commit a0ef1ea

Please sign in to comment.