Top Inners Fields Methods
io.netty5.buffer.internal

public Interface InternalBufferUtils

Imports
io.netty5.buffer.Buffer, .BufferClosedException, .BufferComponent, .BufferReadOnlyException, .Drop, .MemoryManager, io.netty5.util.AsciiString, io.netty5.util.internal.PlatformDependent, java.lang.invoke.MethodHandle, .MethodHandles, .MethodHandles.Lookup, .MethodType, .VarHandle, java.lang.ref.Cleaner, java.nio.ByteBuffer, java.nio.charset.Charset, java.util.Arrays, java.util.concurrent.atomic.LongAdder, java.util.function.Function

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
InternalBufferUtils.UncheckedLoadByte

This interface provides the fastest possible offsetted byte-access to a buffer.

Field Summary

Modifier and TypeField and Description
public static final MethodHandle
public static final MethodHandle
public static final Cleaner
public static final int
MAX_BUFFER_SIZE

The maximum buffer size we support is the maximum array length generally supported by JVMs, because on-heap buffers will be backed by byte-arrays.

public static final LongAdder
public static final Drop<Buffer>
public static final InternalBufferUtils.UncheckedLoadByte

Method Summary

Modifier and TypeMethod and Description
public static <T> T
public static IllegalStateException
public static void
assertValidBufferSize(long
The size to check.
size
)

Check the given size argument is a valid buffer size, or throw an IllegalArgumentException.

public static <E extends Throwable> E
attachTrace(ResourceSupport<?, ?> obj, E throwable)

public static void
bbput(ByteBuffer dest, int destPos, ByteBuffer src, int srcPos, int length)

The ByteBuffer put-buffer-with-offset-and-length method is not available in Java 11.

private static void
bbputFallback(ByteBuffer dest, int destPos, ByteBuffer src, int srcPos, int length)

private static void
bbputJdk16(ByteBuffer dest, int destPos, ByteBuffer src, int srcPos, int length)

public static ByteBuffer
bbslice(ByteBuffer buffer, int fromOffset, int length)

The ByteBuffer slice-with-offset-and-length method is only available from Java 13 and onwards, but we need to support Java 11.

private static ByteBuffer
bbsliceFallback(ByteBuffer buffer, int fromOffset, int length)

private static ByteBuffer
bbsliceJdk13(ByteBuffer buffer, int fromOffset, int length)

public static BufferClosedException
public static BufferReadOnlyException
public static int
private static int
bytesBeforeInnerNonPeriodic(Buffer haystack, InternalBufferUtils.UncheckedLoadByte hl, Buffer needle, InternalBufferUtils.UncheckedLoadByte nl, int haystackLen, int needleLen, int needleStart, int haystackStart, int maxSuffix)

private static int
bytesBeforeInnerPeriodic(Buffer haystack, InternalBufferUtils.UncheckedLoadByte hl, Buffer needle, InternalBufferUtils.UncheckedLoadByte nl, int haystackLen, int needleLen, int needleStart, int haystackStart, int maxSuffix, int period)

public static void
checkImplicitCapacity(int implicitCapacity, int currentCapacity)

public static void
checkLength(int length)

public static <T, R> Drop<R>
convert(Drop<T> drop)

public static CharSequence
copyToCharSequence(Buffer source, int srcIdx, int length, Charset charset)

public static void
copyToViaReverseLoop(Buffer src, int srcPos, Buffer dest, int destPos, int length)

public static int
public static boolean
equals(Buffer bufferA, Buffer bufferB)

public static boolean
equals(Buffer a, int aStartIndex, Buffer b, int bStartIndex, int length)

private static boolean
equalsInner(Buffer a, int aStartIndex, Buffer b, int bStartIndex, int length)

public static VarHandle
findVarHandle(MethodHandles.Lookup lookup, Class<?> recv, String name, Class<?> type)

public static MethodHandle
public static MethodHandle
public static int
hashCode(Buffer buffer)

public static boolean
private static long
maxFixes(Buffer needle, InternalBufferUtils.UncheckedLoadByte nl, int needleLen, int start, boolean isSuffix)

