Package org.apache.druid.frame.processor
Class FrameChannelBatcher
- java.lang.Object
-
- org.apache.druid.frame.processor.FrameChannelBatcher
-
- All Implemented Interfaces:
FrameProcessor<Pair<List<Frame>,it.unimi.dsi.fastutil.ints.IntSet>>
public class FrameChannelBatcher extends Object implements FrameProcessor<Pair<List<Frame>,it.unimi.dsi.fastutil.ints.IntSet>>
Processor that reads up to "maxFrames" frames from some input channels and combines them into a batch. There may be frames left over in the channels when the worker is done. Returns the batch and the set of channels that have more left to read. This processor does not close its input channels. The caller should do that after all input channels are finished.
-
-
Constructor Summary
Constructors Constructor Description FrameChannelBatcher(List<ReadableFrameChannel> channels, int maxFrames)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cleanup()
Closes resources used by this worker.List<ReadableFrameChannel>
inputChannels()
List of input channels.List<WritableFrameChannel>
outputChannels()
List of output channels.ReturnOrAwait<Pair<List<Frame>,it.unimi.dsi.fastutil.ints.IntSet>>
runIncrementally(it.unimi.dsi.fastutil.ints.IntSet readableInputs)
Runs some of the algorithm, without blocking, and either returns a value or a set of input channels to wait for.
-
-
-
Constructor Detail
-
FrameChannelBatcher
public FrameChannelBatcher(List<ReadableFrameChannel> channels, int maxFrames)
-
-
Method Detail
-
inputChannels
public List<ReadableFrameChannel> inputChannels()
Description copied from interface:FrameProcessor
List of input channels. The positions of channels in this list are used to build thereadableInputs
set provided toFrameProcessor.runIncrementally(it.unimi.dsi.fastutil.ints.IntSet)
.- Specified by:
inputChannels
in interfaceFrameProcessor<Pair<List<Frame>,it.unimi.dsi.fastutil.ints.IntSet>>
-
outputChannels
public List<WritableFrameChannel> outputChannels()
Description copied from interface:FrameProcessor
List of output channels.- Specified by:
outputChannels
in interfaceFrameProcessor<Pair<List<Frame>,it.unimi.dsi.fastutil.ints.IntSet>>
-
runIncrementally
public ReturnOrAwait<Pair<List<Frame>,it.unimi.dsi.fastutil.ints.IntSet>> runIncrementally(it.unimi.dsi.fastutil.ints.IntSet readableInputs)
Description copied from interface:FrameProcessor
Runs some of the algorithm, without blocking, and either returns a value or a set of input channels to wait for. This method is called byFrameProcessorExecutor.runFully(org.apache.druid.frame.processor.FrameProcessor<T>, java.lang.String)
when all output channels are writable. Therefore, it is guaranteed that each output channel can accept at least one frame. This method must not read more than one frame from each readable input channel, and must not write more than one frame to each output channel.- Specified by:
runIncrementally
in interfaceFrameProcessor<Pair<List<Frame>,it.unimi.dsi.fastutil.ints.IntSet>>
- Parameters:
readableInputs
- channels fromFrameProcessor.inputChannels()
that are either finished or ready to read. That is: eitherReadableFrameChannel.isFinished()
orReadableFrameChannel.canRead()
are true.- Returns:
- either a final return value or a set of input channels to wait for. Must be nonnull.
-
cleanup
public void cleanup()
Description copied from interface:FrameProcessor
Closes resources used by this worker. Exact same concept asCloseable.close()
. This interface does not extend Closeable, in order to make it easier to find all places where cleanup happens. (Static analysis tools can lose the thread when Closeables are closed in generic ways.) Implementations typically callReadableFrameChannel.close()
andWritableFrameChannel.close()
on all input and output channels, as well as releasing any additional resources that may be held, such asFrameWriter
. In cases of cancellation, this method may be called even ifFrameProcessor.runIncrementally(it.unimi.dsi.fastutil.ints.IntSet)
has not yet returned a result viaReturnOrAwait.returnObject(T)
.- Specified by:
cleanup
in interfaceFrameProcessor<Pair<List<Frame>,it.unimi.dsi.fastutil.ints.IntSet>>
-
-