diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 1a2b32f8c9..0aa39d9be4 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -1720,6 +1720,9 @@ Release 2.7.3 - UNRELEASED OPTIMIZATIONS + HADOOP-12810. FileSystem#listLocatedStatus causes unnecessary RPC calls + (Ryan Blue via vinayakumarb) + BUG FIXES HADOOP-12296. when setnetgrent returns 0 in linux, exception should be diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java index 920c5a6a8b..f4a2e7d060 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java @@ -1749,8 +1749,10 @@ public LocatedFileStatus next() throws IOException { throw new NoSuchElementException("No more entries 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); }