public final class BufferReaderWriterUtil extends Object
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.
Modifier and Type | Field and Description |
---|---|
static int |
HEADER_LENGTH |
Constructor and Description |
---|
BufferReaderWriterUtil() |
Modifier and Type | Method and Description |
---|---|
static ByteBuffer |
allocatedHeaderBuffer() |
static void |
positionToNextBuffer(FileChannel channel,
ByteBuffer headerBuffer)
Skip one data buffer from the channel's current position by headerBuffer.
|
static void |
readByteBufferFully(FileChannel channel,
ByteBuffer b,
long position) |
static Buffer |
readFromByteChannel(FileChannel channel,
ByteBuffer headerBuffer,
MemorySegment memorySegment,
BufferRecycler bufferRecycler) |
static void |
setByteChannelBufferHeader(Buffer buffer,
ByteBuffer header) |
static void |
writeBuffers(FileChannel channel,
long bytesExpected,
ByteBuffer... buffers) |
public static final int HEADER_LENGTH
public static void setByteChannelBufferHeader(Buffer buffer, ByteBuffer header)
@Nullable public static Buffer readFromByteChannel(FileChannel channel, ByteBuffer headerBuffer, MemorySegment memorySegment, BufferRecycler bufferRecycler) throws IOException
IOException
public static ByteBuffer allocatedHeaderBuffer()
public static void positionToNextBuffer(FileChannel channel, ByteBuffer headerBuffer) throws IOException
IOException
public static void readByteBufferFully(FileChannel channel, ByteBuffer b, long position) throws IOException
IOException
public static void writeBuffers(FileChannel channel, long bytesExpected, ByteBuffer... buffers) throws IOException
IOException
Copyright © 2014–2023 The Apache Software Foundation. All rights reserved.