You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by al...@apache.org on 2017/04/18 16:55:54 UTC
[1/2] beam git commit: Making metrics usage in datastore_wordcount
consistent
Repository: beam
Updated Branches:
refs/heads/master 034bcb4e2 -> 0e11a9368
Making metrics usage in datastore_wordcount consistent
Project: http://git-wip-us.apache.org/repos/asf/beam/repo
Commit: http://git-wip-us.apache.org/repos/asf/beam/commit/f9d3c1ee
Tree: http://git-wip-us.apache.org/repos/asf/beam/tree/f9d3c1ee
Diff: http://git-wip-us.apache.org/repos/asf/beam/diff/f9d3c1ee
Branch: refs/heads/master
Commit: f9d3c1ee0973aaa2f98f0ff8dc211e334f9fc355
Parents: 034bcb4
Author: Pablo <pa...@google.com>
Authored: Tue Apr 18 08:43:12 2017 -0700
Committer: Ahmet Altay <al...@google.com>
Committed: Tue Apr 18 09:55:37 2017 -0700
----------------------------------------------------------------------
.../examples/cookbook/datastore_wordcount.py | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/beam/blob/f9d3c1ee/sdks/python/apache_beam/examples/cookbook/datastore_wordcount.py
----------------------------------------------------------------------
diff --git a/sdks/python/apache_beam/examples/cookbook/datastore_wordcount.py b/sdks/python/apache_beam/examples/cookbook/datastore_wordcount.py
index 9fa10d3..6e7ad76 100644
--- a/sdks/python/apache_beam/examples/cookbook/datastore_wordcount.py
+++ b/sdks/python/apache_beam/examples/cookbook/datastore_wordcount.py
@@ -80,14 +80,15 @@ from apache_beam.utils.pipeline_options import GoogleCloudOptions
from apache_beam.utils.pipeline_options import PipelineOptions
from apache_beam.utils.pipeline_options import SetupOptions
-empty_line_counter = Metrics.counter('main', 'empty_lines')
-word_length_counter = Metrics.counter('main', 'word_lengths')
-word_counter = Metrics.counter('main', 'total_words')
-
class WordExtractingDoFn(beam.DoFn):
"""Parse each line of input text into words."""
+ def __init__(self):
+ self.empty_line_counter = Metrics.counter('main', 'empty_lines')
+ self.word_length_counter = Metrics.counter('main', 'word_lengths')
+ self.word_counter = Metrics.counter('main', 'total_words')
+
def process(self, element):
"""Returns an iterator over words in contents of Cloud Datastore entity.
The element is a line of text. If the line is blank, note that, too.
@@ -102,11 +103,11 @@ class WordExtractingDoFn(beam.DoFn):
text_line = content_value.string_value
if not text_line:
- empty_line_counter.inc()
+ self.empty_line_counter.inc()
words = re.findall(r'[A-Za-z\']+', text_line)
for w in words:
- word_length_counter.inc(len(w))
- word_counter.inc()
+ self.word_length_counter.inc(len(w))
+ self.word_counter.inc()
return words
[2/2] beam git commit: This closes #2575
Posted by al...@apache.org.
This closes #2575
Project: http://git-wip-us.apache.org/repos/asf/beam/repo
Commit: http://git-wip-us.apache.org/repos/asf/beam/commit/0e11a936
Tree: http://git-wip-us.apache.org/repos/asf/beam/tree/0e11a936
Diff: http://git-wip-us.apache.org/repos/asf/beam/diff/0e11a936
Branch: refs/heads/master
Commit: 0e11a936808d491ef3d0948ce659b228dd328690
Parents: 034bcb4 f9d3c1e
Author: Ahmet Altay <al...@google.com>
Authored: Tue Apr 18 09:55:43 2017 -0700
Committer: Ahmet Altay <al...@google.com>
Committed: Tue Apr 18 09:55:43 2017 -0700
----------------------------------------------------------------------
.../examples/cookbook/datastore_wordcount.py | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
----------------------------------------------------------------------