Return-Path: Delivered-To: apmail-hadoop-core-commits-archive@www.apache.org Received: (qmail 3265 invoked from network); 5 Dec 2008 01:15:41 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 5 Dec 2008 01:15:41 -0000 Received: (qmail 10332 invoked by uid 500); 5 Dec 2008 01:15:52 -0000 Delivered-To: apmail-hadoop-core-commits-archive@hadoop.apache.org Received: (qmail 10296 invoked by uid 500); 5 Dec 2008 01:15:52 -0000 Mailing-List: contact core-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: core-dev@hadoop.apache.org Delivered-To: mailing list core-commits@hadoop.apache.org Received: (qmail 10287 invoked by uid 99); 5 Dec 2008 01:15:52 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 04 Dec 2008 17:15:52 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Dec 2008 01:14:31 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id DD5522388878; Thu, 4 Dec 2008 17:15:19 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: core-commits@hadoop.apache.org From: cdouglas@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20081205011519.DD5522388878@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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; isrc * 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; }