Package org.apache.druid.frame.processor
Class OutputChannel
java.lang.Object
org.apache.druid.frame.processor.OutputChannel
Represents an output channel for some frame processor. Composed of a pair of
WritableFrameChannel, which the
processor writes to, along with a supplier of a ReadableFrameChannel, which readers can read from.
At the time an instance of this class is created, the writable channel is already open, but the readable channel
has not yet been created. It is created upon the first call to getReadableChannel().-
Method Summary
Modifier and TypeMethodDescriptionvoidRemoves the reference to thewritableChannelandframeMemoryAllocatorfrom the object, making it more efficientReturns the memory allocator for the writable channel.intReturns the readable channel of this pair.Returns the writable channel of this pair.static OutputChannelimmediatelyReadablePair(WritableFrameChannel writableChannel, MemoryAllocator frameMemoryAllocator, ReadableFrameChannel readableChannel, int partitionNumber) Creates an output channel pair, where the readable channel is usable before writing is complete.booleanReturns whether this instance is read-only (has no writable channel).static OutputChannelnil(int partitionNumber) Create a nil output channel, representing a processor that writes nothing.static OutputChannelpair(WritableFrameChannel writableChannel, MemoryAllocator frameMemoryAllocator, Supplier<ReadableFrameChannel> readableChannelSupplier, int partitionNumber) Creates an output channel pair, where the readable channel is not usable until writing is complete.readOnly()Returns a read-only version of this instance.static OutputChannelreadOnly(Supplier<ReadableFrameChannel> readableChannelSupplier, int partitionNumber) Creates a read-only output channel.static OutputChannelreadOnly(ReadableFrameChannel readableChannel, int partitionNumber) Creates a read-only output channel.
-
Method Details
-
pair
public static OutputChannel pair(WritableFrameChannel writableChannel, MemoryAllocator frameMemoryAllocator, Supplier<ReadableFrameChannel> readableChannelSupplier, int partitionNumber) Creates an output channel pair, where the readable channel is not usable until writing is complete.- Parameters:
writableChannel- writable channel for producerframeMemoryAllocator- memory allocator for producer to use while writing frames to the channelreadableChannelSupplier- readable channel for consumer. May be called multiple times, so you should wrap this inSuppliers.memoize(com.google.common.base.Supplier<T>)if needed.partitionNumber- partition number, if any; may beWritableFrameChannel.NO_PARTITIONif unknown
-
immediatelyReadablePair
public static OutputChannel immediatelyReadablePair(WritableFrameChannel writableChannel, MemoryAllocator frameMemoryAllocator, ReadableFrameChannel readableChannel, int partitionNumber) Creates an output channel pair, where the readable channel is usable before writing is complete.- Parameters:
writableChannel- writable channel for producerframeMemoryAllocator- memory allocator for producer to use while writing frames to the channelreadableChannel- readable channel for consumerpartitionNumber- partition number, if any; may beWritableFrameChannel.NO_PARTITIONif unknown
-
readOnly
Creates a read-only output channel.- Parameters:
readableChannel- readable channel for consumer.partitionNumber- partition number, if any; may beWritableFrameChannel.NO_PARTITIONif unknown
-
readOnly
public static OutputChannel readOnly(Supplier<ReadableFrameChannel> readableChannelSupplier, int partitionNumber) Creates a read-only output channel.- Parameters:
readableChannelSupplier- readable channel for consumer. May be called multiple times, so you should wrap this inSuppliers.memoize(com.google.common.base.Supplier<T>)if needed.partitionNumber- partition number, if any; may beWritableFrameChannel.NO_PARTITIONif unknown
-
nil
Create a nil output channel, representing a processor that writes nothing. It is not actually writable, but provides a way for downstream processors to read nothing. -
getWritableChannel
Returns the writable channel of this pair. The producer writes to this channel. Throws ISE if the output channel is read only. -
getFrameMemoryAllocator
Returns the memory allocator for the writable channel. The producer uses this to generate frames for the channel. Throws ISE if the output channel is read only. -
getReadableChannel
Returns the readable channel of this pair. This readable channel may, or may not, be usable before the writable channel is closed. It depends on how the channel pair was created. -
getReadableChannelSupplier
-
getPartitionNumber
public int getPartitionNumber() -
mapWritableChannel
-
readOnly
Returns a read-only version of this instance. Read-only versions have neithergetWritableChannel()norgetFrameMemoryAllocator(), and therefore require substantially less memory. Returns the same instance if it is already read-only. -
isReadOnly
public boolean isReadOnly()Returns whether this instance is read-only (has no writable channel). -
convertToReadOnly
public void convertToReadOnly()Removes the reference to thewritableChannelandframeMemoryAllocatorfrom the object, making it more efficient
-