You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by "ekaterinadimitrova2 (via GitHub)" <gi...@apache.org> on 2023/09/18 14:19:15 UTC

[GitHub] [cassandra] ekaterinadimitrova2 commented on a diff in pull request #2655: CASSANDRA-18813: Simplify the bind marker and Term logic

ekaterinadimitrova2 commented on code in PR #2655:
URL: https://github.com/apache/cassandra/pull/2655#discussion_r1328804322


##########
src/java/org/apache/cassandra/cql3/Term.java:
##########
@@ -188,35 +208,55 @@ public boolean isTerminal()
         /**
          * @return the serialized value of this terminal.
          */
-        public abstract ByteBuffer get(ProtocolVersion version) throws InvalidRequestException;
+        public abstract ByteBuffer get();
 
-        public ByteBuffer bindAndGet(QueryOptions options) throws InvalidRequestException
+        /**
+         * Returns the serialized values of this Term elements, if this term represents a Collection, Tuple or UDT.
+         * If this term does not represent a multi-elements type it will return a list containing the serialized value of this terminal
+         * @return a list containing serialized values of this Term elements
+         */
+        public List<ByteBuffer> getElements()
         {
-            return get(options.getProtocolVersion());
+            ByteBuffer value = get();
+            return value == null ? Collections.emptyList() : Collections.singletonList(value);
         }
-    }
 
-    public abstract class MultiItemTerminal extends Terminal
-    {
-        public abstract List<ByteBuffer> getElements();
+        public ByteBuffer bindAndGet(QueryOptions options)
+        {
+            return get();
+        }
+
+        public List<ByteBuffer> bindAndGetElements(QueryOptions options)
+        {
+            return getElements();
+        }
     }
 
     /**
-     * A non terminal term, i.e. a term that can only be reduce to a byte buffer
+     * A non-terminal term, i.e. a term that can only be reduced to a byte buffer
      * at execution time.
-     *
+     * <p>
      * We have the following type of NonTerminal:
-     *   - marker for a constant value
-     *   - marker for a collection value (list, set, map)
-     *   - a function having bind marker
-     *   - a non pure function (even if it doesn't have bind marker - see #5616)
+     * <ul>
+     *   <li>marker for a constant value</li>
+     *   <li>marker for a collection value (list, set, map)</li>
+     *   <li>a function having bind marker</li>
+     *   <li>a non-pure function (even if it doesn't have bind marker - see #5616)</li>
+     * </ul>
      */
-    public abstract class NonTerminal implements Term
+    abstract class NonTerminal implements Term
     {
         public ByteBuffer bindAndGet(QueryOptions options) throws InvalidRequestException
         {
             Terminal t = bind(options);
-            return t == null ? null : t.get(options.getProtocolVersion());
+            return t == null ? null : t.get();

Review Comment:
   We miss other methods @Override, too; how about we fix that for all of them in a separate commit/ticket?



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