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

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

                Author: ASF GitHub Bot
            Created on: 14/Jun/18 00:35
            Start Date: 14/Jun/18 00:35
    Worklog Time Spent: 10m 
      Work Description: robertwb commented on a change in pull request #5639: 
[BEAM-4546] Multi level combine
URL: https://github.com/apache/beam/pull/5639#discussion_r195274961
 
 

 ##########
 File path: sdks/python/apache_beam/transforms/core.py
 ##########
 @@ -1337,6 +1372,75 @@ def default_type_hints(self):
     return hints
 
 
+class _CombinePerKeyWithHotKeyFanout(PTransform):
+
+  def __init__(self, combine_fn, fanout):
+    self._fanout_fn = (
+        (lambda key: fanout) if isinstance(fanout, int) else fanout)
+    self._combine_fn = combine_fn
+
+  def expand(self, pcoll):
+
+    from apache_beam.transforms.trigger import AccumulationMode
+    combine_fn = self._combine_fn
+    fanout_fn = self._fanout_fn
+
+    class SplitHotCold(DoFn):
+      counter = 0
+
+      def process(self, element):
+        key, value = element
+        fanout = fanout_fn(key)
+        if fanout <= 1:
+          # Boolean indicates this is not an accumulator.
+          yield pvalue.TaggedOutput('cold', (key, (False, value)))
+        else:
+          self.counter += 1  # Round-robin should be more even than random.
 
 Review comment:
   More even. But this is ambitious with "even than." I'll reword.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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: 111732)
    Time Spent: 1h 10m  (was: 1h)

> Implement with hot key fanout for combiners
> -------------------------------------------
>
>                 Key: BEAM-4546
>                 URL: https://issues.apache.org/jira/browse/BEAM-4546
>             Project: Beam
>          Issue Type: New Feature
>          Components: sdk-py-core
>            Reporter: Ahmet Altay
>            Assignee: Robert Bradshaw
>            Priority: Major
>          Time Spent: 1h 10m
>  Remaining Estimate: 0h
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to