You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by sz...@apache.org on 2009/03/27 20:49:07 UTC

svn commit: r759319 - in /hadoop/core/branches/branch-0.20: CHANGES.txt src/core/org/apache/hadoop/fs/FileSystem.java

Author: szetszwo
Date: Fri Mar 27 19:49:07 2009
New Revision: 759319

URL: http://svn.apache.org/viewvc?rev=759319&view=rev
Log:
HADOOP-5588. Remove an unnecessary call to listStatus(..) in FileSystem.globStatusInternal(..).  (Hairong Kuang via szetszwo)

Modified:
    hadoop/core/branches/branch-0.20/CHANGES.txt
    hadoop/core/branches/branch-0.20/src/core/org/apache/hadoop/fs/FileSystem.java

Modified: hadoop/core/branches/branch-0.20/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.20/CHANGES.txt?rev=759319&r1=759318&r2=759319&view=diff
==============================================================================
--- hadoop/core/branches/branch-0.20/CHANGES.txt (original)
+++ hadoop/core/branches/branch-0.20/CHANGES.txt Fri Mar 27 19:49:07 2009
@@ -814,6 +814,9 @@
     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

Modified: hadoop/core/branches/branch-0.20/src/core/org/apache/hadoop/fs/FileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.20/src/core/org/apache/hadoop/fs/FileSystem.java?rev=759319&r1=759318&r2=759319&view=diff
==============================================================================
--- hadoop/core/branches/branch-0.20/src/core/org/apache/hadoop/fs/FileSystem.java (original)
+++ hadoop/core/branches/branch-0.20/src/core/org/apache/hadoop/fs/FileSystem.java Fri Mar 27 19:49:07 2009
@@ -894,9 +894,23 @@
     } 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()]));
       }
     }