public class RemoteBlockReader extends Object implements BlockReader
Constructor and Description |
---|
RemoteBlockReader(FileSystemContext fsContext,
long blockId,
long blockSize,
InetSocketAddress dataSource,
Protocol.OpenUfsBlockOptions ufsOptions)
Constructs a remote block reader.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
ReadableByteChannel |
getChannel()
Returns a readable byte channel of the block.
|
long |
getLength()
Gets the length of the block in bytes.
|
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 RemoteBlockReader(FileSystemContext fsContext, long blockId, long blockSize, InetSocketAddress dataSource, Protocol.OpenUfsBlockOptions ufsOptions)
fsContext
- the filesystem context to use to create BlockInStream
blockId
- the block to cacheblockSize
- the size of the blockdataSource
- the data source to cache fromufsOptions
- the options to read the block from ufs if necessarypublic 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 long getLength()
BlockReader
getLength
in interface BlockReader
public ReadableByteChannel getChannel()
BlockReader
getChannel
in interface BlockReader
public int transferTo(io.netty.buffer.ByteBuf buf) throws IOException
BlockReader
transferTo
in interface BlockReader
buf
- the byte bufferIOException
public boolean isClosed()
isClosed
in interface BlockReader
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
Copyright © 2023. All Rights Reserved.