public interface RandomDataOutput<R extends RandomDataOutput<R>>
RandomDataOutput
interface provides a set of methods for writing data to a buffer
or similar data structure at arbitrary positions (offsets). It includes methods for writing
all primitive types, as well as arrays, CharSequence
s and other types of data.
Writing methods in this interface often include parameters for specifying the offset at which to start writing, as well as the data to be written. These methods can be used for low-level operations such as directly writing to memory regions or disk blocks.
In addition to methods for writing individual items, this interface also includes methods for copying data from one buffer to another or from arrays.
This interface also provides atomic and volatile write operations to ensure thread safety and visibility when accessing and manipulating data in a concurrent environment.
Methods in this interface may throw BufferOverflowException
if the requested
operation would exceed the buffer's current capacity or ClosedIllegalStateException
if the
buffer has been previously released.
RandomDataInput
Modifier and Type | Method and Description |
---|---|
double |
addAndGetDouble(long offset,
double adding)
Atomically adds a 64-bit double value to the current value at the specified offset and
returns the resulting sum.
|
float |
addAndGetFloat(long offset,
float adding)
Atomically adds a 32-bit float value to the current value at the specified offset and
returns the resulting sum.
|
int |
addAndGetInt(long offset,
int adding)
Atomically adds a 32-bit integer value to the current value at the specified offset and
returns the resulting sum.
|
long |
addAndGetLong(long offset,
long adding)
Atomically adds a 64-bit long value to the current value at the specified offset and
returns the resulting sum.
|
long |
addressForRead(long offset)
Retrieves the underlying memory address for reading.
|
default long |
addressForRead(long offset,
int buffer)
Retrieves the underlying memory address for reading.
|
long |
addressForWrite(long offset)
Retrieves the underlying memory address for writing.
|
long |
addressForWritePosition()
Retrieves the underlying memory address for writing at the current write position.
|
default R |
append(long offset,
double value,
int decimalPlaces,
int digits)
Appends a double value as a string with a specified number of decimal places and total digits at the given offset.
|
default R |
append(long offset,
long value,
int digits)
Appends a long value as a string with a specified number of digits at the given offset.
|
default long |
appendAndReturnLength(long writePosition,
boolean negative,
long mantissa,
int exponent,
boolean append0) |
default ByteOrder |
byteOrder()
Retrieves the byte order used by the buffer.
|
@NotNull Bytes<?> |
bytesForRead()
Retrieves a Bytes object for reading.
|
@NotNull Bytes<?> |
bytesForWrite()
Retrieves a Bytes object for writing.
|
default long |
capacity() |
boolean |
compareAndSwapDouble(long offset,
double expected,
double value)
Performs a compare-and-swap (CAS) operation for a 64-bit double at the given offset.
|
boolean |
compareAndSwapFloat(long offset,
float expected,
float value)
Performs a compare-and-swap (CAS) operation for a 32-bit float at the given offset.
|
boolean |
compareAndSwapInt(long offset,
int expected,
int value)
Performs a 32-bit compare-and-swap (CAS) operation at a given offset.
|
boolean |
compareAndSwapLong(long offset,
long expected,
long value)
Performs a 64-bit compare-and-swap (CAS) operation at a given offset.
|
boolean |
isDirectMemory()
Checks if the buffer uses direct memory.
|
default long |
lengthWritten(long startPosition)
Calculates the length of data written from the given start position.
|
void |
nativeWrite(long address,
long position,
long size)
Expert-level method that copies data directly from native memory into this BytesStore.
|
default long |
readLimit()
If the resource is closed, the returned value is unspecified.
|
default long |
readPosition()
Returns the read position.
|
default long |
readRemaining()
Calculates the number of bytes remaining that can be read from the current read position.
|
default long |
realCapacity() |
default long |
realReadRemaining()
Calculates the number of bytes that can be safely read directly.
|
default long |
realWriteRemaining()
Calculates the number of bytes remaining that can be written from the current write position with resizing.
|
boolean |
sharedMemory()
Checks if the Bytes use shared memory.
|
default long |
start() |
void |
testAndSetInt(long offset,
int expected,
int value)
Tests if the current value at the specified offset equals the expected value and, if so, sets it to the provided value.
|
default R |
write(long offsetInRDO,
byte[] bytes)
Copies the entire byte array into this data output.
|
R |
write(long writeOffset,
byte[] byteArray,
int readOffset,
int length)
Copies the provided
byteArray to this Bytes object starting at writeOffset taking
content starting at readOffset but copying at most length bytes. |
void |
write(long writeOffset,
@NotNull ByteBuffer bytes,
int readOffset,
int length)
Copies a segment from the provided ByteBuffer into this data output.
|
default R |
write(long offsetInRDO,
@NotNull BytesStore bytes)
Copies the entire content of the provided BytesStore into this data output.
|
R |
write(long writeOffset,
@NotNull RandomDataInput bytes,
long readOffset,
long length)
Copies a segment from the provided RandomDataInput into this data output.
|
long |
write8bit(long position,
@NotNull BytesStore bs)
Writes a BytesStore instance to this RandomDataOutput at the given position.
|
long |
write8bit(long position,
@NotNull String s,
int start,
int length)
Writes a portion of a string to this RandomDataOutput at the given position.
|
default R |
writeBoolean(long offset,
boolean flag)
Writes a boolean value at the specified offset.
|
R |
writeByte(long offset,
byte i8)
Writes a byte at the specified non-negative offset.
|
default R |
writeByte(long offset,
int i)
Writes a byte value at the specified offset.
|
R |
writeDouble(long offset,
double d)
Writes a double-precision floating-point value at the specified non-negative offset.
|
R |
writeFloat(long offset,
float d)
Writes a single-precision floating-point value at the specified non-negative offset.
|
R |
writeInt(long offset,
int i)
Writes an integer value at the specified non-negative offset.
|
default R |
writeInt24(long offset,
int i)
Writes a 24-bit integer at the specified non-negative offset.
|
default long |
writeLimit()
Retrieves the maximum writable position within the buffer.
|
R |
writeLong(long offset,
long i)
Writes a long integer value at the specified non-negative offset.
|
default R |
writeOrderedDouble(long offset,
double d)
Performs a non-blocking write operation with a memory barrier to ensure order of stores.
|
default R |
writeOrderedFloat(long offset,
float f)
Performs a non-blocking write operation with a memory barrier to ensure order of stores.
|
R |
writeOrderedInt(long offset,
int i)
Performs a non-blocking write operation with a memory barrier to ensure order of stores.
|
R |
writeOrderedLong(long offset,
long i)
Performs a non-blocking write operation with a memory barrier to ensure order of stores.
|
default long |
writePosition()
Returns the write position.
|
default long |
writeRemaining()
Calculates the number of bytes remaining that can be written from the current write position.
|
R |
writeShort(long offset,
short i)
Writes a short integer at the specified non-negative offset.
|
default R |
writeUnsignedByte(long offset,
int i)
Writes an unsigned byte value at the specified offset.
|
default R |
writeUnsignedInt(long offset,
long i)
Writes an unsigned integer value at the specified offset.
|
default R |
writeUnsignedShort(long offset,
int i)
Writes an unsigned short value at the specified offset.
|
default long |
writeUtf8(long writeOffset,
@Nullable CharSequence text)
Writes the provided
text into this RandomDataOutput writing at the given writeOffset ,
in Utf8 format. |
default long |
writeUtf8Limited(long writeOffset,
@Nullable CharSequence text,
int maxUtf8Len)
Writes the given
text to this RandomDataOutput writing at the provided writeOffset ,
in Utf8 format, checking that the utf8 encoding size of the given char sequence is less or
equal to the provided maxUtf8Len , otherwise IllegalArgumentException is thrown,
and no bytes of this RandomDataOutput are overwritten. |
R |
writeVolatileByte(long offset,
byte i8)
Writes a volatile byte at the specified non-negative offset.
|
default R |
writeVolatileDouble(long offset,
double d)
Writes a volatile double-precision floating-point value at the specified non-negative offset.
|
default R |
writeVolatileFloat(long offset,
float f)
Writes a volatile single-precision floating-point value at the specified non-negative offset.
|
R |
writeVolatileInt(long offset,
int i32)
Writes a volatile integer at the specified non-negative offset.
|
R |
writeVolatileLong(long offset,
long i64)
Writes a volatile long integer at the specified non-negative offset.
|
R |
writeVolatileShort(long offset,
short i16)
Writes a volatile short at the specified non-negative offset.
|
R |
zeroOut(long start,
long end)
Fills the specified range in this data output with zeroes.
|
@NotNull default R writeByte(long offset, int i) throws BufferOverflowException, IllegalArgumentException, net.openhft.chronicle.core.io.ClosedIllegalStateException
offset
- The position within the data stream to write the byte to.i
- The byte value to write. Must be within the range of a byte (-128 to 127).BufferOverflowException
- If the specified offset exceeds the available capacity.IllegalArgumentException
- If the provided integer value cannot be safely cast to a byte without loss of information.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 way@NotNull default R writeUnsignedByte(long offset, int i) throws BufferOverflowException, IllegalArgumentException, net.openhft.chronicle.core.io.ClosedIllegalStateException
offset
- The position within the data stream to write the unsigned byte to.i
- The unsigned byte value to write. Must be within the range of an unsigned byte (0 to 255).BufferOverflowException
- If the specified offset exceeds the available capacity.IllegalArgumentException
- If the provided integer value cannot be safely cast to an unsigned byte without loss of information.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 way@NotNull default R writeBoolean(long offset, boolean flag) throws BufferOverflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException
offset
- The position within the data stream to write the boolean value to.flag
- The boolean value to write. Translates 'true' as 'Y' and 'false' as 'N'.BufferOverflowException
- If the specified offset exceeds the available 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 way@NotNull default R writeUnsignedShort(long offset, int i) throws BufferOverflowException, ArithmeticException, net.openhft.chronicle.core.io.ClosedIllegalStateException
offset
- The position within the data stream to write the unsigned short to.i
- The unsigned short value to write. Must be within the range of an unsigned short (0 to 65535).BufferOverflowException
- If the specified offset exceeds the available capacity.ArithmeticException
- If the provided integer value cannot be safely cast to an unsigned short without loss of information.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 way@NotNull default R writeUnsignedInt(long offset, long i) throws BufferOverflowException, ArithmeticException, net.openhft.chronicle.core.io.ClosedIllegalStateException
offset
- The position within the data stream to write the unsigned integer to.i
- The unsigned integer value to write. Must be within the range of an unsigned integer (0 to 4294967295).BufferOverflowException
- If the specified offset exceeds the available capacity.ArithmeticException
- If the provided long value cannot be safely cast to an unsigned integer without loss of information.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 way@NotNull R writeByte(long offset, byte i8) throws BufferOverflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException
offset
- The non-negative position within the data stream to write the byte to.i8
- The byte value to write.BufferOverflowException
- If the specified offset exceeds the available 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 way@NotNull R writeShort(long offset, short i) throws BufferOverflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException
offset
- The non-negative position within the data stream to write the short integer to.i
- The short integer value to write.BufferOverflowException
- If the specified offset exceeds the available 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 way@NotNull default R writeInt24(long offset, int i) throws BufferOverflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException
offset
- The non-negative position within the data stream to write the 24-bit integer to.i
- The integer value to write. Only the lowest 24 bits are used.BufferOverflowException
- If the specified offset plus two exceeds the available 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 way@NotNull R writeInt(long offset, int i) throws BufferOverflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException
offset
- The non-negative position within the data stream to write the integer to.i
- The integer value to write.BufferOverflowException
- If the specified offset exceeds the available 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 way@NotNull R writeOrderedInt(long offset, int i) throws BufferOverflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException
offset
- The non-negative position within the data stream to write the integer to.i
- The integer value to write.BufferOverflowException
- If the specified offset exceeds the available 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 way@NotNull default R writeOrderedFloat(long offset, float f) throws BufferOverflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException
offset
- The position within the data stream to write the float to.f
- The float value to write.BufferOverflowException
- If the specified offset exceeds the available 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 way@NotNull R writeLong(long offset, long i) throws BufferOverflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException
offset
- The non-negative position within the data stream to write the long integer to.i
- The long integer value to write.BufferOverflowException
- If the specified offset exceeds the available 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 way@NotNull R writeOrderedLong(long offset, long i) throws BufferOverflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException
offset
- The non-negative position within the data stream to write the long integer to.i
- The long integer value to write.BufferOverflowException
- If the specified offset exceeds the available 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 way@NotNull default R writeOrderedDouble(long offset, double d) throws BufferOverflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException
offset
- The position within the data stream to write the double to.d
- The double value to write.BufferOverflowException
- If the specified offset exceeds the available 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 way@NotNull R writeFloat(long offset, float d) throws BufferOverflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException
offset
- The non-negative position within the data stream to write the float to.d
- The float value to write.BufferOverflowException
- If the specified offset exceeds the available 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 way@NotNull R writeDouble(long offset, double d) throws BufferOverflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException
offset
- The non-negative position within the data stream to write the double to.d
- The double value to write.BufferOverflowException
- If the specified offset exceeds the available 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 way@NotNull R writeVolatileByte(long offset, byte i8) throws BufferOverflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException
offset
- The non-negative position within the data stream to write the byte to.i8
- The byte value to write.BufferOverflowException
- If the specified offset exceeds the available 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 way@NotNull R writeVolatileShort(long offset, short i16) throws BufferOverflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException
offset
- The non-negative position within the data stream to write the short to.i16
- The short value to write.BufferOverflowException
- If the specified offset exceeds the available 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 way@NotNull R writeVolatileInt(long offset, int i32) throws BufferOverflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException
offset
- The non-negative position within the data stream to write the integer to.i32
- The integer value to write.BufferOverflowException
- If the specified offset exceeds the available 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 way@NotNull R writeVolatileLong(long offset, long i64) throws BufferOverflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException
offset
- The non-negative position within the data stream to write the long integer to.i64
- The long integer value to write.BufferOverflowException
- If the specified offset exceeds the available 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 way@NotNull default R writeVolatileFloat(long offset, float f) throws BufferOverflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException
offset
- The non-negative position within the data stream to write the float to.f
- The float value to write.BufferOverflowException
- If the specified offset exceeds the available 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 way@NotNull default R writeVolatileDouble(long offset, double d) throws BufferOverflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException
offset
- The non-negative position within the data stream to write the double to.d
- The double value to write.BufferOverflowException
- If the specified offset exceeds the available 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 way@NotNull default R write(long offsetInRDO, byte[] bytes) throws BufferOverflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException
write(long, byte[], int, int)
.offsetInRDO
- the non-negative offset within the data output where the byte array should be written.bytes
- the byte array to be written.BufferOverflowException
- If the capacity of this data output was exceeded.NullPointerException
- If the provided byte array is null.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 way@NotNull R write(long writeOffset, byte[] byteArray, int readOffset, int length) throws BufferOverflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
byteArray
to this Bytes object starting at writeOffset
taking
content starting at readOffset
but copying at most length
bytes.
Does not update cursors e.g. writePosition()
writeOffset
- the non-negative offset within the data output where the segment should be written.byteArray
- the byte array containing the segment to be written.readOffset
- the non-negative offset within the byte array where the segment begins.length
- the non-negative length of the segment.BufferOverflowException
- If the capacity of this data output was exceeded.IllegalArgumentException
- If any of the provided offsets or length are negative.NullPointerException
- If the provided byte array is null.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 wayvoid write(long writeOffset, @NotNull @NotNull ByteBuffer bytes, int readOffset, int length) throws BufferOverflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException
Does not update cursors e.g. writePosition()
writeOffset
- the non-negative offset within the data output where the segment should be written.bytes
- the ByteBuffer containing the segment to be written.readOffset
- the non-negative offset within the ByteBuffer where the segment begins.length
- the non-negative length of the segment.BufferOverflowException
- If the capacity of this data output was exceeded.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 way@NotNull default R write(long offsetInRDO, @NotNull @NotNull BytesStore bytes) throws BufferOverflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException
write(long, RandomDataInput, long, long)
.offsetInRDO
- the non-negative offset within the data output where the BytesStore content should be written.bytes
- the BytesStore whose content should be written.BufferOverflowException
- If the capacity of this data output was exceeded.net.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.NullPointerException
- If the provided BytesStore is null.@NotNull R write(long writeOffset, @NotNull @NotNull RandomDataInput bytes, long readOffset, long length) throws BufferOverflowException, BufferUnderflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
writePosition()
of this output nor the RandomCommon.readPosition()
of the input.writeOffset
- the non-negative offset within this data output where the segment should be written.bytes
- the RandomDataInput source containing the segment to be written.readOffset
- the non-negative offset within the source where the segment begins.length
- the non-negative length of the segment.BufferOverflowException
- If the capacity of this data output was exceeded.BufferUnderflowException
- If the source does not have enough data to fill the length.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 way@NotNull R zeroOut(long start, long end) throws net.openhft.chronicle.core.io.ClosedIllegalStateException
start
- the starting index of the range to zero out (inclusive).end
- the ending index of the range to zero out (exclusive).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 way@NotNull default R append(long offset, long value, int digits) throws BufferOverflowException, IllegalArgumentException, net.openhft.chronicle.core.io.ClosedIllegalStateException
offset
- the non-negative offset to append the string at.value
- the long value to be appended.digits
- the number of digits in the appended string.BufferOverflowException
- If the capacity of this data output was exceeded.IllegalArgumentException
- If the number of digits is not compatible with the long value.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 way@NotNull default R append(long offset, double value, int decimalPlaces, int digits) throws BufferOverflowException, IllegalArgumentException, net.openhft.chronicle.core.io.ClosedIllegalStateException, ArithmeticException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
offset
- the non-negative offset to append the string at.value
- the double value to be appended.decimalPlaces
- the number of decimal places in the appended string.digits
- the total number of digits in the appended string.BufferOverflowException
- If the capacity of this data output was exceeded.IllegalArgumentException
- If the number of digits or decimal places is not compatible with the double value.ArithmeticException
- If rounding errors occur during the conversion of the double value to string.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 wayvoid nativeWrite(long address, long position, long size) throws BufferOverflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
address
- the address in the native memory from where data should be copied.position
- the position in the BytesStore where data should be written.size
- the size of the data, in bytes, to be copied from the native memory.BufferOverflowException
- If the capacity of this BytesStore was exceeded.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 waydefault long writeUtf8(long writeOffset, @Nullable @Nullable CharSequence text) throws BufferOverflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException, ArithmeticException
text
into this RandomDataOutput
writing at the given writeOffset
,
in Utf8 format. Returns the new write position after writing the provided text
.writeOffset
- the offset at which the text should be written.text
- the CharSequence to write, which can be null.BufferOverflowException
- If the capacity of this RandomDataOutput was exceeded.net.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.ArithmeticException
- If errors occur during the conversion of the CharSequence to UTF-8.RandomDataInput.readUtf8(long, Appendable)
default long writeUtf8Limited(long writeOffset, @Nullable @Nullable CharSequence text, int maxUtf8Len) throws BufferOverflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException, ArithmeticException
text
to this RandomDataOutput
writing at the provided writeOffset
,
in Utf8 format, checking that the utf8 encoding size of the given char sequence is less or
equal to the provided maxUtf8Len
, otherwise IllegalArgumentException
is thrown,
and no bytes of this RandomDataOutput
are overwritten. Returns the new write position after
writing the provided text
writeOffset
- the offset at which the text should be written.text
- the CharSequence to write, which can be null.maxUtf8Len
- the maximum length of the UTF-8 encoded text.IllegalArgumentException
- If the UTF-8 encoding size of the text exceeds maxUtf8Len.BufferOverflowException
- If the capacity of this RandomDataOutput was exceeded.net.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.ArithmeticException
- If errors occur during the conversion of the CharSequence to UTF-8.RandomDataInput.readUtf8Limited(long, Appendable, int)
,
RandomDataInput.readUtf8Limited(long, int)
long write8bit(long position, @NotNull @NotNull BytesStore bs) throws net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
position
- the position at which the BytesStore content should be written.bs
- the BytesStore instance to write.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 waylong write8bit(long position, @NotNull @NotNull String s, int start, int length) throws net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
position
- the position at which the string should be written.s
- the string to write.start
- the starting index from where characters are to be taken from the string.length
- the number of characters to be written from the string.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 wayboolean compareAndSwapInt(long offset, int expected, int value) throws BufferOverflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException
offset
- the offset at which to perform the CAS operation.expected
- the expected current value.value
- the new value to set if the current value matches the expected value.BufferOverflowException
- If the capacity of this RandomDataOutput was exceeded.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 wayvoid testAndSetInt(long offset, int expected, int value) throws BufferOverflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException
offset
- the offset at which to perform the test-and-set operation.expected
- the expected current value.value
- the new value to set if the current value matches the expected value.BufferOverflowException
- If the capacity of this RandomDataOutput was exceeded.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 wayboolean compareAndSwapLong(long offset, long expected, long value) throws BufferOverflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
offset
- the offset at which to perform the CAS operation.expected
- the expected current value.value
- the new value to set if the current value matches the expected value.BufferOverflowException
- If the capacity of this RandomDataOutput was exceeded.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 wayboolean compareAndSwapFloat(long offset, float expected, float value) throws net.openhft.chronicle.core.io.ClosedIllegalStateException
offset
- the offset at which to perform the CAS operation.expected
- the expected current value.value
- the new value to set if the current value matches the expected value.BufferOverflowException
- If the offset plus the size of a float exceeds the buffer's 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 wayboolean compareAndSwapDouble(long offset, double expected, double value) throws net.openhft.chronicle.core.io.ClosedIllegalStateException
compareAndSwapFloat(long, float, float)
, this is an atomic operation.offset
- the offset at which to perform the CAS operation.expected
- the expected current value.value
- the new value to set if the current value matches the expected value.BufferOverflowException
- If the offset plus the size of a double exceeds the buffer's 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 wayint addAndGetInt(long offset, int adding) throws net.openhft.chronicle.core.io.ClosedIllegalStateException
offset
- the offset at which the current value is stored and to which the specified
value is to be added.adding
- the value to add to the current value at the specified offset.BufferUnderflowException
- If the specified offset is not within the bounds of 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 waylong addAndGetLong(long offset, long adding) throws net.openhft.chronicle.core.io.ClosedIllegalStateException
offset
- the offset where the current value is stored and to which the specified
value is to be added.adding
- the value to add to the current value at the specified offset.BufferUnderflowException
- If the specified offset is not within the bounds of 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 wayfloat addAndGetFloat(long offset, float adding) throws net.openhft.chronicle.core.io.ClosedIllegalStateException
offset
- the offset at which the current value is stored and to which the specified
value is to be added.adding
- the value to add to the current value at the specified offset.BufferUnderflowException
- If the specified offset is not within the bounds of 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 waydouble addAndGetDouble(long offset, double adding) throws net.openhft.chronicle.core.io.ClosedIllegalStateException
offset
- the offset where the current value is stored and to which the specified
value is to be added.adding
- the value to add to the current value at the specified offset.BufferUnderflowException
- If the specified offset is not within the bounds of 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 waydefault long appendAndReturnLength(long writePosition, boolean negative, long mantissa, int exponent, boolean append0)
default long start()
default long capacity()
default long realCapacity()
default long readPosition()
The read position is start() <= readPosition() && readPosition() <= readLimit() && readPosition < safeLimit()
If the resource is closed, the returned value is unspecified.
default long writePosition()
The write position is readPosition() <= writePosition() && writePosition() <= writeLimit()
If the resource is closed, the returned value is unspecified.
default long lengthWritten(long startPosition)
Typically this calculates the difference however for HexDumpBytes it's not as simple.
If the resource is closed, the returned value is unspecified.
startPosition
- The position to calculate the length from.default long readRemaining()
If the resource is closed, the returned value is unspecified.
default long realReadRemaining()
If the resource is closed, the returned value is unspecified.
default long writeRemaining()
If the resource is closed, the returned value is unspecified.
default long realWriteRemaining()
If the resource is closed, the returned value is unspecified.
default long readLimit()
If the resource is closed, the returned value is unspecified.
default long writeLimit()
If the resource is closed, the returned value is unspecified.
long addressForRead(long offset) throws UnsupportedOperationException, BufferUnderflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
offset
- within this buffer. addressForRead(start()) is the actual addressForRead of the first byte.UnsupportedOperationException
- If the underlying buffer is on the heapBufferUnderflowException
- If the offset is before the start() or the after the 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 waydefault long addressForRead(long offset, int buffer) throws UnsupportedOperationException, BufferUnderflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
offset
- The offset within this buffer.buffer
- The buffer index.UnsupportedOperationException
- If the underlying buffer is on the heap.BufferUnderflowException
- If the offset is before the start or after the 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 waylong addressForWrite(long offset) throws UnsupportedOperationException, BufferOverflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
offset
- within this buffer. addressForRead(start()) is the actual addressForRead of the first byte.UnsupportedOperationException
- If the underlying buffer is on the heapBufferOverflowException
- If the offset is before the start() or the after the 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 waylong addressForWritePosition() throws UnsupportedOperationException, BufferOverflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException
UnsupportedOperationException
- If the underlying buffer is on the heap.BufferOverflowException
- If the current write position is before the start or after the 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 waydefault ByteOrder byteOrder()
@NotNull @NotNull Bytes<?> bytesForRead() throws net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
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 way@NotNull @NotNull Bytes<?> bytesForWrite() throws net.openhft.chronicle.core.io.ClosedIllegalStateException
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 wayboolean sharedMemory()
boolean isDirectMemory()
Copyright © 2024. All rights reserved.