adelapena commented on code in PR #2655:
URL: https://github.com/apache/cassandra/pull/2655#discussion_r1313227591
##########
src/java/org/apache/cassandra/cql3/Terms.java:
##########
@@ -47,225 +47,510 @@ public Object get(int index)
@Override
public int size()
{
- return 0;
+ throw new UnsupportedOperationException();
+ }
+ };
+
+ Terminals UNSET_TERMINALS = new Terminals()
+ {
+ @Override
+ public List<ByteBuffer> get()
+ {
+ return (List<ByteBuffer>) UNSET_LIST;
+ }
+
+ @Override
+ public List<List<ByteBuffer>> getElements()
+ {
+ return (List<List<ByteBuffer>>) UNSET_LIST;
+ }
+
+ @Override
+ public List<Terminal> asList()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void addFunctionsTo(List<Function> functions)
+ {
+
+ }
+
+ @Override
+ public boolean containsSingleTerm()
+ {
+ return false;
+ }
+
+ @Override
+ public Term asSingleTerm()
+ {
+ throw new UnsupportedOperationException();
}
};
/**
* Adds all functions (native and user-defined) used by any of the terms
to the specified list.
* @param functions the list to add to
*/
- public void addFunctionsTo(List<Function> functions);
+ void addFunctionsTo(List<Function> functions);
/**
* Collects the column specifications for the bind variables in the terms.
- * This is obviously a no-op if the terms are Terminal.
+ * This is obviously a no-op if the terms are Terminals.
*
* @param boundNames the variables specification where to collect the
* bind variables of the terms in.
*/
- public void collectMarkerSpecification(VariableSpecifications boundNames);
+ void collectMarkerSpecification(VariableSpecifications boundNames);
/**
* Bind the values in these terms to the values contained in {@code
options}.
- * This is obviously a no-op if the term is Terminal.
+ * This is obviously a no-op if this {@code Terms} are Terminals.
*
- * @param options the values to bind markers to.
- * @return the result of binding all the variables of these NonTerminals
or an {@code UNSET_LIST} if the term
- * was unset.
+ * @param options the query options containing the values to bind markers
to.
+ * @return the result of binding all the variables of these NonTerminals.
+ */
+ Terminals bind(QueryOptions options);
+
+ /**
+ * A shorter for {@code bind(options).get()}.
+ * We expose it mainly because for constants it can avoid allocating a
temporary
+ * object between the bind and the get.
+ * @param options the query options containing the values to bind markers
to.
+ */
+ List<ByteBuffer> bindAndGet(QueryOptions options);
+
+ /**
+ * A shorter for {@code bind(options).getElements()}.
+ * We expose it mainly because for constants it can avoid allocating a
temporary
+ * object between the {@code bind} and the {@code getElements}.
+ * @param options the query options containing the values to bind markers
to.
*/
- public List<Terminal> bind(QueryOptions options);
+ List<List<ByteBuffer>> bindAndGetElements(QueryOptions options);
+ /**
+ * Whether those terms are terminal (this is a shortcut for {@code this
instanceof Terms.Terminals}).
+ */
+ default boolean areTerminals()
+ {
+ return false; // overriden below by Terminals
+ }
Review Comment:
Was it the intention to use it in `Terms#of(List<Term>)`, instead of the
stream?
--
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]