Skip to content

Commit

Permalink
linear iteration of bitset
Browse files Browse the repository at this point in the history
  • Loading branch information
shatejas committed Jun 26, 2024
1 parent 150c589 commit 508bc3c
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/main/java/org/opensearch/knn/index/query/KNNWeight.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,19 +143,20 @@ public Scorer scorer(LeafReaderContext context) throws IOException {
}

private BitSet getFilteredDocsBitSet(final LeafReaderContext ctx) throws IOException {
if (this.filterWeight == null) {
return new FixedBitSet(0);
}

final Bits liveDocs = ctx.reader().getLiveDocs();
final int maxDoc = ctx.reader().maxDoc();

final Scorer scorer = filterWeight.scorer(ctx);
if (scorer == null) {
Scorer scorer = null;
if (filterWeight != null) {
scorer = filterWeight.scorer(ctx);
}

if (liveDocs == null && scorer == null) {
return new FixedBitSet(0);
}

return createBitSet(scorer.iterator(), liveDocs, maxDoc);
final DocIdSetIterator docIdSetIterator = scorer != null ? scorer.iterator() : DocIdSetIterator.all(maxDoc);
return createBitSet(docIdSetIterator, liveDocs, maxDoc);
}

private BitSet createBitSet(final DocIdSetIterator filteredDocIdsIterator, final Bits liveDocs, int maxDoc) throws IOException {
Expand Down

0 comments on commit 508bc3c

Please sign in to comment.