Recently I'm learning apache beam, and find some python code like this:
lines = p | 'read' >> ReadFromText(known_args.input)
# Count the occurrences of each word.
def count_ones(word_ones):
(word, ones) = word_ones
return (word, sum(ones))
counts = (lines
| 'split' >> (beam.ParDo(WordExtractingDoFn())
.with_output_types(unicode))
| 'pair_with_one' >> beam.Map(lambda x: (x, 1))
| 'group' >> beam.GroupByKey()
| 'count' >> beam.Map(count_ones))
From: https://github.com/apache/beam/blob/master/sdks/python/apache_beam/examples/wordcount.py#L92
What is the syntax and usage of |
and >>
in python?