public class CompressedBlockChannelWriter extends Object implements BlockChannelWriter<MemorySegment>, BufferRecycler
FileIOChannel.Enumerator, FileIOChannel.ID
Constructor and Description |
---|
CompressedBlockChannelWriter(IOManager ioManager,
FileIOChannel.ID channel,
LinkedBlockingQueue<MemorySegment> blockQueue,
BlockCompressionFactory codecFactory,
int preferBlockSize,
int segmentSize) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the channel.
|
void |
closeAndDelete()
Closes the channel and deletes the underlying file.
|
void |
deleteChannel()
Deletes the file underlying this I/O channel.
|
FileIOChannel.ID |
getChannelID()
Gets the channel ID of this I/O channel.
|
MemorySegment |
getNextReturnedBlock()
Gets the next memory segment that has been written and is available again.
|
FileChannel |
getNioFileChannel() |
LinkedBlockingQueue<MemorySegment> |
getReturnQueue()
Gets the queue in which the memory segments are queued after the asynchronous write
is completed
|
long |
getSize()
Gets the size (in bytes) of the file underlying the channel.
|
boolean |
isClosed()
Checks whether the channel has been closed.
|
void |
recycle(MemorySegment memorySegment)
Recycles the
MemorySegment to its original BufferPool
instance. |
void |
writeBlock(MemorySegment block)
Writes the given block.
|
public CompressedBlockChannelWriter(IOManager ioManager, FileIOChannel.ID channel, LinkedBlockingQueue<MemorySegment> blockQueue, BlockCompressionFactory codecFactory, int preferBlockSize, int segmentSize) throws IOException
IOException
public void writeBlock(MemorySegment block) throws IOException
BlockChannelWriterWithCallback
writeBlock
in interface BlockChannelWriterWithCallback<MemorySegment>
block
- The segment to be written (transferring ownership to this writer).IOException
- Thrown, when the writer encounters an I/O error.public FileIOChannel.ID getChannelID()
FileIOChannel
getChannelID
in interface FileIOChannel
public long getSize() throws IOException
FileIOChannel
getSize
in interface FileIOChannel
IOException
public boolean isClosed()
FileIOChannel
isClosed
in interface FileIOChannel
public void close() throws IOException
FileIOChannel
close
in interface FileIOChannel
IOException
- Thrown, if an error occurred while waiting for pending requests.public void deleteChannel()
FileIOChannel
deleteChannel
in interface FileIOChannel
public void closeAndDelete() throws IOException
FileIOChannel
closeAndDelete
in interface FileIOChannel
IOException
- Thrown, if an error occurred while waiting for pending requests.public FileChannel getNioFileChannel()
getNioFileChannel
in interface FileIOChannel
public void recycle(MemorySegment memorySegment)
BufferRecycler
MemorySegment
to its original BufferPool
instance.recycle
in interface BufferRecycler
memorySegment
- The memory segment to be recycled.public MemorySegment getNextReturnedBlock() throws IOException
BlockChannelWriter
NOTE: If this method is invoked without any segment ever returning (for example, because the
BlockChannelWriterWithCallback.writeBlock(T)
method has not been invoked accordingly), the method may block
forever.
getNextReturnedBlock
in interface BlockChannelWriter<MemorySegment>
IOException
- Thrown, if an I/O error occurs in the writer while waiting for the request to return.public LinkedBlockingQueue<MemorySegment> getReturnQueue()
BlockChannelWriter
getReturnQueue
in interface BlockChannelWriter<MemorySegment>
Copyright © 2014–2020 The Apache Software Foundation. All rights reserved.