@NotThreadSafe public final class UnderFileSystemBlockReader extends Object implements BlockReader
BlockReader
to read a block directly from UFS, and
optionally cache the block to the Alluxio worker if the whole block it is read.Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the block reader.
|
static UnderFileSystemBlockReader |
create(UnderFileSystemBlockMeta blockMeta,
long offset,
boolean positionShort,
BlockStore localBlockStore,
UfsManager ufsManager,
UfsInputStreamManager ufsInstreamManager)
Creates an instance of
UnderFileSystemBlockReader and initializes it with a reading
offset. |
ReadableByteChannel |
getChannel()
Returns a readable byte channel of the block.
|
long |
getLength()
Gets the length of the block in bytes.
|
AlluxioURI |
getUfsMountPointUri() |
boolean |
isClosed() |
ByteBuffer |
read(long offset,
long length)
Reads data from the block.
|
int |
transferTo(io.netty.buffer.ByteBuf buf)
This interface is supposed to be used for sequence block reads.
|
public static UnderFileSystemBlockReader create(UnderFileSystemBlockMeta blockMeta, long offset, boolean positionShort, BlockStore localBlockStore, UfsManager ufsManager, UfsInputStreamManager ufsInstreamManager) throws IOException
UnderFileSystemBlockReader
and initializes it with a reading
offset.blockMeta
- the block metaoffset
- the position within the block to start the readlocalBlockStore
- the Local block storeufsManager
- the manager of ufsufsInstreamManager
- the manager of ufs instreamspositionShort
- whether the client op is a positioned read to a small bufferIOException
public ReadableByteChannel getChannel()
BlockReader
getChannel
in interface BlockReader
public long getLength()
BlockReader
getLength
in interface BlockReader
public 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 int transferTo(io.netty.buffer.ByteBuf buf) throws IOException
transferTo
in interface BlockReader
buf
- the byte bufferIOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public boolean isClosed()
isClosed
in interface BlockReader
public AlluxioURI getUfsMountPointUri()
Copyright © 2023. All Rights Reserved.