-
Notifications
You must be signed in to change notification settings - Fork 0
/
AvroPlayerExample.java
30 lines (27 loc) · 999 Bytes
/
AvroPlayerExample.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import org.apache.beam.sdk.Pipeline;
import org.apache.beam.sdk.options.PipelineOptions;
import org.apache.beam.sdk.options.PipelineOptionsFactory;
import org.apache.beam.sdk.transforms.Create;
import org.apache.beam.sdk.transforms.MapElements;
import org.apache.beam.sdk.values.TypeDescriptors;
import utilities.AvroPlayer;
public class AvroPlayerExample {
public static void main(String[] args) {
PipelineOptions options =
PipelineOptionsFactory.fromArgs(args).withValidation().create();
Pipeline p = Pipeline.create(options);
p
.apply("Create", Create.of(
new AvroPlayer("owl", 22),
new AvroPlayer("finch", 95),
new AvroPlayer("kestrel", 100))
)
.apply("Print", MapElements.into(TypeDescriptors.nulls()).via(
(AvroPlayer player) -> {
System.out.println(player.getName() + ": " + player.getScore());
return null;
}))
;
p.run().waitUntilFinish();
}
}