Return-Path: X-Original-To: apmail-crunch-commits-archive@www.apache.org Delivered-To: apmail-crunch-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 734FE11243 for ; Mon, 2 Jun 2014 03:42:21 +0000 (UTC) Received: (qmail 20159 invoked by uid 500); 2 Jun 2014 03:42:21 -0000 Delivered-To: apmail-crunch-commits-archive@crunch.apache.org Received: (qmail 20116 invoked by uid 500); 2 Jun 2014 03:42:21 -0000 Mailing-List: contact commits-help@crunch.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@crunch.apache.org Delivered-To: mailing list commits@crunch.apache.org Received: (qmail 20109 invoked by uid 99); 2 Jun 2014 03:42:21 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 Jun 2014 03:42:21 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 08FF388527D; Mon, 2 Jun 2014 03:42:21 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jwills@apache.org To: commits@crunch.apache.org Message-Id: <99dcf2ac11134c2bac3ede1823ad39c4@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: git commit: CRUNCH-408: Fix the HFileSource globStatus check to work on Hadoop2 Date: Mon, 2 Jun 2014 03:42:21 +0000 (UTC) Repository: crunch Updated Branches: refs/heads/master f2dee62db -> fcb1aa415 CRUNCH-408: Fix the HFileSource globStatus check to work on Hadoop2 Project: http://git-wip-us.apache.org/repos/asf/crunch/repo Commit: http://git-wip-us.apache.org/repos/asf/crunch/commit/fcb1aa41 Tree: http://git-wip-us.apache.org/repos/asf/crunch/tree/fcb1aa41 Diff: http://git-wip-us.apache.org/repos/asf/crunch/diff/fcb1aa41 Branch: refs/heads/master Commit: fcb1aa4158f90001c114daa90d68ce99fd8870e4 Parents: f2dee62 Author: Josh Wills Authored: Sun Jun 1 20:41:01 2014 -0700 Committer: Josh Wills Committed: Sun Jun 1 20:41:01 2014 -0700 ---------------------------------------------------------------------- .../org/apache/crunch/io/hbase/HFileSource.java | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/crunch/blob/fcb1aa41/crunch-hbase/src/main/java/org/apache/crunch/io/hbase/HFileSource.java ---------------------------------------------------------------------- diff --git a/crunch-hbase/src/main/java/org/apache/crunch/io/hbase/HFileSource.java b/crunch-hbase/src/main/java/org/apache/crunch/io/hbase/HFileSource.java index c21cc47..47abe9a 100644 --- a/crunch-hbase/src/main/java/org/apache/crunch/io/hbase/HFileSource.java +++ b/crunch-hbase/src/main/java/org/apache/crunch/io/hbase/HFileSource.java @@ -120,10 +120,28 @@ public class HFileSource extends FileSourceImpl implements ReadableSou long sum = 0; for (Path path : getPaths()) { try { - sum += SourceTargetHelper.getPathSize(conf, new Path(path, "*")); + sum += getSizeInternal(conf, path); } catch (IOException e) { LOG.warn("Failed to estimate size of " + path); } + System.out.println("Size after read of path = " + path.toString() + " = " + sum); + } + return sum; + } + + private long getSizeInternal(Configuration conf, Path path) throws IOException { + FileSystem fs = path.getFileSystem(conf); + FileStatus[] statuses = fs.globStatus(path, HFileInputFormat.HIDDEN_FILE_FILTER); + if (statuses == null) { + return 0; + } + long sum = 0; + for (FileStatus status : statuses) { + if (status.isDir()) { + sum += SourceTargetHelper.getPathSize(fs, status.getPath()); + } else { + sum += status.getLen(); + } } return sum; }