LUCENE-8420: Fix soft-deletes optimization.

This commit is contained in:
Adrien Grand 2018-07-27 11:08:19 +02:00
parent 914e264165
commit 5f539442a9
2 changed files with 2 additions and 19 deletions

View File

@ -109,7 +109,7 @@ public final class SoftDeletesDirectoryReaderWrapper extends FilterDirectoryRead
Bits liveDocs = reader.getLiveDocs();
final FixedBitSet bits;
if (liveDocs != null) {
bits = SoftDeletesRetentionMergePolicy.cloneLiveDocs(liveDocs);
bits = FixedBitSet.copyOf(liveDocs);
} else {
bits = new FixedBitSet(reader.maxDoc());
bits.set(0, reader.maxDoc());

View File

@ -105,7 +105,7 @@ public final class SoftDeletesRetentionMergePolicy extends OneMergeWrappingMerge
builder.add(retentionQuery, BooleanClause.Occur.FILTER);
Scorer scorer = getScorer(builder.build(), wrappedReader);
if (scorer != null) {
FixedBitSet cloneLiveDocs = cloneLiveDocs(liveDocs);
FixedBitSet cloneLiveDocs = FixedBitSet.copyOf(liveDocs);
DocIdSetIterator iterator = scorer.iterator();
int numExtraLiveDocs = 0;
while (iterator.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
@ -121,23 +121,6 @@ public final class SoftDeletesRetentionMergePolicy extends OneMergeWrappingMerge
}
}
/**
* Clones the given live docs
*/
static FixedBitSet cloneLiveDocs(Bits liveDocs) {
if (liveDocs instanceof FixedBitSet) {
return ((FixedBitSet) liveDocs).clone();
} else { // mainly if we have asserting codec
FixedBitSet mutableBits = new FixedBitSet(liveDocs.length());
for (int i = 0; i < liveDocs.length(); i++) {
if (liveDocs.get(i)) {
mutableBits.set(i);
}
}
return mutableBits;
}
}
private static Scorer getScorer(Query query, CodecReader reader) throws IOException {
IndexSearcher s = new IndexSearcher(reader);
s.setQueryCache(null);