public static long
public static long

Returns:

An offsetted native address, or zero if no native address was available.
nativeAddressWithOffset
(long
The native address, or zero if no native address is available.
address
,
int
The offset into the native address we wish to compute.
offset
)

Compute an offset into a native address.

public static CharSequence
readCharSequence(Buffer source, int length, Charset charset)

public static void
setMemory(ByteBuffer buffer, int length, byte value)

public static Function<Drop<Buffer>, Drop<Buffer>>
public static String
toString(Buffer source, Charset charset)

public static ByteBuffer
public static void
unsafeSetDrop(ResourceSupport<?, ?> obj, Drop<?> replacement)

public static void
writeCharSequence(CharSequence source, Buffer destination, Charset charset)

Field Detail

BB_PUT_OFFSETSback to summary
public static final MethodHandle BB_PUT_OFFSETS
BB_SLICE_OFFSETSback to summary
public static final MethodHandle BB_SLICE_OFFSETS
CLEANERback to summary
public static final Cleaner CLEANER
MAX_BUFFER_SIZEback to summary
public static final int MAX_BUFFER_SIZE

The maximum buffer size we support is the maximum array length generally supported by JVMs, because on-heap buffers will be backed by byte-arrays.

MEM_USAGE_NATIVEback to summary
public static final LongAdder MEM_USAGE_NATIVE
NO_OP_DROPback to summary
public static final Drop<Buffer> NO_OP_DROP
UNCHECKED_LOAD_BYTE_BUFFERback to summary
public static final InternalBufferUtils.UncheckedLoadByte UNCHECKED_LOAD_BYTE_BUFFER

Method Detail

acquireback to summary
public static <T> T acquire(ResourceSupport<?, ?> obj)
allocatorClosedExceptionback to summary
public static IllegalStateException allocatorClosedException()
assertValidBufferSizeback to summary
public static void assertValidBufferSize(long size)

Check the given size argument is a valid buffer size, or throw an IllegalArgumentException.

Parameters
size:long

The size to check.

Exceptions
IllegalArgumentException:
if the size is not positive, or if the size is too big (over ~2 GB) for a buffer to accommodate.
attachTraceback to summary
public static <E extends Throwable> E attachTrace(ResourceSupport<?, ?> obj, E throwable)
bbputback to summary
public static void bbput(ByteBuffer dest, int destPos, ByteBuffer src, int srcPos, int length)

The ByteBuffer put-buffer-with-offset-and-length method is not available in Java 11.

bbputFallbackback to summary
private static void bbputFallback(ByteBuffer dest, int destPos, ByteBuffer src, int srcPos, int length)
bbputJdk16back to summary
private static void bbputJdk16(ByteBuffer dest, int destPos, ByteBuffer src, int srcPos, int length)
bbsliceback to summary
public static ByteBuffer bbslice(ByteBuffer buffer, int fromOffset, int length)

The ByteBuffer slice-with-offset-and-length method is only available from Java 13 and onwards, but we need to support Java 11.

