Jelajahi Sumber

HADOOP-12810. FileSystem#listLocatedStatus causes unnecessary RPC calls (Contributed by Ryan Blue)

(cherry picked from commit 96ea3094315bb1e1a5e268e3817c7fdedc3e9462)
(cherry picked from commit 2bf5a005fab287689a148c1928f3b04c0a8dcedf)
(cherry picked from commit a9c1bb42418dbde8958dbbc115f6045e696ea2ea)
Vinayakumar B 9 tahun lalu
induk
melakukan
a5424e2a10

+ 3 - 0
hadoop-common-project/hadoop-common/CHANGES.txt

@@ -22,6 +22,9 @@ Release 2.6.5 - UNRELEASED
 
   OPTIMIZATIONS
 
+    HADOOP-12810. FileSystem#listLocatedStatus causes unnecessary RPC calls
+    (Ryan Blue via vinayakumarb)
+
   BUG FIXES
 
     HADOOP-12773. HBase classes fail to load with client/job classloader

+ 3 - 1
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java

@@ -1693,8 +1693,10 @@ public abstract class FileSystem extends Configured implements Closeable {
           throw new NoSuchElementException("No more entry in " + f);
         }
         FileStatus result = stats[i++];
+        // for files, use getBlockLocations(FileStatus, int, int) to avoid
+        // calling getFileStatus(Path) to load the FileStatus again
         BlockLocation[] locs = result.isFile() ?
-            getFileBlockLocations(result.getPath(), 0, result.getLen()) :
+            getFileBlockLocations(result, 0, result.getLen()) :
             null;
         return new LocatedFileStatus(result, locs);
       }