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


##########
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:
   Maybe you want to collect the result in a variable and return at the end. 
That might help on branch prediction by avoiding early returns, although iirc 
most modern cpus are already optimized on that front.



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