T
- Tuple type.public class LoadBalancedSplitter<T> extends java.lang.Object implements ToIntFunction<T>
This is intended to be used as an argument to TStream.split(int, ToIntFunction)
.
The splitter maintains state for numChannels
splitter channels,
tracking whether a channel is busy or free.
applyAsInt
awaits a free channel, marks
the channel as busy, and forwards the tuple to the channel. The end
of the channel's pipeline must call channelDone(int)
to
signal that the channel is free.
parallelBalanced
,
Serialized FormConstructor and Description |
---|
LoadBalancedSplitter(int numChannels)
Create a new splitter.
|
Modifier and Type | Method and Description |
---|---|
int |
applyAsInt(T value)
Apply a function to
value . |
void |
channelDone(int channel)
Signal that the channel is done processing the splitter supplied tuple.
|
public LoadBalancedSplitter(int numChannels)
numChannels
- the number of splitter channelspublic void channelDone(int channel)
channel
- the 0-based channel numberpublic int applyAsInt(T value)
ToIntFunction
value
.applyAsInt
in interface ToIntFunction<T>
value
- Value the function is applied tovalue
.Copyright © 2016 The Apache Software Foundation. All Rights Reserved - bbe71fa-20161201-1641