michaeljmarshall commented on code in PR #4353:
URL: https://github.com/apache/cassandra/pull/4353#discussion_r2699549172
##########
src/java/org/apache/cassandra/index/sai/disk/v1/segment/VectorIndexSegmentSearcher.java:
##########
@@ -208,29 +236,72 @@ private SparseFixedBitSet bitSetForSearch()
return bits;
}
+ /**
+ * Produces a correct ranking of the rows in the given segment. Because
this graph does not have compressed
+ * vectors, read all vectors and put them into a priority queue to rank
them lazily. It is assumed that the whole
+ * PQ will often not be needed.
+ */
+ private CloseableIterator<RowIdWithScore> orderByBruteForce(float[]
queryVector, SegmentRowIdOrdinalPairs segmentOrdinalPairs, int limit, int topK)
throws IOException
+ {
+ if (segmentOrdinalPairs.size() == 0)
+ return CloseableIterator.empty();
+
+ // TODO add heuristic to determine if we should use one pass even
though we have PQ
+ if (graph.getCompressedVectors() != null)
+ return orderByBruteForceTwoPass(graph.getCompressedVectors(),
queryVector, segmentOrdinalPairs, limit, topK);
Review Comment:
I added a test to the `VectorSiftSmallTest` to make sure we do.
##########
src/java/org/apache/cassandra/index/sai/plan/Operation.java:
##########
@@ -319,16 +320,23 @@ private static int getPriority(Operator op)
*/
static KeyRangeIterator buildIterator(QueryController controller)
{
- List<RowFilter.Expression> orderings =
controller.indexFilter().getExpressions()
- .stream().filter(e ->
e.operator() == Operator.ANN).collect(Collectors.toList());
- assert orderings.size() <= 1;
- if (controller.indexFilter().getExpressions().size() == 1 &&
orderings.size() == 1)
+ return
Node.buildTree(controller.indexFilter()).analyzeTree(controller).rangeIterator(controller);
+ }
+
+ /**
+ * Converts expressions into filter tree for query.
+ *
+ * @return a KeyRangeIterator over the index query results
+ */
+ static CloseableIterator<PrimaryKeyWithScore>
buildIteratorForOrder(QueryController controller,
QueryViewBuilder.QueryExpressionView view)
+ {
+ if (controller.indexFilter().getExpressions().size() == 1)
// If we only have one expression, we just use the ANN index to
order and limit.
- return controller.getTopKRows(orderings.get(0));
+ return controller.getTopKRows(view);
+
+ // Otherwise, we need to search first, then order.
KeyRangeIterator iterator =
Node.buildTree(controller.indexFilter()).analyzeTree(controller).rangeIterator(controller);
Review Comment:
done.
--
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]