You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@uniffle.apache.org by "kaijchen (via GitHub)" <gi...@apache.org> on 2023/02/13 06:15:14 UTC

[GitHub] [incubator-uniffle] kaijchen commented on a diff in pull request #594: [MINOR] refactor: simplify ShuffleWriteClientImpl#genServerToBlocks()

kaijchen commented on code in PR #594:
URL: https://github.com/apache/incubator-uniffle/pull/594#discussion_r1104034931


##########
client/src/main/java/org/apache/uniffle/client/impl/ShuffleWriteClientImpl.java:
##########
@@ -210,53 +213,36 @@ void genServerToBlocks(
       ShuffleBlockInfo sbi,
       List<ShuffleServerInfo> serverList,
       int replicaNum,
-      List<ShuffleServerInfo> excludeServers,
+      Collection<ShuffleServerInfo> excludeServers,
       Map<ShuffleServerInfo, Map<Integer, Map<Integer, List<ShuffleBlockInfo>>>> serverToBlocks,
       Map<ShuffleServerInfo, List<Long>> serverToBlockIds,
       boolean excludeDefectiveServers) {
     if (replicaNum <= 0) {
       return;
     }
-    int partitionId = sbi.getPartitionId();
-    int shuffleId = sbi.getShuffleId();
-    int assignedNum = 0;
-    for (ShuffleServerInfo ssi : serverList) {
-      if (excludeDefectiveServers && replica > 1 && defectiveServers.contains(ssi)) {
-        continue;
-      }
-      if (CollectionUtils.isNotEmpty(excludeServers) && excludeServers.contains(ssi)) {
-        continue;
-      }
-      if (!serverToBlockIds.containsKey(ssi)) {
-        serverToBlockIds.put(ssi, Lists.newArrayList());
-      }
-      serverToBlockIds.get(ssi).add(sbi.getBlockId());
-
-      if (!serverToBlocks.containsKey(ssi)) {
-        serverToBlocks.put(ssi, Maps.newHashMap());
-      }
-      Map<Integer, Map<Integer, List<ShuffleBlockInfo>>> shuffleIdToBlocks = serverToBlocks.get(ssi);
-      if (!shuffleIdToBlocks.containsKey(shuffleId)) {
-        shuffleIdToBlocks.put(shuffleId, Maps.newHashMap());
-      }
 
-      Map<Integer, List<ShuffleBlockInfo>> partitionToBlocks = shuffleIdToBlocks.get(shuffleId);
-      if (!partitionToBlocks.containsKey(partitionId)) {
-        partitionToBlocks.put(partitionId, Lists.newArrayList());
-      }
-      partitionToBlocks.get(partitionId).add(sbi);
-      if (excludeServers != null) {
-        excludeServers.add(ssi);
-      }
-      assignedNum++;
-      if (assignedNum >= replicaNum) {
-        break;
-      }
+    Stream<ShuffleServerInfo> servers;
+    if (replica > 1 && excludeDefectiveServers) {

Review Comment:
   How about `excludeDefectiveServers && defectiveServers != null && !defectiveServers.isEmpty()`?
   
   Use `defectiveServers != null` instead of `replica > 1` to be consistent with following statements:
   
   https://github.com/apache/incubator-uniffle/blob/master/client/src/main/java/org/apache/uniffle/client/impl/ShuffleWriteClientImpl.java#L138-L140
   
   https://github.com/apache/incubator-uniffle/blob/master/client/src/main/java/org/apache/uniffle/client/impl/ShuffleWriteClientImpl.java#L178-L191



-- 
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: issues-unsubscribe@uniffle.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org