xtern commented on code in PR #6613:
URL: https://github.com/apache/ignite-3/pull/6613#discussion_r2372200066


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/mapping/MappingServiceImpl.java:
##########
@@ -452,6 +507,69 @@ public int hashCode() {
         }
     }
 
+    /** Returns a predicate that returns {@code true} for nodes which should 
be excluded from mapping. */ 
+    private static Predicate<String> composeNodeExclusionFilter(
+            TopologySnapshot topologySnapshot, MappingParameters parameters
+    ) {
+        Predicate<String> filterFromParameters = 
parameters.nodeExclusionFilter();
+        Predicate<String> deadNodesFilter = node -> 
!topologySnapshot.nodes.contains(node);
+
+        if (filterFromParameters == null) {
+            return deadNodesFilter;
+        }
+
+        return filterFromParameters.or(deadNodesFilter);
+    }
+
+    /**
+     * Holder for topology snapshots that guarantees monotonically increasing 
versions.
+     */
+    class LogicalTopologyHolder {
+        private volatile TopologySnapshot topology = new 
TopologySnapshot(Long.MIN_VALUE, List.of());
+
+        void update(LogicalTopologySnapshot topologySnapshot) {
+            synchronized (this) {
+                if (topology.version() < topologySnapshot.version()) {
+                    topology = new 
TopologySnapshot(topologySnapshot.version(), deriveNodeNames(topologySnapshot));
+                }
+
+                if (initialTopologyFuture.isDone() || 
!topology.nodes().contains(localNodeName)) {
+                    return;
+                }
+            }
+
+            initialTopologyFuture.complete(null);
+        }
+
+        TopologySnapshot topology() {
+            return topology;
+        }
+
+        private List<String> deriveNodeNames(LogicalTopologySnapshot topology) 
{

Review Comment:
   Can we collect nodes directly into `Set` (and avoid copying in 
`TopologySnapshot` constructor)?



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