Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 73348200B6F for ; Wed, 24 Aug 2016 22:25:51 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 71C41160AB1; Wed, 24 Aug 2016 20:25:51 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id B85B3160A91 for ; Wed, 24 Aug 2016 22:25:50 +0200 (CEST) Received: (qmail 25314 invoked by uid 500); 24 Aug 2016 20:25:49 -0000 Mailing-List: contact common-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list common-commits@hadoop.apache.org Received: (qmail 25305 invoked by uid 99); 24 Aug 2016 20:25:49 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 24 Aug 2016 20:25:49 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 85F04E024E; Wed, 24 Aug 2016 20:25:49 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: kihwal@apache.org To: common-commits@hadoop.apache.org Message-Id: <931d3bae07844e8587e54f6b217788f5@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: hadoop git commit: HDFS-10772. Reduce byte/string conversions for get listing. Contributed by Daryn Sharp. Date: Wed, 24 Aug 2016 20:25:49 +0000 (UTC) archived-at: Wed, 24 Aug 2016 20:25:51 -0000 Repository: hadoop Updated Branches: refs/heads/branch-2 e31745e28 -> ba3257baf HDFS-10772. Reduce byte/string conversions for get listing. Contributed by Daryn Sharp. (cherry picked from commit a1f3293762dddb0ca953d1145f5b53d9086b25b8) Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/ba3257ba Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/ba3257ba Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/ba3257ba Branch: refs/heads/branch-2 Commit: ba3257baf59cfd0e4d6f84c5b264b47c425f99e7 Parents: e31745e Author: Kihwal Lee Authored: Wed Aug 24 15:25:33 2016 -0500 Committer: Kihwal Lee Committed: Wed Aug 24 15:25:33 2016 -0500 ---------------------------------------------------------------------- .../server/namenode/FSDirStatAndListingOp.java | 26 +++++++++++--------- 1 file changed, 15 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/ba3257ba/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirStatAndListingOp.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirStatAndListingOp.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirStatAndListingOp.java index 9b0e5f7..7761f06 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirStatAndListingOp.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirStatAndListingOp.java @@ -23,6 +23,7 @@ import org.apache.hadoop.fs.ContentSummary; import org.apache.hadoop.fs.DirectoryListingStartAfterNotFoundException; import org.apache.hadoop.fs.FileEncryptionInfo; import org.apache.hadoop.fs.InvalidPathException; +import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.permission.FsAction; import org.apache.hadoop.fs.permission.FsPermission; import org.apache.hadoop.fs.QuotaUsage; @@ -50,7 +51,6 @@ import static org.apache.hadoop.util.Time.now; class FSDirStatAndListingOp { static DirectoryListing getListingInt(FSDirectory fsd, final String srcArg, byte[] startAfter, boolean needLocation) throws IOException { - final String startAfterString = DFSUtil.bytes2String(startAfter); String src = null; final INodesInPath iip; @@ -63,16 +63,20 @@ class FSDirStatAndListingOp { iip = fsd.getINodesInPath(src, true); } - // Get file name when startAfter is an INodePath - if (FSDirectory.isReservedName(startAfterString)) { - try { - String tmp = FSDirectory.resolvePath(startAfterString, fsd); - byte[][] regularPath = INode.getPathComponents(tmp); - startAfter = regularPath[regularPath.length - 1]; - } catch (IOException e) { - // Possibly the inode is deleted - throw new DirectoryListingStartAfterNotFoundException( - "Can't find startAfter " + startAfterString); + // Get file name when startAfter is an INodePath. This is not the + // common case so avoid any unnecessary processing unless required. + if (startAfter.length > 0 && startAfter[0] == Path.SEPARATOR_CHAR) { + final String startAfterString = DFSUtil.bytes2String(startAfter); + if (FSDirectory.isReservedName(startAfterString)) { + try { + byte[][] components = INode.getPathComponents(startAfterString); + components = FSDirectory.resolveComponents(components, fsd); + startAfter = components[components.length - 1]; + } catch (IOException e) { + // Possibly the inode is deleted + throw new DirectoryListingStartAfterNotFoundException( + "Can't find startAfter " + startAfterString); + } } } --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org For additional commands, e-mail: common-commits-help@hadoop.apache.org