public class IOBuffer extends Object implements UtlPool.Item<IOBuffer>
An IOBuffer is a poolable, native ByteBuffer. It serves as the unit for IO
(network or otherwise).
An IOBuffer maintains the following markers:
- Capacity
- Length
When an IO buffer is created, it allocates a ByteBuffer from an appropriate
pool. The capacity of the underlying byte buffer is the requested of the IO buffer
rounded up to the nearest fixed length memory slab. The capacity of an IO buffer is
always equal to the capacity of its underlying ByteBuffer. The length of an
IO buffer is initially set to requested length of a newly created IO buffer and only
changed by ensureCapacity(com.neeve.io.IOBuffer, int, boolean) if the space between length and capacity can
be used to satisfy the increase in requested capacity.
While the underlying ByteBuffer has not been taken by the user,
the markers of the byte buffer honor the following contract:
- position is always equal to 0
- limit is always eqaual to the IO buffer length
- capacity is always eaual to the initial length of the IO buffer rounded up
to the nearest multiple of 2.
There are circumstances when one needs direct access to the ByteBuffer
that underlies the IOBuffer. The usage pattern, in such a situation,
is to take the byte buffer from the IO buffer, use the buffer and then
release the buffer back to the IO buffer. Take is accomplished
via takeBuffer() and release is accomplished via releaseBuffer().
While the byte buffer is taken by the caller, a IOBuffer considers
its underlying ByteBuffer to be owned by the caller and any method implemented by
IOBuffer that returns the underlying ByteBuffer
(e.g. getBufferUnsafe()) or updates the markers of the underlying ByteBuffer
byte buffer (e.g. ensureCapacity(IOBuffer, int, boolean)) will throw
an exception. The caller who has taken a byte buffer from an IO buffer is free to
update the markers of the buffer while the buffer is taken. Once released, the byte
buffers markers will be restored to honor the above describe marker contract.
ByteBuffer is being read
concurrently by multiple threads using methods using methods that utilize the
getTo methods which don't mutate the underlying buffer pointers.| Modifier and Type | Class and Description |
|---|---|
static class |
IOBuffer.ParsedCount
Used to store the number of bytes parsed during a deserialization process
|
static class |
IOBuffer.VarintDeserializeLength
Used to store the number of bytes deserialized by a varint get
|
| Modifier and Type | Method and Description |
|---|---|
IOBuffer |
acquire()
Acquire a reference to an IO buffer
This method increments an IO buffer's ownership count.
|
static ByteBuffer |
allocateByteBuffer(int capacity,
boolean direct)
Allocate a byte buffer
|
static long |
allocateMemoryBlock(long length)
Allocate a block of memory
|
static long |
allocateMemoryBlock(long length,
boolean zeroout)
Allocate a block of memory
|
static int |
calcLongAsASCIICharSequenceLength(long val)
Get serialized length of a long value as an ASCII sequence
|
static int |
calculateUTF8Length(char c)
Calculate the length of the character encoded as UTF-8.
|
static int |
calculateUTF8Length(CharSequence str)
Calculate the length of the character sequence encoded as UTF-8.
|
IOBuffer |
copy()
Creates a copy of this IOBuffer.
|
static void |
copy(long src,
int srcoff,
long dest,
int destoff,
int len)
Copy the contents of one memory region to another
|
static IOBuffer |
create(int length)
Create a new IO buffer
|
static IOBuffer |
createNative(int length)
Deprecated.
|
void |
dispose()
Dispose off an IO buffer
This method is equivalent to
dispose(this.highwater) |
void |
dispose(int highwater)
Dispose of an IO buffer.
|
static String |
dump(long addr,
int offset,
int len)
Dump the contents of a memory region.
|
static IOBuffer |
ensureCapacity(IOBuffer buffer,
int val,
boolean initFromExisting)
Ensure an IO buffer has enough capacity
|
static long |
ensureMemoryBlockCapacity(long addr,
long length,
int newlength)
Ensure a memory block has enough capacity
|
static long |
ensureMemoryBlockCapacity(long addr,
long length,
int newlength,
boolean zeroout)
Ensure a memory block has enough capacity
|
static void |
freeMemoryBlock(long addr,
int length)
Free a native block of memory
|
char |
getASCIIChar(int offset)
Deserialize a char value from an IO buffer serialized using ASCII encoding
|
static char |
getASCIIChar(long addr,
int offset)
Deserialize a char value seerialized as an ASCII char from a specific memory location
|
String |
getASCIICharSequence(int offset,
int len)
Deserialize a character sequence from an IO buffer serialized using ASCII encoding
|
static String |
getASCIICharSequence(long addr,
int offset,
int len)
Deserialize a character sequence encoded as ASCII at a specific memory location as a string value
|
ByteBuffer |
getBuffer()
Deprecated.
This method has been deprecated in favor of
takeBuffer()
and releaseBuffer() |
ByteBuffer |
getBufferUnsafe()
Get the raw underlying byte buffer underlying an IO buffer.
|
byte |
getByte(int offset)
Deserialize a byte value from an IO buffer
|
static byte |
getByte(long addr,
int offset)
Deserialize a byte value from a specific memory location
|
static ByteOrder |
getByteOrder()
Get the byte order of the created IO buffers
By default, data written by IO buffers are encoded using the little
endian format.
|
int |
getCapacity()
Get the buffer capacity
|
char |
getChar(int offset)
Deserialize a char value from an IO buffer
|
static char |
getChar(long addr,
int offset)
Deserialize a char value from a specific memory location
|
double |
getDouble(int offset)
Deserialize a double value from an IO buffer
|
static double |
getDouble(long addr,
int offset)
Deserialize a double value from a specific memory location
|
double |
getDoubleFromASCIICharSequence(int offset)
Deserialize a double value from an IO buffer serialized as an ASCII sequence
|
static double |
getDoubleFromASCIICharSequence(long addr,
int offset,
char terminationMarker,
int limit,
IOBuffer.ParsedCount parsedCount)
Deserialize a double value serialized as an ASCII sequence at a specific memory location
|
float |
getFloat(int offset)
Deserialize a float value from an IO buffer
|
static float |
getFloat(long addr,
int offset)
Deserialize a float value from a specific memory location
|
int |
getInt(int offset)
Deserialize an int value from an IO buffer
|
static int |
getInt(long addr,
int offset)
Deserialize an integer value from a specific memory location
|
IOBuffer |
getIOBuffer()
Deprecated.
|
int |
getLength()
Get the buffer length
|
long |
getLong(int offset)
Deserialize a long value from an IO buffer
|
static long |
getLong(long addr,
int offset)
Deserialize an long value from a specific memory location
|
long |
getLongFromASCIICharSequence(int offset,
char terminationMarker,
int limit,
IOBuffer.ParsedCount parsedCount)
Get a long value serialized as an ASCII sequence
|
static long |
getLongFromASCIICharSequence(long addr,
int offset,
char terminationMarker,
int limit,
IOBuffer.ParsedCount parsedCount)
Deserialize a long value serialized as an ASCII sequence at a specific memory location
|
long |
getNativeAddress()
Get the native address of the buffer's underlying storage
|
int |
getOwnerCount()
Get an IO buffer's ownership count.
|
UtlPool<IOBuffer> |
getPool()
Implementation of UtlPool.Item#getPool.
|
short |
getShort(int offset)
Deserialize a short value from an IO buffer
|
static short |
getShort(long addr,
int offset)
Deserialize a short value from a specific memory location
|
void |
getTo(int offset,
byte[] array,
int arrayoffset,
int numelem)
Deserialize a section of a byte array from an IO buffer
|
void |
getTo(int offset,
ByteBuffer dest,
int len)
Copy the data from an IO buffer to a ByteBuffer
|
void |
getTo(int offset,
ByteBuffer dest,
int bufferOffset,
int len)
Copy the data from an IO buffer to a ByteBuffer
|
void |
getTo(int offset,
char[] array,
int arrayoffset,
int numelem)
Deserialize a section of a char array from an IO buffer
|
void |
getTo(int offset,
double[] array,
int arrayoffset,
int numelem)
Deserialize a section of a double array from an IO buffer
|
void |
getTo(int offset,
float[] array,
int arrayoffset,
int numelem)
Deserialize a section of a float array from an IO buffer
|
void |
getTo(int offset,
int[] array,
int arrayoffset,
int numelem)
Deserialize a section of a int array from an IO buffer
|
void |
getTo(int offset,
IOBuffer dest,
int destoff,
int len)
Copy the contents of a section of an IO buffer to another IO buffer
|
void |
getTo(int offset,
long[] array,
int arrayoffset,
int numelem)
Deserialize a section of a long array from an IO buffer
|
void |
getTo(int offset,
long addr,
int addroffset,
int len)
Copy a section of an IO buffer to a memory region
|
void |
getTo(int offset,
short[] array,
int arrayoffset,
int numelem)
Deserialize a section of a short array from an IO buffer
|
static void |
getTo(long addr,
int offset,
byte[] array,
int arrayoffset,
int numelem)
Deserialize a section of a byte array from a specific memory location
|
static void |
getTo(long addr,
int offset,
ByteBuffer buffer,
int len)
Deserialize a section of a ByteBuffer from a specific memory location
|
static void |
getTo(long addr,
int offset,
ByteBuffer buffer,
int bufferOffset,
int len)
Deserialize a section of a ByteBuffer from a specific memory location
|
static void |
getTo(long addr,
int offset,
char[] array,
int arrayoffset,
int numelem)
Deserialize a section of a char array from a specific memory location
|
static void |
getTo(long addr,
int offset,
double[] array,
int arrayoffset,
int numelem)
Deserialize a section of a double array from a specific memory location
|
static void |
getTo(long addr,
int offset,
float[] array,
int arrayoffset,
int numelem)
Deserialize a section of a float array from a specific memory location
|
static void |
getTo(long addr,
int offset,
int[] array,
int arrayoffset,
int numelem)
Deserialize a section of an int array from a specific memory location
|
static void |
getTo(long addr,
int offset,
long[] array,
int arrayoffset,
int numelem)
Deserialize a section of a long array from a specific memory location
|
static void |
getTo(long addr,
int offset,
short[] array,
int arrayoffset,
int numelem)
Deserialize a section of a short array from a specific memory location
|
int |
getUnsignedByte(int offset)
Deserialize an unsigned byte value from an IO buffer
|
static int |
getUnsignedByte(long addr,
int offset)
Deserialize an unsigned byte value from a specific memory location
|
long |
getUnsignedInt(int offset)
Deserialize an unsigned int value from an IO buffer
|
static long |
getUnsignedInt(long addr,
int offset)
Deserialize an unsigned integer value from a specific memory location
|
int |
getUnsignedShort(int offset)
Deserialize an unsigned short value from an IO buffer
|
static int |
getUnsignedShort(long addr,
int offset)
Deserialize an unsigned short value from a specific memory location
|
String |
getUTF8CharSequence(int offset,
int len)
Deserialize a character sequence from an IO buffer serialized using UTF-8 encoding
|
static String |
getUTF8CharSequence(long addr,
int offset,
int len)
Deserialize a character sequence encoded as UTF-8 at a specific memory location as a string value
|
int |
getVarint32(int offset,
IOBuffer.VarintDeserializeLength deserializeLength)
Deserialize an int value from an IO buffer serialized as a 32-bit varint
|
static int |
getVarint32(long addr,
int offset,
IOBuffer.VarintDeserializeLength deserializeLength)
Deserialize an integer value serialized as a 32-bit varint from a specific memory location
|
long |
getVarint64(int offset,
IOBuffer.VarintDeserializeLength deserializeLength)
Deserialize a long value from an IO buffer serialized as a 64-bit varint
|
static long |
getVarint64(long addr,
int offset,
IOBuffer.VarintDeserializeLength deserializeLength)
Deserialize a long value serialized as a 64-bit varint from a specific memory location
|
IOBuffer |
init()
Implementation of UtlPool.Item#init.
|
static int |
numSlabs()
Get the number of slabs
|
int |
putASCIIChar(int offset,
char val)
Serialize a char value to an IO buffer using ASCII encoding
|
static int |
putASCIIChar(long addr,
int offset,
char val)
Serialize a char value to a specific memory location encoded as ASCII
|
int |
putASCIICharSequence(int offset,
CharSequence val)
Serialize a character sequence to an IO buffer using ASCII encoding
|
int |
putASCIICharSequence(int offset,
CharSequence val,
int start,
int end)
Serialize a character sequence to an IO buffer using ASCII encoding
|
static int |
putASCIICharSequence(long addr,
int offset,
CharSequence val)
Serialize a character sequence to a specific memory location encoded as ASCII
|
static int |
putASCIICharSequence(long addr,
int offset,
CharSequence val,
int start,
int end)
Serialize an character sequence to a specific memory location encoded as ASCII
|
void |
putByte(int offset,
byte val)
Serialize a byte value to an IO buffer
|
static void |
putByte(long addr,
int offset,
byte val)
Serialize a byte value to a specific memory location
|
void |
putChar(int offset,
char val)
Serialize a char value to an IO buffer
|
static void |
putChar(long addr,
int offset,
char val)
Serialize a char value to a specific memory location
|
void |
putDouble(int offset,
double val)
Serialize a double value to an IO buffer
|
static void |
putDouble(long addr,
int offset,
double val)
Serialize a double value to a specific memory location
|
int |
putDoubleAsASCIICharSequence(int offset,
double val,
int precision)
Serialize a double value to an IO buffer as an ASCII character sequence
|
static int |
putDoubleAsASCIICharSequence(long addr,
int offset,
double val,
int precision)
Serialize a double value as an ASCII sequence to a specific memory location
This method invokes
putDoubleAsASCIICharSequence(addr, offset, val, precision, false) |
static int |
putDoubleAsASCIICharSequence(long addr,
int offset,
double val,
int precision,
boolean mock)
Serialize a double value as an ASCII sequence to a specific memory location
|
void |
putFloat(int offset,
float val)
Serialize a float value to an IO buffer
|
static void |
putFloat(long addr,
int offset,
float val)
Serialize a float value to a specific memory location
|
void |
putFrom(int offset,
byte[] array,
int arrayoffset,
int numelem)
Serialize a section of a byte array to an IO buffer
|
void |
putFrom(int offset,
ByteBuffer src)
Copy the data from a ByteBuffer to an IO buffer
|
void |
putFrom(int offset,
ByteBuffer src,
int bufferOffset,
int len)
Copy the data from a ByteBuffer to an IO buffer
|
void |
putFrom(int offset,
char[] array,
int arrayoffset,
int numelem)
Serialize a section of a char array to an IO buffer
|
void |
putFrom(int offset,
double[] array,
int arrayoffset,
int numelem)
Serialize a section of a double array to an IO buffer
|
void |
putFrom(int offset,
float[] array,
int arrayoffset,
int numelem)
Serialize a section of a float array to an IO buffer
|
void |
putFrom(int offset,
int[] array,
int arrayoffset,
int numelem)
Serialize a section of a int array to an IO buffer
|
void |
putFrom(int offset,
IOBuffer src,
int srcoff,
int len)
Copy the contents of a section of an IO buffer to another IO buffer
|
void |
putFrom(int offset,
long[] array,
int arrayoffset,
int numelem)
Serialize a section of a long array to an IO buffer
|
void |
putFrom(int offset,
long addr,
int addroffset,
int len)
Copy a section of a memory region to an IO buffer
|
void |
putFrom(int offset,
short[] array,
int arrayoffset,
int numelem)
Serialize a section of a short array to an IO buffer
|
static void |
putFrom(long addr,
int offset,
byte[] array,
int arrayoffset,
int numelem)
Serialize a section of a byte array to a specific memory location
|
static void |
putFrom(long addr,
int offset,
ByteBuffer buffer)
Serialize a section of a ByteBuffer to a specific memory location
|
static void |
putFrom(long addr,
int offset,
ByteBuffer buffer,
int bufferOffset,
int len)
Serialize a section of a ByteBuffer to a specific memory location
|
static void |
putFrom(long addr,
int offset,
char[] array,
int arrayoffset,
int numelem)
Serialize a section of a char array to a specific memory location
|
static void |
putFrom(long addr,
int offset,
double[] array,
int arrayoffset,
int numelem)
Serialize a section of a double array to a specific memory location
|
static void |
putFrom(long addr,
int offset,
float[] array,
int arrayoffset,
int numelem)
Serialize a section of a float array to a specific memory location
|
static void |
putFrom(long addr,
int offset,
int[] array,
int arrayoffset,
int numelem)
Serialize a section of an integer array to a specific memory location
|
static void |
putFrom(long addr,
int offset,
long[] array,
int arrayoffset,
int numelem)
Serialize a section of a long array to a specific memory location
|
static void |
putFrom(long addr,
int offset,
short[] array,
int arrayoffset,
int numelem)
Serialize a section of a short array to a specific memory location
|
void |
putInt(int offset,
int val)
Serialize an int value to an IO buffer
|
static void |
putInt(long addr,
int offset,
int val)
Serialize an integer value to a specific memory location
|
void |
putLong(int offset,
long val)
Serialize a long value to an IO buffer
|
static void |
putLong(long addr,
int offset,
long val)
Serialize an long value to a specific memory location
|
int |
putLongAsASCIICharSequence(int offset,
long val)
Serialize a long value to an IO buffer as an ASCII character sequence
|
static int |
putLongAsASCIICharSequence(long addr,
int offset,
long val)
Serialize an long value as an ASCII sequence to a specific memory location
This method invokes
putLongAsASCIICharSequence(addr, offset, val, false) |
static int |
putLongAsASCIICharSequence(long addr,
int offset,
long val,
boolean mock)
Serialize an long value as an ASCII sequence to a specific memory location
|
void |
putShort(int offset,
short val)
Serialize a short value to an IO buffer
|
static void |
putShort(long addr,
int offset,
short val)
Serialize a short value to a specific memory location
|
int |
putUTF8Char(int offset,
char val)
Serialize a char value to an IO buffer using UTF8 encoding
|
static int |
putUTF8Char(long addr,
int offset,
char val)
Serialize a char value to a specific memory location encoded as UTF-8
|
int |
putUTF8CharSequence(int offset,
CharSequence val)
Serialize a character sequence to an IO buffer using UTF-8 encoding
|
int |
putUTF8CharSequence(int offset,
CharSequence val,
int start,
int end)
Serialize a character sequence to an IO buffer using UTF-8 encoding
|
int |
putUTF8CharSequence(int offset,
CharSequence val,
int utflen,
int start,
int end)
Serialize a character sequence to an IO buffer using UTF-8 encoding
|
static int |
putUTF8CharSequence(long addr,
int offset,
CharSequence val)
Serialize a character sequence to a specific memory location encoded as UTF-8
|
static int |
putUTF8CharSequence(long addr,
int offset,
CharSequence val,
int start,
int end)
Serialize a character sequence to a specific memory location encoded as UTF-8
|
void |
putVarint32(int offset,
int val)
Serialize an int value to an IO buffer as a 32-bit varint
|
static int |
putVarint32(long addr,
int offset,
int val)
Serialize an integer value as a 32-bit varint to a specific memory location
|
void |
putVarint64(int offset,
long val)
Serialize a long value to an IO buffer as a 64-bit varint
|
static int |
putVarint64(long addr,
int offset,
long val)
Serialize a long value as a 64-bit varint to a specific memory location
|
IOBuffer |
releaseBuffer()
Release an IO buffer's underlying buffer previously taken via
takeBuffer() |
IOBuffer |
setNoWipe()
Set to not wipe an IO buffer on dispose
By default, an IO buffer is wiped clean when disposed.
|
IOBuffer |
setPool(UtlPool<IOBuffer> pool)
Implementation of UtlPool.Item#setPool.
|
static int |
slab(int val)
Get the slab number for a buffer length
When an IO buffer is allocated, what is returned is actually a fixed length
buffer from a particular fixed length buffer slab (the system maintains a
certain number of slabs with each slab holding fixed length buffer of a
particular size).
|
static int |
slabSize(int val)
Get the slab size for a buffer length
This method returns the actual size (capacity) of the buffer that would be
returned for an allocation request of a particular size i.e. this method
returns the size of slab that a request buffer length would resolve to
|
static int |
smallestSlabSize()
Get the smallest slab size
|
ByteBuffer |
takeBuffer()
Take an IO buffer's underlying byte buffer
This method temporarily transfers ownership of an IO buffer's
underlying byte buffer to the caller.
|
String |
toString()
Return a string representation of a buffer
|
static int |
varint32SerializedLength(int val)
Return the serialized length of a 32-bit value serialized as a varint
|
static int |
varint64SerializedLength(long val)
Return the serialized length of a 64-bit value serialized as a varint
|
static void |
wipe(long addr,
int addroff,
int len)
Wipe a section of a memory region
|
static IOBuffer |
wrap(ByteBuffer buffer)
Create an IO buffer wrapped around a byte buffer
|
static ByteBuffer |
wrapByteBuffer(byte[] array)
Wrap a byte buffer
|
static ByteBuffer |
wrapByteBuffer(byte[] array,
int offset,
int length)
Wrap a byte buffer
|
public static IOBuffer create(int length)
length - The length of the buffer to create.@Deprecated public static IOBuffer createNative(int length)
Invoking this method is the same as invoking create(length).
public static IOBuffer wrap(ByteBuffer buffer)
buffer - The byte buffer to wrap aroundpublic static final ByteBuffer allocateByteBuffer(int capacity, boolean direct)
capacity - The buffer capacitydirect - Whether the allocated byte buffer is direct or not
This method allocates a new byte buffer with the same endianness of buffers that back IO buffers
public static final ByteBuffer wrapByteBuffer(byte[] array, int offset, int length)
array - The array to wrap the buffer aroundoffset - The offset into the array from where to wraplength - The length to wrap
This method allocates a new byte buffer wrapped around an array with the same endianness of buffers that back IO buffers
public static final ByteBuffer wrapByteBuffer(byte[] array)
array - The array to wrap the buffer around
This method invokes wrapByteBuffer(array, 0, array.length)
public static final ByteOrder getByteOrder()
By default, data written by IO buffers are encoded using the little endian format. However, setting nv.compat.3x.io changes the default to big endian. The byte order to use can also be set using the nv.io.byteorder configuration parameter. However, this should be done VERY carefully and done across all participants exchanging messages or sharing stored data.
public static final IOBuffer ensureCapacity(IOBuffer buffer, int val, boolean initFromExisting)
buffer - The buffer to check. Can be null in which case this
method creates and returns a new IO bufferval - Minimum length the buffer needs to have.initFromExisting - Indicates whether a new buffer, if created,
should be initialized from the existing buffer or not.
This method checks to see if a supplied IO buffer has enough capacity. The supplied buffer can be null in which case a new buffer of length equal to supplied length is created and returned. If a non-null buffer is supplied, the this method checks if the buffer capacity is large enough to accommodate the supplied length. If so, it adjusts the buffer length to supplied length and returns the supplied buffer. Otherwise, it creates a new buffer, initializes the buffer from the existing buffer, disposes the old buffer and returns the new buffer
public static final int slab(int val)
When an IO buffer is allocated, what is returned is actually a fixed length buffer from a particular fixed length buffer slab (the system maintains a certain number of slabs with each slab holding fixed length buffer of a particular size). This method returns the number of the slab from where the buffer would be returned for a particular allocation length
val - The buffer lengthpublic static final int slabSize(int val)
This method returns the actual size (capacity) of the buffer that would be returned for an allocation request of a particular size i.e. this method returns the size of slab that a request buffer length would resolve to
val - The buffer lengthpublic static final int smallestSlabSize()
public static final int numSlabs()
public static final long allocateMemoryBlock(long length,
boolean zeroout)
length - The length of the block of memory to allocatezeroout - Indicates whether the allocated block should be zeroed outpublic static final long allocateMemoryBlock(long length)
length - The length of the block of memory to allocate
This method invokes allocateMemoryBlock(length, true)
public static final long ensureMemoryBlockCapacity(long addr,
long length,
int newlength,
boolean zeroout)
addr - The pointer to the current block of memory whose capacity needs to be ensuredlength - The length the current memory blocknewlength - The length the memory block needs to bezeroout - Indicates whether the newly allocated portion of the memory should be zeroed outpublic static final long ensureMemoryBlockCapacity(long addr,
long length,
int newlength)
addr - The pointer to the current block of memory whose capacity needs to be ensuredlength - The length the current memory blocknewlength - The length the memory block needs to be
This method invokes ensureMemoryBlockCapacity(addr, length, newlength, true)
public static final void freeMemoryBlock(long addr,
int length)
public static final int calculateUTF8Length(char c)
c - The character whose UTF-8 length to calculate.public static final int calculateUTF8Length(CharSequence str)
str - The str whose UTF-8 length to calculate.public static final void putByte(long addr,
int offset,
byte val)
addr - The native address of the memory region in which to serialize the valueoffset - The offset, relative to starting address of the specified memory region, at which to serialize the valueval - The byte value to serializepublic static final byte getByte(long addr,
int offset)
addr - The native address of the memory region from where to deserialize the valueoffset - The offset, relative to starting address of the specified memory region, from where to deserialize the valuepublic static final int getUnsignedByte(long addr,
int offset)
addr - The native address of the memory region from where to deserialize the valueoffset - The offset, relative to starting address of the specified memory region, from where to deserialize the valuepublic static final void putShort(long addr,
int offset,
short val)
addr - The native address of the memory region in which to serialize the valueoffset - The offset, relative to starting address of the specified memory region, at which to serialize the valueval - The short value to serializepublic static final short getShort(long addr,
int offset)
addr - The native address of the memory region from where to deserialize the valueoffset - The offset, relative to starting address of the specified memory region, from where to deserialize the valuepublic static final int getUnsignedShort(long addr,
int offset)
addr - The native address of the memory region from where to deserialize the valueoffset - The offset, relative to starting address of the specified memory region, from where to deserialize the valuepublic static final void putChar(long addr,
int offset,
char val)
addr - The native address of the memory region in which to serialize the valueoffset - The offset, relative to starting address of the specified memory region, at which to serialize the valueval - The char value to serializepublic static final int putASCIIChar(long addr,
int offset,
char val)
addr - The native address of the memory region in which to serialize the valueoffset - The offset, relative to starting address of the specified memory region, at which to serialize the valueval - The char value to serializepublic static final int putUTF8Char(long addr,
int offset,
char val)
addr - The native address of the memory region in which to serialize the valueoffset - The offset, relative to starting address of the specified memory region, at which to serialize the valueval - The char value to serializeIllegalArgumentException - if the supplied character is part of a surrogate pairpublic static final char getChar(long addr,
int offset)
addr - The native address of the memory region from where to deserialize the valueoffset - The offset, relative to starting address of the specified memory region, from where to deserialize the valuepublic static final char getASCIIChar(long addr,
int offset)
addr - The native address of the memory region from where to deserialize the valueoffset - The offset, relative to starting address of the specified memory region, from where to deserialize the valuepublic static final void putInt(long addr,
int offset,
int val)
addr - The native address of the memory region in which to serialize the valueoffset - The offset, relative to starting address of the specified memory region, at which to serialize the valueval - The integer value to serializepublic static final int getInt(long addr,
int offset)
addr - The native address of the memory region from where to deserialize the valueoffset - The offset, relative to starting address of the specified memory region, from where to deserialize the valuepublic static final long getUnsignedInt(long addr,
int offset)
addr - The native address of the memory region from where to deserialize the valueoffset - The offset, relative to starting address of the specified memory region, from where to deserialize the valuepublic static final void putFloat(long addr,
int offset,
float val)
addr - The native address of the memory region in which to serialize the valueoffset - The offset, relative to starting address of the specified memory region, at which to serialize the valueval - The float value to serializepublic static final float getFloat(long addr,
int offset)
addr - The native address of the memory region from where to deserialize the valueoffset - The offset, relative to starting address of the specified memory region, from where to deserialize the valuepublic static final void putLong(long addr,
int offset,
long val)
addr - The native address of the memory region in which to serialize the valueoffset - The offset, relative to starting address of the specified memory region, at which to serialize the valueval - The long value to serializepublic static final int calcLongAsASCIICharSequenceLength(long val)
val - The long value to serializepublic static final int putLongAsASCIICharSequence(long addr,
int offset,
long val,
boolean mock)
addr - The native address of the memory region in which to serialize the value. This parameter is ignored
if mock is set to trueoffset - The offset, relative to starting address of the specified memory region, at which to serialize
the value. This parameter is ignored if mock is set to trueval - The long value to serializemock - Perform a mock put i.e. do not actually add any data. This parameter should be
set to true if the method is needed to determine the length of the serialized form of valpublic static final int putLongAsASCIICharSequence(long addr,
int offset,
long val)
putLongAsASCIICharSequence(addr, offset, val, false)public static final long getLong(long addr,
int offset)
addr - The native address of the memory region from where to deserialize the valueoffset - The offset, relative to starting address of the specified memory region, from where to deserialize the valuepublic static final long getLongFromASCIICharSequence(long addr,
int offset,
char terminationMarker,
int limit,
IOBuffer.ParsedCount parsedCount)
addr - The native address of the memory region from where to deserialize the valueoffset - The offset, relative to starting address of the specified memory region, from where to deserialize the valueterminationMarker - The marker character that terminates where the long value endslimit - The position at which the memory region becomes invalidpublic static final void putDouble(long addr,
int offset,
double val)
addr - The native address of the memory region in which to serialize the valueoffset - The offset, relative to starting address of the specified memory region, at which to serialize the valueval - The double value to serializepublic static final int putDoubleAsASCIICharSequence(long addr,
int offset,
double val,
int precision,
boolean mock)
addr - The native address of the memory region in which to serialize the value. This parameter
is ignored if mock is set to trueoffset - The offset, relative to starting address of the specified memory region, at which to
serialize the value. This parameter is ignored if mock is set to trueval - The double value to serializeprecision - The double value precisionmock - Perform a mock put i.e. do not actually add any data. This parameter should be
set to true if the method is needed to determine the length of the serialized form of valpublic static final int putDoubleAsASCIICharSequence(long addr,
int offset,
double val,
int precision)
putDoubleAsASCIICharSequence(addr, offset, val, precision, false)public static final double getDouble(long addr,
int offset)
addr - The native address of the memory region from where to deserialize the valueoffset - The offset, relative to starting address of the specified memory region, from where to deserialize the valuepublic static final double getDoubleFromASCIICharSequence(long addr,
int offset,
char terminationMarker,
int limit,
IOBuffer.ParsedCount parsedCount)
addr - The native address of the memory region from where to deserialize the valueoffset - The offset, relative to starting address of the specified memory region, from where to deserialize the valueterminationMarker - The marker character that terminates where the long value endslimit - The position at which the memory region becomes invalidpublic static final int putASCIICharSequence(long addr,
int offset,
CharSequence val,
int start,
int end)
addr - The native address of the memory region in which to serialize the sequenceoffset - The offset, relative to starting address of the specified memory region, at which to serialize the sequenceval - The character sequence to serializestart - The first position in the character sequence to serializeend - The position in the character sequence to end serialization (this position is not serialized)public static final int putASCIICharSequence(long addr,
int offset,
CharSequence val)
addr - The native address of the memory region in which to serialize the sequenceoffset - The offset, relative to starting address of the specified memory region, at which to serialize the sequenceval - The character sequence to serializepublic static final String getASCIICharSequence(long addr, int offset, int len)
addr - The native address of the memory region from where to deserialize the valueoffset - The offset, relative to starting address of the specified memory region, from where to deserialize the valuelen - The length of the stringpublic static final int putUTF8CharSequence(long addr,
int offset,
CharSequence val,
int start,
int end)
addr - The native address of the memory region in which to serialize the sequenceoffset - The offset, relative to starting address of the specified memory region, at which to serialize the sequenceval - The character sequence to serializestart - The first position in the character sequence to serializeend - The position in the character sequence to end serialization (this position is not serialized)public static final int putUTF8CharSequence(long addr,
int offset,
CharSequence val)
addr - The native address of the memory region in which to serialize the sequenceoffset - The offset, relative to starting address of the specified memory region, at which to serialize the sequenceval - The character sequence to serializepublic static final String getUTF8CharSequence(long addr, int offset, int len)
addr - The native address of the memory region from where to deserialize the valueoffset - The offset, relative to starting address of the specified memory region, from where to deserialize the valuelen - The length of the stringpublic static final int varint32SerializedLength(int val)
val - The value whose varint serialized length to returnpublic static final int putVarint32(long addr,
int offset,
int val)
addr - The native address of the memory region in which to serialize the valueoffset - The offset, relative to starting address of the specified memory region, at which to serialize the valueval - The integer value to serializepublic static final int getVarint32(long addr,
int offset,
IOBuffer.VarintDeserializeLength deserializeLength)
addr - The native address of the memory region from where to deserialize the valueoffset - The offset, relative to starting address of the specified memory region, from where to deserialize the valuedeserializeLength - The container of the number of bytes deserializedpublic static final int varint64SerializedLength(long val)
val - The value whose varint serialized length to returnpublic static final int putVarint64(long addr,
int offset,
long val)
addr - The native address of the memory region in which to serialize the valueoffset - The offset, relative to starting address of the specified memory region, at which to serialize the valueval - The long value to serializepublic static final long getVarint64(long addr,
int offset,
IOBuffer.VarintDeserializeLength deserializeLength)
addr - The native address of the memory region from where to deserialize the valueoffset - The offset, relative to starting address of the specified memory region, from where to deserialize the valuedeserializeLength - The container of the number of bytes deserializedpublic static final void putFrom(long addr,
int offset,
byte[] array,
int arrayoffset,
int numelem)
addr - The native address of the memory region in which to serialize the valuesoffset - The offset, relative to starting address of the specified memory region, at which to serialize the valuesarray - The array to serializearrayoffset - The offset, into the array, from where to serializenumelem - The number of array elements to serializepublic static final void getTo(long addr,
int offset,
byte[] array,
int arrayoffset,
int numelem)
addr - The native address of the memory region from where to deserialize the valuesoffset - The offset, relative to starting address of the specified memory region, from where to deserialize the valuesarray - The array to deserializearrayoffset - The offset, into the array, to deserialize intonumelem - The number of array elements to deserializepublic static final void putFrom(long addr,
int offset,
short[] array,
int arrayoffset,
int numelem)
addr - The native address of the memory region in which to serialize the valuesoffset - The offset, relative to starting address of the specified memory region, at which to serialize the valuesarray - The array to serializearrayoffset - The offset, into the array, from where to serializenumelem - The number of array elements to serializepublic static final void getTo(long addr,
int offset,
short[] array,
int arrayoffset,
int numelem)
addr - The native address of the memory region from where to deserialize the valuesoffset - The offset, relative to starting address of the specified memory region, from where to deserialize the valuesarray - The array to deserializearrayoffset - The offset, into the array, to deserialize intonumelem - The number of array elements to deserializepublic static final void putFrom(long addr,
int offset,
char[] array,
int arrayoffset,
int numelem)
addr - The native address of the memory region in which to serialize the valuesoffset - The offset, relative to starting address of the specified memory region, at which to serialize the valuesarray - The array to serializearrayoffset - The offset, into the array, from where to serializenumelem - The number of array elements to serializepublic static final void getTo(long addr,
int offset,
char[] array,
int arrayoffset,
int numelem)
addr - The native address of the memory region from where to deserialize the valuesoffset - The offset, relative to starting address of the specified memory region, from where to deserialize the valuesarray - The array to deserializearrayoffset - The offset, into the array, to deserialize intonumelem - The number of array elements to deserializepublic static final void putFrom(long addr,
int offset,
int[] array,
int arrayoffset,
int numelem)
addr - The native address of the memory region in which to serialize the valuesoffset - The offset, relative to starting address of the specified memory region, at which to serialize the valuesarray - The array to serializearrayoffset - The offset, into the array, from where to serializenumelem - The number of array elements to serializepublic static final void getTo(long addr,
int offset,
int[] array,
int arrayoffset,
int numelem)
addr - The native address of the memory region from where to deserialize the valuesoffset - The offset, relative to starting address of the specified memory region, from where to deserialize the valuesarray - The array to deserializearrayoffset - The offset, into the array, to deserialize intonumelem - The number of array elements to deserializepublic static final void putFrom(long addr,
int offset,
float[] array,
int arrayoffset,
int numelem)
addr - The native address of the memory region in which to serialize the valuesoffset - The offset, relative to starting address of the specified memory region, at which to serialize the valuesarray - The array to serializearrayoffset - The offset, into the array, from where to serializenumelem - The number of array elements to serializepublic static final void getTo(long addr,
int offset,
float[] array,
int arrayoffset,
int numelem)
addr - The native address of the memory region from where to deserialize the valuesoffset - The offset, relative to starting address of the specified memory region, from where to deserialize the valuesarray - The array to deserializearrayoffset - The offset, into the array, to deserialize intonumelem - The number of array elements to deserializepublic static final void putFrom(long addr,
int offset,
long[] array,
int arrayoffset,
int numelem)
addr - The native address of the memory region in which to serialize the valuesoffset - The offset, relative to starting address of the specified memory region, at which to serialize the valuesarray - The array to serializearrayoffset - The offset, into the array, from where to serializenumelem - The number of array elements to serializepublic static final void getTo(long addr,
int offset,
long[] array,
int arrayoffset,
int numelem)
addr - The native address of the memory region from where to deserialize the valuesoffset - The offset, relative to starting address of the specified memory region, from where to deserialize the valuesarray - The array to deserializearrayoffset - The offset, into the array, to deserialize intonumelem - The number of array elements to deserializepublic static final void putFrom(long addr,
int offset,
double[] array,
int arrayoffset,
int numelem)
addr - The native address of the memory region in which to serialize the valuesoffset - The offset, relative to starting address of the specified memory region, at which to serialize the valuesarray - The array to serializearrayoffset - The offset, into the array, from where to serializenumelem - The number of array elements to serializepublic static final void getTo(long addr,
int offset,
double[] array,
int arrayoffset,
int numelem)
addr - The native address of the memory region from where to deserialize the valuesoffset - The offset, relative to starting address of the specified memory region, from where to deserialize the valuesarray - The array to deserializearrayoffset - The offset, into the array, to deserialize intonumelem - The number of array elements to deserializepublic static final void putFrom(long addr,
int offset,
ByteBuffer buffer,
int bufferOffset,
int len)
addr - The native address of the memory region in which to serialize the valuesoffset - The offset, relative to starting address of the specified memory region, at which to serialize the valuesbuffer - The ByteBuffer to serialize frombufferOffset - The offset into the byte buffer to serialize fromlen - The number of bytes to serializepublic static final void putFrom(long addr,
int offset,
ByteBuffer buffer)
addr - The native address of the memory region in which to serialize the valuesoffset - The offset, relative to starting address of the specified memory region, at which to serialize the valuesbuffer - The ByteBuffer to serializepublic static final void getTo(long addr,
int offset,
ByteBuffer buffer,
int bufferOffset,
int len)
addr - The native address of the memory region from where to deserialize the valuesoffset - The offset, relative to starting address of the specified memory region, from where to deserialize the valuesbuffer - The ByteBuffer to deserialize intobufferOffset - The offset into the buffer to deserialize tolen - The number of bytes to deserializepublic static final void getTo(long addr,
int offset,
ByteBuffer buffer,
int len)
addr - The native address of the memory region from where to deserialize the valuesoffset - The offset, relative to starting address of the specified memory region, from where to deserialize the valuesbuffer - The ByteBuffer to deserialize intolen - The number of bytes to deserializepublic static final void copy(long src,
int srcoff,
long dest,
int destoff,
int len)
src - The native address of the source memory regionsrcoff - The offset, relative to the starting address of the source memory, from where to copy the datadest - The native address of the destination memory regiondestoff - The offset, relative to starting address of the destination memory region, at which to copy the datalen - The length of data to copypublic static final void wipe(long addr,
int addroff,
int len)
addr - The native address of the memory region to wipeaddroff - The offset, relative to the starting address of the source memory, from where to wipe the memory contentslen - The number of bytes to wipepublic static final String dump(long addr, int offset, int len)
addr - Starting address of the memory regionoffset - Offset into the memory region from where to start the dumplen - The number of bytes to dump
This method dumps the contents of a section of an IO buffer
public final IOBuffer copy()
public final int getLength()
public final int getCapacity()
public final ByteBuffer takeBuffer()
This method temporarily transfers ownership of an IO buffer's
underlying byte buffer to the caller. The caller is free to
manipulate the buffer markers while it has taken the buffer
from the IO buffer. Once done with the buffer, the caller
must call releaseBuffer() to release the buffer
back to the IO buffer. While an IO buffer's byte buffer is
taken from it, it will throw exceptions if any of the following
methods are invoked:
- takeBuffer()
- dispose(int)
- getBufferUnsafe()
public final IOBuffer releaseBuffer()
takeBuffer()
This method releases an IO buffer's underlying byte buffer. This
call must be preceded by a previous call to takeBuffer().
The method will reset the buffer markers. The released buffer
must NOT be manipulated by the caller once released.
public final ByteBuffer getBufferUnsafe()
NOTE: THIS METHOD IS INTENDED FOR X PLATFORM INTERNAL USE AND SHOULD
NOT BE USED. PLEASE CONSULT NEEVE TECHNICAL SUPPORT BEFORE YOU
USE THIS METHOD. THIS METHOD CAN BE DEPRECATED/REMOVED/CHANGED
AT ANY TIME WIHOUT NOTICE. TO DIRECTLY USE THE BUFFER UNDERLYING
AN IO BUFFER (SUCH AS WITH THE JDK IO METHODS), PLEASE USE THE
takeBuffer()/releaseBuffer() METHOD PAIR TO ENSURE
THE BUFFER MARKERS ARE SET CORRECTLY AND THE IO BUFFER ENSURES
THE UNDERLYING BUFFER IS NOT USED/MANIPULATED WHILE TEMPORARILY
TAKEN FROM THE IO BUFFER FOR USE.
@Deprecated public final ByteBuffer getBuffer()
takeBuffer()
and releaseBuffer()@Deprecated public final IOBuffer getIOBuffer()
This method is only provided to ease migration from an xbuf encoding to xbuf2 encoding e.g. to allow code such as getBackingBuffer().getIOBuffer().getBufferUnsafe() to work unchanged with xbuf2
public final long getNativeAddress()
public final IOBuffer setNoWipe()
By default, an IO buffer is wiped clean when disposed. Calling this method results in the buffer not to be wiped clean on disposed.
public final void putByte(int offset,
byte val)
offset - The offset into the buffer at which to serialize the byte valueval - The value to serializepublic final byte getByte(int offset)
offset - The offset into the buffer from where to deserialize the byte valuepublic final int getUnsignedByte(int offset)
offset - The offset into the buffer from where to deserialize the byte valuepublic final void putShort(int offset,
short val)
offset - The offset into the buffer at which to serialize the short valueval - The value to serializepublic final short getShort(int offset)
offset - The offset into the buffer from where to deserialize the short valuepublic final int getUnsignedShort(int offset)
offset - The offset into the buffer from where to deserialize the short valuepublic final void putChar(int offset,
char val)
offset - The offset into the buffer at which to serialize the char valueval - The value to serializepublic final int putASCIIChar(int offset,
char val)
offset - The offset into the buffer at which to serialize the char valueval - The value to serializepublic final int putUTF8Char(int offset,
char val)
offset - The offset into the buffer at which to serialize the char valueval - The value to serializepublic final char getChar(int offset)
offset - The offset into the buffer from where to deserialize the char valuepublic final char getASCIIChar(int offset)
offset - The offset into the buffer from where to deserialize the char valuepublic final void putInt(int offset,
int val)
offset - The offset into the buffer at which to serialize the int valueval - The value to serializepublic final int getInt(int offset)
offset - The offset into the buffer from where to deserialize the int valuepublic final long getUnsignedInt(int offset)
offset - The offset into the buffer from where to deserialize the int valuepublic final void putFloat(int offset,
float val)
offset - The offset into the buffer at which to serialize the float valueval - The value to serializepublic final float getFloat(int offset)
offset - The offset into the buffer from where to deserialize the float valuepublic final void putLong(int offset,
long val)
offset - The offset into the buffer at which to serialize the byte valueval - The value to serializepublic final int putLongAsASCIICharSequence(int offset,
long val)
offset - The offset into the buffer at which to serialize the long valueval - The value to serializepublic final long getLong(int offset)
offset - The offset into the buffer from where to deserialize the long valuepublic final long getLongFromASCIICharSequence(int offset,
char terminationMarker,
int limit,
IOBuffer.ParsedCount parsedCount)
offset - The offset into the buffer from where to deserialize the long valueterminationMarker - The marker character that terminates where the long value endslimit - The position at which the memory region becomes invalidpublic final void putDouble(int offset,
double val)
offset - The offset into the buffer at which to serialize the double valueval - The value to serializepublic final int putDoubleAsASCIICharSequence(int offset,
double val,
int precision)
offset - The offset into the buffer at which to serialize the double valueval - The value to serializepublic final double getDouble(int offset)
offset - The offset into the buffer from where to deserialize the double valuepublic final double getDoubleFromASCIICharSequence(int offset)
offset - The offset into the buffer from where to deserialize the double valuepublic final int putASCIICharSequence(int offset,
CharSequence val,
int start,
int end)
offset - The offset into the buffer at which to serialize the character sequenceval - The character sequence to serializestart - The first position in the character sequence to serializeend - The end position in the character sequence to serialize (this position is not serialized)public final int putASCIICharSequence(int offset,
CharSequence val)
offset - The offset into the buffer at which to serialize the character sequenceval - The character sequence to serializepublic final String getASCIICharSequence(int offset, int len)
offset - The offset into the buffer from where to deserialize the valuelen - The length of the sequencepublic final int putUTF8CharSequence(int offset,
CharSequence val,
int utflen,
int start,
int end)
offset - The offset into the buffer at which to serialize the character sequenceval - The character sequence to serializeutflen - The UTF-8 length of the character sequence.start - The first position in the character sequence to serializeend - The end position in the character sequence to serialize (this position is not serialized)public final int putUTF8CharSequence(int offset,
CharSequence val,
int start,
int end)
offset - The offset into the buffer at which to serialize the character sequenceval - The character sequence to serializestart - The first position in the character sequence to serializeend - The end position in the character sequence to serialize (this position is not serialized)public final int putUTF8CharSequence(int offset,
CharSequence val)
offset - The offset into the buffer at which to serialize the character sequenceval - The character sequence to serializepublic final String getUTF8CharSequence(int offset, int len)
offset - The offset into the buffer from where to deserialize the valuelen - The length of the sequencepublic final void putVarint32(int offset,
int val)
offset - The offset into the buffer at which to serialize the int valueval - The value to serializepublic final int getVarint32(int offset,
IOBuffer.VarintDeserializeLength deserializeLength)
offset - The offset into the buffer from where to deserialize the int valuedeserializeLength - The container of the number of bytes deserializedpublic final void putVarint64(int offset,
long val)
offset - The offset into the buffer at which to serialize the long valueval - The value to serializepublic final long getVarint64(int offset,
IOBuffer.VarintDeserializeLength deserializeLength)
offset - The offset into the buffer from where to deserialize the long valuedeserializeLength - The container of the number of bytes deserializedpublic final void putFrom(int offset,
byte[] array,
int arrayoffset,
int numelem)
offset - The offset into the buffer at which to serialize the valuesarray - The array to serializearrayoffset - The offset, into the array, from where to serializenumelem - The number of array elements to serializepublic final void getTo(int offset,
byte[] array,
int arrayoffset,
int numelem)
offset - The offset into the buffer from where to deserialize the valuesarray - The array to deserializearrayoffset - The offset, into the array, to deserialize intonumelem - The number of array elements to deserializepublic final void putFrom(int offset,
short[] array,
int arrayoffset,
int numelem)
offset - The offset into the buffer at which to serialize the valuesarray - The array to serializearrayoffset - The offset, into the array, from where to serializenumelem - The number of array elements to serializepublic final void getTo(int offset,
short[] array,
int arrayoffset,
int numelem)
offset - The offset into the buffer from where to deserialize the valuesarray - The array to deserializearrayoffset - The offset, into the array, to deserialize intonumelem - The number of array elements to deserializepublic final void putFrom(int offset,
char[] array,
int arrayoffset,
int numelem)
offset - The offset into the buffer at which to serialize the valuesarray - The array to serializearrayoffset - The offset, into the array, from where to serializenumelem - The number of array elements to serializepublic final void getTo(int offset,
char[] array,
int arrayoffset,
int numelem)
offset - The offset into the buffer from where to deserialize the valuesarray - The array to deserializearrayoffset - The offset, into the array, to deserialize intonumelem - The number of array elements to deserializepublic final void putFrom(int offset,
int[] array,
int arrayoffset,
int numelem)
offset - The offset into the buffer at which to serialize the valuesarray - The array to serializearrayoffset - The offset, into the array, from where to serializenumelem - The number of array elements to serializepublic final void getTo(int offset,
int[] array,
int arrayoffset,
int numelem)
offset - The offset into the buffer from where to deserialize the valuesarray - The array to deserializearrayoffset - The offset, into the array, to deserialize intonumelem - The number of array elements to deserializepublic final void putFrom(int offset,
float[] array,
int arrayoffset,
int numelem)
offset - The offset into the buffer at which to serialize the valuesarray - The array to serializearrayoffset - The offset, into the array, from where to serializenumelem - The number of array elements to serializepublic final void getTo(int offset,
float[] array,
int arrayoffset,
int numelem)
offset - The offset into the buffer from where to deserialize the valuesarray - The array to deserializearrayoffset - The offset, into the array, to deserialize intonumelem - The number of array elements to deserializepublic final void putFrom(int offset,
long[] array,
int arrayoffset,
int numelem)
offset - The offset into the buffer at which to serialize the valuesarray - The array to serializearrayoffset - The offset, into the array, from where to serializenumelem - The number of array elements to serializepublic final void getTo(int offset,
long[] array,
int arrayoffset,
int numelem)
offset - The offset into the buffer from where to deserialize the valuesarray - The array to deserializearrayoffset - The offset, into the array, to deserialize intonumelem - The number of array elements to deserializepublic final void putFrom(int offset,
double[] array,
int arrayoffset,
int numelem)
offset - The offset into the buffer at which to serialize the valuesarray - The array to serializearrayoffset - The offset, into the array, from where to serializenumelem - The number of array elements to serializepublic final void getTo(int offset,
double[] array,
int arrayoffset,
int numelem)
offset - The offset into the buffer from where to deserialize the valuesarray - The array to deserializearrayoffset - The offset, into the array, to deserialize intonumelem - The number of array elements to deserializepublic final void putFrom(int offset,
long addr,
int addroffset,
int len)
offset - The offset into the buffer at which to copy the dataaddr - The native address of the start of the memory regionaddroffset - The offset, into the memory region, from where to copy the datalen - The data length to copypublic final void getTo(int offset,
long addr,
int addroffset,
int len)
offset - The offset into the buffer from where to copy the dataaddr - The native address of the start of the memory regionaddroffset - The offset, into the memory region, to copy the data tolen - The data length to copypublic final void putFrom(int offset,
ByteBuffer src,
int bufferOffset,
int len)
offset - The offset into the buffer to copy the data tosrc - The source bufferbufferOffset - The offset into the buffer to copy fromlen - The number of bytes to copypublic final void putFrom(int offset,
ByteBuffer src)
offset - The offset into the buffer to copy the data tosrc - The source bufferpublic final void getTo(int offset,
ByteBuffer dest,
int bufferOffset,
int len)
offset - The offset into the IO buffer to copy the data fromdest - The target bufferbufferOffset - The offset into the buffer to copy tolen - The number of bytes to copypublic final void getTo(int offset,
ByteBuffer dest,
int len)
offset - The offset into the IO buffer to copy the data fromdest - The target bufferlen - The number of bytes to copypublic final void putFrom(int offset,
IOBuffer src,
int srcoff,
int len)
offset - The offset into the buffer to copy the data tosrc - The source buffersrcoff - The offset into the source buffer from where to copy the datalen - The length of data to copypublic final void getTo(int offset,
IOBuffer dest,
int destoff,
int len)
offset - The offset into the buffer from where to copy the datadest - The destinaton bufferdestoff - The offset into the destination buffer at which to copy the datalen - The length of data to copypublic final IOBuffer acquire()
This method increments an IO buffer's ownership count. Buffer
ownership is used in conjunction with managing buffer pools.
If a buffer is tagged to an object pool, the buffer is released
back to the pool by dispose(int) when the ownership count
reduces to 0. If not tagged to a pool, change of ownership
count has no side effects.
A buffer's ownership count starts at 1.
public final int getOwnerCount()
public final void dispose(int highwater)
highwater - Specifies the maximum length of the buffer that
was used. This value is used to determine how much of the buffer
to wipe during the pool washing process.
This method should be invoked by the user when done with an IO buffer. It decrements the buffer's ownership count and releases it to its object pool (if one is tagged to it) and this method causes the ownership count to reduce to zero. If not tagged to a pool, ownership change methods have no side effects aside from just updating the ownership counter.
Upon return from this method, the caller should assume that the buffer has been disposed and release its reference to the buffer.
public final void dispose()
This method is equivalent to dispose(this.highwater)
public final IOBuffer init()
init in interface UtlPool.Item<IOBuffer>public final IOBuffer setPool(UtlPool<IOBuffer> pool)
setPool in interface UtlPool.Item<IOBuffer>public final UtlPool<IOBuffer> getPool()
getPool in interface UtlPool.Item<IOBuffer>UtlPool.Item.setPool(com.neeve.util.UtlPool<T>)Copyright © 2019 N5 Technologies, Inc. All Rights Reserved.