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 |
address(long offset)
Obtain the underlying address.
|
default ByteOrder |
byteOrder() |
Bytes |
bytesForRead() |
Bytes |
bytesForWrite() |
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,
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(byte[] bytes)
Read a byte[] from memory.
|
default int |
copyTo(ByteBuffer bb) |
static String[] |
createCharToString() |
default int |
fastHash(long offset,
int length) |
default int |
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 String |
readUtf8Limited(long offset,
int maxUtf8Len)
Reads a char sequence from the given
offset , encoded as Utf8. |
default 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.
|
default long |
readVolatileLong(long offset)
Read a 64-bit long from memory with a load barrier.
|
default short |
readVolatileShort(long offset)
Read a 16-bit short from memory with a load barrier.
|
long |
realCapacity() |
boolean |
sharedMemory() |
default long |
start() |
default BytesStore |
subBytes(long start,
long length)
Copy a sub sequence of bytes as a BytesStore.
|
default 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 String[] createCharToString()
default int peekVolatileInt()
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)
offset
- to readshort 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 Bytesdefault byte readVolatileByte(long offset) throws BufferUnderflowException
offset
- to readBufferUnderflowException
- if the offset is outside the limits of the Bytesdefault short 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 Bytesdefault long 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 byte[] bytes) throws BufferUnderflowException
BufferUnderflowException
- if the offset is outside the limits of the Bytesdefault int copyTo(@NotNull ByteBuffer bb) throws BufferUnderflowException
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 Bytesdefault BytesStore subBytes(long start, long length)
start
- of byteslength
- of bytesdefault int 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 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 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.default byte[] toByteArray() throws IllegalArgumentException
IllegalArgumentException
default long read(long offsetInRDI, byte[] bytes, int offset, int length)
default ByteBuffer toTemporaryDirectByteBuffer()
default int fastHash(long offset, int 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 address(long offset) throws UnsupportedOperationException, IllegalArgumentException
offset
- within this buffer. address(start()) is the actual address of the first byte.UnsupportedOperationException
- if the underlying buffer is on the heapIllegalArgumentException
- if the offset is before the start() or the after the capacity()default ByteOrder byteOrder()
Bytes bytesForRead() throws IllegalStateException
IllegalStateException
Bytes bytesForWrite() throws IllegalStateException
IllegalStateException
boolean compareAndSwapInt(long offset, int expected, int value) throws BufferOverflowException, IllegalArgumentException
offset
- to perform CASexpected
- valuevalue
- to setBufferOverflowException
IllegalArgumentException
boolean compareAndSwapLong(long offset, long expected, long value) throws BufferOverflowException, IllegalArgumentException
offset
- to perform CASexpected
- valuevalue
- to setBufferOverflowException
IllegalArgumentException
default boolean compareAndSwapFloat(long offset, float expected, float value) throws BufferOverflowException, IllegalArgumentException
offset
- to perform CASexpected
- valuevalue
- to setBufferOverflowException
IllegalArgumentException
default boolean compareAndSwapDouble(long offset, double expected, double value) throws BufferOverflowException, IllegalArgumentException
offset
- to perform CASexpected
- valuevalue
- to setBufferOverflowException
IllegalArgumentException
boolean sharedMemory()
boolean isDirectMemory()
Copyright © 2016. All rights reserved.