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

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

                Author: ASF GitHub Bot
            Created on: 20/May/19 16:59
            Start Date: 20/May/19 16:59
    Worklog Time Spent: 10m 
      Work Description: lukecwik commented on pull request #8607: [BEAM-7342] 
Extend SyntheticPipeline map steps to be splittable.
URL: https://github.com/apache/beam/pull/8607#discussion_r285682295
 
 

 ##########
 File path: sdks/python/apache_beam/testing/synthetic_pipeline.py
 ##########
 @@ -115,6 +115,108 @@ def process(self, element):
       for _ in range(self._output_records_per_input_record):
         yield element
 
+class SyntheticSDFStepRestrictionProvider(RestrictionProvider):
+  """A `RestrictionProvider` for SyntheticSDFStep.
+
+  In initial_restriction and split that operates on num_records and ignores
+  source description (element).
+
+  """
+
+  def __init__(self, num_records, initial_splitting_num_bundles):
+    self._num_records = num_records
+    self._initial_splitting_num_bundles = initial_splitting_num_bundles
+
+  def initial_restriction(self, element):
+    return (0, self._num_records)
+
+  def create_tracker(self, restriction):
+    return restriction_trackers.OffsetRestrictionTracker(
+        restriction[0], restriction[1])
+
+  def split(self, element, restriction):
+    bundle_ranges = []
+    start_position, stop_position = restriction
+    if self._initial_splitting_num_bundles < 2:
+      bundle_ranges.append((start_position, stop_position))
+      return bundle_ranges
+    num_bundles = self._initial_splitting_num_bundles
+    num_records_per_bundle = (stop_position - start_position) // num_bundles
 
 Review comment:
   What about using 
https://github.com/apache/beam/blob/069fc3de95bd96f34c363308ad9ba988ab58502d/sdks/python/apache_beam/io/restriction_trackers.py#L53
 to perform the splitting logic?
   
   This would fall out naturally if we used OffsetRange as the restriction type.
 
----------------------------------------------------------------
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:
[email protected]


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

    Worklog Id:     (was: 245324)
    Time Spent: 40m  (was: 0.5h)

> Extend SyntheticPipeline map steps to be able to be splittable (Beam Python 
> SDK)
> --------------------------------------------------------------------------------
>
>                 Key: BEAM-7342
>                 URL: https://issues.apache.org/jira/browse/BEAM-7342
>             Project: Beam
>          Issue Type: New Feature
>          Components: testing
>         Environment: Beam Python
>            Reporter: Lara Schmidt
>            Assignee: Lara Schmidt
>            Priority: Minor
>   Original Estimate: 1m
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> Add the ability for map steps to be configured to be splittable. 
> Possible configuration options:
>  - uneven bundle sizes
>  - possible incorrect sizing returned



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

Reply via email to