Fix computation of the missing ord (leftover of the ordinals change).
This commit is contained in:
parent
fe89b8735a
commit
6ec01c13e5
|
@ -279,15 +279,20 @@ public final class BytesRefOrdValComparator extends NestedWrappableComparator<By
|
||||||
|
|
||||||
// find where to insert an ord in the current terms index
|
// find where to insert an ord in the current terms index
|
||||||
private long ordInCurrentReader(BytesValues.WithOrdinals termsIndex, BytesRef value) {
|
private long ordInCurrentReader(BytesValues.WithOrdinals termsIndex, BytesRef value) {
|
||||||
final long docOrd = binarySearch(termsIndex, value);
|
|
||||||
final long ord;
|
final long ord;
|
||||||
if (docOrd >= 0) {
|
if (value == null) {
|
||||||
|
ord = Ordinals.MISSING_ORDINAL << 2;
|
||||||
|
} else {
|
||||||
|
final long docOrd = binarySearch(termsIndex, value);
|
||||||
|
if (docOrd >= Ordinals.MIN_ORDINAL) {
|
||||||
// value exists in the current segment
|
// value exists in the current segment
|
||||||
ord = docOrd << 2;
|
ord = docOrd << 2;
|
||||||
} else {
|
} else {
|
||||||
// value doesn't exist, use the ord between the previous and the next term
|
// value doesn't exist, use the ord between the previous and the next term
|
||||||
ord = ((-2 - docOrd) << 2) + 2;
|
ord = ((-2 - docOrd) << 2) + 2;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
assert (ord & 1) == 0;
|
assert (ord & 1) == 0;
|
||||||
return ord;
|
return ord;
|
||||||
}
|
}
|
||||||
|
@ -296,12 +301,8 @@ public final class BytesRefOrdValComparator extends NestedWrappableComparator<By
|
||||||
public FieldComparator<BytesRef> setNextReader(AtomicReaderContext context) throws IOException {
|
public FieldComparator<BytesRef> setNextReader(AtomicReaderContext context) throws IOException {
|
||||||
termsIndex = indexFieldData.load(context).getBytesValues(false);
|
termsIndex = indexFieldData.load(context).getBytesValues(false);
|
||||||
assert termsIndex.ordinals() != null;
|
assert termsIndex.ordinals() != null;
|
||||||
if (missingValue == null) {
|
|
||||||
missingOrd = Ordinals.MISSING_ORDINAL;
|
|
||||||
} else {
|
|
||||||
missingOrd = ordInCurrentReader(termsIndex, missingValue);
|
missingOrd = ordInCurrentReader(termsIndex, missingValue);
|
||||||
assert consistentInsertedOrd(termsIndex, missingOrd, missingValue);
|
assert consistentInsertedOrd(termsIndex, missingOrd, missingValue);
|
||||||
}
|
|
||||||
FieldComparator<BytesRef> perSegComp = null;
|
FieldComparator<BytesRef> perSegComp = null;
|
||||||
assert termsIndex.ordinals() != null;
|
assert termsIndex.ordinals() != null;
|
||||||
if (termsIndex.isMultiValued()) {
|
if (termsIndex.isMultiValued()) {
|
||||||
|
@ -332,14 +333,12 @@ public final class BytesRefOrdValComparator extends NestedWrappableComparator<By
|
||||||
bottomSlot = bottom;
|
bottomSlot = bottom;
|
||||||
final BytesRef bottomValue = values[bottomSlot];
|
final BytesRef bottomValue = values[bottomSlot];
|
||||||
|
|
||||||
if (bottomValue == null) {
|
if (currentReaderGen == readerGen[bottomSlot]) {
|
||||||
bottomOrd = Ordinals.MISSING_ORDINAL;
|
|
||||||
} else if (currentReaderGen == readerGen[bottomSlot]) {
|
|
||||||
bottomOrd = ords[bottomSlot];
|
bottomOrd = ords[bottomSlot];
|
||||||
} else {
|
} else {
|
||||||
// insert an ord
|
// insert an ord
|
||||||
bottomOrd = ordInCurrentReader(termsIndex, bottomValue);
|
bottomOrd = ordInCurrentReader(termsIndex, bottomValue);
|
||||||
if (bottomOrd == missingOrd) {
|
if (bottomOrd == missingOrd && bottomValue != null) {
|
||||||
// bottomValue and missingValue and in-between the same field data values -> tie-break
|
// bottomValue and missingValue and in-between the same field data values -> tie-break
|
||||||
// this is why we multiply ords by 4
|
// this is why we multiply ords by 4
|
||||||
assert missingValue != null;
|
assert missingValue != null;
|
||||||
|
|
Loading…
Reference in New Issue