Now that we have introduced the big picture and concepts of Beam, we'll walk through the basic example of Beam WordCount in Java, run it first in a testing runner, and later on Apex. Since you have already seen this on Apex elsewhere in the book, we will jump right into the Beam code.
Here is the entirety of the example we call minimal word count:
PipelineOptions options = ... Pipeline pipeline = Pipeline.create(options);pipeline .begin() // Read some data (parallel connector that ships with Beam) .apply(TextIO.read().from("gs://apache-beam-samples/shakespeare/*"))\ // Split into "words" (elementwise transform) .apply(FlatMapElements .into(TypeDescriptors.strings()) .via((String word) -> Arrays.asList(word.split("[^\\p{L}]+")))) // Drop empty strings (elementwise transform) .apply(Filter.by((String word) -> !word.isEmpty())) // Count per words (per key aggregation) .apply(Count.<String>perElement()) // Format...