[
https://issues.apache.org/jira/browse/BEAM-2939?focusedWorklogId=232463&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-232463
]
ASF GitHub Bot logged work on BEAM-2939:
----------------------------------------
Author: ASF GitHub Bot
Created on: 25/Apr/19 01:06
Start Date: 25/Apr/19 01:06
Worklog Time Spent: 10m
Work Description: pabloem commented on pull request #8338: [BEAM-2939]
Initial SyntheticSDF as Source and add an Synthetic pipeline to sdf test
URL: https://github.com/apache/beam/pull/8338#discussion_r278367916
##########
File path: sdks/python/apache_beam/testing/synthetic_pipeline.py
##########
@@ -250,6 +252,95 @@ def default_output_coder(self):
[beam.coders.BytesCoder(), beam.coders.BytesCoder()])
+class SyntheticSDFSourceRestrictionProvider(RestrictionProvider):
+ """A `RestrictionProvider` for SyntheticSDFAsSource.
+
+ In initial_restriction(element) and split(element), element means source
+ description.
+ A typical element is like:
+
+ {
+ 'key_size': 1,
+ 'value_size': 1,
+ 'initial_splitting_num_bundles': 2,
+ 'initial_splitting_desired_bundle_size': 2,
+ 'sleep_per_input_record_sec': 0,
+ 'initial_splitting' : 'const'
+
+ }
+
+ """
+
+ def initial_restriction(self, element):
+ return (0, element['num_records'])
+
+ def create_tracker(self, restriction):
+ return restriction_trackers.OffsetRestrictionTracker(
+ restriction[0], restriction[1])
+
+ def split(self, element, restriction):
+ start_position, stop_position = restriction
+ element_size = element['key_size'] + element['value_size']
+ estimate_size = element_size * element['num_records']
+ if element['initial_splitting'] == 'zipf':
+ desired_num_bundles = (
+ element['initial_splitting_num_bundles'] or
+ math.ceil(float(estimate_size) /
+ element['initial_splitting_desired_bundle_size']))
+ samples = np.random.zipf(
+ element['initial_splitting_distribution_parameter'],
+ desired_num_bundles)
+ total = sum(samples)
+ relative_bundle_sizes = [(float(sample) / total) for sample in samples]
+ bundle_ranges = []
+ start = start_position
+ index = 0
+ while start < stop_position:
+ if index == desired_num_bundles - 1:
+ bundle_ranges.append((start, stop_position))
+ break
+ stop = start + int(
+ element['num_records'] * relative_bundle_sizes[index])
+ bundle_ranges.append((start, stop))
+ start = stop
+ index += 1
+ else:
+ if element['initial_splitting_num_bundles']:
+ bundle_size_in_elements = max(1, int(
+ element['num_records'] /
+ element['initial_splitting_num_bundles']))
+ else:
+ bundle_size_in_elements = (max(
+ div_round_up(
Review comment:
Not a big deal, but just above, you're using `int(math.ceil....)`. Maybe
settle on one? : )
----------------------------------------------------------------
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: 232463)
Time Spent: 17h 10m (was: 17h)
> Fn API SDF support
> ------------------
>
> Key: BEAM-2939
> URL: https://issues.apache.org/jira/browse/BEAM-2939
> Project: Beam
> Issue Type: Improvement
> Components: beam-model
> Reporter: Henning Rohde
> Assignee: Luke Cwik
> Priority: Major
> Labels: portability, triaged
> Time Spent: 17h 10m
> Remaining Estimate: 0h
>
> The Fn API should support streaming SDF. Detailed design TBD.
> Once design is ready, expand subtasks similarly to BEAM-2822.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)