Class OutputEmitter<T>
- java.lang.Object
-
- org.apache.flink.runtime.operators.shipping.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 Summary
Constructors Constructor Description OutputEmitter(ShipStrategyType strategy, int indexInSubtaskGroup)
Creates a new channel selector that uses the given strategy (broadcasting, partitioning, ...)OutputEmitter(ShipStrategyType strategy, int indexInSubtaskGroup, TypeComparator<T> comparator, Partitioner<?> partitioner, DataDistribution distribution)
OutputEmitter(ShipStrategyType strategy, TypeComparator<T> comparator)
Creates a new channel selector that uses the given strategy (broadcasting, partitioning, ...)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
isBroadcast()
Returns whether the channel selector always selects all the output channels.int
selectChannel(SerializationDelegate<T> record)
Returns the logical channel index, to which the given record should be written.void
setup(int numberOfChannels)
Initializes the channel selector with the number of output channels.
-
-
-
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.
-
OutputEmitter
public OutputEmitter(ShipStrategyType strategy, int indexInSubtaskGroup, TypeComparator<T> comparator, Partitioner<?> partitioner, DataDistribution distribution)
-
-
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 interfaceChannelSelector<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 throwingUnsupportedOperationException
).- Specified by:
selectChannel
in interfaceChannelSelector<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 interfaceChannelSelector<T>
- Returns:
- true if the selector is for broadcast mode.
-
-