You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by GitBox <gi...@apache.org> on 2022/03/10 11:13:37 UTC

[GitHub] [cassandra] Ankou76ers commented on a change in pull request #1380: CASSANDRA-10537: CONTAINS and CONTAINS KEY support for Lightweight Transactions

Ankou76ers commented on a change in pull request #1380:
URL: https://github.com/apache/cassandra/pull/1380#discussion_r823610171



##########
File path: src/java/org/apache/cassandra/cql3/conditions/ColumnCondition.java
##########
@@ -531,6 +534,25 @@ private static boolean setOrListAppliesTo(AbstractType<?> type, Iterator<Cell<?>
             return operator == Operator.EQ || operator == Operator.LTE || operator == Operator.GTE;
         }
 
+        private static boolean valueAppliesTo(Iterator<Cell<?>> iter, ByteBuffer value, boolean appliesToSetOrMapKeys)
+        {
+            while(iter.hasNext())
+            {
+                // for lists and map values we use the cell value; for sets and map keys we use the cell name
+                ByteBuffer cellValue = appliesToSetOrMapKeys ? iter.next().path().get(0) : iter.next().buffer();
+                int comparison = BytesType.instance.compare(cellValue, value);

Review comment:
       If we fallback on `evaluateComparisonWithOperator()` when a comparison is `!=0` we will return **false** for the condition and it can be wrong (other item of the collection can satisfied the contains condition).
   
   Exemple =>  evaluation of the `l CONTAINS 'bar'` condition against the collection `l = ['foo', 'bar', 'foobar']`
   
   The comparison 'foo' vs 'bar' will be `!= 0` but the condition still applies to the collection. We have to perform a second comparison 'bar' vs 'bar' `==0` to return the final status of the condition (**true**).
   




-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org