mirror of https://github.com/apache/lucene.git
LUCENE-7528: Fix Lucene54's advanceExact impl in the sparse case.
This commit is contained in:
parent
325b74e0e3
commit
66c90a9683
|
@ -715,7 +715,7 @@ final class Lucene54DocValuesProducer extends DocValuesProducer implements Close
|
|||
}
|
||||
--index;
|
||||
doc = target;
|
||||
return false;
|
||||
return index >= 0 && docIds.get(index) == target;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -488,6 +488,33 @@ public class TestLucene54DocValuesFormat extends BaseCompressingDocValuesFormatT
|
|||
}
|
||||
}
|
||||
|
||||
// advanceExact
|
||||
for (int i = 0; i < 2000; ++i) {
|
||||
sparseValues.reset();
|
||||
if (random().nextBoolean() && docIds.length > 0) {
|
||||
sparseValues.advance(docIds[TestUtil.nextInt(random(), 0, docIds.length - 1)]);
|
||||
}
|
||||
|
||||
final int target = TestUtil.nextInt(random(), Math.max(0, sparseValues.docID()), maxDoc - 1);
|
||||
final boolean exists = sparseValues.advanceExact(target);
|
||||
|
||||
final int index = Arrays.binarySearch(docIds, target);
|
||||
assertEquals(index >= 0, exists);
|
||||
assertEquals(target, sparseValues.docID());
|
||||
|
||||
final boolean exists2 = sparseValues.advanceExact(target);
|
||||
assertEquals(index >= 0, exists2);
|
||||
assertEquals(target, sparseValues.docID());
|
||||
|
||||
final int nextIndex = index >= 0 ? index + 1 : -1 - index;
|
||||
if (nextIndex >= docIds.length) {
|
||||
assertEquals(DocIdSetIterator.NO_MORE_DOCS, sparseValues.nextDoc());
|
||||
} else {
|
||||
assertEquals(docIds[nextIndex], sparseValues.nextDoc());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
final SparseNumericDocValuesRandomAccessWrapper raWrapper = new SparseNumericDocValuesRandomAccessWrapper(sparseValues, missingValue);
|
||||
|
||||
// random-access
|
||||
|
|
Loading…
Reference in New Issue