Package org.apache.druid.frame.processor
Class FrameChannelHashPartitioner
java.lang.Object
org.apache.druid.frame.processor.FrameChannelHashPartitioner
- All Implemented Interfaces:
FrameProcessor<Long>
Processor that hash-partitions rows from any number of input channels, and writes partitioned frames to output
channels.
Input frames must be
FrameType.isRowBased(), and input signature must be the same as output signature.
This processor hashes each row using BaseState.xxHash64(long, long, long) with a seed of HASH_SEED.-
Constructor Summary
ConstructorsConstructorDescriptionFrameChannelHashPartitioner(List<ReadableFrameChannel> inputChannels, List<WritableFrameChannel> outputChannels, FrameReader frameReader, int keyFieldCount, FrameWriterFactory frameWriterFactory) -
Method Summary
Modifier and TypeMethodDescriptionvoidcleanup()Closes resources used by this worker.List of input channels.List of output channels.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 Details
-
FrameChannelHashPartitioner
public FrameChannelHashPartitioner(List<ReadableFrameChannel> inputChannels, List<WritableFrameChannel> outputChannels, FrameReader frameReader, int keyFieldCount, FrameWriterFactory frameWriterFactory)
-
-
Method Details
-
inputChannels
Description copied from interface:FrameProcessorList of input channels. The positions of channels in this list are used to build thereadableInputsset provided toFrameProcessor.runIncrementally(it.unimi.dsi.fastutil.ints.IntSet).- Specified by:
inputChannelsin interfaceFrameProcessor<Long>
-
outputChannels
Description copied from interface:FrameProcessorList of output channels.- Specified by:
outputChannelsin interfaceFrameProcessor<Long>
-
runIncrementally
public ReturnOrAwait<Long> runIncrementally(it.unimi.dsi.fastutil.ints.IntSet readableInputs) throws IOException Description copied from interface:FrameProcessorRuns 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:
runIncrementallyin interfaceFrameProcessor<Long>- 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.
- Throws:
IOException
-
cleanup
Description copied from interface:FrameProcessorCloses 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:
cleanupin interfaceFrameProcessor<Long>- Throws:
IOException
-