Class OutputEmitter<T>

  • Type Parameters:
    T - The type of the element handled by the emitter.
    All Implemented Interfaces:
    ChannelSelector<SerializationDelegate<T>>

    public class OutputEmitter<T>
    extends Object
    implements ChannelSelector<SerializationDelegate<T>>
    The output emitter decides to which of the possibly multiple output channels a record is sent. It implement routing based on hash-partitioning, broadcasting, round-robin, custom partition functions, etc.
    • Constructor Detail

      • OutputEmitter

        public OutputEmitter​(ShipStrategyType strategy,
                             int indexInSubtaskGroup)
        Creates a new channel selector that uses the given strategy (broadcasting, partitioning, ...) and uses the supplied task index perform a round robin distribution.
        Parameters:
        strategy - The distribution strategy to be used.
      • OutputEmitter

        public OutputEmitter​(ShipStrategyType strategy,
                             TypeComparator<T> comparator)
        Creates a new channel selector that uses the given strategy (broadcasting, partitioning, ...) and uses the supplied comparator to hash / compare records for partitioning them deterministically.
        Parameters:
        strategy - The distribution strategy to be used.
        comparator - The comparator used to hash / compare the records.
    • Method Detail

      • setup

        public void setup​(int numberOfChannels)
        Description copied from interface: ChannelSelector
        Initializes the channel selector with the number of output channels.
        Specified by:
        setup in interface ChannelSelector<T>
        Parameters:
        numberOfChannels - the total number of output channels which are attached to respective output gate.
      • selectChannel

        public final int selectChannel​(SerializationDelegate<T> record)
        Description copied from interface: ChannelSelector
        Returns the logical channel index, to which the given record should be written. It is illegal to call this method for broadcast channel selectors and this method can remain not implemented in that case (for example by throwing UnsupportedOperationException).
        Specified by:
        selectChannel in interface ChannelSelector<T>
        Parameters:
        record - the record to determine the output channels for.
        Returns:
        an integer number which indicates the index of the output channel through which the record shall be forwarded.
      • isBroadcast

        public boolean isBroadcast()
        Description copied from interface: ChannelSelector
        Returns whether the channel selector always selects all the output channels.
        Specified by:
        isBroadcast in interface ChannelSelector<T>
        Returns:
        true if the selector is for broadcast mode.