public class BinaryLongArrayReference extends AbstractReference implements ByteableLongArrayValues, BytesMarshallable
BytesStore.
This class provides various operations to access and manipulate an array of 64-bit long integers in binary form. The long integers are stored in a BytesStore, and this class provides methods for reading and writing values at specific indices.
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 synchronization may be necessary if instances are shared between threads.
BytesStore,
BinaryLongReference| Modifier and Type | Field and Description |
|---|---|
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 ByteStore to which this object currently points.
|
void |
bytesStore(@NotNull BytesStore bytes,
long offset,
long length)
Sets the underlying BytesStore to work with, along with the offset and length.
|
ByteableLongArrayValues |
capacity(long arrayLength)
Sets the capacity of the array, in terms of the number of long integers it can hold.
|
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()
Returns the maximum size in bytes that this reference can point to.
|
long |
offset()
Returns the offset within the ByteStore to which this object currently points.
|
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 the state of this object from the bytes.
|
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 size in bytes needed to store the given number of long integers.
|
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 the state of this object to the bytes.
|
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 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 in interface ByteablebytesStore in class AbstractReferencebytes - the BytesStore to setoffset - the offset to setlength - the length to setIllegalArgumentException - If the arguments are invalidnet.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 wayBufferOverflowException - If the provided buffer is too smallIllegalStateExceptionpublic void readMarshallable(BytesIn<?> bytes) throws net.openhft.chronicle.core.io.IORuntimeException, IllegalStateException, BufferUnderflowException
BytesMarshallablereadMarshallable in interface BytesMarshallablereadMarshallable in interface ReadBytesMarshallablebytes - the BytesIn object to read from.net.openhft.chronicle.core.io.IORuntimeException - If an I/O error 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 wayBufferUnderflowException - If there is not enough data available in the buffer.IllegalStateExceptionpublic void writeMarshallable(BytesOut<?> bytes) throws IllegalStateException, BufferOverflowException, BufferUnderflowException
BytesMarshallablewriteMarshallable in interface BytesMarshallablewriteMarshallable in interface WriteBytesMarshallablebytes - the BytesOut object to write to.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 wayBufferOverflowException - If there is not enough space in the buffer.BufferUnderflowException - If there is not enough data available in the buffer.IllegalStateExceptionpublic 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()
ByteablebytesStore in interface ByteablebytesStore in class AbstractReferencepublic long offset()
Byteableoffset in interface Byteableoffset in class AbstractReferencepublic long maxSize()
Byteable@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 long integers to be stored.IllegalStateExceptionpublic ByteableLongArrayValues capacity(long arrayLength) throws IllegalStateException
ByteableLongArrayValuescapacity in interface ByteableLongArrayValuesarrayLength - the desired array capacity, in number of long integers.ByteableLongArrayValues instance.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,
long expected,
long value)
throws BufferOverflowException,
IllegalStateException
compareAndSet in interface net.openhft.chronicle.core.values.LongArrayValuesBufferOverflowExceptionIllegalStateExceptionCopyright © 2024. All rights reserved.