Class FileRegionWriteReadUtils
- java.lang.Object
-
- org.apache.flink.runtime.io.network.partition.hybrid.index.FileRegionWriteReadUtils
-
public class FileRegionWriteReadUtils extends Object
Utils for read and writeFileDataIndexRegionHelper.Region.
-
-
Constructor Summary
Constructors Constructor Description FileRegionWriteReadUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ByteBufferallocateAndConfigureBuffer(int bufferSize)Allocate a buffer with specific size and configure it to native order.static ProducerMergedPartitionFileIndex.FixedSizeRegionreadFixedSizeRegionFromFile(FileChannel channel, ByteBuffer regionBuffer, long fileOffset)static HsFileDataIndexImpl.InternalRegionreadHsInternalRegionFromFile(FileChannel channel, ByteBuffer headerBuffer, long fileOffset)ReadHsFileDataIndexImpl.InternalRegionfromFileChannel.static voidwriteFixedSizeRegionToFile(FileChannel channel, ByteBuffer regionBuffer, FileDataIndexRegionHelper.Region region)static voidwriteHsInternalRegionToFile(FileChannel channel, ByteBuffer headerBuffer, HsFileDataIndexImpl.InternalRegion region)
-
-
-
Method Detail
-
allocateAndConfigureBuffer
public static ByteBuffer allocateAndConfigureBuffer(int bufferSize)
Allocate a buffer with specific size and configure it to native order.- Parameters:
bufferSize- the size of buffer to allocate.- Returns:
- a native order buffer with expected size.
-
writeHsInternalRegionToFile
public static void writeHsInternalRegionToFile(FileChannel channel, ByteBuffer headerBuffer, HsFileDataIndexImpl.InternalRegion region) throws IOException
WriteHsFileDataIndexImpl.InternalRegiontoFileChannel.Note that this type of region's length may be variable because it contains an array to indicate each buffer's release state.
- Parameters:
channel- the file's channel to write.headerBuffer- the buffer to writeHsFileDataIndexImpl.InternalRegion's header.region- the region to be written to channel.- Throws:
IOException
-
readHsInternalRegionFromFile
public static HsFileDataIndexImpl.InternalRegion readHsInternalRegionFromFile(FileChannel channel, ByteBuffer headerBuffer, long fileOffset) throws IOException
ReadHsFileDataIndexImpl.InternalRegionfromFileChannel.Note that this type of region's length may be variable because it contains an array to indicate each buffer's release state.
- Parameters:
channel- the channel to read.headerBuffer- the buffer to readHsFileDataIndexImpl.InternalRegion's header.fileOffset- the file offset to start read.- Returns:
- the
HsFileDataIndexImpl.InternalRegionthat read from this channel. - Throws:
IOException
-
writeFixedSizeRegionToFile
public static void writeFixedSizeRegionToFile(FileChannel channel, ByteBuffer regionBuffer, FileDataIndexRegionHelper.Region region) throws IOException
WriteProducerMergedPartitionFileIndex.FixedSizeRegiontoFileChannel.Note that this type of region's length is fixed.
- Parameters:
channel- the file's channel to write.regionBuffer- the buffer to writeProducerMergedPartitionFileIndex.FixedSizeRegion's header.region- the region to be written to channel.- Throws:
IOException
-
readFixedSizeRegionFromFile
public static ProducerMergedPartitionFileIndex.FixedSizeRegion readFixedSizeRegionFromFile(FileChannel channel, ByteBuffer regionBuffer, long fileOffset) throws IOException
ReadProducerMergedPartitionFileIndex.FixedSizeRegionfromFileChannel.Note that this type of region's length is fixed.
- Parameters:
channel- the channel to read.regionBuffer- the buffer to readProducerMergedPartitionFileIndex.FixedSizeRegion's header.fileOffset- the file offset to start read.- Returns:
- the
ProducerMergedPartitionFileIndex.FixedSizeRegionthat read from this channel. - Throws:
IOException
-
-