public class BinaryLongArrayReference extends AbstractReference implements ByteableLongArrayValues, BytesMarshallable
[capacity][used][values...] in little-endian order.
The value region starts at offset VALUES and each entry is shifted by
SHIFT bytes.
Example usage:
BytesStore bytesStore = BytesStore.nativeStoreWithFixedCapacity(32); BinaryLongArrayReference ref = new BinaryLongArrayReference(4); // Creates an array with 4 longs ref.bytesStore(bytesStore, 0, ref.maxSize()); ref.setValueAt(0, 1234567890L); long value = ref.getValueAt(0);
Note: This class is not thread-safe. External synchronisation may be necessary if instances are shared between threads.
BytesStore,
BinaryLongReference| Modifier and Type | Field and Description |
|---|---|
static long |
MAX_CAPACITY |
static int |
SHIFT |
bytesStore, offset| Constructor and Description |
|---|
BinaryLongArrayReference()
Constructs a BinaryLongArrayReference with a default capacity of 0.
|
BinaryLongArrayReference(long defaultCapacity)
Constructs a BinaryLongArrayReference with the specified default capacity.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
acceptNewBytesStore(@NotNull BytesStore<?,?> bytes)
Updates the BytesStore for this reference, releasing any previous BytesStore
|
void |
bindValueAt(long index,
@NotNull net.openhft.chronicle.core.values.LongValue value) |
@Nullable BytesStore<?,?> |
bytesStore()
Returns the
BytesStore that backs this reference, or null if none is set. |
void |
bytesStore(@NotNull BytesStore bytes,
long offset,
long length)
Sets the underlying
BytesStore together with the offset and length. |
ByteableLongArrayValues |
capacity(long arrayLength)
Sets the capacity of the array as a count of elements, not bytes.
|
boolean |
compareAndSet(long index,
long expected,
long value) |
static void |
forceAllToNotCompleteState()
Sets all values in the BinaryLongArrayReference instances to the "not complete" state.
|
long |
getCapacity() |
long |
getUsed() |
long |
getValueAt(long index) |
long |
getVolatileValueAt(long index) |
boolean |
isNull() |
static void |
lazyWrite(@NotNull Bytes<?> bytes,
long capacity)
Lazily writes to the provided Bytes object with the given capacity.
|
long |
maxSize() |
long |
offset()
Returns the byte offset relative to the start of the associated store.
|
static long |
peakLength(@NotNull BytesStore<?,?> bytes,
long offset)
Returns the capacity from the BytesStore object and adding the fixed values size to get a length.
|
static long |
peakLength(@NotNull BytesStore<?,?> bytes,
long offset,
long capacityHint)
Returns the capacity from the BytesStore object, adding the fixed values size to get a length
If the read capacity is 0, the method writes the capacityHint at the offset and
updates the capacity with the capacityHint.
|
void |
readMarshallable(BytesIn<?> bytes)
Reads data from the provided
BytesIn object. |
void |
reset() |
void |
setMaxUsed(long usedAtLeast) |
void |
setOrderedValueAt(long index,
long value) |
void |
setUsed(long used) |
void |
setValueAt(long index,
long value) |
long |
sizeInBytes(long capacity)
Calculates the byte size required to hold the provided element capacity.
|
static void |
startCollecting()
Enables collection of BinaryLongArrayReference instances.
|
@NotNull String |
toString() |
static void |
write(@NotNull Bytes<?> bytes,
long capacity)
Writes to the provided Bytes object with the given capacity.
|
void |
writeMarshallable(BytesOut<?> bytes)
Writes this object's state to
bytes using a custom binary format. |
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 BinaryLongArrayReference()
public BinaryLongArrayReference(long defaultCapacity)
defaultCapacity - the initial capacity of the long array in number of elements.public static void startCollecting()
This method is used for debugging and monitoring. It should not be used in production environments.
public static void forceAllToNotCompleteState()
throws IllegalStateException,
BufferOverflowException
This method is used for debugging and monitoring. It should not be used in production environments.
BufferOverflowException - If the bytes cannot be written.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
AbstractReferenceacceptNewBytesStore in class AbstractReferencebytes - the new BytesStorenet.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 write to.capacity - the capacity to be written and used for subsequent zeroing.BufferOverflowException - If there is insufficient space in the buffer.IllegalArgumentException - If arguments violate precondition constraints.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 write to.capacity - the capacity to be written.BufferOverflowException - If there is insufficient space in the buffer.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 at which to start reading.BufferUnderflowException - If there is not enough remaining data.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,
long capacityHint)
throws BufferUnderflowException,
IllegalStateException
bytes - the BytesStore object to read from.offset - the offset at which to start reading.capacityHint - the capacity to be used if the initial capacity is 0.BufferUnderflowException - If there is not enough remaining data.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.LongArrayValuesIllegalStateExceptionpublic long getUsed()
throws IllegalStateException,
BufferUnderflowException
getUsed in interface net.openhft.chronicle.core.values.LongArrayValuesIllegalStateExceptionBufferUnderflowExceptionpublic void setMaxUsed(long usedAtLeast)
throws IllegalStateException,
BufferUnderflowException
setMaxUsed in interface net.openhft.chronicle.core.values.LongArrayValuesIllegalStateExceptionBufferUnderflowExceptionpublic void setUsed(long used)
throws IllegalStateException,
BufferUnderflowException
setUsed in interface net.openhft.chronicle.core.values.LongArrayValuesIllegalStateExceptionBufferUnderflowExceptionpublic long getValueAt(long index)
throws BufferUnderflowException,
IllegalStateException
getValueAt in interface net.openhft.chronicle.core.values.LongArrayValuesBufferUnderflowExceptionIllegalStateExceptionpublic void setValueAt(long index,
long value)
throws BufferOverflowException,
IllegalStateException
setValueAt in interface net.openhft.chronicle.core.values.LongArrayValuesBufferOverflowExceptionIllegalStateExceptionpublic long getVolatileValueAt(long index)
throws BufferUnderflowException,
IllegalStateException
getVolatileValueAt in interface net.openhft.chronicle.core.values.LongArrayValuesBufferUnderflowExceptionIllegalStateExceptionpublic void bindValueAt(long index,
@NotNull
@NotNull net.openhft.chronicle.core.values.LongValue value)
throws IllegalStateException,
BufferOverflowException
bindValueAt in interface net.openhft.chronicle.core.values.LongArrayValuesIllegalStateExceptionBufferOverflowExceptionpublic void setOrderedValueAt(long index,
long value)
throws BufferOverflowException,
IllegalStateException
setOrderedValueAt in interface net.openhft.chronicle.core.values.LongArrayValuesBufferOverflowExceptionIllegalStateExceptionpublic void bytesStore(@NotNull
@NotNull BytesStore bytes,
long offset,
long length)
throws IllegalArgumentException,
IllegalStateException,
BufferOverflowException
AbstractReferenceBytesStore together with the offset and length.bytesStore in interface ByteablebytesStore in class AbstractReferencebytes - the BytesStore providing the backing memoryoffset - the non-negative offset within the storelength - the number of bytes this reference spansIllegalArgumentException - if length does not match Byteable.maxSize()net.openhft.chronicle.core.io.ClosedIllegalStateException - if the store is closednet.openhft.chronicle.core.io.ThreadingIllegalStateException - if accessed from the wrong threadBufferOverflowException - if the region exceeds the store capacityIllegalStateExceptionpublic void readMarshallable(BytesIn<?> bytes) throws net.openhft.chronicle.core.io.IORuntimeException, IllegalStateException, BufferUnderflowException
BytesMarshallableBytesIn object. Implementations of this method are
responsible for handling their own data reading logic based on the structure of the data
they expect to read.
Note: Implementations are also responsible for calling
Validatable.validate() when necessary.
readMarshallable in interface BytesMarshallablereadMarshallable in interface ReadBytesMarshallablebytes - The BytesIn instance to read data from.net.openhft.chronicle.core.io.IORuntimeException - If an I/O error occurs during reading.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 wayBufferUnderflowException - If there is not enough data in the buffer to read.IllegalStateExceptionpublic void writeMarshallable(BytesOut<?> bytes) throws IllegalStateException, BufferOverflowException, BufferUnderflowException
BytesMarshallablebytes using a custom binary format.
Implementations may validate their state prior to writing and throw
InvalidMarshallableException if invalid.writeMarshallable in interface BytesMarshallablewriteMarshallable in interface WriteBytesMarshallablebytes - the target streamnet.openhft.chronicle.core.io.ClosedIllegalStateException - if the resource has been released or closednet.openhft.chronicle.core.io.ThreadingIllegalStateException - if accessed by multiple threads in an unsafe wayBufferOverflowException - if there is insufficient space in the bufferIllegalStateExceptionBufferUnderflowExceptionpublic boolean isNull()
throws IllegalStateException
isNull in interface net.openhft.chronicle.core.values.LongArrayValuesIllegalStateExceptionpublic void reset()
throws IllegalStateException
reset in interface net.openhft.chronicle.core.values.LongArrayValuesIllegalStateException@Nullable public @Nullable BytesStore<?,?> bytesStore()
AbstractReferenceBytesStore that backs this reference, or null if none is set.bytesStore in interface ByteablebytesStore in class AbstractReferenceBytesStore or null if unmappedpublic long offset()
AbstractReferenceoffset in interface Byteableoffset in class AbstractReferenceBytesStorepublic long maxSize()
@NotNull public @NotNull String toString()
toString in class net.openhft.chronicle.core.io.AbstractCloseablepublic long sizeInBytes(long capacity)
throws IllegalStateException
ByteableLongArrayValuessizeInBytes in interface ByteableLongArrayValuessizeInBytes in interface net.openhft.chronicle.core.values.LongArrayValuescapacity - the number of elementsIllegalStateExceptionpublic ByteableLongArrayValues capacity(long arrayLength) throws IllegalStateException
ByteableLongArrayValuescapacity in interface ByteableLongArrayValuesarrayLength - the desired element countnet.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,
long expected,
long value)
throws BufferOverflowException,
IllegalStateException
compareAndSet in interface net.openhft.chronicle.core.values.LongArrayValuesBufferOverflowExceptionIllegalStateExceptionCopyright © 2026 Chronicle Software Ltd. All rights reserved.