@NotThreadSafe public final class LocalFileBlockReader extends Object implements BlockReader
Constructor and Description |
---|
LocalFileBlockReader(String path)
Constructs a Block reader given the file path of the block.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
decreaseUsageCount()
decrease the file reader usage count.
|
ReadableByteChannel |
getChannel()
Returns a readable byte channel of the block.
|
String |
getFilePath() |
long |
getLength()
Gets the length of the block in bytes.
|
int |
getUsageCount() |
void |
increaseUsageCount()
increase the file reader usage count.
|
boolean |
isClosed() |
ByteBuffer |
read(long offset,
long length)
Reads data from the block.
|
int |
transferTo(io.netty.buffer.ByteBuf buf)
Transfers data (up to buf.writableBytes()) from this reader to the buffer.
|
public LocalFileBlockReader(String path) throws IOException
path
- file path of the blockIOException
public ReadableByteChannel getChannel()
BlockReader
getChannel
in interface BlockReader
public long getLength()
BlockReader
getLength
in interface BlockReader
public void increaseUsageCount()
public void decreaseUsageCount()
public int getUsageCount()
public String getFilePath()
public ByteBuffer read(long offset, long length) throws IOException
BlockReader
read
in interface BlockReader
offset
- the offset from starting of the block file in byteslength
- the length of data to read in bytes, -1 for the rest of the blockByteBuffer
the data that was readIOException
public int transferTo(io.netty.buffer.ByteBuf buf) throws IOException
BlockReader
transferTo
in interface BlockReader
buf
- the byte bufferIOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public boolean isClosed()
isClosed
in interface BlockReader
Copyright © 2023. All Rights Reserved.