public abstract class BlockReader extends BlockClient
This class does not provide thread-safety.
BlockClient.Type
Constructor and Description |
---|
BlockReader()
Default constructor for the abstract reader implementations.
|
Modifier and Type | Method and Description |
---|---|
abstract ReadableByteChannel |
getChannel()
Returns a readable byte channel of the block.
|
abstract long |
getLength()
Gets the length of the block in bytes.
|
abstract String |
getLocation() |
abstract boolean |
isClosed() |
abstract ByteBuffer |
read(long offset,
long length)
Reads data from the block.
|
abstract int |
transferTo(io.netty.buffer.ByteBuf buf)
Transfers data (up to buf.writableBytes()) from this reader to the buffer.
|
close, toString
public BlockReader()
public abstract ByteBuffer read(long offset, long length) throws IOException
ByteBuf
and call
transferTo(ByteBuf)
instead. It is then the caller's responsibility to de-allocate
the buffer.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 abstract long getLength()
public abstract ReadableByteChannel getChannel()
public abstract int transferTo(io.netty.buffer.ByteBuf buf) throws IOException
buf
- the byte bufferIOException
public abstract boolean isClosed()
public abstract String getLocation()
Copyright © 2023. All Rights Reserved.