public interface RandomDataInput
Modifier and Type | Field and Description |
---|---|
static String[] |
charToString |
Modifier and Type | Method and Description |
---|---|
default double |
addAndGetDouble(long offset,
double adding)
Perform an atomic add and get operation for a 64-bit double
|
default float |
addAndGetFloat(long offset,
float adding)
Perform an atomic add and get operation for a 32-bit float
|
default int |
addAndGetInt(long offset,
int adding)
Perform an atomic add and get operation for a 32-bit int
|
default 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 ByteOrder |
byteOrder() |
@NotNull Bytes |
bytesForRead() |
@NotNull Bytes |
bytesForWrite() |
default boolean |
canReadDirect(long length) |
default long |
capacity() |
default boolean |
compareAndSwapDouble(long offset,
double expected,
double value)
Perform a 64-bit double CAS at a given offset.
|
default 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.
|
default boolean |
compareUtf8(long offset,
@Nullable CharSequence other)
Compares the UTF-8 encoded char sequence, written in this
RandomDataInput at the
given offset, with the given char sequence. |
default int |
copyTo(@NotNull byte[] bytes)
Read a byte[] from memory.
|
default int |
copyTo(@NotNull ByteBuffer bb)
Copy data from this RandomDataInput to the ByteBuffer.
|
static @NotNull String[] |
createCharToString() |
default int |
fastHash(long offset,
int length) |
default long |
findByte(byte stopByte) |
boolean |
isDirectMemory() |
void |
nativeRead(long position,
long address,
long size)
expert level method for copying data to native memory.
|
default long |
parseLong(long offset) |
int |
peekUnsignedByte(long offset)
Read an unsigned byte at an offset, or -1
|
default int |
peekVolatileInt() |
default String |
printable(long offset)
Read the byte at an offset and converts it into a printable
|
default long |
read(long offsetInRDI,
byte[] bytes,
int offset,
int length) |
default boolean |
readBoolean(long offset)
Read boolean at an offset
|
byte |
readByte(long offset)
Read byte at an offset
|
double |
readDouble(long offset)
Read a double at an offset
|
float |
readFloat(long offset)
Read a float at an offset
|
default long |
readIncompleteLong(long offset)
Read a long which is zero padded (high bytes) if the available bytes is less than 8.
|
int |
readInt(long offset)
Read an int at an offset
|
default long |
readLimit() |
long |
readLong(long offset)
Read a long at an offset
|
default long |
readPosition()
The read position must be start() <= readPosition() && readPosition() <= readLimit() && readPosition < safeLimit()
|
default long |
readRemaining() |
short |
readShort(long offset)
Read a short at an offset
|
default int |
readUnsignedByte(long offset)
Read an unsigned byte at an offset
|
default long |
readUnsignedInt(long offset)
Read an unsigned int at an offset
|
default int |
readUnsignedInt24(long offset)
Read an unsigned int at an offset
|
default int |
readUnsignedShort(long offset)
Read an unsigned short at an offset
|
default <ACS extends Appendable & CharSequence> |
readUtf8(long offset,
ACS sb)
Truncates
sb (it must be a StringBuilder or Bytes ) and reads a char
sequence from the given offset , encoded as Utf8, into it. |
default <ACS extends Appendable & CharSequence> |
readUtf8Limited(long offset,
ACS sb,
int maxUtf8Len)
Truncates
sb (it must be a StringBuilder or Bytes ) and reads a char
sequence from the given offset , encoded as Utf8, into it. |
default @Nullable String |
readUtf8Limited(long offset,
int maxUtf8Len)
Reads a char sequence from the given
offset , encoded as Utf8. |
byte |
readVolatileByte(long offset)
Read a 8-bit byte from memory with a load barrier.
|
default double |
readVolatileDouble(long offset)
Read a 64-bit double from memory with a load barrier.
|
default float |
readVolatileFloat(long offset)
Read a float from memory with a load barrier.
|
int |
readVolatileInt(long offset)
Read a 32-bit int from memory with a load barrier.
|
long |
readVolatileLong(long offset)
Read a 64-bit long from memory with a load barrier.
|
short |
readVolatileShort(long offset)
Read a 16-bit short from memory with a load barrier.
|
long |
realCapacity()
Returns the actual capacity that can be potentially read.
|
boolean |
sharedMemory() |
default long |
start() |
default @NotNull BytesStore |
subBytes(long start,
long length)
Copy a sub sequence of bytes as a BytesStore.
|
void |
testAndSetInt(long offset,
int expected,
int value) |
default @NotNull byte[] |
toByteArray() |
default ByteBuffer |
toTemporaryDirectByteBuffer() |
default long |
writeLimit() |
default long |
writePosition()
The read position must be readPosition() <= writePosition() && writePosition() <= writeLimit()
|
default long |
writeRemaining() |
static final String[] charToString
@NotNull static @NotNull String[] createCharToString()
default int peekVolatileInt() throws BufferUnderflowException
BufferUnderflowException
default boolean readBoolean(long offset) throws BufferUnderflowException
offset
- to readBufferUnderflowException
- if the offset is outside the limits of the Bytesbyte readByte(long offset) throws BufferUnderflowException
offset
- to readBufferUnderflowException
- if the offset is outside the limits of the Bytesdefault int readUnsignedByte(long offset) throws BufferUnderflowException
offset
- to readBufferUnderflowException
- if the offset is outside the limits of the Bytesint peekUnsignedByte(long offset) throws BufferUnderflowException
offset
- to readBufferUnderflowException
short readShort(long offset) throws BufferUnderflowException
offset
- to readBufferUnderflowException
- if the offset is outside the limits of the Bytesdefault int readUnsignedShort(long offset) throws BufferUnderflowException
offset
- to readBufferUnderflowException
- if the offset is outside the limits of the Bytesdefault int readUnsignedInt24(long offset) throws BufferUnderflowException
offset
- to readBufferUnderflowException
- if the offset is outside the limits of the Bytesint readInt(long offset) throws BufferUnderflowException
offset
- to readBufferUnderflowException
- if the offset is outside the limits of the Bytesdefault long readUnsignedInt(long offset) throws BufferUnderflowException
offset
- to readBufferUnderflowException
- if the offset is outside the limits of the Byteslong readLong(long offset) throws BufferUnderflowException
offset
- to readBufferUnderflowException
- if the offset is outside the limits of the Bytesfloat readFloat(long offset) throws BufferUnderflowException
offset
- to readBufferUnderflowException
- if the offset is outside the limits of the Bytesdouble readDouble(long offset) throws BufferUnderflowException
offset
- to readBufferUnderflowException
- if the offset is outside the limits of the Bytesdefault String printable(long offset) throws BufferUnderflowException
offset
- to readBufferUnderflowException
- if the offset is outside the limits of the Bytesbyte readVolatileByte(long offset) throws BufferUnderflowException
offset
- to readBufferUnderflowException
- if the offset is outside the limits of the Bytesshort readVolatileShort(long offset) throws BufferUnderflowException
offset
- to readBufferUnderflowException
- if the offset is outside the limits of the Bytesint readVolatileInt(long offset) throws BufferUnderflowException
offset
- to readBufferUnderflowException
- if the offset is outside the limits of the Bytesdefault float readVolatileFloat(long offset) throws BufferUnderflowException
offset
- to readBufferUnderflowException
- if the offset is outside the limits of the Byteslong readVolatileLong(long offset) throws BufferUnderflowException
offset
- to readBufferUnderflowException
- if the offset is outside the limits of the Bytesdefault double readVolatileDouble(long offset) throws BufferUnderflowException
offset
- to readBufferUnderflowException
- if the offset is outside the limits of the Bytesdefault long parseLong(long offset) throws BufferUnderflowException
BufferUnderflowException
void nativeRead(long position, long address, long size) throws BufferUnderflowException
position
- within the ByteStore to copy.address
- in native memorysize
- in bytesBufferUnderflowException
- if the offset is outside the limits of the Bytesdefault int copyTo(@NotNull @NotNull byte[] bytes) throws BufferUnderflowException
BufferUnderflowException
- if the offset is outside the limits of the Bytesdefault int copyTo(@NotNull @NotNull ByteBuffer bb) throws BufferUnderflowException
readRemaining()
and
Buffer.remaining()
. Starting from start()
in this RandomDataInput and from Buffer.position()
of the given bb. Does NOT change the position or limit or mark of the given ByteBuffer.
Returns the number of the copied bytes.BufferUnderflowException
default long readIncompleteLong(long offset)
offset
- to read fromlong realCapacity()
default int addAndGetInt(long offset, int adding) throws BufferUnderflowException
offset
- to add and getadding
- value to add, can be 1BufferUnderflowException
- if the offset is outside the limits of the Bytesdefault long addAndGetLong(long offset, long adding) throws BufferUnderflowException
offset
- to add and getadding
- value to add, can be 1BufferUnderflowException
- if the offset is outside the limits of the Bytesdefault float addAndGetFloat(long offset, float adding) throws BufferUnderflowException
offset
- to add and getadding
- value to add, can be 1BufferUnderflowException
- if the offset is outside the limits of the Bytesdefault double addAndGetDouble(long offset, double adding) throws BufferUnderflowException
offset
- to add and getadding
- value to add, can be 1BufferUnderflowException
- if the offset is outside the limits of the Bytes@NotNull default @NotNull BytesStore subBytes(long start, long length) throws BufferUnderflowException
start
- of byteslength
- of bytesBufferUnderflowException
default long findByte(byte stopByte)
default <ACS extends Appendable & CharSequence> long readUtf8(long offset, @NotNull ACS sb) throws net.openhft.chronicle.core.io.IORuntimeException, IllegalArgumentException, BufferUnderflowException
sb
(it must be a StringBuilder
or Bytes
) and reads a char
sequence from the given offset
, encoded as Utf8, into it. Returns offset after
the read Utf8, if a normal char sequence was read, or -1 - offset
, if null
was observed (in this case, sb
is truncated too, but not updated then, by querying
sb
only this case is indistinguishable from reading an empty char sequence).ACS
- buffer type, must be StringBuilder
or Bytes
offset
- the offset in this RandomDataInput
to read char sequence fromsb
- the buffer to read char sequence into (truncated first)null
net.openhft.chronicle.core.io.IORuntimeException
IllegalArgumentException
BufferUnderflowException
RandomDataOutput.writeUtf8(long, CharSequence)
default <ACS extends Appendable & CharSequence> long readUtf8Limited(long offset, @NotNull ACS sb, int maxUtf8Len) throws net.openhft.chronicle.core.io.IORuntimeException, IllegalArgumentException, BufferUnderflowException, IllegalStateException
sb
(it must be a StringBuilder
or Bytes
) and reads a char
sequence from the given offset
, encoded as Utf8, into it. Returns offset after
the read Utf8, if a normal char sequence was read, or -1 - offset
, if null
was observed (in this case, sb
is truncated too, but not updated then, by querying
sb
only this case is indistinguishable from reading an empty char sequence). If
length of Utf8 encoding of the char sequence exceeds maxUtf8Len
,
IllegalStateException
is thrown.ACS
- buffer type, must be StringBuilder
or Bytes
offset
- the offset in this RandomDataInput
to read char sequence fromsb
- the buffer to read char sequence into (truncated first)maxUtf8Len
- the maximum allowed length of the char sequence in Utf8 encodingnull
net.openhft.chronicle.core.io.IORuntimeException
IllegalArgumentException
BufferUnderflowException
IllegalStateException
RandomDataOutput.writeUtf8Limited(long, CharSequence, int)
@Nullable default @Nullable String readUtf8Limited(long offset, int maxUtf8Len) throws BufferUnderflowException, net.openhft.chronicle.core.io.IORuntimeException, IllegalArgumentException, IllegalStateException
offset
, encoded as Utf8. If length of Utf8
encoding of the char sequence exceeds maxUtf8Len
, IllegalStateException
is thrown.offset
- the offset in this RandomDataInput
to read char sequence frommaxUtf8Len
- the maximum allowed length of the char sequence in Utf8 encodingBufferUnderflowException
net.openhft.chronicle.core.io.IORuntimeException
IllegalArgumentException
IllegalStateException
RandomDataOutput.writeUtf8Limited(long, CharSequence, int)
default boolean compareUtf8(long offset, @Nullable @Nullable CharSequence other) throws net.openhft.chronicle.core.io.IORuntimeException
RandomDataInput
at the
given offset, with the given char sequence. Returns true
, if they are equal. Both
char sequences (encoded in bytes and the given) may be null
.offset
- the offset in this RandomDataInput
where the char sequence to compare
is writtenother
- the second char sequence to comparetrue
if two char sequences are equalnet.openhft.chronicle.core.io.IORuntimeException
- if the contents are not a valid string.@NotNull default @NotNull byte[] toByteArray() throws IllegalArgumentException
IllegalArgumentException
default long read(long offsetInRDI, byte[] bytes, int offset, int length)
default ByteBuffer toTemporaryDirectByteBuffer() throws IllegalArgumentException
IllegalArgumentException
default int fastHash(long offset, int length) throws BufferUnderflowException
BufferUnderflowException
default boolean canReadDirect(long length)
default long start()
default long capacity()
default long readPosition()
default long writePosition()
default long readRemaining()
default long writeRemaining()
default long readLimit()
default long writeLimit()
long addressForRead(long offset) throws UnsupportedOperationException, BufferUnderflowException
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()default long addressForRead(long offset, int buffer) throws UnsupportedOperationException, BufferUnderflowException
long addressForWrite(long offset) throws UnsupportedOperationException, BufferOverflowException
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()long addressForWritePosition() throws UnsupportedOperationException, BufferOverflowException
default ByteOrder byteOrder()
@NotNull @NotNull Bytes bytesForRead() throws IllegalStateException
IllegalStateException
@NotNull @NotNull Bytes bytesForWrite() throws IllegalStateException
IllegalStateException
boolean compareAndSwapInt(long offset, int expected, int value) throws BufferOverflowException
offset
- to perform CASexpected
- valuevalue
- to setBufferOverflowException
void testAndSetInt(long offset, int expected, int value)
boolean compareAndSwapLong(long offset, long expected, long value) throws BufferOverflowException
offset
- to perform CASexpected
- valuevalue
- to setBufferOverflowException
default boolean compareAndSwapFloat(long offset, float expected, float value) throws BufferOverflowException
offset
- to perform CASexpected
- valuevalue
- to setBufferOverflowException
default boolean compareAndSwapDouble(long offset, double expected, double value) throws BufferOverflowException
offset
- to perform CASexpected
- valuevalue
- to setBufferOverflowException
boolean sharedMemory()
boolean isDirectMemory()
Copyright © 2020. All rights reserved.