@NotThreadSafe public class LocalFileBlockReader extends BlockReader
BlockClient.Type
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.
|
toString
public LocalFileBlockReader(String path) throws IOException
path
- file path of the blockIOException
public ReadableByteChannel getChannel()
BlockReader
getChannel
in class BlockReader
public long getLength()
BlockReader
getLength
in class 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 class 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 class BlockReader
buf
- the byte bufferIOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class BlockClient
IOException
public boolean isClosed()
isClosed
in class BlockReader
Copyright © 2023. All Rights Reserved.