Class UserScore
- java.lang.Object
-
- org.apache.beam.examples.complete.game.UserScore
-
- Direct Known Subclasses:
HourlyTeamScore
public class UserScore extends java.lang.ObjectThis class is the first in a series of four pipelines that tell a story in a 'gaming' domain. Concepts: batch processing, reading input from text files, writing output to text files, using standalone DoFns, use of the sum per key transform, and use of Java 8 lambda syntax.In this gaming scenario, many users play, as members of different teams, over the course of a day, and their actions are logged for processing. Some of the logged game events may be late- arriving, if users play on mobile devices and go transiently offline for a period.
This pipeline does batch processing of data collected from gaming events. It calculates the sum of scores per user, over an entire batch of gaming data (collected, say, for each day). The batch processing will not include any late data that arrives after the day's cutoff point.
To execute this pipeline, specify the pipeline configuration like this:
--tempLocation=YOUR_TEMP_DIRECTORY --runner=YOUR_RUNNER --output=YOUR_OUTPUT_DIRECTORY (possibly options specific to your runner or permissions for your temp/output locations)Optionally include the --input argument to specify a batch input file. See the --input default value for example batch data file, or use
injector.Injectorto generate your own batch data.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classUserScore.ExtractAndSumScoreA transform to extract key/score information from GameActionInfo, and sum the scores.static interfaceUserScore.OptionsOptions supported byUserScore.
-
Constructor Summary
Constructors Constructor Description UserScore()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description protected static java.util.Map<java.lang.String,WriteToText.FieldFn<org.apache.beam.sdk.values.KV<java.lang.String,java.lang.Integer>>>configureOutput()Create a map of information that describes how to write pipeline output to text.static voidmain(java.lang.String[] args)Run a batch pipeline.
-
-
-
Method Detail
-
configureOutput
protected static java.util.Map<java.lang.String,WriteToText.FieldFn<org.apache.beam.sdk.values.KV<java.lang.String,java.lang.Integer>>> configureOutput()
Create a map of information that describes how to write pipeline output to text. This map is passed to theWriteToTextconstructor to write user score sums.
-
main
public static void main(java.lang.String[] args) throws java.lang.ExceptionRun a batch pipeline.- Throws:
java.lang.Exception
-
-