public interface RandomDataOutput<R extends RandomDataOutput<R>>
Modifier and Type | Method and Description |
---|---|
double |
addAndGetDouble(long offset,
double adding)
Perform an atomic add and get operation for a 64-bit double
|
float |
addAndGetFloat(long offset,
float adding)
Perform an atomic add and get operation for a 32-bit float
|
int |
addAndGetInt(long offset,
int adding)
Perform an atomic add and get operation for a 32-bit int
|
long |
addAndGetLong(long offset,
long adding)
Perform an atomic add and get operation for a 64-bit long
|
long |
addressForRead(long offset)
Obtain the underlying addressForRead.
|
default long |
addressForRead(long offset,
int buffer) |
long |
addressForWrite(long offset)
Obtain the underlying addressForRead.
|
long |
addressForWritePosition() |
default R |
append(long offset,
double value,
int decimalPlaces,
int digits) |
default R |
append(long offset,
long value,
int digits) |
default ByteOrder |
byteOrder() |
@NotNull Bytes<?> |
bytesForRead() |
@NotNull Bytes<?> |
bytesForWrite() |
default long |
capacity() |
boolean |
compareAndSwapDouble(long offset,
double expected,
double value)
Perform a 64-bit double CAS at a given offset.
|
boolean |
compareAndSwapFloat(long offset,
float expected,
float value)
Perform a 32-bit float CAS at a given offset.
|
boolean |
compareAndSwapInt(long offset,
int expected,
int value)
Perform a 32-bit CAS at a given offset.
|
boolean |
compareAndSwapLong(long offset,
long expected,
long value)
Perform a 64-bit CAS at a given offset.
|
byte[] |
internalNumberBuffer() |
boolean |
isDirectMemory() |
default long |
lengthWritten(long startPosition)
Typically this calculates the difference however for HexDumpBytes it's not as simple.
|
void |
nativeWrite(long address,
long position,
long size)
expert level method to copy data from native memory into the BytesStore
|
default long |
readLimit()
If the resource is closed, the returned value is unspecified.
|
default long |
readPosition()
Returns the read position.
|
default long |
readRemaining()
Returns the remaining bytes that can be read.
|
default long |
realCapacity() |
default long |
realReadRemaining()
If the resource is closed, the returned value is unspecified.
|
default long |
realWriteRemaining()
If the resource is closed, the returned value is unspecified.
|
boolean |
sharedMemory() |
default long |
start() |
void |
testAndSetInt(long offset,
int expected,
int value) |
default R |
write(long offsetInRDO,
byte[] bytes)
Copies whole byte[] into this.
|
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)
Copy from ByteBuffer into this.
|
default R |
write(long offsetInRDO,
@NotNull BytesStore bytes)
Copies whole BytesStore into this - see
write(long, RandomDataInput, long, long) |
R |
write(long writeOffset,
@NotNull RandomDataInput bytes,
long readOffset,
long length)
Copy from RandomDataInput into this.
|
long |
write8bit(long position,
@NotNull BytesStore bs)
Write the stop bit length and copy the BytesStore
|
long |
write8bit(long position,
@NotNull String s,
int start,
int length) |
default R |
writeBoolean(long offset,
boolean flag)
Write a boolean at an offset.
|
R |
writeByte(long offset,
byte i8)
Write an unsigned byte at an offset.
|
default R |
writeByte(long offset,
int i)
Write a byte at an offset.
|
R |
writeDouble(long offset,
double d)
Write a double at an offset.
|
R |
writeFloat(long offset,
float d)
Write a float at an offset.
|
R |
writeInt(long offset,
int i)
Write an int at an offset.
|
default R |
writeInt24(long offset,
int i) |
default long |
writeLimit()
Returns the write limit.
|
R |
writeLong(long offset,
long i)
Write a long at an offset.
|
default R |
writeOrderedDouble(long offset,
double d)
Perform a non stalling write with a store barrier.
|
default R |
writeOrderedFloat(long offset,
float f)
Perform a non stalling write with a store barrier.
|
R |
writeOrderedInt(long offset,
int i)
Perform a non stalling write with a store barrier.
|
R |
writeOrderedLong(long offset,
long i)
Perform a non stalling write with a store barrier.
|
default long |
writePosition()
Returns the write position.
|
default long |
writeRemaining()
If the resource is closed, the returned value is unspecified.
|
R |
writeShort(long offset,
short i)
Write a short at an offset.
|
default R |
writeUnsignedByte(long offset,
int i)
Write an unsigned byte at an offset.
|
default R |
writeUnsignedInt(long offset,
long i)
Write an unsigned byte at an offset.
|
default R |
writeUnsignedShort(long offset,
int i)
Write an unsigned byte at an 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) |
default R |
writeVolatileDouble(long offset,
double d) |
default R |
writeVolatileFloat(long offset,
float f) |
R |
writeVolatileInt(long offset,
int i32) |
R |
writeVolatileLong(long offset,
long i64) |
R |
writeVolatileShort(long offset,
short i16) |
R |
zeroOut(long start,
long end)
Zero out the bytes between the start and the end.
|
@NotNull default R writeByte(long offset, int i) throws BufferOverflowException, IllegalArgumentException, ArithmeticException, IllegalStateException
offset
- to write toi
- the valueBufferOverflowException
- if the capacity was exceededIllegalArgumentException
- if the value cannot be cast to the type without loss.ArithmeticException
IllegalStateException
@NotNull default R writeUnsignedByte(long offset, int i) throws BufferOverflowException, IllegalArgumentException, ArithmeticException, IllegalStateException
offset
- to write toi
- the valueBufferOverflowException
- if the capacity was exceededIllegalArgumentException
- if the value cannot be cast to the type without loss.ArithmeticException
IllegalStateException
@NotNull default R writeBoolean(long offset, boolean flag) throws BufferOverflowException, IllegalStateException
offset
- to write toflag
- the valueBufferOverflowException
- if the capacity was exceededIllegalStateException
@NotNull default R writeUnsignedShort(long offset, int i) throws BufferOverflowException, ArithmeticException, IllegalStateException
offset
- to write toi
- the valueBufferOverflowException
- if the capacity was exceededArithmeticException
- if the value cannot be cast to the type without loss.IllegalStateException
@NotNull default R writeUnsignedInt(long offset, long i) throws BufferOverflowException, ArithmeticException, IllegalStateException
offset
- to write toi
- the valueBufferOverflowException
- if the capacity was exceededArithmeticException
- if the value cannot be cast to the type without loss.IllegalStateException
@NotNull R writeByte(long offset, byte i8) throws BufferOverflowException, IllegalStateException
offset
- to write toi8
- the valueBufferOverflowException
- if the capacity was exceededIllegalStateException
@NotNull R writeShort(long offset, short i) throws BufferOverflowException, IllegalStateException
offset
- to write toi
- the valueBufferOverflowException
- if the capacity was exceededIllegalStateException
@NotNull default R writeInt24(long offset, int i) throws BufferOverflowException, IllegalStateException
@NotNull R writeInt(long offset, int i) throws BufferOverflowException, IllegalStateException
offset
- to write toi
- the valueBufferOverflowException
- if the capacity was exceededIllegalStateException
@NotNull R writeOrderedInt(long offset, int i) throws BufferOverflowException, IllegalStateException
offset
- to write toi
- value to writeBufferOverflowException
- if the capacity was exceededIllegalStateException
@NotNull default R writeOrderedFloat(long offset, float f) throws BufferOverflowException, IllegalStateException
offset
- to write tof
- value to writeBufferOverflowException
- if the capacity was exceededIllegalStateException
@NotNull R writeLong(long offset, long i) throws BufferOverflowException, IllegalStateException
offset
- to write toi
- the valueBufferOverflowException
- if the capacity was exceededIllegalStateException
@NotNull R writeOrderedLong(long offset, long i) throws BufferOverflowException, IllegalStateException
offset
- to write toi
- value to writeBufferOverflowException
IllegalStateException
@NotNull default R writeOrderedDouble(long offset, double d) throws BufferOverflowException, IllegalStateException
offset
- to write tod
- value to writeBufferOverflowException
IllegalStateException
@NotNull R writeFloat(long offset, float d) throws BufferOverflowException, IllegalStateException
offset
- to write tod
- the valueBufferOverflowException
- if the capacity was exceededIllegalStateException
@NotNull R writeDouble(long offset, double d) throws BufferOverflowException, IllegalStateException
offset
- to write tod
- the valueBufferOverflowException
- if the capacity was exceededIllegalStateException
@NotNull R writeVolatileByte(long offset, byte i8) throws BufferOverflowException, IllegalStateException
@NotNull R writeVolatileShort(long offset, short i16) throws BufferOverflowException, IllegalStateException
@NotNull R writeVolatileInt(long offset, int i32) throws BufferOverflowException, IllegalStateException
@NotNull R writeVolatileLong(long offset, long i64) throws BufferOverflowException, IllegalStateException
@NotNull default R writeVolatileFloat(long offset, float f) throws BufferOverflowException, IllegalStateException
@NotNull default R writeVolatileDouble(long offset, double d) throws BufferOverflowException, IllegalStateException
@NotNull default R write(long offsetInRDO, byte[] bytes) throws BufferOverflowException, IllegalStateException
write(long, byte[], int, int)
@NotNull R write(long writeOffset, byte[] byteArray, int readOffset, int length) throws BufferOverflowException, IllegalStateException
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
- non-negative offset to write tobyteArray
- non-null copy from byteArrayreadOffset
- non-negative copy from offsetlength
- non-negative length to copyBufferOverflowException
- if this Bytes object cannot accommodate all the bytes to copy.IllegalStateException
- if this Bytes object has been previously releasedIllegalArgumentException
- if the provided writeOffset
, readOffset
or length
is negativeNullPointerException
- if the provided byteArray
is null
void write(long writeOffset, @NotNull @NotNull ByteBuffer bytes, int readOffset, int length) throws BufferOverflowException, IllegalStateException
Does not update cursors e.g. writePosition()
writeOffset
- offset to write tobytes
- copy from bytesreadOffset
- copy from offsetlength
- BufferOverflowException
IllegalStateException
@NotNull default R write(long offsetInRDO, @NotNull @NotNull BytesStore bytes) throws BufferOverflowException, IllegalStateException
write(long, RandomDataInput, long, long)
@NotNull R write(long writeOffset, @NotNull @NotNull RandomDataInput bytes, long readOffset, long length) throws BufferOverflowException, BufferUnderflowException, IllegalStateException
writePosition()
nor RandomCommon.readPosition()
writeOffset
- offset to write tobytes
- copy from bytesreadOffset
- copy from offsetlength
- BufferOverflowException
IllegalStateException
BufferUnderflowException
@NotNull R zeroOut(long start, long end) throws IllegalStateException
start
- index of first byte inclusiveend
- index of last byte exclusiveBufferOverflowException
- if the capacity was exceededIllegalStateException
@NotNull default R append(long offset, long value, int digits) throws BufferOverflowException, IllegalArgumentException, IllegalStateException
@NotNull default R append(long offset, double value, int decimalPlaces, int digits) throws BufferOverflowException, IllegalArgumentException, IllegalStateException, ArithmeticException
void nativeWrite(long address, long position, long size) throws BufferOverflowException, IllegalStateException
address
- in native memory to copy fromposition
- in BytesStore to copy tosize
- in bytesBufferOverflowException
IllegalStateException
default long writeUtf8(long writeOffset, @Nullable @Nullable CharSequence text) throws BufferOverflowException, IllegalStateException, 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 writeOffset to write char sequence fromtext
- the char sequence to write, could be null
RandomDataOutput
BufferOverflowException
IllegalStateException
ArithmeticException
RandomDataInput.readUtf8(long, Appendable)
default long writeUtf8Limited(long writeOffset, @Nullable @Nullable CharSequence text, int maxUtf8Len) throws BufferOverflowException, IllegalStateException, 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 writeOffset to write char sequence fromtext
- the char sequence to write, could be null
maxUtf8Len
- the maximum allowed length (in Utf8 encoding) of the given char sequenceRandomDataOutput
IllegalArgumentException
- if the given char sequence size in Utf8 encoding exceeds
maxUtf8LenBufferOverflowException
IllegalStateException
ArithmeticException
RandomDataInput.readUtf8Limited(long, Appendable, int)
,
RandomDataInput.readUtf8Limited(long, int)
long write8bit(long position, @NotNull @NotNull BytesStore bs)
position
- to writebs
- to copy.RandomDataOutput
long write8bit(long position, @NotNull @NotNull String s, int start, int length)
boolean compareAndSwapInt(long offset, int expected, int value) throws BufferOverflowException, IllegalStateException
offset
- to perform CASexpected
- valuevalue
- to setBufferOverflowException
IllegalStateException
void testAndSetInt(long offset, int expected, int value) throws BufferOverflowException, IllegalStateException
boolean compareAndSwapLong(long offset, long expected, long value) throws BufferOverflowException, IllegalStateException
offset
- to perform CASexpected
- valuevalue
- to setBufferOverflowException
IllegalStateException
boolean compareAndSwapFloat(long offset, float expected, float value)
offset
- to perform CASexpected
- valuevalue
- to setboolean compareAndSwapDouble(long offset, double expected, double value)
offset
- to perform CASexpected
- valuevalue
- to setint addAndGetInt(long offset, int adding)
offset
- to add and getadding
- value to add, can be 1BufferUnderflowException
- if the offset is outside the limits of the BytesIllegalStateException
- if releasedlong addAndGetLong(long offset, long adding)
offset
- to add and getadding
- value to add, can be 1BufferUnderflowException
- if the offset is outside the limits of the BytesIllegalStateException
- if releasedfloat addAndGetFloat(long offset, float adding)
offset
- to add and getadding
- value to add, can be 1BufferUnderflowException
- if the offset is outside the limits of the Bytesdouble addAndGetDouble(long offset, double adding)
offset
- to add and getadding
- value to add, can be 1BufferUnderflowException
- if the offset is outside the limits of the BytesIllegalStateException
- if releasedbyte[] internalNumberBuffer()
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)
If the resource is closed, the returned value is unspecified.
startPosition
- to compare againstdefault 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, IllegalStateException
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()IllegalStateException
default long addressForRead(long offset, int buffer) throws UnsupportedOperationException, BufferUnderflowException, IllegalStateException
long addressForWrite(long offset) throws UnsupportedOperationException, BufferOverflowException, IllegalStateException
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()IllegalStateException
long addressForWritePosition() throws UnsupportedOperationException, BufferOverflowException, IllegalStateException
default ByteOrder byteOrder()
@NotNull @NotNull Bytes<?> bytesForRead() throws IllegalStateException
IllegalStateException
@NotNull @NotNull Bytes<?> bytesForWrite() throws IllegalStateException
IllegalStateException
boolean sharedMemory()
boolean isDirectMemory()
Copyright © 2023. All rights reserved.