AMashenkov commented on code in PR #2455:
URL: https://github.com/apache/ignite-3/pull/2455#discussion_r1300029773


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/trait/Identity.java:
##########
@@ -0,0 +1,61 @@
+/*
+ * 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.ignite.internal.sql.engine.trait;
+
+import java.util.List;
+import org.apache.ignite.internal.sql.engine.exec.RowHandler;
+
+/**
+ * Destination, which uses a column raw value as a target.
+ */
+public class Identity<RowT> implements Destination<RowT> {
+    private final RowHandler<RowT> rowHandler;
+    private final List<String> nodes;
+    private final int columnIndex;
+
+    /**
+     * Constructor.
+     *
+     * @param rowHandler Row handler.
+     * @param columnIndex Column index in a row, which used for affinity 
calculation.
+     * @param nodes Names of nodes, which are valid destinations.
+     */
+    public Identity(RowHandler<RowT> rowHandler, int columnIndex, List<String> 
nodes) {
+        this.rowHandler = rowHandler;
+        this.columnIndex = columnIndex;
+        this.nodes = nodes;
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public List<String> targets(RowT row) {
+        String node = (String) rowHandler.get(columnIndex, row);
+
+        if (nodes.contains(node)) {
+            return List.of(node);
+        }
+
+        return List.of();

Review Comment:
   >second, you are calling nodes.contains on a List for every row.
   Agree. We have to fix the Destination interface, as Outbox do the same (call 
`nodes.contains`) and Partitioned destination return a List.



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

Reply via email to