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


##########
src/java/org/apache/cassandra/cql3/InMarker.java:
##########
@@ -0,0 +1,178 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.cassandra.cql3;
+
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.cassandra.cql3.functions.Function;
+import org.apache.cassandra.db.marshal.AbstractType;
+import org.apache.cassandra.db.marshal.ByteBufferAccessor;
+import org.apache.cassandra.db.marshal.CollectionType;
+import org.apache.cassandra.db.marshal.ListType;
+import org.apache.cassandra.db.marshal.MapType;
+import org.apache.cassandra.db.marshal.SetType;
+import org.apache.cassandra.db.marshal.UserType;
+import org.apache.cassandra.db.marshal.TupleType;
+import org.apache.cassandra.exceptions.InvalidRequestException;
+import org.apache.cassandra.utils.ByteBufferUtil;
+
+public class InMarker extends Terms.NonTerminals
+{
+    private final int bindIndex;
+    private final ColumnSpecification receiver;
+
+    protected InMarker(int bindIndex, ColumnSpecification receiver)
+    {
+        this.bindIndex = bindIndex;
+        this.receiver = receiver;
+    }
+
+    @Override
+    public void addFunctionsTo(List<Function> functions) {}
+
+    @Override
+    public void collectMarkerSpecification(VariableSpecifications boundNames)
+    {
+        boundNames.add(bindIndex, receiver);
+    }
+
+    @Override
+    public Terminals bind(QueryOptions options)
+    {
+        ByteBuffer values = options.getValues().get(bindIndex);
+        if (values == null)
+            return null;
+
+        if (values == ByteBufferUtil.UNSET_BYTE_BUFFER)
+            return UNSET_TERMINALS;
+
+        ListType<?> type = (ListType) receiver.type;
+        return toTerminals(values, type, 
terminalConverter(type.getElementsType()));
+    }
+
+    private <T> Terminals toTerminals(ByteBuffer value,
+                                      ListType<T> type,
+                                      java.util.function.Function<ByteBuffer, 
Term.Terminal> terminalConverter)
+    {
+        List<T> l = type.getSerializer().deserialize(value, 
ByteBufferAccessor.instance);
+        List<Term.Terminal> terminals = new ArrayList<>(l.size());
+        for (T element : l)
+        {
+            terminals.add(element == null ? null : 
terminalConverter.apply(type.getElementsType().decompose(element)));
+        }
+        return Terminals.of(terminals);
+    }
+
+    public static java.util.function.Function<ByteBuffer, Term.Terminal> 
terminalConverter(AbstractType<?> type)
+    {
+        if (type.isCollection())
+        {
+            switch (((CollectionType<?>) type).kind)
+            {
+                case LIST:
+                    return e -> Lists.Value.fromSerialized(e, (ListType<?>) 
type);
+                case SET:
+                    return e -> Sets.Value.fromSerialized(e, (SetType<?>) 
type);
+                case MAP:
+                    return e -> Maps.Value.fromSerialized(e, (MapType<?, ?>) 
type);
+            }
+            throw new AssertionError();
+        }
+
+        if (type.isUDT())
+            return e -> UserTypes.Value.fromSerialized(e, (UserType) type);
+
+        if (type.isTuple())
+            return e -> Tuples.Value.fromSerialized(e, (TupleType) type);
+
+        return Constants.Value::new;

Review Comment:
   The vector type is now a `MultiElements` type



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