public class DelegatingBlockReader extends BlockReader
BlockClient.Type
Constructor and Description |
---|
DelegatingBlockReader(BlockReader blockReader,
Closeable closeable)
Default constructor for the abstract reader implementations.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
ReadableByteChannel |
getChannel()
Returns a readable byte channel of the block.
|
BlockReader |
getDelegate() |
long |
getLength()
Gets the length of the block in bytes.
|
String |
getLocation() |
boolean |
isClosed() |
ByteBuffer |
read(long offset,
long length)
Reads data from the block.
|
String |
toString() |
int |
transferTo(io.netty.buffer.ByteBuf buf)
Transfers data (up to buf.writableBytes()) from this reader to the buffer.
|
public DelegatingBlockReader(BlockReader blockReader, Closeable closeable)
blockReader
- block readercloseable
- closerpublic BlockReader getDelegate()
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 long getLength()
BlockReader
getLength
in class BlockReader
public ReadableByteChannel getChannel()
BlockReader
getChannel
in class BlockReader
public int transferTo(io.netty.buffer.ByteBuf buf) throws IOException
BlockReader
transferTo
in class BlockReader
buf
- the byte bufferIOException
public boolean isClosed()
isClosed
in class BlockReader
public String getLocation()
getLocation
in class BlockReader
public String toString()
toString
in class BlockClient
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class BlockClient
IOException
Copyright © 2023. All Rights Reserved.