[ 
https://issues.apache.org/jira/browse/BEAM-8575?focusedWorklogId=369518&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-369518
 ]

ASF GitHub Bot logged work on BEAM-8575:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 10/Jan/20 01:24
            Start Date: 10/Jan/20 01:24
    Worklog Time Spent: 10m 
      Work Description: robertwb commented on pull request #10190: [BEAM-8575] 
Added two unit tests to CombineTest class to test that Co…
URL: https://github.com/apache/beam/pull/10190#discussion_r365036490
 
 

 ##########
 File path: sdks/python/apache_beam/transforms/combiners_test.py
 ##########
 @@ -50,6 +52,39 @@
 from apache_beam.utils.timestamp import Timestamp
 
 
+class CounterIncrememtingCombineFn(beam.CombineFn):
+  """CombineFn for incrementing three different counters:
+     counter, distribution, gauge,
+     at the same time concatenating words."""
+
+  def __init__(self):
+    beam.CombineFn.__init__(self)
+    self.word_counter = Metrics.counter(self.__class__, 'word_counter')
+    self.word_lengths_counter = Metrics.counter(
+        self.__class__, 'word_lengths')
+    self.word_lengths_dist = Metrics.distribution(
+        self.__class__, 'word_len_dist')
+    self.last_word_len = Metrics.gauge(self.__class__, 'last_word_len')
+
+  def create_accumulator(self):
+    return ''
+
+  def add_input(self, acc, element):
+    self.word_counter.inc(1)
+    self.word_lengths_counter.inc(len(element))
+    self.word_lengths_dist.update(len(element))
+    self.last_word_len.set(len(element))
+
+    # ''.join() converts the list to a string.
+    return ''.join(sorted(acc + element))
+
+  def merge_accumulators(self, accs):
+    return ''.join(sorted(''.join(accs)))
 
 Review comment:
   Likewise, `return sum(accs, '')`
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 369518)
    Time Spent: 44.5h  (was: 44h 20m)

> Add more Python validates runner tests
> --------------------------------------
>
>                 Key: BEAM-8575
>                 URL: https://issues.apache.org/jira/browse/BEAM-8575
>             Project: Beam
>          Issue Type: Test
>          Components: sdk-py-core, testing
>            Reporter: wendy liu
>            Assignee: wendy liu
>            Priority: Major
>          Time Spent: 44.5h
>  Remaining Estimate: 0h
>
> This is the umbrella issue to track the work of adding more Python tests to 
> improve test coverage.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to