Github user zentol commented on a diff in the pull request: https://github.com/apache/flink/pull/2136#discussion_r67719598 --- Diff: flink-libraries/flink-python/src/main/python/org/apache/flink/python/api/flink/plan/DataSet.py --- @@ -572,6 +572,41 @@ def set_parallelism(self, parallelism): self._info.parallelism.value = parallelism return self + def count_elements_per_partition(self): + class CountElementsPerPartitionMapper(MapPartitionFunction): + + def map_partition(self, iterator, collector): + counter = 0 + for x in iterator: + counter += 1 + + collector.collect((self.context.get_index_of_this_subtask(), counter)) + return self.map_partition(CountElementsPerPartitionMapper()) + + def zip_with_index(self): + element_count = self.count_elements_per_partition() + class ZipWithIndexMapper(MapPartitionFunction): + start = 0 --- End diff -- if we would start at -1 we wouldn't have to decrement it when collecting the value
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---