ygerzhedovich commented on code in PR #1501:
URL: https://github.com/apache/ignite-3/pull/1501#discussion_r1087882834
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/metadata/ColocationGroup.java:
##########
@@ -194,30 +186,73 @@ public ColocationGroup colocate(ColocationGroup other)
throws ColocationMappingE
return new ColocationGroup(sourceIds, nodeNames, assignments);
}
+ private List<NodeWithTerm> intersect(List<NodeWithTerm> assign0,
List<NodeWithTerm> assign1, @Nullable Set<String> filter, int partId)
+ throws ColocationMappingException {
+ List<NodeWithTerm> intersection = new ArrayList<>();
+
+ for (NodeWithTerm nodeWithTerm : assign0) {
+ if (filter != null && !filter.contains(nodeWithTerm.name())) {
+ continue;
+ }
+
+ for (NodeWithTerm otherNodeWithTerm : assign1) {
+ if (!otherNodeWithTerm.name().equals(nodeWithTerm.name())) {
+ continue;
+ }
+
+ if (nodeWithTerm.term() != otherNodeWithTerm.term()) {
+ throw new ColocationMappingException("Raft group primary
replica term has been changed during mapping ["
+ + "part=" + partId
+ + ", leader=" + nodeWithTerm.name()
+ + ", expectedTerm=" + nodeWithTerm.term()
+ + ", actualTerm=" + otherNodeWithTerm.term() +
']');
+ }
+
+ intersection.add(otherNodeWithTerm);
+ }
+ }
+
+ return intersection;
+ }
+
+ private List<NodeWithTerm> filter(List<NodeWithTerm> assignment,
Set<String> filter) {
+ List<NodeWithTerm> res = new ArrayList<>();
+
Review Comment:
let's do check before creating `res`.
Also please pass size for `res`
--
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]