PrachiKhobragade commented on code in PR #8550:
URL: https://github.com/apache/pinot/pull/8550#discussion_r854420378


##########
pinot-broker/src/main/java/org/apache/pinot/broker/routing/instanceselector/ReplicaGroupInstanceSelector.java:
##########
@@ -49,15 +50,26 @@ public ReplicaGroupInstanceSelector(String 
tableNameWithType, BrokerMetrics brok
 
   @Override
   Map<String, String> select(List<String> segments, int requestId,
-      Map<String, List<String>> segmentToEnabledInstancesMap) {
+      Map<String, List<String>> segmentToEnabledInstancesMap, Map<String, 
String> queryOptions) {
     Map<String, String> segmentToSelectedInstanceMap = new 
HashMap<>(HashUtil.getHashMapCapacity(segments.size()));
+    // validate queryOptions to get query
+    String replicaGroup = 
queryOptions.get(CommonConstants.Broker.Request.QueryOptionKey.NUM_REPLICA_GROUPS);
+    int replicaGroupNum = 1;
+    int currentRequest = 0;
+    if (replicaGroup != null) {
+      replicaGroupNum = Integer.parseInt(replicaGroup);
+    }
     for (String segment : segments) {
       List<String> enabledInstances = 
segmentToEnabledInstancesMap.get(segment);
       // NOTE: enabledInstances can be null when there is no enabled instances 
for the segment, or the instance selector
       // has not been updated (we update all components for routing in 
sequence)
       if (enabledInstances != null) {
         int numEnabledInstances = enabledInstances.size();
-        segmentToSelectedInstanceMap.put(segment, 
enabledInstances.get(requestId % numEnabledInstances));
+        int instanceToSelect = (requestId + currentRequest++) % 
numEnabledInstances;

Review Comment:
   added



-- 
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: commits-unsubscr...@pinot.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to