Remove ScriptDocValues.EMPTY.

Instead the default implementation is used, but on top of empty
(Bytes|Long|Double|GeoPoint)Values. This makes sure there is no
inconsistency between documents depending on whether other documents in the
segment have values or not.

Close #5646
This commit is contained in:
Adrien Grand 2014-04-01 17:47:02 +02:00
parent ac5701968b
commit 4ff3e1926b
5 changed files with 7 additions and 23 deletions

View File

@ -29,7 +29,6 @@ import org.elasticsearch.common.util.SlicedObjectList;
import org.joda.time.DateTimeZone;
import org.joda.time.MutableDateTime;
import java.util.Collections;
import java.util.List;
/**
@ -38,7 +37,9 @@ import java.util.List;
*/
public abstract class ScriptDocValues {
public static final ScriptDocValues EMPTY = new Empty();
public static final Longs EMPTY_LONGS = new Longs(LongValues.EMPTY);
public static final Doubles EMPTY_DOUBLES = new Doubles(DoubleValues.EMPTY);
public static final GeoPoints EMPTY_GEOPOINTS = new GeoPoints(GeoPointValues.EMPTY);
public static final Strings EMPTY_STRINGS = new Strings(BytesValues.EMPTY);
protected int docId;
protected boolean listLoaded = false;
@ -52,23 +53,6 @@ public abstract class ScriptDocValues {
public abstract List<?> getValues();
public static class Empty extends ScriptDocValues {
@Override
public void setNextDocId(int docId) {
}
@Override
public boolean isEmpty() {
return true;
}
@Override
public List<?> getValues() {
return Collections.emptyList();
}
}
public final static class Strings extends ScriptDocValues {
private final BytesValues values;

View File

@ -76,7 +76,7 @@ abstract class AbstractGeoPointIndexFieldData extends AbstractIndexFieldData<Ato
@Override
public ScriptDocValues getScriptValues() {
return ScriptDocValues.EMPTY;
return ScriptDocValues.EMPTY_GEOPOINTS;
}
@Override

View File

@ -94,7 +94,7 @@ public abstract class DoubleArrayAtomicFieldData extends AbstractAtomicNumericFi
@Override
public ScriptDocValues getScriptValues() {
return ScriptDocValues.EMPTY;
return ScriptDocValues.EMPTY_DOUBLES;
}
}

View File

@ -93,7 +93,7 @@ public abstract class FloatArrayAtomicFieldData extends AbstractAtomicNumericFie
@Override
public ScriptDocValues getScriptValues() {
return ScriptDocValues.EMPTY;
return ScriptDocValues.EMPTY_DOUBLES;
}
}

View File

@ -95,7 +95,7 @@ public abstract class PackedArrayAtomicFieldData extends AbstractAtomicNumericFi
@Override
public ScriptDocValues getScriptValues() {
return ScriptDocValues.EMPTY;
return ScriptDocValues.EMPTY_LONGS;
}
}