kangkaisen commented on a change in pull request #5104:
URL: https://github.com/apache/incubator-doris/pull/5104#discussion_r549550083



##########
File path: fe/fe-core/src/main/java/org/apache/doris/qe/Coordinator.java
##########
@@ -1276,10 +1276,22 @@ private void computeScanRangeAssignmentByColocate(
     }
 
     // randomly choose a backend from the TScanRangeLocations for a certain 
bucket sequence.
-    private void getExecHostPortForFragmentIDAndBucketSeq(TScanRangeLocations 
seqLocation, PlanFragmentId fragmentId, Integer bucketSeq) throws Exception {
-        int randomLocation = new 
Random().nextInt(seqLocation.locations.size());
+    private void getExecHostPortForFragmentIDAndBucketSeq(TScanRangeLocations 
seqLocation, PlanFragmentId fragmentId, Integer bucketSeq,
+                                                          
HashMap<TNetworkAddress, Long> assignedBytesPerHost) throws Exception {
+        Long minAssignedBytes = Long.MAX_VALUE;

Review comment:
       These codes are also used in `computeScanRangeAssignmentByScheduler`, 
would better abstract these codes to a method
   ```
               Long minAssignedBytes = Long.MAX_VALUE;
               TScanRangeLocation minLocation = null;
               for (final TScanRangeLocation location : 
scanRangeLocations.getLocations()) {
                   Long assignedBytes = findOrInsert(assignedBytesPerHost, 
location.server, 0L);
                   if (assignedBytes < minAssignedBytes) {
                       minAssignedBytes = assignedBytes;
                       minLocation = location;
                   }
               }
   ```




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

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