Class Top.TopCombineFn<T,​ComparatorT extends java.util.Comparator<T> & java.io.Serializable>

  • Type Parameters:
    T - type of element being compared
    All Implemented Interfaces:
    java.io.Serializable, CombineFnBase.GlobalCombineFn<T,​org.apache.beam.sdk.transforms.Top.BoundedHeap<T,​ComparatorT>,​java.util.List<T>>, HasDisplayData, NameUtils.NameOverride
    Enclosing class:
    Top

    public static class Top.TopCombineFn<T,​ComparatorT extends java.util.Comparator<T> & java.io.Serializable>
    extends Combine.AccumulatingCombineFn<T,​org.apache.beam.sdk.transforms.Top.BoundedHeap<T,​ComparatorT>,​java.util.List<T>>
    implements NameUtils.NameOverride
    CombineFn for Top transforms that combines a bunch of Ts into a single count-long List<T>, using compareFn to choose the largest Ts.
    See Also:
    Serialized Form
    • Constructor Detail

      • TopCombineFn

        public TopCombineFn​(int count,
                            ComparatorT compareFn)
    • Method Detail

      • createAccumulator

        public org.apache.beam.sdk.transforms.Top.BoundedHeap<T,​ComparatorT> createAccumulator()
        Description copied from class: Combine.CombineFn
        Returns a new, mutable accumulator value, representing the accumulation of zero input values.
        Specified by:
        createAccumulator in class Combine.CombineFn<T,​org.apache.beam.sdk.transforms.Top.BoundedHeap<T,​ComparatorT extends java.util.Comparator<T> & java.io.Serializable>,​java.util.List<T>>
      • getAccumulatorCoder

        public Coder<org.apache.beam.sdk.transforms.Top.BoundedHeap<T,​ComparatorT>> getAccumulatorCoder​(CoderRegistry registry,
                                                                                                              Coder<T> inputCoder)
        Description copied from interface: CombineFnBase.GlobalCombineFn
        Returns the Coder to use for accumulator AccumT values, or null if it is not able to be inferred.

        By default, uses the knowledge of the Coder being used for InputT values and the enclosing Pipeline's CoderRegistry to try to infer the Coder for AccumT values.

        This is the Coder used to send data through a communication-intensive shuffle step, so a compact and efficient representation may have significant performance benefits.

        Specified by:
        getAccumulatorCoder in interface CombineFnBase.GlobalCombineFn<T,​org.apache.beam.sdk.transforms.Top.BoundedHeap<T,​ComparatorT extends java.util.Comparator<T> & java.io.Serializable>,​java.util.List<T>>
      • populateDisplayData

        public void populateDisplayData​(DisplayData.Builder builder)
        Register display data for the given transform or component.

        populateDisplayData(DisplayData.Builder) is invoked by Pipeline runners to collect display data via DisplayData.from(HasDisplayData). Implementations may call super.populateDisplayData(builder) in order to register display data in the current namespace, but should otherwise use subcomponent.populateDisplayData(builder) to use the namespace of the subcomponent.

        By default, does not register any display data. Implementors may override this method to provide their own display data.

        Specified by:
        populateDisplayData in interface HasDisplayData
        Parameters:
        builder - The builder to populate with display data.
        See Also:
        HasDisplayData
      • getInputTVariable

        public java.lang.reflect.TypeVariable<?> getInputTVariable()
        Returns the TypeVariable of InputT.
      • getAccumTVariable

        public java.lang.reflect.TypeVariable<?> getAccumTVariable()
        Returns the TypeVariable of AccumT.
      • getOutputTVariable

        public java.lang.reflect.TypeVariable<?> getOutputTVariable()
        Returns the TypeVariable of OutputT.