odraese commented on a change in pull request #690: HIVE-21910: Multiple target 
location generation in HostAffinitySplitLocationProvider
URL: https://github.com/apache/hive/pull/690#discussion_r298302912
 
 

 ##########
 File path: 
ql/src/java/org/apache/hadoop/hive/ql/exec/tez/HostAffinitySplitLocationProvider.java
 ##########
 @@ -72,11 +78,17 @@ public HostAffinitySplitLocationProvider(List<String> 
knownLocations) {
     FileSplit fsplit = (FileSplit) split;
     String splitDesc = "Split at " + fsplit.getPath() + " with offset= " + 
fsplit.getStart()
         + ", length=" + fsplit.getLength();
-    List<String> preferredLocations = preferLocations(fsplit);
-    String location =
-        preferredLocations.get(determineLocation(preferredLocations, 
fsplit.getPath().toString(),
-            fsplit.getStart(), splitDesc));
-    return (location != null) ? new String[] { location } : null;
+    List<String> preferredLocations = new ArrayList<>(preferLocations(fsplit));
+    List<String> finalLocations = new ArrayList<>(numberOfLocations);
+    // Generate new preferred locations until we need more, or we do not have 
any preferred
+    // location left
+    while (finalLocations.size() < numberOfLocations && 
preferredLocations.size() > 0) {
+      String nextLocation = 
preferredLocations.get(determineLocation(preferredLocations,
+          fsplit.getPath().toString(), fsplit.getStart(), splitDesc));
+      finalLocations.add(nextLocation);
+      preferredLocations.remove(nextLocation);
 
 Review comment:
   Instead of having an own array list, from which we remove 1 for each split 
(which is quite often), we could simply pass down numberOfLocations (and 
decrement it) to determineLocation and change
   
   `int index = Hashing.consistentHash(hash1, locations.size());`
   to
   `int index = Hashing.consistentHash(hash1, numLocations);`
   
   in determineLocations. Seems to be more efficient.

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


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to