Class BeamWordCount.CountWords

  • All Implemented Interfaces:
    Serializable, org.apache.beam.sdk.transforms.display.HasDisplayData
    Enclosing class:
    BeamWordCount

    public static final class BeamWordCount.CountWords
    extends org.apache.beam.sdk.transforms.PTransform<org.apache.beam.sdk.values.PCollection<String>,​org.apache.beam.sdk.values.PCollection<org.apache.beam.sdk.values.KV<String,​Long>>>
    A PTransform that converts a PCollection containing lines of text into a PCollection of formatted word counts.

    Concept #3: This is a custom composite transform that bundles two transforms (ParDo and Count) as a reusable PTransform subclass. Using composite transforms allows for easy reuse, modular testing, and an improved monitoring experience.

    See Also:
    Serialized Form
    • Field Summary

      • Fields inherited from class org.apache.beam.sdk.transforms.PTransform

        name
    • Constructor Summary

      Constructors 
      Constructor Description
      CountWords()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.apache.beam.sdk.values.PCollection<org.apache.beam.sdk.values.KV<String,​Long>> expand​(org.apache.beam.sdk.values.PCollection<String> lines)  
      • Methods inherited from class org.apache.beam.sdk.transforms.PTransform

        compose, compose, getAdditionalInputs, getDefaultOutputCoder, getDefaultOutputCoder, getDefaultOutputCoder, getKindString, getName, populateDisplayData, toString, validate
    • Constructor Detail

      • CountWords

        public CountWords()
    • Method Detail

      • expand

        public org.apache.beam.sdk.values.PCollection<org.apache.beam.sdk.values.KV<String,​Long>> expand​(org.apache.beam.sdk.values.PCollection<String> lines)
        Specified by:
        expand in class org.apache.beam.sdk.transforms.PTransform<org.apache.beam.sdk.values.PCollection<String>,​org.apache.beam.sdk.values.PCollection<org.apache.beam.sdk.values.KV<String,​Long>>>