-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBeamExample.java
More file actions
36 lines (28 loc) · 1.13 KB
/
BeamExample.java
File metadata and controls
36 lines (28 loc) · 1.13 KB
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
31
32
33
34
35
36
package com.example;
import org.apache.beam.sdk.Pipeline;
import org.apache.beam.sdk.transforms.*;
import org.apache.beam.sdk.values.PCollection;
import org.apache.beam.sdk.Pipeline;
import org.apache.beam.sdk.values.PCollection;
import org.apache.beam.sdk.transforms.MapElements;
import org.apache.beam.sdk.transforms.SimpleFunction;
public class BeamExample {
public static void main(String[] args) {
Pipeline pipeline = Pipeline.create();
PCollection<String> input = pipeline.apply("Create Input",
Create.of("Hello", "World"));
PCollection<String> output = input.apply("To Uppercase",
MapElements.via(new SimpleFunction<String, String>() {
public String apply(String input) {
return input.toUpperCase();
}
}));
output.apply("Print Output", ParDo.of(new DoFn<String, Void>() {
@ProcessElement
public void processElement(ProcessContext context) {
System.out.println(context.element());
}
}));
pipeline.run().waitUntilFinish();
}
}