jasonstack commented on code in PR #3649:
URL: https://github.com/apache/cassandra/pull/3649#discussion_r1832222320
##########
src/java/org/apache/cassandra/index/sai/plan/StorageAttachedIndexSearcher.java:
##########
@@ -412,15 +433,15 @@ private UnfilteredRowIterator applyIndexFilter(PrimaryKey
key, UnfilteredRowIter
{
queryContext.rowsFiltered++;
- if (tree.isSatisfiedBy(key.partitionKey(), staticRow,
staticRow))
+ if (tree.isSatisfiedBy(partition.partitionKey(), staticRow,
staticRow))
hasMatch = true;
}
if (!hasMatch)
{
// shadowed by expired TTL or row tombstone or range tombstone
if (topK)
- queryContext.vectorContext().recordShadowedPrimaryKey(key);
+
queryContext.vectorContext().recordShadowedPrimaryKey(keys);
Review Comment:
```
private UnfilteredRowIterator applyIndexFilter(List<PrimaryKey>
keys, UnfilteredRowIterator partition, FilterTree tree)
{
Row staticRow = partition.staticRow();
List<Unfiltered> matchingRows = new ArrayList<>();
boolean hasMatch = false;
Set<PrimaryKey> keysToShadow = new HashSet<>(keys);
// We need to filter the partition rows before filtering on the
static row. If this is done in the other
// order then we get incorrect results if we are filtering on a
partition key index on a table with a
// composite partition key.
while (partition.hasNext())
{
Unfiltered unfiltered = partition.next();
if (unfiltered.isRow())
{
queryContext.rowsFiltered++;
if (tree.isSatisfiedBy(partition.partitionKey(), (Row)
unfiltered, staticRow))
{
matchingRows.add(unfiltered);
hasMatch = true;
PrimaryKey key =
keyFactory.create(partition.partitionKey(), ((Row) unfiltered).clustering());
keysToShadow.remove(key);
}
}
}
if (!hasMatch)
{
queryContext.rowsFiltered++;
if (tree.isSatisfiedBy(partition.partitionKey(), staticRow,
staticRow))
{
hasMatch = true;
keysToShadow.clear();
}
}
// shadowed by expired TTL or row tombstone or range tombstone
if (topK)
queryContext.vectorContext().recordShadowedPrimaryKey(keysToShadow);
if (!hasMatch)
{
// If there are no matches, return an empty partition. If
reconciliation is required at the
// coordinator, replica filtering protection may make a
second round trip to complete its view
// of the partition.
return null;
}
// Return all matches found, along with the static row...
return new PartitionIterator(partition, staticRow,
matchingRows.iterator());
}
```
this might work.. but we need some tests...
--
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]