blerer commented on code in PR #3095:
URL: https://github.com/apache/cassandra/pull/3095#discussion_r1567398438


##########
src/java/org/apache/cassandra/cql3/Relation.java:
##########
@@ -125,119 +105,28 @@ public final boolean isSlice()
      * @return the <code>Restriction</code> corresponding to this 
<code>Relation</code>
      * @throws InvalidRequestException if this <code>Relation</code> is not 
valid
      */
-    public final Restriction toRestriction(TableMetadata table, 
VariableSpecifications boundNames)
+    public SingleRestriction toRestriction(TableMetadata table, 
VariableSpecifications boundNames)
     {
-        switch (operator)
-        {
-            case EQ: return newEQRestriction(table, boundNames);
-            case LT: return newSliceRestriction(table, boundNames, Bound.END, 
false);
-            case LTE: return newSliceRestriction(table, boundNames, Bound.END, 
true);
-            case GTE: return newSliceRestriction(table, boundNames, 
Bound.START, true);
-            case GT: return newSliceRestriction(table, boundNames, 
Bound.START, false);
-            case IN: return newINRestriction(table, boundNames);
-            case CONTAINS: return newContainsRestriction(table, boundNames, 
false);
-            case CONTAINS_KEY: return newContainsRestriction(table, 
boundNames, true);
-            case IS_NOT: return newIsNotRestriction(table, boundNames);
-            case LIKE_PREFIX:
-            case LIKE_SUFFIX:
-            case LIKE_CONTAINS:
-            case LIKE_MATCHES:
-            case LIKE:
-                return newLikeRestriction(table, boundNames, operator);
-            case ANN:
-                throw invalidRequest("ANN is only supported in ORDER BY");
-            default: throw invalidRequest("Unsupported \"!=\" relation: %s", 
this);
-        }
-    }
-
-    /**
-     * Creates a new EQ restriction instance.
-     *
-     * @param table the table meta data
-     * @param boundNames the variables specification where to collect the bind 
variables
-     * @return a new EQ restriction instance.
-     * @throws InvalidRequestException if the relation cannot be converted 
into an EQ restriction.
-     */
-    protected abstract Restriction newEQRestriction(TableMetadata table, 
VariableSpecifications boundNames);
+        if (operator == Operator.NEQ)
+            throw invalidRequest("Unsupported '!=' relation: %s", this);
 
-    /**
-     * Creates a new IN restriction instance.
-     *
-     * @param table the table meta data
-     * @param boundNames the variables specification where to collect the bind 
variables
-     * @return a new IN restriction instance
-     * @throws InvalidRequestException if the relation cannot be converted 
into an IN restriction.
-     */
-    protected abstract Restriction newINRestriction(TableMetadata table, 
VariableSpecifications boundNames);
+        ColumnsExpression expression = rawExpressions.prepare(table);
+        expression.collectMarkerSpecification(boundNames);
 
-    /**
-     * Creates a new Slice restriction instance.
-     *
-     * @param table the table meta data
-     * @param boundNames the variables specification where to collect the bind 
variables
-     * @param bound the slice bound
-     * @param inclusive <code>true</code> if the bound is included.
-     * @return a new slice restriction instance
-     * @throws InvalidRequestException if the <code>Relation</code> is not 
valid
-     */
-    protected abstract Restriction newSliceRestriction(TableMetadata table,
-                                                       VariableSpecifications 
boundNames,
-                                                       Bound bound,
-                                                       boolean inclusive);
-
-    /**
-     * Creates a new Contains restriction instance.
-     *
-     * @param table the table meta data
-     * @param boundNames the variables specification where to collect the bind 
variables
-     * @param isKey <code>true</code> if the restriction to create is a 
CONTAINS KEY
-     * @return a new Contains <code>Restriction</code> instance
-     * @throws InvalidRequestException if the <code>Relation</code> is not 
valid
-     */
-    protected abstract Restriction newContainsRestriction(TableMetadata table, 
VariableSpecifications boundNames, boolean isKey);

Review Comment:
   Those logics where required by the old Relation implementation but were in 
fact not needed as they are enforced by the parser.



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