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)
Deprecated.
|
default float |
addAndGetFloat(long offset,
float adding)
Deprecated.
|
default int |
addAndGetInt(long offset,
int adding)
Deprecated.
|
default long |
addAndGetLong(long offset,
long adding)
Deprecated.
|
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() |
default boolean |
canReadDirect(long length) |
default long |
capacity() |
default boolean |
compareAndSwapDouble(long offset,
double expected,
double value)
Deprecated.
|
default boolean |
compareAndSwapFloat(long offset,
float expected,
float value)
Deprecated.
|
boolean |
compareAndSwapInt(long offset,
int expected,
int value)
Deprecated.
|
boolean |
compareAndSwapLong(long offset,
long expected,
long value)
Deprecated.
|
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(byte[] bytes)
Read a byte[] from memory from
RandomCommon.readPosition()
to RandomCommon.readLimit() . |
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() |
default long |
lengthWritten(long startPosition)
Typically this calculates the difference however for HexDumpBytes it's not as simple.
|
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()
If the resource is closed, the returned value is unspecified.
|
long |
readLong(long offset)
Read a long at an offset
|
default long |
readPosition()
Returns the read position.
|
default long |
readRemaining()
Returns the remaining bytes that can be read.
|
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 <T extends Appendable & CharSequence> |
readUtf8(long offset,
T 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 @Nullable String |
readUtf8Limited(long offset,
int maxUtf8Len)
Reads a char sequence from the given
offset , encoded as Utf8. |
default <T extends Appendable & CharSequence> |
readUtf8Limited(long offset,
T 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. |
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.
|
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() |
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)
Deprecated.
|
default byte[] |
toByteArray() |
default ByteBuffer |
toTemporaryDirectByteBuffer() |
default long |
writeLimit()
Returns the write limit.
|
default long |
writePosition()
Returns the write position.
|
default long |
writeRemaining()
If the resource is closed, the returned value is unspecified.
|
static final String[] charToString
@NotNull static @NotNull String[] createCharToString()
default int peekVolatileInt() throws BufferUnderflowException, IllegalStateException
default boolean readBoolean(long offset) throws BufferUnderflowException, IllegalStateException
offset
- to readBufferUnderflowException
- if the offset is outside the limits of the BytesIllegalStateException
- if releasedbyte readByte(long offset) throws BufferUnderflowException, IllegalStateException
offset
- to readBufferUnderflowException
- if the offset is outside the limits of the BytesIllegalStateException
- if releaseddefault int readUnsignedByte(long offset) throws BufferUnderflowException, IllegalStateException
offset
- to readBufferUnderflowException
- if the offset is outside the limits of the BytesIllegalStateException
- if releasedint peekUnsignedByte(long offset) throws IllegalStateException
offset
- to readIllegalStateException
- if releasedshort readShort(long offset) throws BufferUnderflowException, IllegalStateException
offset
- to readBufferUnderflowException
- if the offset is outside the limits of the BytesIllegalStateException
- if releaseddefault int readUnsignedShort(long offset) throws BufferUnderflowException, IllegalStateException
offset
- to readBufferUnderflowException
- if the offset is outside the limits of the BytesIllegalStateException
- if releaseddefault int readUnsignedInt24(long offset) throws BufferUnderflowException, IllegalStateException
offset
- to readBufferUnderflowException
- if the offset is outside the limits of the BytesIllegalStateException
- if releasedint readInt(long offset) throws BufferUnderflowException, IllegalStateException
offset
- to readBufferUnderflowException
- if the offset is outside the limits of the BytesIllegalStateException
- if releaseddefault long readUnsignedInt(long offset) throws BufferUnderflowException, IllegalStateException
offset
- to readBufferUnderflowException
- if the offset is outside the limits of the BytesIllegalStateException
- if releasedlong readLong(long offset) throws BufferUnderflowException, IllegalStateException
offset
- to readBufferUnderflowException
- if the offset is outside the limits of the BytesIllegalStateException
- if releasedfloat readFloat(long offset) throws BufferUnderflowException, IllegalStateException
offset
- to readBufferUnderflowException
- if the offset is outside the limits of the BytesIllegalStateException
- if releaseddouble readDouble(long offset) throws BufferUnderflowException, IllegalStateException
offset
- to readBufferUnderflowException
- if the offset is outside the limits of the BytesIllegalStateException
- if releaseddefault String printable(long offset) throws BufferUnderflowException, IllegalStateException
offset
- to readBufferUnderflowException
- if the offset is outside the limits of the BytesIllegalStateException
- if releasedbyte readVolatileByte(long offset) throws BufferUnderflowException, IllegalStateException
offset
- to readBufferUnderflowException
- if the offset is outside the limits of the BytesIllegalStateException
- if releasedshort readVolatileShort(long offset) throws BufferUnderflowException, IllegalStateException
offset
- to readBufferUnderflowException
- if the offset is outside the limits of the BytesIllegalStateException
- if releasedint readVolatileInt(long offset) throws BufferUnderflowException, IllegalStateException
offset
- to readBufferUnderflowException
- if the offset is outside the limits of the BytesIllegalStateException
- if releaseddefault float readVolatileFloat(long offset) throws BufferUnderflowException, IllegalStateException
offset
- to readBufferUnderflowException
- if the offset is outside the limits of the BytesIllegalStateException
- if releasedlong readVolatileLong(long offset) throws BufferUnderflowException, IllegalStateException
offset
- to readBufferUnderflowException
- if the offset is outside the limits of the BytesIllegalStateException
- if releaseddefault double readVolatileDouble(long offset) throws BufferUnderflowException, IllegalStateException
offset
- to readBufferUnderflowException
- if the offset is outside the limits of the BytesIllegalStateException
- if releaseddefault long parseLong(long offset) throws BufferUnderflowException, IllegalStateException
void nativeRead(long position, long address, long size) throws BufferUnderflowException, IllegalStateException
position
- within the ByteStore to copy.address
- in native memorysize
- in bytesBufferUnderflowException
- if the offset is outside the limits of the BytesIllegalStateException
- if releaseddefault int copyTo(byte[] bytes) throws BufferUnderflowException, IllegalStateException
RandomCommon.readPosition()
to RandomCommon.readLimit()
.BufferUnderflowException
- if the offset is outside the limits of the BytesIllegalStateException
- if releaseddefault int copyTo(@NotNull @NotNull ByteBuffer bb) throws BufferUnderflowException, IllegalStateException
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.IllegalStateException
- if releasedBufferUnderflowException
default long readIncompleteLong(long offset) throws IllegalStateException
offset
- to read fromIllegalStateException
- if releasedlong realCapacity()
@Deprecated default int addAndGetInt(long offset, int adding) throws BufferUnderflowException, IllegalStateException
offset
- to add and getadding
- value to add, can be 1BufferUnderflowException
- if the offset is outside the limits of the BytesIllegalStateException
- if released@Deprecated default long addAndGetLong(long offset, long adding) throws BufferUnderflowException, IllegalStateException
offset
- to add and getadding
- value to add, can be 1BufferUnderflowException
- if the offset is outside the limits of the BytesIllegalStateException
- if released@Deprecated default float addAndGetFloat(long offset, float adding) throws BufferUnderflowException, IllegalStateException
offset
- to add and getadding
- value to add, can be 1BufferUnderflowException
- if the offset is outside the limits of the BytesIllegalStateException
@Deprecated default double addAndGetDouble(long offset, double adding) throws BufferUnderflowException, IllegalStateException
offset
- to add and getadding
- value to add, can be 1BufferUnderflowException
- if the offset is outside the limits of the BytesIllegalStateException
- if released@Deprecated boolean compareAndSwapInt(long offset, int expected, int value) throws BufferOverflowException, IllegalStateException
offset
- to perform CASexpected
- valuevalue
- to setBufferOverflowException
IllegalStateException
@Deprecated void testAndSetInt(long offset, int expected, int value) throws BufferOverflowException, IllegalStateException
@Deprecated boolean compareAndSwapLong(long offset, long expected, long value) throws BufferOverflowException, IllegalStateException
offset
- to perform CASexpected
- valuevalue
- to setBufferOverflowException
IllegalStateException
@Deprecated default boolean compareAndSwapFloat(long offset, float expected, float value) throws BufferOverflowException, IllegalStateException
offset
- to perform CASexpected
- valuevalue
- to setBufferOverflowException
IllegalStateException
@Deprecated default boolean compareAndSwapDouble(long offset, double expected, double value) throws BufferOverflowException, IllegalStateException
offset
- to perform CASexpected
- valuevalue
- to setBufferOverflowException
IllegalStateException
@NotNull default @NotNull BytesStore subBytes(long start, long length) throws BufferUnderflowException, IllegalStateException
start
- of byteslength
- of bytesIllegalStateException
- if releasedBufferUnderflowException
default long findByte(byte stopByte) throws IllegalStateException
IllegalStateException
default <T extends Appendable & CharSequence> long readUtf8(long offset, @NotNull T sb) throws net.openhft.chronicle.core.io.IORuntimeException, IllegalArgumentException, BufferUnderflowException, ArithmeticException, 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).T
- 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
IllegalStateException
- if releasednet.openhft.chronicle.core.io.IORuntimeException
IllegalArgumentException
BufferUnderflowException
ArithmeticException
RandomDataOutput.writeUtf8(long, CharSequence)
default <T extends Appendable & CharSequence> long readUtf8Limited(long offset, @NotNull T 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.T
- 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
IllegalStateException
- if releasednet.openhft.chronicle.core.io.IORuntimeException
IllegalArgumentException
BufferUnderflowException
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 encodingIllegalStateException
- if releasedBufferUnderflowException
net.openhft.chronicle.core.io.IORuntimeException
IllegalArgumentException
RandomDataOutput.writeUtf8Limited(long, CharSequence, int)
default boolean compareUtf8(long offset, @Nullable @Nullable CharSequence other) throws net.openhft.chronicle.core.io.IORuntimeException, BufferUnderflowException, IllegalStateException
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 equalIllegalStateException
- if releasednet.openhft.chronicle.core.io.IORuntimeException
- if the contents are not a valid string.BufferUnderflowException
default byte[] toByteArray() throws IllegalStateException
IllegalStateException
default long read(long offsetInRDI, byte[] bytes, int offset, int length) throws IllegalStateException
IllegalStateException
default ByteBuffer toTemporaryDirectByteBuffer() throws IllegalArgumentException, ArithmeticException, IllegalStateException
default int fastHash(long offset, int length) throws BufferUnderflowException, IllegalStateException
default boolean canReadDirect()
default boolean canReadDirect(long length)
default long start()
default long capacity()
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()
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 © 2022. All rights reserved.