public class StatefulTeamScore extends LeaderBoard
This pipeline processes an unbounded stream of 'game events'. It uses stateful processing to aggregate team scores per team and outputs team name and it's total score every time the team passes a new multiple of a threshold score. For example, multiples of the threshold could be the corresponding scores required to pass each level of the game. By default, this threshold is set to 5000.
Stateful processing allows us to write pipelines that output based on a runtime state (when a team reaches a certain score, in every 100 game events etc) without time triggers. See https://beam.apache.org/blog/2017/02/13/stateful-processing.html for more information on using stateful processing.
Run injector.Injector to generate pubsub data for this pipeline. The Injector
documentation provides more detail on how to do this.
To execute this pipeline, specify the pipeline configuration like this:
--project=YOUR_PROJECT_ID
--tempLocation=gs://YOUR_TEMP_DIRECTORY
--runner=YOUR_RUNNER
--dataset=YOUR-DATASET
--topic=projects/YOUR-PROJECT/topics/YOUR-TOPIC
The BigQuery dataset you specify must already exist. The PubSub topic you specify should be the same topic to which the Injector is publishing.
| Modifier and Type | Class and Description |
|---|---|
static interface |
StatefulTeamScore.Options
Options supported by
StatefulTeamScore. |
static class |
StatefulTeamScore.UpdateTeamScoreFn
Tracks each team's score separately in a single state cell and outputs the score every time it
passes a new multiple of a threshold.
|
UserScore.ExtractAndSumScore| Constructor and Description |
|---|
StatefulTeamScore() |
| Modifier and Type | Method and Description |
|---|---|
static void |
main(java.lang.String[] args) |
configureBigQueryWrite, configureGlobalWindowBigQueryWrite, configureWindowedTableWriteconfigureOutput