public class RemoteBlockReader extends BlockReader
BlockClient.Type
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.
|
toString
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 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 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 void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class BlockClient
IOException
Copyright © 2023. All Rights Reserved.