浏览代码

HADOOP-5588. Remove an unnecessary call to listStatus(..) in FileSystem.globStatusInternal(..). (Hairong Kuang via szetszwo)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/branches/branch-0.20@759319 13f79535-47bb-0310-9956-ffa450edef68
Tsz-wo Sze 16 年之前
父节点
当前提交
2a6128cb60
共有 2 个文件被更改,包括 18 次插入1 次删除
  1. 3 0
      CHANGES.txt
  2. 15 1
      src/core/org/apache/hadoop/fs/FileSystem.java

+ 3 - 0
CHANGES.txt

@@ -814,6 +814,9 @@ Release 0.20.0 - Unreleased
     HADOOP-5571. Remove widening primitive conversion in TupleWritable mask
     manipulation. (Jingkei Ly via cdouglas)
 
+    HADOOP-5588. Remove an unnecessary call to listStatus(..) in
+    FileSystem.globStatusInternal(..).  (Hairong Kuang via szetszwo)
+
 Release 0.19.2 - Unreleased
 
   BUG FIXES

+ 15 - 1
src/core/org/apache/hadoop/fs/FileSystem.java

@@ -894,9 +894,23 @@ public abstract class FileSystem extends Configured implements Closeable {
     } else {
       // Now work on the last component of the path
       GlobFilter fp = new GlobFilter(components[components.length - 1], filter);
-      results = listStatus(parentPaths, fp);
       if (fp.hasPattern()) { // last component has a pattern
+        // list parent directories and then glob the results
+        results = listStatus(parentPaths, fp);
         hasGlob[0] = true;
+      } else { // last component does not have a pattern
+        // get all the path names
+        ArrayList<Path> filteredPaths = new ArrayList<Path>(parentPaths.length);
+        for (int i = 0; i < parentPaths.length; i++) {
+          parentPaths[i] = new Path(parentPaths[i],
+            components[components.length - 1]);
+          if (fp.accept(parentPaths[i])) {
+            filteredPaths.add(parentPaths[i]);
+          }
+        }
+        // get all their statuses
+        results = getFileStatus(
+            filteredPaths.toArray(new Path[filteredPaths.size()]));
       }
     }