public class PagedUfsBlockReader extends BlockReader
BlockClient.Type
Constructor and Description |
---|
PagedUfsBlockReader(UfsManager ufsManager,
UfsInputStreamCache ufsInStreamCache,
BlockMeta blockMeta,
long offset,
UfsBlockReadOptions ufsBlockReadOptions,
long pageSize) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
ReadableByteChannel |
getChannel()
Returns a readable byte channel of the block.
|
ReadableByteChannel |
getChannel(long offset) |
long |
getLength()
Gets the length of the block in bytes.
|
String |
getLocation() |
UfsBlockReadOptions |
getUfsReadOptions() |
boolean |
isClosed() |
ByteBuffer |
read(long offset,
long length)
Reads data from the block.
|
int |
readPageAtIndex(ByteBuffer buffer,
long pageIndex)
Reads a page from the UFS block at index
pageIndex . |
int |
transferTo(io.netty.buffer.ByteBuf buf)
Transfers data (up to buf.writableBytes()) from this reader to the buffer.
|
toString
public PagedUfsBlockReader(UfsManager ufsManager, UfsInputStreamCache ufsInStreamCache, BlockMeta blockMeta, long offset, UfsBlockReadOptions ufsBlockReadOptions, long pageSize)
ufsManager
- ufsInStreamCache
- blockMeta
- offset
- ufsBlockReadOptions
- pageSize
- 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 readPageAtIndex(ByteBuffer buffer, long pageIndex) throws IOException
pageIndex
. This method will try to read as
many bytes as the page size designated by PropertyKey.USER_CLIENT_CACHE_PAGE_SIZE
,
and append to buffer
. If pageIndex
points to the last page of the block,
the size of the data read can be smaller than the page size.buffer
- writable output buffer, must have enough remaining space for a pagepageIndex
- the index of the page within the blockIOException
public long getLength()
BlockReader
getLength
in class BlockReader
public ReadableByteChannel getChannel()
BlockReader
getChannel
in class BlockReader
public ReadableByteChannel getChannel(long offset)
offset
- offset within the blockpublic UfsBlockReadOptions getUfsReadOptions()
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 String getLocation()
getLocation
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.