public class PagedFileReader extends BlockReader implements PositionReader
BlockClient.Type
Constructor and Description |
---|
PagedFileReader(LocalCachePositionReader localCachePositionReader,
long fileSize,
long startPosition)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the positon reader and do cleanup job if any.
|
static PagedFileReader |
create(AlluxioConfiguration conf,
CacheManager cacheManager,
UnderFileSystem ufs,
String fileId,
String ufsPath,
long fileSize,
long startPosition)
Creates a new
PagedFileReader . |
ReadableByteChannel |
getChannel()
Returns a readable byte channel of the block.
|
long |
getLength()
Gets the length of the block in bytes.
|
String |
getLocation() |
CompositeDataBuffer |
getMultipleDataFileChannel(io.netty.channel.Channel channel,
long length)
Get a
CompositeDataBuffer which has a list of DataFileChannel . |
boolean |
isClosed() |
ByteBuffer |
read(long offset,
long length)
Reads data from the block.
|
int |
readInternal(long position,
ReadTargetBuffer buffer,
int length) |
int |
transferTo(io.netty.buffer.ByteBuf buf)
Transfers data (up to buf.writableBytes()) from this reader to the buffer.
|
toString
public PagedFileReader(LocalCachePositionReader localCachePositionReader, long fileSize, long startPosition)
localCachePositionReader
- fileSize
- startPosition
- public static PagedFileReader create(AlluxioConfiguration conf, CacheManager cacheManager, UnderFileSystem ufs, String fileId, String ufsPath, long fileSize, long startPosition)
PagedFileReader
.conf
- cacheManager
- ufs
- fileId
- ufsPath
- fileSize
- startPosition
- PagedFileReader
public CompositeDataBuffer getMultipleDataFileChannel(io.netty.channel.Channel channel, long length) throws IOException
CompositeDataBuffer
which has a list of DataFileChannel
.channel
- the Channel object which is used for allocating ByteBuflength
- the bytes to readCompositeDataBuffer
IOException
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 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 int readInternal(long position, ReadTargetBuffer buffer, int length) throws IOException
readInternal
in interface PositionReader
position
- position of the file to start reading databuffer
- target byte bufferlength
- bytes to readIOException
public void close() throws IOException
PositionReader
close
in interface PositionReader
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.