public class NativeBytesStore<U> extends AbstractBytesStore<NativeBytesStore<U>,U>
Modifier and Type | Field and Description |
---|---|
long |
address |
protected long |
limit |
long |
maximumLimit |
net.openhft.chronicle.core.Memory |
memory |
referenceCounted, WARN_COUNT, WARN_NS
charToString
Modifier | Constructor and Description |
---|---|
|
NativeBytesStore(@NotNull ByteBuffer bb,
boolean elastic,
int maximumLimit) |
|
NativeBytesStore(long address,
long limit) |
|
NativeBytesStore(long address,
long limit,
@Nullable Runnable deallocator,
boolean elastic) |
protected |
NativeBytesStore(long address,
long limit,
@Nullable Runnable deallocator,
boolean elastic,
boolean monitored) |
Modifier and Type | Method and Description |
---|---|
int |
addAndGetInt(long offset,
int adding)
Adds an integer to the current integer value at the specified offset and returns the result.
|
long |
addAndGetLong(long offset,
long adding)
Similar to
BytesStore.addAndGetInt(long, int) but operates on a long value. |
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.
|
long |
appendAndReturnLength(long writePosition,
boolean negative,
long mantissa,
int exponent,
boolean append0) |
long |
appendUtf8(long pos,
char[] chars,
int offset,
int length) |
protected void |
backgroundPerformRelease() |
int |
byteCheckSum()
Returns the bytes sum of the readable bytes in this BytesStore.
|
int |
byteCheckSum(long position,
long limit)
Returns the bytes sum between the specified indexes; start (inclusive) and end (exclusive).
|
default ByteOrder |
byteOrder()
Retrieves the byte order used by the buffer.
|
@NotNull VanillaBytes<U> |
bytesForWrite()
Returns a Bytes that wraps this ByteStore from the
start to the realCapacity . |
boolean |
canReadDirect(long length)
Checks if the specified length of bytes can be read directly from native memory.
|
long |
capacity()
Provides the maximum limit that can be set for the ByteStore.
|
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.
|
@NotNull BytesStore<NativeBytesStore<U>,U> |
copy()
Creates and returns a copy of this BytesStore.
|
long |
copyTo(@NotNull BytesStore store)
Returns the number of bytes that were copied from this BytesStore to a destination BytesStore.
|
long |
copyToDirect(@NotNull BytesStore store) |
static @NotNull NativeBytesStore<ByteBuffer> |
elasticByteBuffer() |
static @NotNull NativeBytesStore<ByteBuffer> |
elasticByteBuffer(int size,
long maxSize)
Creates a flexible ByteBuffer instance that resides in native memory.
|
boolean |
equals(Object obj) |
int |
fastHash(long offset,
int length)
Computes a hash code for a sequence of bytes.
|
static @NotNull NativeBytesStore<ByteBuffer> |
follow(@NotNull ByteBuffer bb)
Wraps a ByteBuffer which can be either on heap or off heap without taking ownership of that buffer.
|
static @NotNull NativeBytesStore |
from(byte[] bytes) |
static @NotNull NativeBytesStore |
from(@NotNull String text)
Converts a String into a BytesStore.
|
int |
hashCode() |
void |
init(@NotNull ByteBuffer bb,
boolean elastic)
Deprecated.
use
follow(ByteBuffer) instead. |
boolean |
isDirectMemory()
Checks if this BytesStore uses direct memory.
|
boolean |
isEqual(long start,
long length,
String s)
Returns if a specified portion of this BytesStore is equal to a specified String.
|
static @NotNull NativeBytesStore<Void> |
lazyNativeBytesStoreWithFixedCapacity(long capacity)
Creates a lazily initialized BytesStore instance with a fixed capacity that resides in native memory.
|
default long |
lengthWritten(long startPosition)
Calculates the length of data written from the given start position.
|
void |
move(long from,
long to,
long length)
Moves a sequence of bytes within this BytesStore from the source to destination index.
|
void |
nativeRead(long position,
long address,
long size)
Expert-level method for transferring data from this byte source to native memory.
|
static @NotNull NativeBytesStore<Void> |
nativeStore(long capacity)
this is an elastic native store
|
static @NotNull NativeBytesStore<Void> |
nativeStoreWithFixedCapacity(long capacity)
Creates a BytesStore instance with a fixed capacity that resides in native memory.
|
void |
nativeWrite(long address,
long position,
long size)
Expert-level method that copies data directly from native memory into this BytesStore.
|
int |
peekUnsignedByte(long offset)
Reads an unsigned byte value from a specific offset.
|
protected void |
performRelease() |
long |
read(long offsetInRDI,
byte[] bytes,
int offset,
int length)
Reads a sequence of bytes from the specified offset into a byte array.
|
void |
read8bit(long position,
char[] chars,
int length) |
byte |
readByte(long offset)
Reads a byte value from a specific offset.
|
double |
readDouble(long offset)
Reads a 64-bit floating point value from a specified offset.
|
float |
readFloat(long offset)
Reads a 32-bit floating point value from a specified offset.
|
long |
readIncompleteLong(long offset)
Reads a long value from the specified offset.
|
int |
readInt(long offset)
Reads a 32-bit integer value from a specific offset.
|
default long |
readLimit()
If the resource is closed, the returned value is unspecified.
|
long |
readLong(long offset)
Reads a 64-bit long value from a specific offset.
|
short |
readShort(long offset)
Reads a short value from a specific offset.
|
int |
readUnsignedByte(long offset)
Reads an unsigned byte value from a specific offset.
|
byte |
readVolatileByte(long offset)
Reads a volatile 8-bit byte value from a specified offset.
|
int |
readVolatileInt(long offset)
Reads a volatile 32-bit integer value from a specified offset.
|
long |
readVolatileLong(long offset)
Reads a volatile 64-bit long value from a specified offset.
|
short |
readVolatileShort(long offset)
Reads a volatile 16-bit short value from a specified offset.
|
long |
realCapacity()
Returns the actual capacity of the ByteStore before any resizing occurs.
|
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.
|
protected void |
reverseBytesFrom(long start,
long end) |
long |
safeLimit() |
void |
setAddress(long address) |
boolean |
sharedMemory()
Checks if the Bytes use shared memory.
|
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.
|
@NotNull String |
toString() |
@NotNull ByteBuffer |
toTemporaryDirectByteBuffer()
Converts the byte sequence into a direct byte buffer.
|
long |
translate(long offset) |
U |
underlyingObject() |
void |
uninit()
Deprecated.
use
follow(ByteBuffer) instead. |
static <T> @NotNull NativeBytesStore<T> |
uninitialized() |
static @NotNull NativeBytesStore<ByteBuffer> |
wrap(@NotNull ByteBuffer bb)
Wraps a ByteBuffer into a BytesStore.
|
@NotNull NativeBytesStore<U> |
write(long offsetInRDO,
byte[] byteArray,
int offset,
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 offsetInRDO,
@NotNull ByteBuffer bytes,
int offset,
int length)
Copies a segment from the provided ByteBuffer into this data output.
|
@NotNull NativeBytesStore<U> |
write(long writeOffset,
@NotNull RandomDataInput bytes,
long readOffset,
long length)
Copies a segment from the provided RandomDataInput into this data output.
|
void |
write0(long offsetInRDO,
@NotNull RandomDataInput bytes,
long offset,
long length) |
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.
|
@NotNull NativeBytesStore<U> |
writeByte(long offset,
byte i8)
Writes a byte at the specified non-negative offset.
|
@NotNull NativeBytesStore<U> |
writeDouble(long offset,
double d)
Writes a double-precision floating-point value at the specified non-negative offset.
|
@NotNull NativeBytesStore<U> |
writeFloat(long offset,
float f)
Writes a single-precision floating-point value at the specified non-negative offset.
|
@NotNull NativeBytesStore<U> |
writeInt(long offset,
int i32)
Writes an integer value at the specified non-negative offset.
|
default long |
writeLimit()
Retrieves the maximum writable position within the buffer.
|
@NotNull NativeBytesStore<U> |
writeLong(long offset,
long i64)
Writes a long integer value at the specified non-negative offset.
|
@NotNull NativeBytesStore<U> |
writeOrderedInt(long offset,
int i)
Performs a non-blocking write operation with a memory barrier to ensure order of stores.
|
@NotNull NativeBytesStore<U> |
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.
|
@NotNull NativeBytesStore<U> |
writeShort(long offset,
short i16)
Writes a short integer at the specified non-negative offset.
|
@NotNull NativeBytesStore<U> |
writeVolatileByte(long offset,
byte i8)
Writes a volatile byte at the specified non-negative offset.
|
@NotNull NativeBytesStore<U> |
writeVolatileInt(long offset,
int i32)
Writes a volatile integer at the specified non-negative offset.
|
@NotNull NativeBytesStore<U> |
writeVolatileLong(long offset,
long i64)
Writes a volatile long integer at the specified non-negative offset.
|
@NotNull NativeBytesStore<U> |
writeVolatileShort(long offset,
short i16)
Writes a volatile short at the specified non-negative offset.
|
@NotNull NativeBytesStore<U> |
zeroOut(long start,
long end)
Fills the BytesStore with zeros.
|
canReleaseInBackground, internalNumberBuffer, readPosition, readRemaining, start, writeRemaining
addReferenceChangeListener, assertReferencesReleased, clearUsedByThread, createdHere, disableReferenceTracing, enableReferenceTracing, refCount, referenceCountedUnmonitored, referenceId, release, releaseLast, removeReferenceChangeListener, reserve, reservedBy, reserveTransfer, singleThreadedCheckDisabled, singleThreadedCheckReset, threadSafetyCheck, throwExceptionIfNotReleased, throwExceptionIfReleased, tryReserve, unmonitor, warnAndReleaseIfNotReleased
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
addAndGetDouble, addAndGetDoubleNotAtomic, addAndGetFloat, addAndGetFloatNotAtomic, addAndGetIntNotAtomic, addAndGetShortNotAtomic, addAndGetUnsignedByteNotAtomic, bytesForRead, bytesStore, charAt, cipher, cipher, compareAndSwapDouble, compareAndSwapFloat, contentEquals, copyTo, empty, endsWith, equalBytes, forFields, from, from, hash, inside, inside, isClear, isEmpty, isImmutableEmptyByteStore, length, nativePointer, nativeStoreFrom, readWrite, startsWith, startsWith, subSequence, to8bitString, toDebugString, toDebugString, wrap, wrap, writeMaxInt, writeMaxLong
canReadDirect, compareUtf8, copyTo, copyTo, createCharToString, findByte, parseLong, peekVolatileInt, printable, readBoolean, readUnsignedInt, readUnsignedInt24, readUnsignedShort, readUtf8, readUtf8Limited, readUtf8Limited, readVolatileDouble, readVolatileFloat, subBytes, toByteArray
append, append, write, write, writeBoolean, writeByte, writeInt24, writeOrderedDouble, writeOrderedFloat, writeUnsignedByte, writeUnsignedInt, writeUnsignedShort, writeUtf8, writeUtf8Limited, writeVolatileDouble, writeVolatileFloat
addReferenceChangeListener, refCount, release, releaseLast, releaseLast, removeReferenceChangeListener, reserve, reservedBy, reserveTransfer, tryReserve
referenceId, referenceName, temporary
chars, codePoints
public long address
public net.openhft.chronicle.core.Memory memory
public long maximumLimit
protected long limit
public NativeBytesStore(@NotNull @NotNull ByteBuffer bb, boolean elastic, int maximumLimit)
public NativeBytesStore(long address, long limit)
public NativeBytesStore(long address, long limit, @Nullable @Nullable Runnable deallocator, boolean elastic)
protected NativeBytesStore(long address, long limit, @Nullable @Nullable Runnable deallocator, boolean elastic, boolean monitored)
@NotNull public static @NotNull NativeBytesStore<ByteBuffer> wrap(@NotNull @NotNull ByteBuffer bb)
BytesStore
bb
- ByteBufferBytesStore.wrap(ByteBuffer)
@NotNull public static @NotNull NativeBytesStore<ByteBuffer> follow(@NotNull @NotNull ByteBuffer bb)
BytesStore
When resulting BytesStore instance is closed, direct byteBuffer
will not be deallocated so its
life cycle should be tracked elsewhere.
bb
- ByteBufferBytesStore.follow(ByteBuffer)
@NotNull public static <T> @NotNull NativeBytesStore<T> uninitialized()
@NotNull public static @NotNull NativeBytesStore<Void> nativeStore(long capacity) throws IllegalArgumentException
capacity
- of the buffer.IllegalArgumentException
@NotNull public static @NotNull NativeBytesStore<Void> nativeStoreWithFixedCapacity(long capacity) throws IllegalArgumentException
BytesStore
capacity
- the fixed capacity of the bufferIllegalArgumentException
@NotNull public static @NotNull NativeBytesStore<Void> lazyNativeBytesStoreWithFixedCapacity(long capacity) throws IllegalArgumentException
BytesStore
capacity
- the fixed capacity of the bufferIllegalArgumentException
@NotNull public static @NotNull NativeBytesStore<ByteBuffer> elasticByteBuffer()
@NotNull public static @NotNull NativeBytesStore<ByteBuffer> elasticByteBuffer(int size, long maxSize)
BytesStore
size
- the initial size of the ByteBuffermaxSize
- the maximum allowable size of the ByteBuffer@NotNull public static @NotNull NativeBytesStore from(@NotNull @NotNull String text)
BytesStore
text
- the String to be converted@NotNull public static @NotNull NativeBytesStore from(byte[] bytes)
public boolean isDirectMemory()
BytesStore
public boolean canReadDirect(long length)
RandomDataInput
length
- the number of bytes to check.@Deprecated public void init(@NotNull @NotNull ByteBuffer bb, boolean elastic)
follow(ByteBuffer)
instead.@Deprecated public void uninit()
follow(ByteBuffer)
instead.public void move(long from, long to, long length) throws BufferUnderflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException
BytesStore
from
- the index of the first byte to be movedto
- the index where the first byte should be moved tolength
- the number of bytes to be movedBufferUnderflowException
- If there's not enough data to be movednet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.@NotNull public @NotNull BytesStore<NativeBytesStore<U>,U> copy() throws net.openhft.chronicle.core.io.ClosedIllegalStateException
BytesStore
net.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.@NotNull public @NotNull VanillaBytes<U> bytesForWrite() throws net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
BytesStore
start
to the realCapacity
.
The returned Bytes is not elastic and can be both read and written using cursors.
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.public long realCapacity()
BytesStore
public long capacity()
BytesStore
@Nullable public U underlyingObject()
@NotNull public @NotNull NativeBytesStore<U> zeroOut(long start, long end)
BytesStore
start
- first byte inclusiveend
- last byte exclusivepublic boolean compareAndSwapInt(long offset, int expected, int value) throws net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
RandomDataInput
offset
- to perform CASexpected
- valuevalue
- to setnet.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 waypublic void testAndSetInt(long offset, int expected, int value) throws net.openhft.chronicle.core.io.ClosedIllegalStateException
RandomDataOutput
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.net.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.public boolean compareAndSwapLong(long offset, long expected, long value) throws net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
RandomDataInput
offset
- to perform CASexpected
- valuevalue
- to setnet.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 waypublic long addAndGetLong(long offset, long adding) throws BufferUnderflowException
BytesStore
BytesStore.addAndGetInt(long, int)
but operates on a long value.offset
- to add and getadding
- value to add, can be 1BufferUnderflowException
- If the offset is outside the limits of the Bytespublic int addAndGetInt(long offset, int adding) throws BufferUnderflowException
BytesStore
offset
- the position where the integer is storedadding
- the integer to addBufferUnderflowException
- If the offset is out of boundspublic long translate(long offset)
public byte readByte(long offset)
RandomDataInput
offset
- the location from where the byte value is read.public int readUnsignedByte(long offset) throws BufferUnderflowException
RandomDataInput
offset
- the location from where the unsigned byte value is read.BufferUnderflowException
- If the offset is outside the bounds of the byte source.public short readShort(long offset)
RandomDataInput
offset
- the location from where the short value is read.public int readInt(long offset)
RandomDataInput
offset
- the location from where the 32-bit integer value is read.public long readLong(long offset)
RandomDataInput
offset
- the location from where the long value is read.public float readFloat(long offset)
RandomDataInput
offset
- the location from where the float value is read.public double readDouble(long offset)
RandomDataInput
offset
- the location from where the double value is read.public byte readVolatileByte(long offset)
RandomDataInput
offset
- the location from where the byte value is read.public short readVolatileShort(long offset)
RandomDataInput
offset
- the location from where the short value is read.public int readVolatileInt(long offset)
RandomDataInput
offset
- the location from where the int value is read.public long readVolatileLong(long offset)
RandomDataInput
offset
- the location from where the long value is read.@NotNull public @NotNull NativeBytesStore<U> writeByte(long offset, byte i8) throws net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
RandomDataOutput
offset
- The non-negative position within the data stream to write the byte to.i8
- The byte value 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 way@NotNull public @NotNull NativeBytesStore<U> writeShort(long offset, short i16) throws net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
RandomDataOutput
offset
- The non-negative position within the data stream to write the short integer to.i16
- The short integer value 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 way@NotNull public @NotNull NativeBytesStore<U> writeInt(long offset, int i32) throws net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
RandomDataOutput
offset
- The non-negative position within the data stream to write the integer to.i32
- The integer value 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 way@NotNull public @NotNull NativeBytesStore<U> writeOrderedInt(long offset, int i)
RandomDataOutput
offset
- The non-negative position within the data stream to write the integer to.i
- The integer value to write.@NotNull public @NotNull NativeBytesStore<U> writeLong(long offset, long i64) throws net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
RandomDataOutput
offset
- The non-negative position within the data stream to write the long integer to.i64
- The long integer value 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 way@NotNull public @NotNull NativeBytesStore<U> writeOrderedLong(long offset, long i) throws net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
RandomDataOutput
offset
- The non-negative position within the data stream to write the long integer to.i
- The long integer value 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 way@NotNull public @NotNull NativeBytesStore<U> writeFloat(long offset, float f) throws net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
RandomDataOutput
offset
- The non-negative position within the data stream to write the float to.f
- The float value 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 way@NotNull public @NotNull NativeBytesStore<U> writeDouble(long offset, double d) throws net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
RandomDataOutput
offset
- The non-negative position within the data stream to write the double to.d
- The double value 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 way@NotNull public @NotNull NativeBytesStore<U> writeVolatileByte(long offset, byte i8) throws net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
RandomDataOutput
offset
- The non-negative position within the data stream to write the byte to.i8
- The byte value 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 way@NotNull public @NotNull NativeBytesStore<U> writeVolatileShort(long offset, short i16) throws net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
RandomDataOutput
offset
- The non-negative position within the data stream to write the short to.i16
- The short value 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 way@NotNull public @NotNull NativeBytesStore<U> writeVolatileInt(long offset, int i32) throws net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
RandomDataOutput
offset
- The non-negative position within the data stream to write the integer to.i32
- The integer value 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 way@NotNull public @NotNull NativeBytesStore<U> writeVolatileLong(long offset, long i64) throws net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
RandomDataOutput
offset
- The non-negative position within the data stream to write the long integer to.i64
- The long integer value 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 way@NotNull public @NotNull NativeBytesStore<U> write(long offsetInRDO, byte[] byteArray, int offset, int length) throws net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
RandomDataOutput
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()
offsetInRDO
- the non-negative offset within the data output where the segment should be written.byteArray
- the byte array containing the segment to be written.offset
- the non-negative offset within the byte array where the segment begins.length
- the non-negative length of the segment.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 waypublic void write(long offsetInRDO, @NotNull @NotNull ByteBuffer bytes, int offset, int length) throws net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
RandomDataOutput
Does not update cursors e.g. writePosition()
offsetInRDO
- the non-negative offset within the data output where the segment should be written.bytes
- the ByteBuffer containing the segment to be written.offset
- the non-negative offset within the ByteBuffer where the segment begins.length
- the non-negative length of the segment.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 public @NotNull NativeBytesStore<U> 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
RandomDataOutput
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 waypublic void write0(long offsetInRDO, @NotNull @NotNull RandomDataInput bytes, long offset, long length) throws BufferUnderflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException
BufferUnderflowException
net.openhft.chronicle.core.io.ClosedIllegalStateException
public long addressForRead(long offset) throws BufferUnderflowException
offset
- within this buffer. addressForRead(start()) is the actual addressForRead of the first byte.BufferUnderflowException
- If the offset is before the start() or the after the capacity()public long addressForWrite(long offset) throws BufferOverflowException
offset
- within this buffer. addressForRead(start()) is the actual addressForRead of the first byte.BufferOverflowException
- If the offset is before the start() or the after the capacity()public long addressForWritePosition() throws UnsupportedOperationException, BufferOverflowException
UnsupportedOperationException
- If the underlying buffer is on the heap.BufferOverflowException
- If the current write position is before the start or after the capacity.protected void backgroundPerformRelease()
backgroundPerformRelease
in class net.openhft.chronicle.core.io.AbstractReferenceCounted
protected void performRelease()
performRelease
in class net.openhft.chronicle.core.io.AbstractReferenceCounted
@NotNull public @NotNull String toString()
toString
in interface CharSequence
toString
in class net.openhft.chronicle.core.io.AbstractReferenceCounted
public void nativeRead(long position, long address, long size) throws BufferUnderflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException
RandomDataInput
position
- the starting point within the byte source from which data is copied.address
- the destination address in native memory.size
- the number of bytes to transfer.BufferUnderflowException
- If the specified position or size exceeds the byte source limits.net.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.public void nativeWrite(long address, long position, long size) throws BufferOverflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
RandomDataOutput
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 waypublic long write8bit(long position, @NotNull @NotNull BytesStore bs)
RandomDataOutput
position
- the position at which the BytesStore content should be written.bs
- the BytesStore instance to write.public long write8bit(long position, @NotNull @NotNull String s, int start, int length) throws net.openhft.chronicle.core.io.ClosedIllegalStateException
RandomDataOutput
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.public void read8bit(long position, char[] chars, int length)
public long readIncompleteLong(long offset)
RandomDataInput
offset
- the location from where the long value is read.public void setAddress(long address)
public long appendUtf8(long pos, char[] chars, int offset, int length) throws BufferOverflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
BufferOverflowException
net.openhft.chronicle.core.io.ClosedIllegalStateException
net.openhft.chronicle.core.io.ThreadingIllegalStateException
public long copyTo(@NotNull @NotNull BytesStore store) throws net.openhft.chronicle.core.io.ClosedIllegalStateException
BytesStore
Copies the data to another BytesStore as long as space is available in the destination BytesStore.
store
- the BytesStore to copy tonet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.public long copyToDirect(@NotNull @NotNull BytesStore store) throws net.openhft.chronicle.core.io.ClosedIllegalStateException
net.openhft.chronicle.core.io.ClosedIllegalStateException
@NotNull public @NotNull ByteBuffer toTemporaryDirectByteBuffer()
RandomDataInput
public int byteCheckSum() throws net.openhft.chronicle.core.io.IORuntimeException
BytesStore
net.openhft.chronicle.core.io.IORuntimeException
public int byteCheckSum(long position, long limit)
BytesStore
position
- the index of the first byte to sumlimit
- the index of the last byte to sumpublic boolean sharedMemory()
public long read(long offsetInRDI, byte[] bytes, int offset, int length)
RandomDataInput
offsetInRDI
- the offset in the byte sequence from which to start reading.bytes
- the byte array into which the data is read.offset
- the start offset in the byte array at which the data is written.length
- the maximum number of bytes to read.public int peekUnsignedByte(long offset)
RandomDataInput
peekUnsignedByte
in interface RandomDataInput
peekUnsignedByte
in class AbstractBytesStore<NativeBytesStore<U>,U>
offset
- the location from where the unsigned byte value is read.public int fastHash(long offset, int length) throws BufferUnderflowException, net.openhft.chronicle.core.io.ClosedIllegalStateException
RandomDataInput
offset
- the start offset of the sequence of bytes.length
- the length of the sequence of bytes.BufferUnderflowException
- If the specified sequence of bytes extends beyond the limits of this byte sequence.net.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.public long safeLimit()
public boolean isEqual(long start, long length, String s)
BytesStore
start
- the portion offsetlength
- the number of bytes from this BytesStore that should be compared to ss
- the String to compare totrue
if the specified portion of this BytesStore is equal to spublic int hashCode()
hashCode
in class AbstractBytesStore<NativeBytesStore<U>,U>
public boolean equals(Object obj)
equals
in class AbstractBytesStore<NativeBytesStore<U>,U>
public long appendAndReturnLength(long writePosition, boolean negative, long mantissa, int exponent, boolean append0)
protected void reverseBytesFrom(long start, long end)
public long writePosition()
The write position is readPosition() <= writePosition() && writePosition() <= writeLimit()
If the resource is closed, the returned value is unspecified.
public 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.public long realReadRemaining()
If the resource is closed, the returned value is unspecified.
public long realWriteRemaining()
If the resource is closed, the returned value is unspecified.
public long readLimit()
If the resource is closed, the returned value is unspecified.
public long writeLimit()
If the resource is closed, the returned value is unspecified.
public 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 waypublic ByteOrder byteOrder()
Copyright © 2023. All rights reserved.