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 7AA8E200B83 for ; Sat, 6 Aug 2016 04:52:26 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 79860160A8E; Sat, 6 Aug 2016 02:52:26 +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 A867F160AB8 for ; Sat, 6 Aug 2016 04:52:25 +0200 (CEST) Received: (qmail 50414 invoked by uid 500); 6 Aug 2016 02:52:24 -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 50316 invoked by uid 99); 6 Aug 2016 02:52:24 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 06 Aug 2016 02:52:24 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 70AE7C034D for ; Sat, 6 Aug 2016 02:52:24 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-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 mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id vjMkQBfe4zXi for ; Sat, 6 Aug 2016 02:52:23 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with SMTP id 6154D60E3B for ; Sat, 6 Aug 2016 02:52:21 +0000 (UTC) Received: (qmail 49184 invoked by uid 99); 6 Aug 2016 02:52:20 -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; Sat, 06 Aug 2016 02:52:20 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id ECAF9EEE20; Sat, 6 Aug 2016 02:52:19 +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: Sat, 06 Aug 2016 02:52:31 -0000 Message-Id: In-Reply-To: <59600a8fc24049c3aca7dc78a08bd648@git.apache.org> References: <59600a8fc24049c3aca7dc78a08bd648@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [13/51] [abbrv] incubator-beam git commit: Port WindowedWordCount example from OldDoFn to DoFn archived-at: Sat, 06 Aug 2016 02:52:26 -0000 Port WindowedWordCount example from OldDoFn to DoFn Project: http://git-wip-us.apache.org/repos/asf/incubator-beam/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-beam/commit/ca9e3372 Tree: http://git-wip-us.apache.org/repos/asf/incubator-beam/tree/ca9e3372 Diff: http://git-wip-us.apache.org/repos/asf/incubator-beam/diff/ca9e3372 Branch: refs/heads/python-sdk Commit: ca9e337203208c7c5876f0710fb3a45430a5b3a8 Parents: 4ceec0e Author: Kenneth Knowles Authored: Fri Jul 22 14:29:01 2016 -0700 Committer: Dan Halperin Committed: Wed Aug 3 18:25:53 2016 -0700 ---------------------------------------------------------------------- .../org/apache/beam/examples/WindowedWordCount.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/ca9e3372/examples/java/src/main/java/org/apache/beam/examples/WindowedWordCount.java ---------------------------------------------------------------------- diff --git a/examples/java/src/main/java/org/apache/beam/examples/WindowedWordCount.java b/examples/java/src/main/java/org/apache/beam/examples/WindowedWordCount.java index 17f7da3..842cb54 100644 --- a/examples/java/src/main/java/org/apache/beam/examples/WindowedWordCount.java +++ b/examples/java/src/main/java/org/apache/beam/examples/WindowedWordCount.java @@ -27,7 +27,7 @@ import org.apache.beam.sdk.io.gcp.bigquery.BigQueryIO; import org.apache.beam.sdk.options.Default; import org.apache.beam.sdk.options.Description; import org.apache.beam.sdk.options.PipelineOptionsFactory; -import org.apache.beam.sdk.transforms.OldDoFn; +import org.apache.beam.sdk.transforms.DoFn; import org.apache.beam.sdk.transforms.ParDo; import org.apache.beam.sdk.transforms.windowing.FixedWindows; import org.apache.beam.sdk.transforms.windowing.Window; @@ -103,14 +103,14 @@ public class WindowedWordCount { static final int WINDOW_SIZE = 1; // Default window duration in minutes /** - * Concept #2: A OldDoFn that sets the data element timestamp. This is a silly method, just for + * Concept #2: A DoFn that sets the data element timestamp. This is a silly method, just for * this example, for the bounded data case. * *

Imagine that many ghosts of Shakespeare are all typing madly at the same time to recreate * his masterworks. Each line of the corpus will get a random associated timestamp somewhere in a * 2-hour period. */ - static class AddTimestampFn extends OldDoFn { + static class AddTimestampFn extends DoFn { private static final Duration RAND_RANGE = Duration.standardHours(2); private final Instant minTimestamp; @@ -118,7 +118,7 @@ public class WindowedWordCount { this.minTimestamp = new Instant(System.currentTimeMillis()); } - @Override + @ProcessElement public void processElement(ProcessContext c) { // Generate a timestamp that falls somewhere in the past two hours. long randMillis = (long) (Math.random() * RAND_RANGE.getMillis()); @@ -130,9 +130,9 @@ public class WindowedWordCount { } } - /** A OldDoFn that converts a Word and Count into a BigQuery table row. */ - static class FormatAsTableRowFn extends OldDoFn, TableRow> { - @Override + /** A DoFn that converts a Word and Count into a BigQuery table row. */ + static class FormatAsTableRowFn extends DoFn, TableRow> { + @ProcessElement public void processElement(ProcessContext c) { TableRow row = new TableRow() .set("word", c.element().getKey())