yashmayya commented on code in PR #17215:
URL: https://github.com/apache/pinot/pull/17215#discussion_r2695371134


##########
pinot-broker/src/main/java/org/apache/pinot/broker/routing/instanceselector/BaseInstanceSelector.java:
##########
@@ -245,6 +247,32 @@ static SortedMap<String, String> 
convertToSortedMap(Map<String, String> map) {
     }
   }
 
+  /// Returns a map from server instance to replica group ID, generated from 
the ideal state instance partitions
+  /// metadata.
+  static Map<String, Integer> serverToReplicaGroupMap(IdealState idealState) {
+    Map<String, Integer> serverToReplicaGroupMap = new HashMap<>();
+
+    for (Map.Entry<String, List<String>> listFields : 
idealState.getRecord().getListFields().entrySet()) {
+      String key = listFields.getKey();
+      // key looks like "INSTANCE_PARTITIONS__myTable_CONSUMING__0_0"
+      if (key.startsWith(InstancePartitionsUtils.IDEAL_STATE_IP_PREFIX)) {
+        String[] parts = 
key.split(InstancePartitionsUtils.IDEAL_STATE_IP_SEPARATOR);

Review Comment:
   This is only called once per instance partition type.
   
   > We can read from right hand side and directly extract the replica group id
   
   Do you mean manual string parsing and integer conversion? That feels quite 
hackish 😅 



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