maedhroz commented on code in PR #2645:
URL: https://github.com/apache/cassandra/pull/2645#discussion_r1312302176
##########
src/java/org/apache/cassandra/index/sai/plan/QueryController.java:
##########
@@ -215,7 +216,12 @@ private ClusteringIndexFilter makeFilter(PrimaryKey key)
{
ClusteringIndexFilter clusteringIndexFilter =
command.clusteringIndexFilter(key.partitionKey());
- if (key.hasEmptyClustering())
+ assert cfs.metadata().comparator.size() == 0 &&
!key.kind().isClustering ||
+ cfs.metadata().comparator.size() > 0 && key.kind().isClustering
:
+ "PrimaryKey " + key + " clustering does not match table. There
should be a clustering of size " + cfs.metadata().comparator.size();
+
+ // TODO How do we avoid iterating the whole partition for static rows?
Review Comment:
I've been looking at `StorageAttachedIndexSearcher#applyIndexFilter()`, and
one thing I notice is that, when a static row is present, and we only have
index expressions against it, we could avoid post-filtering on every row in the
partition, even if we have to return every row in the partition. In other
words, `QueryWriteLifecycleTest` passes if you rewrite `applyIndexFilter()`
like this:
```
private static UnfilteredRowIterator applyIndexFilter(UnfilteredRowIterator
partition, FilterTree tree, QueryContext queryContext)
{
Row staticRow = partition.staticRow();
queryContext.rowsFiltered++;
if (tree.isSatisfiedBy(partition.partitionKey(), staticRow, staticRow))
return partition;
List<Unfiltered> clusters = new ArrayList<>();
while (partition.hasNext())
{
Unfiltered row = partition.next();
queryContext.rowsFiltered++;
if (tree.isSatisfiedBy(partition.partitionKey(), row, staticRow))
clusters.add(row);
}
if (clusters.isEmpty())
return null;
return new PartitionIterator(partition, staticRow,
Iterators.filter(clusters.iterator(), u -> !((Row)u).isStatic()));
}
```
(Note that I've left out the comments in the method, which may need some
tweaking.)
Maybe there's some other problem w/ this I'm not seeing, but it does short
circuit a lot of work if we're just querying static columns?
--
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]