From 4ff3e1926b0b0a092a9fcb70f47fb49977ec2d70 Mon Sep 17 00:00:00 2001 From: Adrien Grand Date: Tue, 1 Apr 2014 17:47:02 +0200 Subject: [PATCH] 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 --- .../index/fielddata/ScriptDocValues.java | 22 +++---------------- .../plain/AbstractGeoPointIndexFieldData.java | 2 +- .../plain/DoubleArrayAtomicFieldData.java | 2 +- .../plain/FloatArrayAtomicFieldData.java | 2 +- .../plain/PackedArrayAtomicFieldData.java | 2 +- 5 files changed, 7 insertions(+), 23 deletions(-) diff --git a/src/main/java/org/elasticsearch/index/fielddata/ScriptDocValues.java b/src/main/java/org/elasticsearch/index/fielddata/ScriptDocValues.java index e06977ffd5a..68957352798 100644 --- a/src/main/java/org/elasticsearch/index/fielddata/ScriptDocValues.java +++ b/src/main/java/org/elasticsearch/index/fielddata/ScriptDocValues.java @@ -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; diff --git a/src/main/java/org/elasticsearch/index/fielddata/plain/AbstractGeoPointIndexFieldData.java b/src/main/java/org/elasticsearch/index/fielddata/plain/AbstractGeoPointIndexFieldData.java index 0373c301ba7..886f39bf0fb 100644 --- a/src/main/java/org/elasticsearch/index/fielddata/plain/AbstractGeoPointIndexFieldData.java +++ b/src/main/java/org/elasticsearch/index/fielddata/plain/AbstractGeoPointIndexFieldData.java @@ -76,7 +76,7 @@ abstract class AbstractGeoPointIndexFieldData extends AbstractIndexFieldData