public class OutputChannel extends Object
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().| Modifier and Type | Method and Description |
|---|---|
void |
convertToReadOnly()
Removes the reference to the
writableChannel and frameMemoryAllocator from the object, making
it more efficient |
MemoryAllocator |
getFrameMemoryAllocator()
Returns the memory allocator for the writable channel.
|
int |
getPartitionNumber() |
ReadableFrameChannel |
getReadableChannel()
Returns the readable channel of this pair.
|
Supplier<ReadableFrameChannel> |
getReadableChannelSupplier() |
WritableFrameChannel |
getWritableChannel()
Returns the writable channel of this pair.
|
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.
|
boolean |
isReadableChannelReady()
Whether
getReadableChannel() is ready to use. |
OutputChannel |
mapWritableChannel(Function<WritableFrameChannel,WritableFrameChannel> mapFn) |
static OutputChannel |
nil(int partitionNumber)
Create a nil output channel, representing a processor that writes nothing.
|
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.
|
OutputChannel |
readOnly()
Returns a read-only version of this instance.
|
static OutputChannel |
readOnly(ReadableFrameChannel readableChannel,
int partitionNumber)
Creates a read-only output channel.
|
static OutputChannel |
readOnly(Supplier<ReadableFrameChannel> readableChannelSupplier,
int partitionNumber)
Creates a read-only output channel.
|
public static OutputChannel pair(WritableFrameChannel writableChannel, MemoryAllocator frameMemoryAllocator, Supplier<ReadableFrameChannel> readableChannelSupplier, int partitionNumber)
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
in Suppliers.memoize(com.google.common.base.Supplier<T>) if needed.partitionNumber - partition number, if any; may be FrameWithPartition.NO_PARTITION if unknownpublic static OutputChannel immediatelyReadablePair(WritableFrameChannel writableChannel, MemoryAllocator frameMemoryAllocator, ReadableFrameChannel readableChannel, int partitionNumber)
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 be FrameWithPartition.NO_PARTITION if unknownpublic static OutputChannel readOnly(ReadableFrameChannel readableChannel, int partitionNumber)
readableChannel - readable channel for consumer.partitionNumber - partition number, if any; may be FrameWithPartition.NO_PARTITION if unknownpublic static OutputChannel readOnly(Supplier<ReadableFrameChannel> readableChannelSupplier, int partitionNumber)
readableChannelSupplier - readable channel for consumer. May be called multiple times, so you should wrap this
in Suppliers.memoize(com.google.common.base.Supplier<T>) if needed.partitionNumber - partition number, if any; may be FrameWithPartition.NO_PARTITION if unknownpublic static OutputChannel nil(int partitionNumber)
public WritableFrameChannel getWritableChannel()
public MemoryAllocator getFrameMemoryAllocator()
public ReadableFrameChannel getReadableChannel()
isReadableChannelReady() to find out.public boolean isReadableChannelReady()
getReadableChannel() is ready to use.public Supplier<ReadableFrameChannel> getReadableChannelSupplier()
public int getPartitionNumber()
public OutputChannel mapWritableChannel(Function<WritableFrameChannel,WritableFrameChannel> mapFn)
public OutputChannel readOnly()
getWritableChannel() nor
getFrameMemoryAllocator(), and therefore require substantially less memory.public void convertToReadOnly()
writableChannel and frameMemoryAllocator from the object, making
it more efficientCopyright © 2011–2023 The Apache Software Foundation. All rights reserved.