public class BinaryIntArrayReference extends AbstractReference implements ByteableIntArrayValues, BytesMarshallable
[capacity][used][values...] in little-endian order.
Each entry is shifted by SHIFT bytes from VALUES.
Example usage:
BytesStore bytesStore = ... BinaryIntArrayReference arrayRef = new BinaryIntArrayReference(); arrayRef.bytesStore(bytesStore, 0, bytesStore.capacity()); arrayRef.setOrderedValueAt(5, 12345); int value = arrayRef.getValueAt(5);
Note: This class is not thread-safe. External synchronisation may be required if instances are shared between threads.
| Modifier and Type | Field and Description |
|---|---|
static long |
MAX_CAPACITY |
static int |
SHIFT |
bytesStore, offset| Constructor and Description |
|---|
BinaryIntArrayReference()
Default constructor initializes the BinaryIntArrayReference with a default capacity of 0.
|
BinaryIntArrayReference(long defaultCapacity)
Constructs a new BinaryIntArrayReference with the specified default capacity.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
acceptNewBytesStore(@NotNull BytesStore<?,?> bytes)
Assigns a new BytesStore to this BinaryIntArrayReference.
|
void |
bindValueAt(long index,
@NotNull net.openhft.chronicle.core.values.IntValue value)
Binds the value at the specified index to the provided IntValue.
|
@Nullable BytesStore<?,?> |
bytesStore()
Retrieves the BytesStore.
|
void |
bytesStore(@NotNull BytesStore bytes,
long offset,
long length)
Stores a bytes sequence into the BinaryIntArrayReference.
|
ByteableIntArrayValues |
capacity(long arrayLength)
Sets the capacity of the BinaryIntArrayReference.
|
boolean |
compareAndSet(long index,
int expected,
int value)
Atomically sets the value at the specified index to the given updated value
if the current value equals the expected value.
|
static void |
forceAllToNotCompleteState()
Forces all BinaryIntArrayReferences to a not complete state.
|
long |
getCapacity()
Gets the capacity of the array.
|
long |
getUsed()
Gets the number of used elements in the array.
|
int |
getValueAt(long index)
Gets the value at the specified index.
|
int |
getVolatileValueAt(long index)
Retrieves the value at the specified index with volatile semantics.
|
boolean |
isNull()
Checks if the instance is null.
|
static void |
lazyWrite(@NotNull Bytes<?> bytes,
long capacity)
Lazily initializes the binary data in the provided Bytes object with the given capacity.
|
long |
maxSize()
Retrieves the maximum size.
|
long |
offset()
Retrieves the offset position.
|
static long |
peakLength(@NotNull BytesStore<?,?> bytes,
long offset)
Calculates and returns the peak length from the BytesStore at the given offset.
|
void |
readMarshallable(BytesIn<?> bytes)
Reads and deserializes data from the input stream.
|
void |
reset()
Resets the instance to its initial state.
|
void |
setMaxUsed(long usedAtLeast)
Sets the maximum number of used elements in the array.
|
void |
setOrderedValueAt(long index,
int value)
Sets the value at the specified index with ordered semantics.
|
void |
setValueAt(long index,
int value)
Sets the value at the specified index.
|
long |
sizeInBytes(long capacity)
Calculates the size in bytes of the array with the given capacity.
|
static void |
startCollecting()
Initializes the collection that keeps references to BinaryIntArrayReference instances.
|
@NotNull String |
toString()
Returns a string representation of the BinaryIntArrayReference.
|
static void |
write(@NotNull Bytes<?> bytes,
long capacity)
Initializes the binary data in the provided Bytes object with the given capacity.
|
void |
writeMarshallable(BytesOut<?> bytes)
Serializes and writes data to the output stream.
|
address, lock, performClose, tryLock, unmonitorassertCloseable, assertCloseablesClosed, close, createdHere, disableCloseableTracing, enableCloseableTracing, gcAndWaitForCloseablesToClose, isClosed, isClosing, isInUserThread, referenceId, shouldPerformCloseInBackground, shouldWaitForClosed, singleThreadedCheckDisabled, singleThreadedCheckDisabled, singleThreadedCheckReset, threadSafetyCheck, throwExceptionIfClosed, throwExceptionIfClosedInSetter, waitForCloseablesToClose, waitForClosed, warnAndCloseIfNotClosedclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitclose, closeQuietly, closeQuietly$toString, usesSelfDescribingMessagepublic static final int SHIFT
public static final long MAX_CAPACITY
public BinaryIntArrayReference()
public BinaryIntArrayReference(long defaultCapacity)
defaultCapacity - the default capacity of the array.public static void startCollecting()
public static void forceAllToNotCompleteState()
throws IllegalStateException,
BufferOverflowException
BufferOverflowException - If buffer overflows.net.openhft.chronicle.core.io.ClosedIllegalStateException - If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptionpublic static void write(@NotNull
@NotNull Bytes<?> bytes,
long capacity)
throws BufferOverflowException,
IllegalArgumentException,
IllegalStateException
bytes - the Bytes object to be written.capacity - the capacity to be set.BufferOverflowException - If buffer overflows.IllegalArgumentException - If an illegal argument is encountered.net.openhft.chronicle.core.io.ClosedIllegalStateException - If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptionpublic static void lazyWrite(@NotNull
@NotNull Bytes<?> bytes,
long capacity)
throws BufferOverflowException,
IllegalStateException
bytes - the Bytes object to be written.capacity - the capacity to be set.BufferOverflowException - If buffer overflows.net.openhft.chronicle.core.io.ClosedIllegalStateException - If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptionpublic static long peakLength(@NotNull
@NotNull BytesStore<?,?> bytes,
long offset)
throws BufferUnderflowException,
IllegalStateException
bytes - the BytesStore object to read from.offset - the offset in the BytesStore to start reading from.BufferUnderflowException - If buffer underflows.net.openhft.chronicle.core.io.ClosedIllegalStateException - If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException - if this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptionprotected void acceptNewBytesStore(@NotNull
@NotNull BytesStore<?,?> bytes)
throws IllegalStateException
acceptNewBytesStore in class AbstractReferencebytes - the new BytesStore to be assigned.net.openhft.chronicle.core.io.ClosedIllegalStateException - If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException - if this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptionpublic long getCapacity()
throws IllegalStateException
getCapacity in interface net.openhft.chronicle.core.values.IntArrayValuesnet.openhft.chronicle.core.io.ClosedIllegalStateException - If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException - if this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptionpublic long getUsed()
throws IllegalStateException,
BufferUnderflowException
getUsed in interface net.openhft.chronicle.core.values.IntArrayValuesBufferUnderflowException - If buffer underflows.net.openhft.chronicle.core.io.ClosedIllegalStateException - If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptionpublic void setMaxUsed(long usedAtLeast)
throws IllegalStateException,
BufferUnderflowException
setMaxUsed in interface net.openhft.chronicle.core.values.IntArrayValuesusedAtLeast - the number of used elements to be set.BufferUnderflowException - If buffer underflows.net.openhft.chronicle.core.io.ClosedIllegalStateException - If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptionpublic int getValueAt(long index)
throws IllegalStateException,
BufferUnderflowException
getValueAt in interface net.openhft.chronicle.core.values.IntArrayValuesindex - the index to retrieve the value from.BufferUnderflowException - If buffer underflows.net.openhft.chronicle.core.io.ClosedIllegalStateException - If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptionpublic void setValueAt(long index,
int value)
throws IllegalStateException,
BufferOverflowException
setValueAt in interface net.openhft.chronicle.core.values.IntArrayValuesindex - the index to set the value at.value - the value to be set.BufferOverflowException - If buffer overflows.net.openhft.chronicle.core.io.ClosedIllegalStateException - If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptionpublic int getVolatileValueAt(long index)
throws IllegalStateException,
BufferUnderflowException
getVolatileValueAt in interface net.openhft.chronicle.core.values.IntArrayValuesindex - the index to retrieve the value from.BufferUnderflowException - If buffer underflows.net.openhft.chronicle.core.io.ClosedIllegalStateException - If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptionpublic void bindValueAt(long index,
@NotNull
@NotNull net.openhft.chronicle.core.values.IntValue value)
throws IllegalStateException,
BufferOverflowException,
IllegalArgumentException
bindValueAt in interface net.openhft.chronicle.core.values.IntArrayValuesindex - the index to bind the value at.value - the IntValue to be bound.BufferOverflowException - If buffer overflows.IllegalArgumentException - If the arguments are invalid.net.openhft.chronicle.core.io.ClosedIllegalStateException - If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptionpublic void setOrderedValueAt(long index,
int value)
throws BufferOverflowException,
IllegalStateException
setOrderedValueAt in interface net.openhft.chronicle.core.values.IntArrayValuesindex - the index to set the value at.value - the value to be set.BufferOverflowException - If buffer overflows.net.openhft.chronicle.core.io.ClosedIllegalStateException - If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException - if this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptionpublic void bytesStore(@NotNull
@NotNull BytesStore bytes,
long offset,
long length)
throws IllegalArgumentException,
IllegalStateException,
BufferOverflowException
bytesStore in interface ByteablebytesStore in class AbstractReferencebytes - the bytes sequence to store.offset - the starting position.length - the length of bytes sequence.IllegalArgumentException - If the length does not match the peak length.BufferOverflowException - If buffer overflows.net.openhft.chronicle.core.io.ClosedIllegalStateException - If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptionpublic void readMarshallable(BytesIn<?> bytes) throws net.openhft.chronicle.core.io.IORuntimeException, IllegalStateException, BufferUnderflowException
readMarshallable in interface BytesMarshallablereadMarshallable in interface ReadBytesMarshallablebytes - the input stream.net.openhft.chronicle.core.io.IORuntimeException - If an IO exception occurs.BufferUnderflowException - If buffer underflow occurs.net.openhft.chronicle.core.io.ClosedIllegalStateException - If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptionpublic void writeMarshallable(BytesOut<?> bytes) throws IllegalStateException, BufferOverflowException
writeMarshallable in interface BytesMarshallablewriteMarshallable in interface WriteBytesMarshallablebytes - the output stream.BufferOverflowException - If buffer overflow occurs.net.openhft.chronicle.core.io.ClosedIllegalStateException - If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException - If this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptionpublic boolean isNull()
throws IllegalStateException
isNull in interface net.openhft.chronicle.core.values.IntArrayValuesnet.openhft.chronicle.core.io.ClosedIllegalStateException - If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException - if this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptionpublic void reset()
throws IllegalStateException
reset in interface net.openhft.chronicle.core.values.IntArrayValuesnet.openhft.chronicle.core.io.ClosedIllegalStateException - If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException - if this resource was accessed by multiple threads in an unsafe wayIllegalStateException@Nullable public @Nullable BytesStore<?,?> bytesStore()
bytesStore in interface ByteablebytesStore in class AbstractReferencepublic long offset()
offset in interface Byteableoffset in class AbstractReferencepublic long maxSize()
@NotNull public @NotNull String toString()
toString in class net.openhft.chronicle.core.io.AbstractCloseablepublic long sizeInBytes(long capacity)
throws IllegalStateException
sizeInBytes in interface ByteableIntArrayValuessizeInBytes in interface net.openhft.chronicle.core.values.IntArrayValuescapacity - the capacity of the array.net.openhft.chronicle.core.io.ClosedIllegalStateException - If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException - if this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptionpublic ByteableIntArrayValues capacity(long arrayLength) throws IllegalStateException
capacity in interface ByteableIntArrayValuesarrayLength - the desired capacity.net.openhft.chronicle.core.io.ClosedIllegalStateException - If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException - if this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptionpublic boolean compareAndSet(long index,
int expected,
int value)
throws BufferOverflowException,
IllegalStateException
compareAndSet in interface net.openhft.chronicle.core.values.IntArrayValuesindex - the index of the value to be updated.expected - the expected value.value - the new value.BufferOverflowException - If buffer overflow occurs.net.openhft.chronicle.core.io.ClosedIllegalStateException - If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException - if this resource was accessed by multiple threads in an unsafe wayIllegalStateExceptionCopyright © 2026 Chronicle Software Ltd. All rights reserved.