Skip to content

speed up numDeletesToMerge of SoftDeletesRetentionMergePolicy #14531

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -161,20 +161,25 @@ public int numDeletesToMerge(
BooleanQuery.Builder builder = new BooleanQuery.Builder();
builder.add(new FieldExistsQuery(field), BooleanClause.Occur.FILTER);
builder.add(retentionQuerySupplier.get(), BooleanClause.Occur.FILTER);
Scorer scorer =
getScorer(
builder.build(), FilterCodecReader.wrapLiveDocs(reader, null, reader.maxDoc()));
if (scorer != null) {
DocIdSetIterator iterator = scorer.iterator();
Bits liveDocs = reader.getLiveDocs();
int numDeletedDocs = reader.numDeletedDocs();
while (iterator.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
if (liveDocs.get(iterator.docID()) == false) {
numDeletedDocs--;
}
}
return numDeletedDocs;
}
Bits liveDocs = reader.getLiveDocs();
CodecReader codecReader =
FilterCodecReader.wrapLiveDocs(
reader,
new Bits() {

@Override
public boolean get(int index) {
return liveDocs.get(index) == false;
}

@Override
public int length() {
return liveDocs.length();
}
},
reader.maxDoc());
IndexSearcher searcher = new IndexSearcher(codecReader);
return reader.numDeletedDocs() - searcher.count(builder.build());
}
}
assert numDeletesToMerge >= 0 : "numDeletesToMerge: " + numDeletesToMerge;
Expand Down