public class CompressedBlockChannelReader extends Object implements BlockChannelReader<MemorySegment>, RequestDoneCallback<Buffer>, BufferRecycler
FileIOChannel.Enumerator, FileIOChannel.ID
BufferRecycler.DummyBufferRecycler
Constructor and Description |
---|
CompressedBlockChannelReader(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 filled with data by the reader.
|
FileChannel |
getNioFileChannel() |
LinkedBlockingQueue<MemorySegment> |
getReturnQueue()
Gets the queue in which the full memory segments are queued after the read is complete.
|
long |
getSize()
Gets the size (in bytes) of the file underlying the channel.
|
boolean |
isClosed()
Checks whether the channel has been closed.
|
void |
readBlock(MemorySegment segment)
Issues a read request, which will fill the given segment with the next block in the
underlying file channel.
|
void |
recycle(MemorySegment segment)
Recycles the
MemorySegment to its original BufferPool instance. |
void |
requestFailed(Buffer buffer,
IOException e) |
void |
requestSuccessful(Buffer request) |
void |
seekToPosition(long position) |
public CompressedBlockChannelReader(IOManager ioManager, FileIOChannel.ID channel, LinkedBlockingQueue<MemorySegment> blockQueue, BlockCompressionFactory codecFactory, int preferBlockSize, int segmentSize) throws IOException
IOException
public void readBlock(MemorySegment segment) throws IOException
BlockChannelReader
readBlock
in interface BlockChannelReader<MemorySegment>
segment
- The segment to read the block into.IOException
- Thrown, when the reader encounters an I/O error.public void seekToPosition(long position) throws IOException
seekToPosition
in interface BlockChannelReader<MemorySegment>
IOException
public MemorySegment getNextReturnedBlock() throws IOException
BlockChannelReader
WARNING: If this method is invoked without any segment ever returning (for example,
because the BlockChannelReader.readBlock(T)
method has not been invoked appropriately), the method may
block forever.
getNextReturnedBlock
in interface BlockChannelReader<MemorySegment>
IOException
- Thrown, if an I/O error occurs in the reader while waiting for the
request to return.public LinkedBlockingQueue<MemorySegment> getReturnQueue()
BlockChannelReader
getReturnQueue
in interface BlockChannelReader<MemorySegment>
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 requestSuccessful(Buffer request)
requestSuccessful
in interface RequestDoneCallback<Buffer>
public void requestFailed(Buffer buffer, IOException e)
requestFailed
in interface RequestDoneCallback<Buffer>
public void recycle(MemorySegment segment)
BufferRecycler
MemorySegment
to its original BufferPool
instance.recycle
in interface BufferRecycler
segment
- The memory segment to be recycled.Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.