ygerzhedovich commented on code in PR #1501:
URL: https://github.com/apache/ignite-3/pull/1501#discussion_r1088100237
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/metadata/ColocationGroup.java:
##########
@@ -230,29 +266,40 @@ public ColocationGroup mapToNodes(List<String> nodeNames)
{
@NotNull
private ColocationGroup forNodes0(List<String> nodeNames) {
- List<List<String>> assignments = new
ArrayList<>(SYNTHETIC_PARTITIONS_COUNT);
- for (int i = 0; i < SYNTHETIC_PARTITIONS_COUNT; i++) {
- assignments.add(asList(nodeNames.get(i % nodeNames.size())));
- }
return new ColocationGroup(sourceIds, nodeNames, assignments);
}
/**
* Returns List of partitions to scan on the given node.
*
- * @param nodeNames Cluster node consistent ID.
+ * @param nodeName Cluster node consistent ID.
* @return List of partitions to scan on the given node.
*/
- public int[] partitions(String nodeNames) {
+ public int[] partitions(String nodeName) {
IgniteIntList parts = new IgniteIntList(assignments.size());
- for (int i = 0; i < assignments.size(); i++) {
- List<String> assignment = assignments.get(i);
- if (Objects.equals(nodeNames, first(assignment))) {
- parts.add(i);
+ for (int p = 0; p < assignments.size(); p++) {
+ List<NodeWithTerm> assignment = assignments.get(p);
+
+ NodeWithTerm nodeWithTerm = first(assignment);
+
+ assert nodeWithTerm != null : "part=" + p;
+
+ if (Objects.equals(nodeName, nodeWithTerm.name())) {
+ parts.add(p);
}
}
return parts.array();
}
+
+ /**
+ * Returns a raft group leader term.
+ *
+ * @param partId Partition ID.
+ * @return Raft group leader term.
+ */
+ public long partitionLeaderTerm(int partId) {
+ return first(assignments.get(partId)).term();
Review Comment:
the `first` method could return null. In case you don't expect it then don't
use it :)
--
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]