Skip to content

Instantly share code, notes, and snippets.

@DennisAlund
Created October 10, 2018 12:18
Show Gist options
  • Save DennisAlund/8869e76ae77916e9d3482c0c9a66e616 to your computer and use it in GitHub Desktop.
Save DennisAlund/8869e76ae77916e9d3482c0c9a66e616 to your computer and use it in GitHub Desktop.
pipeline
.apply("Receive PubSub", PubsubIO.readMessagesWithAttributes().fromTopic(fromTopic))
.apply("Transform to KeyValue", ParDo.of(new TransformPubSubMessage()))
.apply("Apply window of time", Window.into(FixedWindows.of(WINDOW_SIZE)))
.apply("Group by contestant", GroupByKey.create())
.apply("Count votes", Combine.groupedValues(new CountFn()))
.apply("Transform to PubSub Message", ParDo.of(new MakePubSubPayload()))
.apply("Send PubSub", PubsubIO.writeMessages().to(toTopic));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment