@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.
|
String |
getLocation() |
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
ByteBuf
and call
BlockReader.transferTo(ByteBuf)
instead. It is then the caller's responsibility to de-allocate
the buffer.read
in class BlockReader
offset
- the offset from starting of the block file in byteslength
- the length of data to read in bytes. If offset + length exceeds the block size,
the part of data from offset to the end of block is returned.ByteBuffer
the data that was read, empty buffer if offset
is at
the end of blockIOException
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
public String getLocation()
getLocation
in class BlockReader
Copyright © 2023. All Rights Reserved.