Class BufferReaderWriterUtil
java.lang.Object
org.apache.flink.runtime.io.network.partition.BufferReaderWriterUtil
Putting and getting of a sequence of buffers to/from a FileChannel or a ByteBuffer. This class
handles the headers, length encoding, memory slicing.
The encoding is the same across FileChannel and ByteBuffer, so this class can write to a file and read from the byte buffer that results from mapping this file to memory.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ByteBufferstatic BufferHeaderparseBufferHeader(ByteBuffer headerBuffer) static voidpositionToNextBuffer(FileChannel channel, ByteBuffer headerBuffer) Skip one data buffer from the channel's current position by headerBuffer.static voidreadByteBufferFully(FileChannel channel, ByteBuffer b) static voidreadByteBufferFully(FileChannel channel, ByteBuffer b, long position) static BufferreadFromByteChannel(FileChannel channel, ByteBuffer headerBuffer, org.apache.flink.core.memory.MemorySegment memorySegment, BufferRecycler bufferRecycler) static voidsetByteChannelBufferHeader(Buffer buffer, ByteBuffer header) static voidwriteBuffers(FileChannel channel, long bytesExpected, ByteBuffer... buffers)
-
Field Details
-
HEADER_LENGTH
public static final int HEADER_LENGTH- See Also:
-
-
Constructor Details
-
BufferReaderWriterUtil
public BufferReaderWriterUtil()
-
-
Method Details
-
setByteChannelBufferHeader
-
readFromByteChannel
@Nullable public static Buffer readFromByteChannel(FileChannel channel, ByteBuffer headerBuffer, org.apache.flink.core.memory.MemorySegment memorySegment, BufferRecycler bufferRecycler) throws IOException - Throws:
IOException
-
allocatedHeaderBuffer
-
positionToNextBuffer
public static void positionToNextBuffer(FileChannel channel, ByteBuffer headerBuffer) throws IOException Skip one data buffer from the channel's current position by headerBuffer.- Throws:
IOException
-
readByteBufferFully
- Throws:
IOException
-
readByteBufferFully
public static void readByteBufferFully(FileChannel channel, ByteBuffer b, long position) throws IOException - Throws:
IOException
-
writeBuffers
public static void writeBuffers(FileChannel channel, long bytesExpected, ByteBuffer... buffers) throws IOException - Throws:
IOException
-
parseBufferHeader
-