diff --git a/src/main/java/org/elasticsearch/index/fielddata/BytesValues.java b/src/main/java/org/elasticsearch/index/fielddata/BytesValues.java index 20d1502d632..b44faf79d09 100644 --- a/src/main/java/org/elasticsearch/index/fielddata/BytesValues.java +++ b/src/main/java/org/elasticsearch/index/fielddata/BytesValues.java @@ -55,11 +55,6 @@ public interface BytesValues { */ BytesRef getValueScratch(int docId, BytesRef ret); - /** - * Returns a bytes value for a docId. The content is guaranteed not to be shared. - */ - BytesRef getValueSafe(int docId); - /** * Returns an array wrapping all the bytes values for a doc. The content is guaranteed not to be shared. */ @@ -70,21 +65,11 @@ public interface BytesValues { */ Iter getIter(int docId); - /** - * Returns a bytes value iterator for a docId. The content is guaranteed not to be shared. - */ - Iter getIterSafe(int docId); - /** * Go over all the possible values in their BytesRef format for a specific doc. */ void forEachValueInDoc(int docId, ValueInDocProc proc); - /** - * Go over all the possible values in their BytesRef format for a specific doc. - */ - void forEachSafeValueInDoc(int docId, ValueInDocProc proc); - public static interface ValueInDocProc { void onValue(int docId, BytesRef value); @@ -144,9 +129,7 @@ public interface BytesValues { protected final BytesRef scratch = new BytesRef(); private final BytesRefArrayRef arrayScratch = new BytesRefArrayRef(new BytesRef[1], 1); private final ValueIter valueIter = new ValueIter(); - private final SafeValueIter safeValueIter = new SafeValueIter(); private final Proc proc = new Proc(); - private final SafeProc safeProc = new SafeProc(); public StringBased(StringValues values) { this.values = values; @@ -187,13 +170,6 @@ public interface BytesValues { return ret; } - @Override - public BytesRef getValueSafe(int docId) { - String value = values.getValue(docId); - if (value == null) return null; - return new BytesRef(value); - } - @Override public BytesRefArrayRef getValues(int docId) { StringArrayRef arrayRef = values.getValues(docId); @@ -214,21 +190,11 @@ public interface BytesValues { return valueIter.reset(values.getIter(docId)); } - @Override - public Iter getIterSafe(int docId) { - return safeValueIter.reset(values.getIter(docId)); - } - @Override public void forEachValueInDoc(int docId, ValueInDocProc proc) { values.forEachValueInDoc(docId, this.proc.reset(proc)); } - @Override - public void forEachSafeValueInDoc(int docId, ValueInDocProc proc) { - values.forEachValueInDoc(docId, this.safeProc.reset(proc)); - } - static class ValueIter implements Iter { private final BytesRef scratch = new BytesRef(); @@ -251,26 +217,6 @@ public interface BytesValues { } } - static class SafeValueIter implements Iter { - - private StringValues.Iter iter; - - public SafeValueIter reset(StringValues.Iter iter) { - this.iter = iter; - return this; - } - - @Override - public boolean hasNext() { - return iter.hasNext(); - } - - @Override - public BytesRef next() { - return new BytesRef(iter.next()); - } - } - static class Proc implements StringValues.ValueInDocProc { private final BytesRef scratch = new BytesRef(); @@ -292,25 +238,5 @@ public interface BytesValues { proc.onMissing(docId); } } - - static class SafeProc implements StringValues.ValueInDocProc { - - private BytesValues.ValueInDocProc proc; - - public SafeProc reset(BytesValues.ValueInDocProc proc) { - this.proc = proc; - return this; - } - - @Override - public void onValue(int docId, String value) { - proc.onValue(docId, new BytesRef(value)); - } - - @Override - public void onMissing(int docId) { - proc.onMissing(docId); - } - } } } diff --git a/src/main/java/org/elasticsearch/index/fielddata/HashedBytesValues.java b/src/main/java/org/elasticsearch/index/fielddata/HashedBytesValues.java index 2fe6f6da61b..f3479b900f2 100644 --- a/src/main/java/org/elasticsearch/index/fielddata/HashedBytesValues.java +++ b/src/main/java/org/elasticsearch/index/fielddata/HashedBytesValues.java @@ -43,35 +43,22 @@ public interface HashedBytesValues { HashedBytesRef makeSafe(HashedBytesRef bytes); /** - * Returns a bytes value for a docId. Note, the content of it might be shared across invocation. + * Returns a bytes value for a docId. Note, the content of it might be shared across invocation, + * call {@link #makeSafe(org.elasticsearch.common.lucene.HashedBytesRef)} to converts it to a "safe" + * option (if needed). */ HashedBytesRef getValue(int docId); - /** - * Returns a bytes value for a docId. The content is guaranteed not to be shared. - */ - HashedBytesRef getValueSafe(int docId); - /** * Returns a bytes value iterator for a docId. Note, the content of it might be shared across invocation. */ Iter getIter(int docId); - /** - * Returns a bytes value iterator for a docId. The content is guaranteed not to be shared. - */ - Iter getIterSafe(int docId); - /** * Go over all the possible values in their BytesRef format for a specific doc. */ void forEachValueInDoc(int docId, ValueInDocProc proc); - /** - * Go over all the possible values in their BytesRef format for a specific doc. - */ - void forEachSafeValueInDoc(int docId, ValueInDocProc proc); - public static interface ValueInDocProc { void onValue(int docId, HashedBytesRef value); @@ -133,9 +120,7 @@ public interface HashedBytesValues { protected final HashedBytesRef scratch = new HashedBytesRef(new BytesRef()); private final ValueIter valueIter = new ValueIter(); - private final SafeValueIter safeValueIter = new SafeValueIter(); private final Proc proc = new Proc(); - private final SafeProc safeProc = new SafeProc(); public BytesBased(BytesValues values) { this.values = values; @@ -164,31 +149,16 @@ public interface HashedBytesValues { return scratch.resetHashCode(); } - @Override - public HashedBytesRef getValueSafe(int docId) { - return new HashedBytesRef(values.getValueSafe(docId)); - } - @Override public Iter getIter(int docId) { return valueIter.reset(values.getIter(docId)); } - @Override - public Iter getIterSafe(int docId) { - return safeValueIter.reset(values.getIterSafe(docId)); - } - @Override public void forEachValueInDoc(int docId, final ValueInDocProc proc) { values.forEachValueInDoc(docId, this.proc.reset(proc)); } - @Override - public void forEachSafeValueInDoc(int docId, final ValueInDocProc proc) { - values.forEachValueInDoc(docId, this.safeProc.reset(proc)); - } - static class ValueIter implements Iter { private final HashedBytesRef scratch = new HashedBytesRef(new BytesRef()); @@ -211,26 +181,6 @@ public interface HashedBytesValues { } } - static class SafeValueIter implements Iter { - - private BytesValues.Iter iter; - - public SafeValueIter reset(BytesValues.Iter iter) { - this.iter = iter; - return this; - } - - @Override - public boolean hasNext() { - return iter.hasNext(); - } - - @Override - public HashedBytesRef next() { - return new HashedBytesRef(iter.next()); - } - } - static class Proc implements BytesValues.ValueInDocProc { private final HashedBytesRef scratch = new HashedBytesRef(); @@ -252,27 +202,6 @@ public interface HashedBytesValues { proc.onMissing(docId); } } - - static class SafeProc implements BytesValues.ValueInDocProc { - - private ValueInDocProc proc; - - public SafeProc reset(ValueInDocProc proc) { - this.proc = proc; - return this; - } - - @Override - public void onValue(int docId, BytesRef value) { - proc.onValue(docId, new HashedBytesRef(value)); - } - - @Override - public void onMissing(int docId) { - proc.onMissing(docId); - } - } - } static class StringBased implements HashedBytesValues { @@ -281,9 +210,7 @@ public interface HashedBytesValues { protected final HashedBytesRef scratch = new HashedBytesRef(new BytesRef()); private final ValueIter valueIter = new ValueIter(); - private final SafeValueIter safeValueIter = new SafeValueIter(); private final Proc proc = new Proc(); - private final SafeProc safeProc = new SafeProc(); public StringBased(StringValues values) { this.values = values; @@ -313,33 +240,16 @@ public interface HashedBytesValues { return scratch.resetHashCode(); } - @Override - public HashedBytesRef getValueSafe(int docId) { - String value = values.getValue(docId); - if (value == null) return null; - return new HashedBytesRef(new BytesRef(values.getValue(docId))); - } - @Override public Iter getIter(int docId) { return valueIter.reset(values.getIter(docId)); } - @Override - public Iter getIterSafe(int docId) { - return safeValueIter.reset(values.getIter(docId)); - } - @Override public void forEachValueInDoc(int docId, final ValueInDocProc proc) { values.forEachValueInDoc(docId, this.proc.reset(proc)); } - @Override - public void forEachSafeValueInDoc(int docId, final ValueInDocProc proc) { - values.forEachValueInDoc(docId, this.safeProc.reset(proc)); - } - static class ValueIter implements Iter { private final HashedBytesRef scratch = new HashedBytesRef(new BytesRef()); @@ -362,26 +272,6 @@ public interface HashedBytesValues { } } - static class SafeValueIter implements Iter { - - private StringValues.Iter iter; - - public SafeValueIter reset(StringValues.Iter iter) { - this.iter = iter; - return this; - } - - @Override - public boolean hasNext() { - return iter.hasNext(); - } - - @Override - public HashedBytesRef next() { - return new HashedBytesRef(new BytesRef(iter.next())); - } - } - static class Proc implements StringValues.ValueInDocProc { private final HashedBytesRef scratch = new HashedBytesRef(new BytesRef()); @@ -403,25 +293,5 @@ public interface HashedBytesValues { proc.onMissing(docId); } } - - static class SafeProc implements StringValues.ValueInDocProc { - - private ValueInDocProc proc; - - public SafeProc reset(ValueInDocProc proc) { - this.proc = proc; - return this; - } - - @Override - public void onValue(int docId, String value) { - proc.onValue(docId, new HashedBytesRef(new BytesRef(value))); - } - - @Override - public void onMissing(int docId) { - proc.onMissing(docId); - } - } } } diff --git a/src/main/java/org/elasticsearch/index/fielddata/plain/ConcreteBytesRefAtomicFieldData.java b/src/main/java/org/elasticsearch/index/fielddata/plain/ConcreteBytesRefAtomicFieldData.java index 127e661f64c..fcafcba97bd 100644 --- a/src/main/java/org/elasticsearch/index/fielddata/plain/ConcreteBytesRefAtomicFieldData.java +++ b/src/main/java/org/elasticsearch/index/fielddata/plain/ConcreteBytesRefAtomicFieldData.java @@ -170,16 +170,6 @@ public class ConcreteBytesRefAtomicFieldData implements AtomicOrdinalFieldData