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 E107C200B52 for ; Mon, 25 Jul 2016 21:11:49 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id DFBDD160A67; Mon, 25 Jul 2016 19:11:49 +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 33667160A8F for ; Mon, 25 Jul 2016 21:11:49 +0200 (CEST) Received: (qmail 68884 invoked by uid 500); 25 Jul 2016 19:11:48 -0000 Mailing-List: contact commits-help@beam.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@beam.incubator.apache.org Delivered-To: mailing list commits@beam.incubator.apache.org Received: (qmail 68875 invoked by uid 99); 25 Jul 2016 19:11:48 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 25 Jul 2016 19:11:48 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id D1F50187984 for ; Mon, 25 Jul 2016 19:11:47 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -4.646 X-Spam-Level: X-Spam-Status: No, score=-4.646 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-1.426] autolearn=disabled Received: from mx2-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id YEKdr1x3kEFh for ; Mon, 25 Jul 2016 19:11:47 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx2-lw-us.apache.org (ASF Mail Server at mx2-lw-us.apache.org) with SMTP id 4F0A65FB83 for ; Mon, 25 Jul 2016 19:11:45 +0000 (UTC) Received: (qmail 68698 invoked by uid 99); 25 Jul 2016 19:11:45 -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; Mon, 25 Jul 2016 19:11:45 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 4F758E02A2; Mon, 25 Jul 2016 19:11:45 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: kenn@apache.org To: commits@beam.incubator.apache.org Date: Mon, 25 Jul 2016 19:11:47 -0000 Message-Id: <38d6a76aa5c4486c94f98a12ed31af1b@git.apache.org> In-Reply-To: <0c9aacbebfe84693872f193e79a15b88@git.apache.org> References: <0c9aacbebfe84693872f193e79a15b88@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [3/4] incubator-beam git commit: Tidy WriteWithShardingFactory archived-at: Mon, 25 Jul 2016 19:11:50 -0000 Tidy WriteWithShardingFactory Project: http://git-wip-us.apache.org/repos/asf/incubator-beam/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-beam/commit/20244bad Tree: http://git-wip-us.apache.org/repos/asf/incubator-beam/tree/20244bad Diff: http://git-wip-us.apache.org/repos/asf/incubator-beam/diff/20244bad Branch: refs/heads/master Commit: 20244badc3d1b8defd9e5b9a718f54475c502365 Parents: cf14644 Author: Kenneth Knowles Authored: Tue Jul 19 19:16:13 2016 -0700 Committer: Kenneth Knowles Committed: Mon Jul 25 09:30:32 2016 -0700 ---------------------------------------------------------------------- .../apache/beam/runners/direct/WriteWithShardingFactory.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/20244bad/runners/direct-java/src/main/java/org/apache/beam/runners/direct/WriteWithShardingFactory.java ---------------------------------------------------------------------- diff --git a/runners/direct-java/src/main/java/org/apache/beam/runners/direct/WriteWithShardingFactory.java b/runners/direct-java/src/main/java/org/apache/beam/runners/direct/WriteWithShardingFactory.java index 93f2408..d6ee6ea 100644 --- a/runners/direct-java/src/main/java/org/apache/beam/runners/direct/WriteWithShardingFactory.java +++ b/runners/direct-java/src/main/java/org/apache/beam/runners/direct/WriteWithShardingFactory.java @@ -78,7 +78,8 @@ class WriteWithShardingFactory implements PTransformOverrideFactory { Window.into(new GlobalWindows()).triggering(DefaultTrigger.of()) .withAllowedLateness(Duration.ZERO) .discardingFiredPanes()); - final PCollectionView numRecords = records.apply(Count.globally().asSingletonView()); + final PCollectionView numRecords = records + .apply("CountRecords", Count.globally().asSingletonView()); PCollection resharded = records .apply( @@ -107,7 +108,7 @@ class WriteWithShardingFactory implements PTransformOverrideFactory { private final PCollectionView numRecords; private final int randomExtraShards; private int currentShard; - private int maxShards; + private int maxShards = 0; KeyBasedOnCountFn(PCollectionView numRecords, int extraShards) { this.numRecords = numRecords; @@ -116,7 +117,7 @@ class WriteWithShardingFactory implements PTransformOverrideFactory { @Override public void processElement(ProcessContext c) throws Exception { - if (maxShards == 0L) { + if (maxShards == 0) { maxShards = calculateShards(c.sideInput(numRecords)); currentShard = ThreadLocalRandom.current().nextInt(maxShards); }