public abstract class ByteBufs extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
SIZE_BYTES_BOOLEAN |
static int |
SIZE_BYTES_CHECKSUM |
static int |
SIZE_BYTES_INT |
static int |
SIZE_BYTES_LONG |
static int |
SIZE_BYTES_SHORT |
static io.netty.buffer.ByteBufAllocator |
UNPOOLED_HEAP_BASED_ALLOCATOR |
| Modifier and Type | Method and Description |
|---|---|
static long |
calculateChecksum(io.netty.buffer.ByteBuf givenByteBuf) |
static io.netty.buffer.ByteBuf |
compress(io.netty.buffer.ByteBufAllocator allocator,
io.netty.buffer.ByteBuf decompressed) |
static io.netty.buffer.ByteBuf |
decompress(io.netty.buffer.ByteBufAllocator allocator,
io.netty.buffer.ByteBuf compressed) |
static <R> R |
mapAndApply(FileChannel fileChannel,
long position,
long size,
Function<io.netty.buffer.ByteBuf,R> action)
Memory-maps the given
FileChannel and then wraps the mapped region with ByteBuf and then
invokes the "action" with it. |
static int |
write(FileChannel destination,
long positionToWriteTo,
long numBytesToWrite,
ReadableByteChannel source) |
static int |
writeChunks(WritableByteChannel destination,
io.netty.buffer.ByteBuf data,
int chunkWriteSizeBytes) |
static int |
writeOptimized(WritableByteChannel destination,
io.netty.buffer.ByteBuf data,
int pow2ChunkWriteSizeBytes)
An optimized form of
writeChunks(WritableByteChannel, ByteBuf, int) where data is written in chunks
that are aligned at the given size. |
public static final int SIZE_BYTES_BOOLEAN
public static final int SIZE_BYTES_SHORT
public static final int SIZE_BYTES_INT
public static final int SIZE_BYTES_LONG
public static final int SIZE_BYTES_CHECKSUM
public static final io.netty.buffer.ByteBufAllocator UNPOOLED_HEAP_BASED_ALLOCATOR
public static <R> R mapAndApply(FileChannel fileChannel, long position, long size, Function<io.netty.buffer.ByteBuf,R> action) throws IOException
FileChannel and then wraps the mapped region with ByteBuf and then
invokes the "action" with it.
The region is unmapped before exiting from this method and the ReferenceCounted.release() invoked too.
fileChannel - position - size - action - The mapped region is provided to this.IOExceptionpublic static int writeOptimized(@CallerMustRelease WritableByteChannel destination, @CallerMustRelease io.netty.buffer.ByteBuf data, int pow2ChunkWriteSizeBytes) throws IOException
writeChunks(WritableByteChannel, ByteBuf, int) where data is written in chunks
that are aligned at the given size.
The first chunked write may not be aligned if there already is content in the channel.
Same with the last chunked write if it does not fill the entire chunk size.
If destination is a FileChannel then use write(FileChannel, long, long, ReadableByteChannel).
destination - data - pow2ChunkWriteSizeBytes - Has to be a power of 2 (typically the page size).IOExceptionpublic static int writeChunks(@CallerMustRelease WritableByteChannel destination, @CallerMustRelease io.netty.buffer.ByteBuf data, int chunkWriteSizeBytes) throws IOException
destination - data - chunkWriteSizeBytes - IOExceptionpublic static int write(@CallerMustRelease FileChannel destination, long positionToWriteTo, long numBytesToWrite, @CallerMustRelease ReadableByteChannel source) throws IOException
destination - Does not change the FileChannel.position().positionToWriteTo - numBytesToWrite - source - IOExceptionpublic static io.netty.buffer.ByteBuf compress(io.netty.buffer.ByteBufAllocator allocator,
@CallerMustRelease
io.netty.buffer.ByteBuf decompressed)
public static io.netty.buffer.ByteBuf decompress(io.netty.buffer.ByteBufAllocator allocator,
@CallerMustRelease
io.netty.buffer.ByteBuf compressed)
public static long calculateChecksum(@CallerMustRelease io.netty.buffer.ByteBuf givenByteBuf)
givenByteBuf - SIZE_BYTES_CHECKSUMCopyright © 2018. All rights reserved.