@NotThreadSafe public final class UnderFileSystemBlockReader extends 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.BlockClient.Type
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,
UfsInputStreamCache ufsInStreamCache)
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.
|
String |
getLocation() |
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.
|
toString
public static UnderFileSystemBlockReader create(UnderFileSystemBlockMeta blockMeta, long offset, boolean positionShort, BlockStore localBlockStore, UfsManager ufsManager, UfsInputStreamCache ufsInStreamCache) 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 ufspositionShort
- whether the client op is a positioned read to a small bufferufsInStreamCache
- the UFS in stream cacheIOException
public ReadableByteChannel getChannel()
BlockReader
getChannel
in class BlockReader
public long getLength()
BlockReader
getLength
in class BlockReader
public 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 int transferTo(io.netty.buffer.ByteBuf buf) throws IOException
transferTo
in class BlockReader
buf
- the byte bufferIOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class BlockClient
IOException
public boolean isClosed()
isClosed
in class BlockReader
public String getLocation()
getLocation
in class BlockReader
public AlluxioURI getUfsMountPointUri()
Copyright © 2023. All Rights Reserved.