Skip to content

Commit

Permalink
Remove ScriptDocValues.EMPTY.
Browse files Browse the repository at this point in the history
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 elastic#5646
  • Loading branch information
jpountz committed Apr 1, 2014
1 parent 268f2c3 commit 47cef2e
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 23 deletions.
Expand Up @@ -29,7 +29,6 @@
import org.joda.time.DateTimeZone;
import org.joda.time.MutableDateTime;

import java.util.Collections;
import java.util.List;

/**
Expand All @@ -38,7 +37,9 @@
*/
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;
Expand All @@ -52,23 +53,6 @@ public void setNextDocId(int docId) {

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;
Expand Down
Expand Up @@ -76,7 +76,7 @@ public GeoPointValues getGeoPointValues() {

@Override
public ScriptDocValues getScriptValues() {
return ScriptDocValues.EMPTY;
return ScriptDocValues.EMPTY_GEOPOINTS;
}

@Override
Expand Down
Expand Up @@ -94,7 +94,7 @@ public BytesValues getBytesValues(boolean needsHashes) {

@Override
public ScriptDocValues getScriptValues() {
return ScriptDocValues.EMPTY;
return ScriptDocValues.EMPTY_DOUBLES;
}
}

Expand Down
Expand Up @@ -93,7 +93,7 @@ public BytesValues getBytesValues(boolean needsHashes) {

@Override
public ScriptDocValues getScriptValues() {
return ScriptDocValues.EMPTY;
return ScriptDocValues.EMPTY_DOUBLES;
}
}

Expand Down
Expand Up @@ -95,7 +95,7 @@ public BytesValues getBytesValues(boolean needsHashes) {

@Override
public ScriptDocValues getScriptValues() {
return ScriptDocValues.EMPTY;
return ScriptDocValues.EMPTY_LONGS;
}
}

Expand Down

0 comments on commit 47cef2e

Please sign in to comment.