maedhroz commented on code in PR #2105:
URL: https://github.com/apache/cassandra/pull/2105#discussion_r1087185173


##########
src/java/org/apache/cassandra/cql3/restrictions/StatementRestrictions.java:
##########
@@ -390,6 +390,54 @@ public boolean isColumnRestrictedByEq(ColumnMetadata 
columnDef)
                            .anyMatch(p -> ((SingleRestriction) p).isEQ());
     }
 
+    /**
+     * This method determines whether a specified column is restricted on 
equality or something equivalent, like IN.
+     * It can be used in conjunction with the columns selected by a query to 
determine which of those columns is 
+     * already bound by the client and not necessarily retrieved by the 
database.
+     *
+     * @param column a column from the same table these restrictions are 
against
+     *
+     * @return true if the given column is restricted on equality
+     */
+    public boolean isEqualityRestricted(ColumnMetadata column)
+    {
+        if (column.kind == ColumnMetadata.Kind.PARTITION_KEY)
+        {
+            if (partitionKeyRestrictions.hasOnlyEqualityRestrictions())
+                for (ColumnMetadata restricted : 
partitionKeyRestrictions.getColumnDefinitions())
+                    if (restricted.name.equals(column.name))
+                        return true;
+        }
+        else if (column.kind == ColumnMetadata.Kind.CLUSTERING)
+        {
+            if (hasClusteringColumnsRestrictions())
+            {
+                for (SingleRestriction restriction : 
clusteringColumnsRestrictions.getRestrictionSet())
+                {
+                    if (restriction.isEQ() || restriction.isIN())

Review Comment:
   In the sense that `CONTAINS` and `CONTAINS_KEY` both deal w/ information 
provided by the user, I think it makes sense to include them if we're looking 
at whether or not the metric counts them as "read". I'll throw together a 
couple tests. While I'm at it, something like `isEqualityBased()` on 
`SingleRestriction` to avoid a messy/long if condition here probably also makes 
sense.



-- 
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]

Reply via email to