maedhroz commented on code in PR #2935:
URL: https://github.com/apache/cassandra/pull/2935#discussion_r1442396190
##########
src/java/org/apache/cassandra/index/sai/plan/FilterTree.java:
##########
@@ -96,22 +100,56 @@ private boolean localSatisfiedBy(DecoratedKey key,
Unfiltered unfiltered, Row st
if (filter.getIndexTermType().isNonFrozenCollection())
{
Iterator<ByteBuffer> valueIterator =
filter.getIndexTermType().valuesOf(row, now);
- result = op.apply(result, collectionMatch(valueIterator,
filter));
+ result = localOperator.apply(result,
collectionMatch(valueIterator, filter));
}
else
{
ByteBuffer value = filter.getIndexTermType().valueOf(key,
row, now);
- result = op.apply(result, singletonMatch(value, filter));
+ result = localOperator.apply(result, singletonMatch(value,
filter));
}
// If the operation is an AND then exit early if we get a
single false
- if (op == BooleanOperator.AND && !result)
+ if (localOperator == BooleanOperator.AND && !result)
return false;
+
+ // If the operation is an OR then exit early if we get a
single true
+ if (localOperator == BooleanOperator.OR && result)
+ return true;
}
}
return result;
}
+ private BooleanOperator getLocalOperator(Row regularRow, Row staticRow)
+ {
+ // This is an AND query, but the coordinator has indicated strict
filtering might not be allowed...
+ if (baseOperator == BooleanOperator.AND && !strict)
+ {
+ Long lastTimestamp = null;
+ Iterator<ColumnMetadata> columns = expressions.keySet().iterator();
+
+ while (columns.hasNext())
+ {
+ ColumnMetadata column = columns.next();
+ Row row = column.kind == Kind.STATIC ? staticRow : regularRow;
+ ColumnData data = row.getColumnData(column);
+
+ if (data == null)
+ // Degrade to non-strict filtering if we're missing a
value for a filtered column, as it could be
+ // partially updated on another replica.
+ return BooleanOperator.OR;
+
+ if (lastTimestamp == null)
+ lastTimestamp = data.maxTimestamp();
+ else if (lastTimestamp != data.maxTimestamp())
Review Comment:
The only question I threw around during development here was whether this is
really safe for collections/complex types. (Max timestamp is the only timestamp
for simple cells, so that's simpler.) I couldn't work through an example where
the max timestamp is the same as the other column's timestamps and there is
still a problematic partial update possibility, but perhaps I've just not been
sufficiently creative...
--
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]