jadami10 commented on code in PR #9803: URL: https://github.com/apache/pinot/pull/9803#discussion_r1036226603
########## pinot-broker/src/main/java/org/apache/pinot/broker/routing/adaptiveserverselector/HybridSelector.java: ########## @@ -85,4 +87,30 @@ public List<Pair<String, Double>> fetchAllServerRankingsWithScores() { return pairList; } + + @Override + public List<Pair<String, Double>> fetchServerRankingsWithScores(List<String> serverCandidates) { + List<Pair<String, Double>> pairList = new ArrayList<>(); + if (serverCandidates.size() == 0) { + return pairList; + } + + for (String server : serverCandidates) { + Double score = _serverRoutingStatsManager.fetchHybridScoreForServer(server); + if (score == null) { + score = -1.0; + } + + pairList.add(new ImmutablePair<>(server, score)); + } + + // Let's shuffle the list before sorting. This helps with randomly choosing different servers if there is a tie. + Collections.shuffle(pairList); Review Comment: nit: this feels unnecessarily expensive if there are a lot of servers. Can it be done by randomly returning 1 or -1 when val==0 in the `.sort` below? -- 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