msokolov commented on a change in pull request #618:
URL: https://github.com/apache/lucene/pull/618#discussion_r790152858
##########
File path: lucene/core/src/java/org/apache/lucene/search/KnnVectorQuery.java
##########
@@ -70,9 +96,9 @@ public Query rewrite(IndexReader reader) throws IOException {
return createRewrittenQuery(reader, topK);
}
- private TopDocs searchLeaf(LeafReaderContext ctx, int kPerLeaf) throws
IOException {
+ private TopDocs searchLeaf(LeafReaderContext ctx, int kPerLeaf, Bits
bitsFilter) throws IOException {
Bits liveDocs = ctx.reader().getLiveDocs();
Review comment:
In some cases there's > 0 cost to `getLiveDocs` -- we could skip it here
in case it's not needed.
##########
File path: lucene/core/src/java/org/apache/lucene/search/KnnVectorQuery.java
##########
@@ -56,11 +59,34 @@ public KnnVectorQuery(String field, float[] target, int k) {
}
}
+ /**
+ * Find the <code>k</code> nearest documents to the target vector according
to the vectors in the
+ * given field. <code>target</code> vector.
+ *
+ * @param field a field that has been indexed as a {@link KnnVectorField}.
+ * @param target the target of the search
+ * @param k the number of documents to find
+ * @param filter a filter applied before the vector search
Review comment:
Wording nit: maybe "applied to the vector search"? Only because it's
really computed before, applied during...
##########
File path: lucene/core/src/java/org/apache/lucene/search/KnnVectorQuery.java
##########
@@ -84,6 +110,33 @@ private TopDocs searchLeaf(LeafReaderContext ctx, int
kPerLeaf) throws IOExcepti
return results;
}
+ private static class BitSetCollector extends SimpleCollector {
+
+ private final BitSet[] bitSets;
+ private BitSet leafBits;
+ private int docBase;
+
+ private BitSetCollector(BitSet[] bitSets) {
+ this.bitSets = bitSets;
+ }
+
+ @Override
+ public void collect(int doc) throws IOException {
+ leafBits.set(doc);
+ }
+
+ @Override
+ protected void doSetNextReader(LeafReaderContext context) throws
IOException {
+ this.leafBits = new FixedBitSet(context.reader().maxDoc());
Review comment:
We might want to be able to make a sparse bitset in case we have a
highly selective Query? But nothing here precludes that, and anyway it's
probably not needed if we decide to fall back to full KNN in that case, so +1
for simplicity.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]