use of com.google.cloud.dataflow.examples.complete.game.utils.WriteToText in project DataflowJavaSDK-examples by GoogleCloudPlatform.
the class HourlyTeamScore method configureOutput.
/**
* Create a map of information that describes how to write pipeline output to text. This map
* is passed to the {@link WriteToText} constructor to write team score sums and
* includes information about window start time.
*/
protected static Map<String, WriteToText.FieldFn<KV<String, Integer>>> configureOutput() {
Map<String, WriteToText.FieldFn<KV<String, Integer>>> config = new HashMap<String, WriteToText.FieldFn<KV<String, Integer>>>();
config.put("team", (c, w) -> c.element().getKey());
config.put("total_score", (c, w) -> c.element().getValue());
config.put("window_start", (c, w) -> {
IntervalWindow window = (IntervalWindow) w;
return fmt.print(window.start());
});
return config;
}
Aggregations