hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cdoug...@apache.org
Subject svn commit: r723548 - in /hadoop/core/trunk: CHANGES.txt src/core/org/apache/hadoop/fs/FsShell.java
Date Fri, 05 Dec 2008 01:15:19 GMT
Author: cdouglas
Date: Thu Dec  4 17:15:19 2008
New Revision: 723548

URL: http://svn.apache.org/viewvc?rev=723548&view=rev
Log:
HADOOP-4747. Speed up FsShell::ls by removing redundant calls to the
filesystem. Contributed by David Phillips.

Modified:
    hadoop/core/trunk/CHANGES.txt
    hadoop/core/trunk/src/core/org/apache/hadoop/fs/FsShell.java

Modified: hadoop/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/CHANGES.txt?rev=723548&r1=723547&r2=723548&view=diff
==============================================================================
--- hadoop/core/trunk/CHANGES.txt (original)
+++ hadoop/core/trunk/CHANGES.txt Thu Dec  4 17:15:19 2008
@@ -168,11 +168,14 @@
     via cdouglas)
 
     HADOOP-4690.  fuse-dfs - create source file/function + utils + config +
-main source files. (pete wyckoff via mahadev)
+    main source files. (pete wyckoff via mahadev)
 
     HADOOP-3750. Fix and enforce module dependencies. (Sharad Agarwal via
     tomwhite)
 
+    HADOOP-4747. Speed up FsShell::ls by removing redundant calls to the
+    filesystem. (David Phillips via cdouglas)
+
   OPTIMIZATIONS
 
     HADOOP-3293. Fixes FileInputFormat to do provide locations for splits

Modified: hadoop/core/trunk/src/core/org/apache/hadoop/fs/FsShell.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/core/org/apache/hadoop/fs/FsShell.java?rev=723548&r1=723547&r2=723548&view=diff
==============================================================================
--- hadoop/core/trunk/src/core/org/apache/hadoop/fs/FsShell.java (original)
+++ hadoop/core/trunk/src/core/org/apache/hadoop/fs/FsShell.java Thu Dec  4 17:15:19 2008
@@ -573,7 +573,7 @@
     boolean printHeader = (srcs.length == 1) ? true: false;
     int numOfErrors = 0;
     for(int i=0; i<srcs.length; i++) {
-      numOfErrors += ls(srcs[i].getPath(), srcFs, recursive, printHeader);
+      numOfErrors += ls(srcs[i], srcFs, recursive, printHeader);
     }
     return numOfErrors == 0 ? 0 : -1;
   }
@@ -581,7 +581,7 @@
   /* list all files under the directory <i>src</i>
    * ideally we should provide "-l" option, that lists like "ls -l".
    */
-  private int ls(Path src, FileSystem srcFs, boolean recursive,
+  private int ls(FileStatus src, FileSystem srcFs, boolean recursive,
       boolean printHeader) throws IOException {
     final String cmd = recursive? "lsr": "ls";
     final FileStatus[] items = shellListStatus(cmd, srcFs, src);
@@ -627,7 +627,7 @@
         System.out.print(mdate + " ");
         System.out.println(cur.toUri().getPath());
         if (recursive && stat.isDir()) {
-          numOfErrors += ls(cur,srcFs, recursive, printHeader);
+          numOfErrors += ls(stat,srcFs, recursive, printHeader);
         }
       }
       return numOfErrors;
@@ -1136,7 +1136,12 @@
   /** helper returns listStatus() */
   private static FileStatus[] shellListStatus(String cmd, 
                                                    FileSystem srcFs,
-                                                   Path path) {
+                                                   FileStatus src) {
+    if (!src.isDir()) {
+      FileStatus[] files = { src };
+      return files;
+    }
+    Path path = src.getPath();
     try {
       FileStatus[] files = srcFs.listStatus(path);
       if ( files == null ) {
@@ -1163,8 +1168,7 @@
     int errors = 0;
     handler.run(stat, srcFs);
     if (recursive && stat.isDir() && handler.okToContinue()) {
-      FileStatus[] files = shellListStatus(handler.getName(), srcFs, 
-                                                stat.getPath());
+      FileStatus[] files = shellListStatus(handler.getName(), srcFs, stat);
       if (files == null) {
         return 1;
       }



Mime
View raw message