bbsliceFallbackback to summary
private static ByteBuffer bbsliceFallback(ByteBuffer buffer, int fromOffset, int length)
bbsliceJdk13back to summary
private static ByteBuffer bbsliceJdk13(ByteBuffer buffer, int fromOffset, int length)
bufferIsClosedback to summary
public static BufferClosedException bufferIsClosed(Buffer buffer)
bufferIsReadOnlyback to summary
public static BufferReadOnlyException bufferIsReadOnly(Buffer buffer)
bytesBeforeback to summary
public static int bytesBefore(Buffer haystack, InternalBufferUtils.UncheckedLoadByte hl, Buffer needle, InternalBufferUtils.UncheckedLoadByte nl)
bytesBeforeInnerNonPeriodicback to summary
private static int bytesBeforeInnerNonPeriodic(Buffer haystack, InternalBufferUtils.UncheckedLoadByte hl, Buffer needle, InternalBufferUtils.UncheckedLoadByte nl, int haystackLen, int needleLen, int needleStart, int haystackStart, int maxSuffix)
bytesBeforeInnerPeriodicback to summary
private static int bytesBeforeInnerPeriodic(Buffer haystack, InternalBufferUtils.UncheckedLoadByte hl, Buffer needle, InternalBufferUtils.UncheckedLoadByte nl, int haystackLen, int needleLen, int needleStart, int haystackStart, int maxSuffix, int period)
checkImplicitCapacityback to summary
public static void checkImplicitCapacity(int implicitCapacity, int currentCapacity)
checkLengthback to summary
public static void checkLength(int length)
convertback to summary
public static <T, R> Drop<R> convert(Drop<T> drop)
Annotations
@SuppressWarnings:unchecked
copyToCharSequenceback to summary
public static CharSequence copyToCharSequence(Buffer source, int srcIdx, int length, Charset charset)
copyToViaReverseLoopback to summary
public static void copyToViaReverseLoop(Buffer src, int srcPos, Buffer dest, int destPos, int length)
countBorrowsback to summary
public static int countBorrows(ResourceSupport<?, ?> obj)
equalsback to summary
public static boolean equals(Buffer bufferA, Buffer bufferB)
equalsback to summary
public static boolean equals(Buffer a, int aStartIndex, Buffer b, int bStartIndex, int length)
equalsInnerback to summary
private static boolean equalsInner(Buffer a, int aStartIndex, Buffer b, int bStartIndex, int length)
findVarHandleback to summary
public static VarHandle findVarHandle(MethodHandles.Lookup lookup, Class<?> recv, String name, Class<?> type)
getByteBufferPutOffsetsMethodHandleback to summary
public static MethodHandle getByteBufferPutOffsetsMethodHandle()
Annotations
@SuppressWarnings:JavaLangInvokeHandleSignature
getByteBufferSliceOffsetsMethodHandleback to summary
public static MethodHandle getByteBufferSliceOffsetsMethodHandle()
hashCodeback to summary
public static int hashCode(Buffer buffer)
isOwnedback to summary
public static boolean isOwned(ResourceSupport<?, ?> obj)
maxFixesback to summary
private static long maxFixes(Buffer needle, InternalBufferUtils.UncheckedLoadByte nl, int needleLen, int start, boolean isSuffix)
nativeAddressOfDirectByteBufferback to summary
public static long nativeAddressOfDirectByteBuffer(ByteBuffer byteBuffer)
nativeAddressWithOffsetback to summary
public static long nativeAddressWithOffset(long address, int offset)

Compute an offset into a native address. Zero is used as a marker for when a native address is not available, and an offset into a zero address will remain zero.

Parameters
address:long

The native address, or zero if no native address is available.

offset:int

The offset into the native address we wish to compute.

Returns:long

An offsetted native address, or zero if no native address was available.

readCharSequenceback to summary
public static CharSequence readCharSequence(Buffer source, int length, Charset charset)
setMemoryback to summary
public static void setMemory(ByteBuffer buffer, int length, byte value)
standardDropback to summary
public static Function<Drop<Buffer>, Drop<Buffer>> standardDrop(MemoryManager manager)
toStringback to summary
public static String toString(Buffer source, Charset charset)
tryGetWritableBufferFromReadableComponentback to summary
public static ByteBuffer tryGetWritableBufferFromReadableComponent(BufferComponent component)
unsafeSetDropback to summary
public static void unsafeSetDrop(ResourceSupport<?, ?> obj, Drop<?> replacement)
Annotations
@SuppressWarnings:unchecked, rawtypes
writeCharSequenceback to summary
public static void writeCharSequence(CharSequence source, Buffer destination, Charset charset)
io.netty5.buffer.internal back to summary

public Interface InternalBufferUtils.UncheckedLoadByte


This interface provides the fastest possible offsetted byte-access to a buffer. Used by bytesBefore(Buffer, UncheckedLoadByte, Buffer, UncheckedLoadByte) to access memory faster.

Method Summary

Modifier and TypeMethod and Description
public byte
load(Buffer buffer, int offset)

Method Detail

loadback to summary
public byte load(Buffer buffer, int offset)