remove some safe methods because of the new makeSafe method usage
This commit is contained in:
parent
f189a832c5
commit
e5b651321f
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -170,16 +170,6 @@ public class ConcreteBytesRefAtomicFieldData implements AtomicOrdinalFieldData<S
|
|||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BytesRef getValueSafe(int docId) {
|
||||
return values[ordinals.getOrd(docId)];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEachSafeValueInDoc(int docId, ValueInDocProc proc) {
|
||||
forEachValueInDoc(docId, proc);
|
||||
}
|
||||
|
||||
static class Single extends BytesValues {
|
||||
|
||||
private final BytesRefArrayRef arrayScratch = new BytesRefArrayRef(new BytesRef[1], 1);
|
||||
|
@ -209,13 +199,6 @@ public class ConcreteBytesRefAtomicFieldData implements AtomicOrdinalFieldData<S
|
|||
return iter.reset(values[ord]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iter getIterSafe(int docId) {
|
||||
int ord = ordinals.getOrd(docId);
|
||||
if (ord == 0) return Iter.Empty.INSTANCE;
|
||||
return iter.reset(values[ord]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEachValueInDoc(int docId, ValueInDocProc proc) {
|
||||
int ord = ordinals.getOrd(docId);
|
||||
|
@ -260,11 +243,6 @@ public class ConcreteBytesRefAtomicFieldData implements AtomicOrdinalFieldData<S
|
|||
return iter.reset(ordinals.getIter(docId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iter getIterSafe(int docId) {
|
||||
return iter.reset(ordinals.getIter(docId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEachValueInDoc(int docId, ValueInDocProc proc) {
|
||||
Ordinals.Docs.Iter iter = ordinals.getIter(docId);
|
||||
|
@ -357,13 +335,6 @@ public class ConcreteBytesRefAtomicFieldData implements AtomicOrdinalFieldData<S
|
|||
return scratch.reset(values[ord], hashes[ord]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashedBytesRef getValueSafe(int docId) {
|
||||
int ord = ordinals.getOrd(docId);
|
||||
if (ord == 0) return null;
|
||||
return new HashedBytesRef(values[ord], hashes[ord]);
|
||||
}
|
||||
|
||||
static class Single extends HashedBytesValues {
|
||||
|
||||
private final Iter.Single iter = new Iter.Single();
|
||||
|
@ -384,13 +355,6 @@ public class ConcreteBytesRefAtomicFieldData implements AtomicOrdinalFieldData<S
|
|||
return iter.reset(scratch.reset(values[ord], hashes[ord]));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iter getIterSafe(int docId) {
|
||||
int ord = ordinals.getOrd(docId);
|
||||
if (ord == 0) return Iter.Empty.INSTANCE;
|
||||
return iter.reset(new HashedBytesRef(values[ord], hashes[ord]));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEachValueInDoc(int docId, ValueInDocProc proc) {
|
||||
int ord = ordinals.getOrd(docId);
|
||||
|
@ -400,27 +364,15 @@ public class ConcreteBytesRefAtomicFieldData implements AtomicOrdinalFieldData<S
|
|||
proc.onValue(docId, scratch.reset(values[ord], hashes[ord]));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEachSafeValueInDoc(int docId, ValueInDocProc proc) {
|
||||
int ord = ordinals.getOrd(docId);
|
||||
if (ord == 0) {
|
||||
proc.onMissing(docId);
|
||||
} else {
|
||||
proc.onValue(docId, new HashedBytesRef(values[ord], hashes[ord]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class Multi extends HashedBytesValues {
|
||||
|
||||
private final ValuesIter iter;
|
||||
private final SafeValuesIter safeIter;
|
||||
|
||||
Multi(BytesRef[] values, int[] hashes, Ordinals.Docs ordinals) {
|
||||
super(values, hashes, ordinals);
|
||||
this.iter = new ValuesIter(values, hashes);
|
||||
this.safeIter = new SafeValuesIter(values, hashes);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -433,11 +385,6 @@ public class ConcreteBytesRefAtomicFieldData implements AtomicOrdinalFieldData<S
|
|||
return iter.reset(ordinals.getIter(docId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iter getIterSafe(int docId) {
|
||||
return safeIter.reset(ordinals.getIter(docId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEachValueInDoc(int docId, ValueInDocProc proc) {
|
||||
Ordinals.Docs.Iter iter = ordinals.getIter(docId);
|
||||
|
@ -451,19 +398,6 @@ public class ConcreteBytesRefAtomicFieldData implements AtomicOrdinalFieldData<S
|
|||
} while ((ord = iter.next()) != 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEachSafeValueInDoc(int docId, ValueInDocProc proc) {
|
||||
Ordinals.Docs.Iter iter = ordinals.getIter(docId);
|
||||
int ord = iter.next();
|
||||
if (ord == 0) {
|
||||
proc.onMissing(docId);
|
||||
return;
|
||||
}
|
||||
do {
|
||||
proc.onValue(docId, new HashedBytesRef(values[ord], hashes[ord]));
|
||||
} while ((ord = iter.next()) != 0);
|
||||
}
|
||||
|
||||
static class ValuesIter implements Iter {
|
||||
|
||||
private final BytesRef[] values;
|
||||
|
@ -496,37 +430,6 @@ public class ConcreteBytesRefAtomicFieldData implements AtomicOrdinalFieldData<S
|
|||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
static class SafeValuesIter implements Iter {
|
||||
|
||||
private final BytesRef[] values;
|
||||
private final int[] hashes;
|
||||
private Ordinals.Docs.Iter ordsIter;
|
||||
private int ord;
|
||||
|
||||
SafeValuesIter(BytesRef[] values, int[] hashes) {
|
||||
this.values = values;
|
||||
this.hashes = hashes;
|
||||
}
|
||||
|
||||
public SafeValuesIter reset(Ordinals.Docs.Iter ordsIter) {
|
||||
this.ordsIter = ordsIter;
|
||||
this.ord = ordsIter.next();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return ord != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashedBytesRef next() {
|
||||
HashedBytesRef value = new HashedBytesRef(values[ord], hashes[ord]);
|
||||
ord = ordsIter.next();
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -165,13 +165,6 @@ public class PagedBytesAtomicFieldData implements AtomicOrdinalFieldData<ScriptD
|
|||
return bytes.fill(ret, termOrdToBytesOffset.get(ordinals.getOrd(docId)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BytesRef getValueSafe(int docId) {
|
||||
int ord = ordinals.getOrd(docId);
|
||||
if (ord == 0) return null;
|
||||
return bytes.fill(new BytesRef(), termOrdToBytesOffset.get(ord));
|
||||
}
|
||||
|
||||
static class Single extends BytesValues {
|
||||
|
||||
private final BytesRefArrayRef arrayScratch = new BytesRefArrayRef(new BytesRef[1], 1);
|
||||
|
@ -201,13 +194,6 @@ public class PagedBytesAtomicFieldData implements AtomicOrdinalFieldData<ScriptD
|
|||
return iter.reset(bytes.fill(scratch, termOrdToBytesOffset.get(ord)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iter getIterSafe(int docId) {
|
||||
int ord = ordinals.getOrd(docId);
|
||||
if (ord == 0) return Iter.Empty.INSTANCE;
|
||||
return iter.reset(bytes.fill(new BytesRef(), termOrdToBytesOffset.get(ord)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEachValueInDoc(int docId, ValueInDocProc proc) {
|
||||
int ord = ordinals.getOrd(docId);
|
||||
|
@ -217,28 +203,16 @@ public class PagedBytesAtomicFieldData implements AtomicOrdinalFieldData<ScriptD
|
|||
proc.onValue(docId, bytes.fill(scratch, termOrdToBytesOffset.get(ord)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEachSafeValueInDoc(int docId, ValueInDocProc proc) {
|
||||
int ord = ordinals.getOrd(docId);
|
||||
if (ord == 0) {
|
||||
proc.onMissing(docId);
|
||||
} else {
|
||||
proc.onValue(docId, bytes.fill(new BytesRef(), termOrdToBytesOffset.get(ord)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class Multi extends BytesValues {
|
||||
|
||||
private final BytesRefArrayRef arrayScratch = new BytesRefArrayRef(new BytesRef[10], 0);
|
||||
private final ValuesIter iter;
|
||||
private final SafeValuesIter safeIter;
|
||||
|
||||
Multi(PagedBytes.Reader bytes, PackedInts.Reader termOrdToBytesOffset, Ordinals.Docs ordinals) {
|
||||
super(bytes, termOrdToBytesOffset, ordinals);
|
||||
this.iter = new ValuesIter(bytes, termOrdToBytesOffset);
|
||||
this.safeIter = new SafeValuesIter(bytes, termOrdToBytesOffset);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -264,11 +238,6 @@ public class PagedBytesAtomicFieldData implements AtomicOrdinalFieldData<ScriptD
|
|||
return iter.reset(ordinals.getIter(docId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iter getIterSafe(int docId) {
|
||||
return safeIter.reset(ordinals.getIter(docId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEachValueInDoc(int docId, ValueInDocProc proc) {
|
||||
Ordinals.Docs.Iter iter = ordinals.getIter(docId);
|
||||
|
@ -282,19 +251,6 @@ public class PagedBytesAtomicFieldData implements AtomicOrdinalFieldData<ScriptD
|
|||
} while ((ord = iter.next()) != 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEachSafeValueInDoc(int docId, ValueInDocProc proc) {
|
||||
Ordinals.Docs.Iter iter = ordinals.getIter(docId);
|
||||
int ord = iter.next();
|
||||
if (ord == 0) {
|
||||
proc.onMissing(docId);
|
||||
return;
|
||||
}
|
||||
do {
|
||||
proc.onValue(docId, bytes.fill(new BytesRef(), termOrdToBytesOffset.get(ord)));
|
||||
} while ((ord = iter.next()) != 0);
|
||||
}
|
||||
|
||||
static class ValuesIter implements Iter {
|
||||
|
||||
private final PagedBytes.Reader bytes;
|
||||
|
@ -326,37 +282,6 @@ public class PagedBytesAtomicFieldData implements AtomicOrdinalFieldData<ScriptD
|
|||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
static class SafeValuesIter implements Iter {
|
||||
|
||||
private final PagedBytes.Reader bytes;
|
||||
private final PackedInts.Reader termOrdToBytesOffset;
|
||||
private Ordinals.Docs.Iter ordsIter;
|
||||
private int ord;
|
||||
|
||||
SafeValuesIter(PagedBytes.Reader bytes, PackedInts.Reader termOrdToBytesOffset) {
|
||||
this.bytes = bytes;
|
||||
this.termOrdToBytesOffset = termOrdToBytesOffset;
|
||||
}
|
||||
|
||||
public SafeValuesIter reset(Ordinals.Docs.Iter ordsIter) {
|
||||
this.ordsIter = ordsIter;
|
||||
this.ord = ordsIter.next();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return ord != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BytesRef next() {
|
||||
BytesRef value = bytes.fill(new BytesRef(), termOrdToBytesOffset.get(ord));
|
||||
ord = ordsIter.next();
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -409,13 +334,6 @@ public class PagedBytesAtomicFieldData implements AtomicOrdinalFieldData<ScriptD
|
|||
return scratch.reset(bytes.fill(scratch1, termOrdToBytesOffset.get(ord)), hashes[ord]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashedBytesRef getValueSafe(int docId) {
|
||||
int ord = ordinals.getOrd(docId);
|
||||
if (ord == 0) return null;
|
||||
return new HashedBytesRef(bytes.fill(new BytesRef(), termOrdToBytesOffset.get(ord)), hashes[ord]);
|
||||
}
|
||||
|
||||
static class Single extends HashedBytesValues {
|
||||
|
||||
private final Iter.Single iter = new Iter.Single();
|
||||
|
@ -436,13 +354,6 @@ public class PagedBytesAtomicFieldData implements AtomicOrdinalFieldData<ScriptD
|
|||
return iter.reset(scratch.reset(bytes.fill(scratch1, termOrdToBytesOffset.get(ord)), hashes[ord]));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iter getIterSafe(int docId) {
|
||||
int ord = ordinals.getOrd(docId);
|
||||
if (ord == 0) return Iter.Empty.INSTANCE;
|
||||
return iter.reset(new HashedBytesRef(bytes.fill(new BytesRef(), termOrdToBytesOffset.get(ord)), hashes[ord]));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEachValueInDoc(int docId, ValueInDocProc proc) {
|
||||
int ord = ordinals.getOrd(docId);
|
||||
|
@ -452,27 +363,15 @@ public class PagedBytesAtomicFieldData implements AtomicOrdinalFieldData<ScriptD
|
|||
proc.onValue(docId, scratch.reset(bytes.fill(scratch1, termOrdToBytesOffset.get(ord)), hashes[ord]));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEachSafeValueInDoc(int docId, ValueInDocProc proc) {
|
||||
int ord = ordinals.getOrd(docId);
|
||||
if (ord == 0) {
|
||||
proc.onMissing(docId);
|
||||
} else {
|
||||
proc.onValue(docId, new HashedBytesRef(bytes.fill(new BytesRef(), termOrdToBytesOffset.get(ord)), hashes[ord]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class Multi extends HashedBytesValues {
|
||||
|
||||
private final ValuesIter iter;
|
||||
private final SafeValuesIter safeIter;
|
||||
|
||||
Multi(PagedBytes.Reader bytes, PackedInts.Reader termOrdToBytesOffset, int[] hashes, Ordinals.Docs ordinals) {
|
||||
super(bytes, termOrdToBytesOffset, hashes, ordinals);
|
||||
this.iter = new ValuesIter(bytes, termOrdToBytesOffset, hashes);
|
||||
this.safeIter = new SafeValuesIter(bytes, termOrdToBytesOffset, hashes);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -485,11 +384,6 @@ public class PagedBytesAtomicFieldData implements AtomicOrdinalFieldData<ScriptD
|
|||
return iter.reset(ordinals.getIter(docId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iter getIterSafe(int docId) {
|
||||
return safeIter.reset(ordinals.getIter(docId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEachValueInDoc(int docId, ValueInDocProc proc) {
|
||||
Ordinals.Docs.Iter iter = ordinals.getIter(docId);
|
||||
|
@ -503,19 +397,6 @@ public class PagedBytesAtomicFieldData implements AtomicOrdinalFieldData<ScriptD
|
|||
} while ((ord = iter.next()) != 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEachSafeValueInDoc(int docId, ValueInDocProc proc) {
|
||||
Ordinals.Docs.Iter iter = ordinals.getIter(docId);
|
||||
int ord = iter.next();
|
||||
if (ord == 0) {
|
||||
proc.onMissing(docId);
|
||||
return;
|
||||
}
|
||||
do {
|
||||
proc.onValue(docId, new HashedBytesRef(bytes.fill(new BytesRef(), termOrdToBytesOffset.get(ord)), hashes[ord]));
|
||||
} while ((ord = iter.next()) != 0);
|
||||
}
|
||||
|
||||
static class ValuesIter implements Iter {
|
||||
|
||||
private final PagedBytes.Reader bytes;
|
||||
|
@ -551,39 +432,6 @@ public class PagedBytesAtomicFieldData implements AtomicOrdinalFieldData<ScriptD
|
|||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
static class SafeValuesIter implements Iter {
|
||||
|
||||
private final PagedBytes.Reader bytes;
|
||||
private final PackedInts.Reader termOrdToBytesOffset;
|
||||
private final int[] hashes;
|
||||
private Ordinals.Docs.Iter ordsIter;
|
||||
private int ord;
|
||||
|
||||
SafeValuesIter(PagedBytes.Reader bytes, PackedInts.Reader termOrdToBytesOffset, int[] hashes) {
|
||||
this.bytes = bytes;
|
||||
this.termOrdToBytesOffset = termOrdToBytesOffset;
|
||||
this.hashes = hashes;
|
||||
}
|
||||
|
||||
public SafeValuesIter reset(Ordinals.Docs.Iter ordsIter) {
|
||||
this.ordsIter = ordsIter;
|
||||
this.ord = ordsIter.next();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return ord != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashedBytesRef next() {
|
||||
HashedBytesRef value = new HashedBytesRef(bytes.fill(new BytesRef(), termOrdToBytesOffset.get(ord)), hashes[ord]);
|
||||
ord = ordsIter.next();
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -101,10 +101,6 @@ public abstract class StringFieldDataTests extends AbstractFieldDataTests {
|
|||
assertThat(bytesValues.getValue(1), equalTo(new BytesRef(one())));
|
||||
assertThat(bytesValues.getValue(2), equalTo(new BytesRef(three())));
|
||||
|
||||
assertThat(bytesValues.getValueSafe(0), equalTo(new BytesRef(two())));
|
||||
assertThat(bytesValues.getValueSafe(1), equalTo(new BytesRef(one())));
|
||||
assertThat(bytesValues.getValueSafe(2), equalTo(new BytesRef(three())));
|
||||
|
||||
BytesRef bytesRef = new BytesRef();
|
||||
assertThat(bytesValues.getValueScratch(0, bytesRef), equalTo(new BytesRef(two())));
|
||||
assertThat(bytesRef, equalTo(new BytesRef(two())));
|
||||
|
@ -131,19 +127,10 @@ public abstract class StringFieldDataTests extends AbstractFieldDataTests {
|
|||
assertThat(bytesValuesIter.next(), equalTo(new BytesRef(two())));
|
||||
assertThat(bytesValuesIter.hasNext(), equalTo(false));
|
||||
|
||||
bytesValuesIter = bytesValues.getIterSafe(0);
|
||||
assertThat(bytesValuesIter.hasNext(), equalTo(true));
|
||||
assertThat(bytesValuesIter.next(), equalTo(new BytesRef(two())));
|
||||
assertThat(bytesValuesIter.hasNext(), equalTo(false));
|
||||
|
||||
bytesValues.forEachValueInDoc(0, new BytesValuesVerifierProc(0).addExpected(two()));
|
||||
bytesValues.forEachValueInDoc(1, new BytesValuesVerifierProc(1).addExpected(one()));
|
||||
bytesValues.forEachValueInDoc(2, new BytesValuesVerifierProc(2).addExpected(three()));
|
||||
|
||||
bytesValues.forEachSafeValueInDoc(0, new BytesValuesVerifierProc(0).addExpected(two()));
|
||||
bytesValues.forEachSafeValueInDoc(1, new BytesValuesVerifierProc(1).addExpected(one()));
|
||||
bytesValues.forEachSafeValueInDoc(2, new BytesValuesVerifierProc(2).addExpected(three()));
|
||||
|
||||
HashedBytesValues hashedBytesValues = fieldData.getHashedBytesValues();
|
||||
|
||||
assertThat(hashedBytesValues.hasValue(0), equalTo(true));
|
||||
|
@ -154,28 +141,15 @@ public abstract class StringFieldDataTests extends AbstractFieldDataTests {
|
|||
assertThat(hashedBytesValues.getValue(1), equalTo(new HashedBytesRef(one())));
|
||||
assertThat(hashedBytesValues.getValue(2), equalTo(new HashedBytesRef(three())));
|
||||
|
||||
assertThat(hashedBytesValues.getValueSafe(0), equalTo(new HashedBytesRef(two())));
|
||||
assertThat(hashedBytesValues.getValueSafe(1), equalTo(new HashedBytesRef(one())));
|
||||
assertThat(hashedBytesValues.getValueSafe(2), equalTo(new HashedBytesRef(three())));
|
||||
|
||||
HashedBytesValues.Iter hashedBytesValuesIter = hashedBytesValues.getIter(0);
|
||||
assertThat(hashedBytesValuesIter.hasNext(), equalTo(true));
|
||||
assertThat(hashedBytesValuesIter.next(), equalTo(new HashedBytesRef(two())));
|
||||
assertThat(hashedBytesValuesIter.hasNext(), equalTo(false));
|
||||
|
||||
hashedBytesValuesIter = hashedBytesValues.getIterSafe(0);
|
||||
assertThat(hashedBytesValuesIter.hasNext(), equalTo(true));
|
||||
assertThat(hashedBytesValuesIter.next(), equalTo(new HashedBytesRef(two())));
|
||||
assertThat(hashedBytesValuesIter.hasNext(), equalTo(false));
|
||||
|
||||
hashedBytesValues.forEachValueInDoc(0, new HashedBytesValuesVerifierProc(0).addExpected(two()));
|
||||
hashedBytesValues.forEachValueInDoc(1, new HashedBytesValuesVerifierProc(1).addExpected(one()));
|
||||
hashedBytesValues.forEachValueInDoc(2, new HashedBytesValuesVerifierProc(2).addExpected(three()));
|
||||
|
||||
hashedBytesValues.forEachSafeValueInDoc(0, new HashedBytesValuesVerifierProc(0).addExpected(two()));
|
||||
hashedBytesValues.forEachSafeValueInDoc(1, new HashedBytesValuesVerifierProc(1).addExpected(one()));
|
||||
hashedBytesValues.forEachSafeValueInDoc(2, new HashedBytesValuesVerifierProc(2).addExpected(three()));
|
||||
|
||||
StringValues stringValues = fieldData.getStringValues();
|
||||
|
||||
assertThat(stringValues.hasValue(0), equalTo(true));
|
||||
|
@ -277,10 +251,6 @@ public abstract class StringFieldDataTests extends AbstractFieldDataTests {
|
|||
assertThat(bytesValues.getValue(1), nullValue());
|
||||
assertThat(bytesValues.getValue(2), equalTo(new BytesRef(three())));
|
||||
|
||||
assertThat(bytesValues.getValueSafe(0), equalTo(new BytesRef(two())));
|
||||
assertThat(bytesValues.getValueSafe(1), nullValue());
|
||||
assertThat(bytesValues.getValueSafe(2), equalTo(new BytesRef(three())));
|
||||
|
||||
BytesRef bytesRef = new BytesRef();
|
||||
assertThat(bytesValues.getValueScratch(0, bytesRef), equalTo(new BytesRef(two())));
|
||||
assertThat(bytesRef, equalTo(new BytesRef(two())));
|
||||
|
@ -309,22 +279,10 @@ public abstract class StringFieldDataTests extends AbstractFieldDataTests {
|
|||
bytesValuesIter = bytesValues.getIter(1);
|
||||
assertThat(bytesValuesIter.hasNext(), equalTo(false));
|
||||
|
||||
bytesValuesIter = bytesValues.getIterSafe(0);
|
||||
assertThat(bytesValuesIter.hasNext(), equalTo(true));
|
||||
assertThat(bytesValuesIter.next(), equalTo(new BytesRef(two())));
|
||||
assertThat(bytesValuesIter.hasNext(), equalTo(false));
|
||||
|
||||
bytesValuesIter = bytesValues.getIterSafe(1);
|
||||
assertThat(bytesValuesIter.hasNext(), equalTo(false));
|
||||
|
||||
bytesValues.forEachValueInDoc(0, new BytesValuesVerifierProc(0).addExpected(two()));
|
||||
bytesValues.forEachValueInDoc(1, new BytesValuesVerifierProc(1).addMissing());
|
||||
bytesValues.forEachValueInDoc(2, new BytesValuesVerifierProc(2).addExpected(three()));
|
||||
|
||||
bytesValues.forEachSafeValueInDoc(0, new BytesValuesVerifierProc(0).addExpected(two()));
|
||||
bytesValues.forEachSafeValueInDoc(1, new BytesValuesVerifierProc(1).addMissing());
|
||||
bytesValues.forEachSafeValueInDoc(2, new BytesValuesVerifierProc(2).addExpected(three()));
|
||||
|
||||
HashedBytesValues hashedBytesValues = fieldData.getHashedBytesValues();
|
||||
|
||||
assertThat(hashedBytesValues.hasValue(0), equalTo(true));
|
||||
|
@ -335,10 +293,6 @@ public abstract class StringFieldDataTests extends AbstractFieldDataTests {
|
|||
assertThat(hashedBytesValues.getValue(1), nullValue());
|
||||
assertThat(hashedBytesValues.getValue(2), equalTo(new HashedBytesRef(three())));
|
||||
|
||||
assertThat(hashedBytesValues.getValueSafe(0), equalTo(new HashedBytesRef(two())));
|
||||
assertThat(hashedBytesValues.getValueSafe(1), nullValue());
|
||||
assertThat(hashedBytesValues.getValueSafe(2), equalTo(new HashedBytesRef(three())));
|
||||
|
||||
HashedBytesValues.Iter hashedBytesValuesIter = hashedBytesValues.getIter(0);
|
||||
assertThat(hashedBytesValuesIter.hasNext(), equalTo(true));
|
||||
assertThat(hashedBytesValuesIter.next(), equalTo(new HashedBytesRef(two())));
|
||||
|
@ -347,22 +301,10 @@ public abstract class StringFieldDataTests extends AbstractFieldDataTests {
|
|||
hashedBytesValuesIter = hashedBytesValues.getIter(1);
|
||||
assertThat(hashedBytesValuesIter.hasNext(), equalTo(false));
|
||||
|
||||
hashedBytesValuesIter = hashedBytesValues.getIterSafe(0);
|
||||
assertThat(hashedBytesValuesIter.hasNext(), equalTo(true));
|
||||
assertThat(hashedBytesValuesIter.next(), equalTo(new HashedBytesRef(two())));
|
||||
assertThat(hashedBytesValuesIter.hasNext(), equalTo(false));
|
||||
|
||||
hashedBytesValuesIter = hashedBytesValues.getIterSafe(1);
|
||||
assertThat(hashedBytesValuesIter.hasNext(), equalTo(false));
|
||||
|
||||
hashedBytesValues.forEachValueInDoc(0, new HashedBytesValuesVerifierProc(0).addExpected(two()));
|
||||
hashedBytesValues.forEachValueInDoc(1, new HashedBytesValuesVerifierProc(1).addMissing());
|
||||
hashedBytesValues.forEachValueInDoc(2, new HashedBytesValuesVerifierProc(2).addExpected(three()));
|
||||
|
||||
hashedBytesValues.forEachSafeValueInDoc(0, new HashedBytesValuesVerifierProc(0).addExpected(two()));
|
||||
hashedBytesValues.forEachSafeValueInDoc(1, new HashedBytesValuesVerifierProc(1).addMissing());
|
||||
hashedBytesValues.forEachSafeValueInDoc(2, new HashedBytesValuesVerifierProc(2).addExpected(three()));
|
||||
|
||||
StringValues stringValues = fieldData.getStringValues();
|
||||
|
||||
assertThat(stringValues.hasValue(0), equalTo(true));
|
||||
|
@ -443,10 +385,6 @@ public abstract class StringFieldDataTests extends AbstractFieldDataTests {
|
|||
assertThat(bytesValues.getValue(1), equalTo(new BytesRef(one())));
|
||||
assertThat(bytesValues.getValue(2), equalTo(new BytesRef(three())));
|
||||
|
||||
assertThat(bytesValues.getValueSafe(0), equalTo(new BytesRef(two())));
|
||||
assertThat(bytesValues.getValueSafe(1), equalTo(new BytesRef(one())));
|
||||
assertThat(bytesValues.getValueSafe(2), equalTo(new BytesRef(three())));
|
||||
|
||||
BytesRef bytesRef = new BytesRef();
|
||||
assertThat(bytesValues.getValueScratch(0, bytesRef), equalTo(new BytesRef(two())));
|
||||
assertThat(bytesRef, equalTo(new BytesRef(two())));
|
||||
|
@ -476,21 +414,10 @@ public abstract class StringFieldDataTests extends AbstractFieldDataTests {
|
|||
assertThat(bytesValuesIter.next(), equalTo(new BytesRef(four())));
|
||||
assertThat(bytesValuesIter.hasNext(), equalTo(false));
|
||||
|
||||
bytesValuesIter = bytesValues.getIterSafe(0);
|
||||
assertThat(bytesValuesIter.hasNext(), equalTo(true));
|
||||
assertThat(bytesValuesIter.next(), equalTo(new BytesRef(two())));
|
||||
assertThat(bytesValuesIter.hasNext(), equalTo(true));
|
||||
assertThat(bytesValuesIter.next(), equalTo(new BytesRef(four())));
|
||||
assertThat(bytesValuesIter.hasNext(), equalTo(false));
|
||||
|
||||
bytesValues.forEachValueInDoc(0, new BytesValuesVerifierProc(0).addExpected(two()).addExpected(four()));
|
||||
bytesValues.forEachValueInDoc(1, new BytesValuesVerifierProc(1).addExpected(one()));
|
||||
bytesValues.forEachValueInDoc(2, new BytesValuesVerifierProc(2).addExpected(three()));
|
||||
|
||||
bytesValues.forEachSafeValueInDoc(0, new BytesValuesVerifierProc(0).addExpected(two()).addExpected(four()));
|
||||
bytesValues.forEachSafeValueInDoc(1, new BytesValuesVerifierProc(1).addExpected(one()));
|
||||
bytesValues.forEachSafeValueInDoc(2, new BytesValuesVerifierProc(2).addExpected(three()));
|
||||
|
||||
HashedBytesValues hashedBytesValues = fieldData.getHashedBytesValues();
|
||||
|
||||
assertThat(hashedBytesValues.hasValue(0), equalTo(true));
|
||||
|
@ -501,10 +428,6 @@ public abstract class StringFieldDataTests extends AbstractFieldDataTests {
|
|||
assertThat(hashedBytesValues.getValue(1), equalTo(new HashedBytesRef(one())));
|
||||
assertThat(hashedBytesValues.getValue(2), equalTo(new HashedBytesRef(three())));
|
||||
|
||||
assertThat(hashedBytesValues.getValueSafe(0), equalTo(new HashedBytesRef(two())));
|
||||
assertThat(hashedBytesValues.getValueSafe(1), equalTo(new HashedBytesRef(one())));
|
||||
assertThat(hashedBytesValues.getValueSafe(2), equalTo(new HashedBytesRef(three())));
|
||||
|
||||
HashedBytesValues.Iter hashedBytesValuesIter = hashedBytesValues.getIter(0);
|
||||
assertThat(hashedBytesValuesIter.hasNext(), equalTo(true));
|
||||
assertThat(hashedBytesValuesIter.next(), equalTo(new HashedBytesRef(two())));
|
||||
|
@ -512,21 +435,10 @@ public abstract class StringFieldDataTests extends AbstractFieldDataTests {
|
|||
assertThat(hashedBytesValuesIter.next(), equalTo(new HashedBytesRef(four())));
|
||||
assertThat(hashedBytesValuesIter.hasNext(), equalTo(false));
|
||||
|
||||
hashedBytesValuesIter = hashedBytesValues.getIterSafe(0);
|
||||
assertThat(hashedBytesValuesIter.hasNext(), equalTo(true));
|
||||
assertThat(hashedBytesValuesIter.next(), equalTo(new HashedBytesRef(two())));
|
||||
assertThat(hashedBytesValuesIter.hasNext(), equalTo(true));
|
||||
assertThat(hashedBytesValuesIter.next(), equalTo(new HashedBytesRef(four())));
|
||||
assertThat(hashedBytesValuesIter.hasNext(), equalTo(false));
|
||||
|
||||
hashedBytesValues.forEachValueInDoc(0, new HashedBytesValuesVerifierProc(0).addExpected(two()).addExpected(four()));
|
||||
hashedBytesValues.forEachValueInDoc(1, new HashedBytesValuesVerifierProc(1).addExpected(one()));
|
||||
hashedBytesValues.forEachValueInDoc(2, new HashedBytesValuesVerifierProc(2).addExpected(three()));
|
||||
|
||||
hashedBytesValues.forEachSafeValueInDoc(0, new HashedBytesValuesVerifierProc(0).addExpected(two()).addExpected(four()));
|
||||
hashedBytesValues.forEachSafeValueInDoc(1, new HashedBytesValuesVerifierProc(1).addExpected(one()));
|
||||
hashedBytesValues.forEachSafeValueInDoc(2, new HashedBytesValuesVerifierProc(2).addExpected(three()));
|
||||
|
||||
StringValues stringValues = fieldData.getStringValues();
|
||||
|
||||
assertThat(stringValues.hasValue(0), equalTo(true));
|
||||
|
@ -611,10 +523,6 @@ public abstract class StringFieldDataTests extends AbstractFieldDataTests {
|
|||
assertThat(bytesValues.getValue(1), nullValue());
|
||||
assertThat(bytesValues.getValue(2), equalTo(new BytesRef(three())));
|
||||
|
||||
assertThat(bytesValues.getValueSafe(0), equalTo(new BytesRef(two())));
|
||||
assertThat(bytesValues.getValueSafe(1), nullValue());
|
||||
assertThat(bytesValues.getValueSafe(2), equalTo(new BytesRef(three())));
|
||||
|
||||
BytesRef bytesRef = new BytesRef();
|
||||
assertThat(bytesValues.getValueScratch(0, bytesRef), equalTo(new BytesRef(two())));
|
||||
assertThat(bytesRef, equalTo(new BytesRef(two())));
|
||||
|
@ -646,24 +554,10 @@ public abstract class StringFieldDataTests extends AbstractFieldDataTests {
|
|||
bytesValuesIter = bytesValues.getIter(1);
|
||||
assertThat(bytesValuesIter.hasNext(), equalTo(false));
|
||||
|
||||
bytesValuesIter = bytesValues.getIterSafe(0);
|
||||
assertThat(bytesValuesIter.hasNext(), equalTo(true));
|
||||
assertThat(bytesValuesIter.next(), equalTo(new BytesRef(two())));
|
||||
assertThat(bytesValuesIter.hasNext(), equalTo(true));
|
||||
assertThat(bytesValuesIter.next(), equalTo(new BytesRef(four())));
|
||||
assertThat(bytesValuesIter.hasNext(), equalTo(false));
|
||||
|
||||
bytesValuesIter = bytesValues.getIterSafe(1);
|
||||
assertThat(bytesValuesIter.hasNext(), equalTo(false));
|
||||
|
||||
bytesValues.forEachValueInDoc(0, new BytesValuesVerifierProc(0).addExpected(two()).addExpected(four()));
|
||||
bytesValues.forEachValueInDoc(1, new BytesValuesVerifierProc(1).addMissing());
|
||||
bytesValues.forEachValueInDoc(2, new BytesValuesVerifierProc(2).addExpected(three()));
|
||||
|
||||
bytesValues.forEachSafeValueInDoc(0, new BytesValuesVerifierProc(0).addExpected(two()).addExpected(four()));
|
||||
bytesValues.forEachSafeValueInDoc(1, new BytesValuesVerifierProc(1).addMissing());
|
||||
bytesValues.forEachSafeValueInDoc(2, new BytesValuesVerifierProc(2).addExpected(three()));
|
||||
|
||||
HashedBytesValues hashedBytesValues = fieldData.getHashedBytesValues();
|
||||
|
||||
assertThat(hashedBytesValues.hasValue(0), equalTo(true));
|
||||
|
@ -674,10 +568,6 @@ public abstract class StringFieldDataTests extends AbstractFieldDataTests {
|
|||
assertThat(hashedBytesValues.getValue(1), nullValue());
|
||||
assertThat(hashedBytesValues.getValue(2), equalTo(new HashedBytesRef(three())));
|
||||
|
||||
assertThat(hashedBytesValues.getValueSafe(0), equalTo(new HashedBytesRef(two())));
|
||||
assertThat(hashedBytesValues.getValueSafe(1), nullValue());
|
||||
assertThat(hashedBytesValues.getValueSafe(2), equalTo(new HashedBytesRef(three())));
|
||||
|
||||
HashedBytesValues.Iter hashedBytesValuesIter = hashedBytesValues.getIter(0);
|
||||
assertThat(hashedBytesValuesIter.hasNext(), equalTo(true));
|
||||
assertThat(hashedBytesValuesIter.next(), equalTo(new HashedBytesRef(two())));
|
||||
|
@ -688,24 +578,10 @@ public abstract class StringFieldDataTests extends AbstractFieldDataTests {
|
|||
hashedBytesValuesIter = hashedBytesValues.getIter(1);
|
||||
assertThat(hashedBytesValuesIter.hasNext(), equalTo(false));
|
||||
|
||||
hashedBytesValuesIter = hashedBytesValues.getIterSafe(0);
|
||||
assertThat(hashedBytesValuesIter.hasNext(), equalTo(true));
|
||||
assertThat(hashedBytesValuesIter.next(), equalTo(new HashedBytesRef(two())));
|
||||
assertThat(hashedBytesValuesIter.hasNext(), equalTo(true));
|
||||
assertThat(hashedBytesValuesIter.next(), equalTo(new HashedBytesRef(four())));
|
||||
assertThat(hashedBytesValuesIter.hasNext(), equalTo(false));
|
||||
|
||||
hashedBytesValuesIter = hashedBytesValues.getIterSafe(1);
|
||||
assertThat(hashedBytesValuesIter.hasNext(), equalTo(false));
|
||||
|
||||
hashedBytesValues.forEachValueInDoc(0, new HashedBytesValuesVerifierProc(0).addExpected(two()).addExpected(four()));
|
||||
hashedBytesValues.forEachValueInDoc(1, new HashedBytesValuesVerifierProc(1).addMissing());
|
||||
hashedBytesValues.forEachValueInDoc(2, new HashedBytesValuesVerifierProc(2).addExpected(three()));
|
||||
|
||||
hashedBytesValues.forEachSafeValueInDoc(0, new HashedBytesValuesVerifierProc(0).addExpected(two()).addExpected(four()));
|
||||
hashedBytesValues.forEachSafeValueInDoc(1, new HashedBytesValuesVerifierProc(1).addMissing());
|
||||
hashedBytesValues.forEachSafeValueInDoc(2, new HashedBytesValuesVerifierProc(2).addExpected(three()));
|
||||
|
||||
StringValues stringValues = fieldData.getStringValues();
|
||||
|
||||
assertThat(stringValues.hasValue(0), equalTo(true));
|
||||
|
|
Loading…
Reference in New Issue