@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,
LocalBlockStore localBlockStore,
UfsManager.UfsClient ufsClient,
UfsInputStreamCache ufsInStreamCache,
com.codahale.metrics.Counter ufsBytesRead,
com.codahale.metrics.Meter ufsBytesReadThroughput)
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() |
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, LocalBlockStore localBlockStore, UfsManager.UfsClient ufsClient, UfsInputStreamCache ufsInStreamCache, com.codahale.metrics.Counter ufsBytesRead, com.codahale.metrics.Meter ufsBytesReadThroughput) 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 storeufsClient
- the manager of ufspositionShort
- whether the client op is a positioned read to a small bufferufsInStreamCache
- the UFS in stream cacheufsBytesRead
- counter metric to track ufs bytes readufsBytesReadThroughput
- meter metric to track bytes read throughputIOException
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
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 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
Copyright © 2023. All Rights Reserved.