U
- Underlying typepublic class HeapBytesStore<U> extends AbstractBytesStore<HeapBytesStore<U>,U>
referenceCounted, WARN_COUNT, WARN_NS
charToString
Modifier and Type | Method and Description |
---|---|
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) |
default ByteOrder |
byteOrder()
Retrieves the byte order used by the buffer.
|
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<HeapBytesStore<U>,U> |
copy()
Creates and returns a copy of this BytesStore.
|
boolean |
equals(Object obj) |
static <T> HeapBytesStore<T> |
forFields(Object o,
String groupName,
int padding)
Provides a BytesStore that allows access to a group of fields in a given object.
|
int |
hashCode() |
boolean |
isDirectMemory()
Checks if this BytesStore uses direct 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.
|
void |
nativeWrite(long address,
long position,
long size)
Expert-level method that copies data directly from native memory into this BytesStore.
|
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.
|
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.
|
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.
|
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.
|
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) |
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() |
U |
underlyingObject() |
static @NotNull HeapBytesStore<byte[]> |
wrap(byte[] byteArray)
Wraps a byte array into a BytesStore.
|
static @NotNull HeapBytesStore<ByteBuffer> |
wrap(@NotNull ByteBuffer bb)
Wraps a ByteBuffer into a BytesStore.
|
@NotNull HeapBytesStore<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 HeapBytesStore<U> |
write(long writeOffset,
@NotNull RandomDataInput bytes,
long readOffset,
long length)
Copies a segment from the provided RandomDataInput into this data output.
|
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 HeapBytesStore<U> |
writeByte(long offset,
byte b)
Writes a byte at the specified non-negative offset.
|
@NotNull HeapBytesStore<U> |
writeDouble(long offset,
double d)
Writes a double-precision floating-point value at the specified non-negative offset.
|
@NotNull HeapBytesStore<U> |
writeFloat(long offset,
float f)
Writes a single-precision floating-point value at the specified non-negative offset.
|
@NotNull HeapBytesStore<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 HeapBytesStore<U> |
writeLong(long offset,
long i64)
Writes a long integer value at the specified non-negative offset.
|
@NotNull HeapBytesStore<U> |
writeOrderedInt(long offset,
int i32)
Performs a non-blocking write operation with a memory barrier to ensure order of stores.
|
@NotNull HeapBytesStore<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 HeapBytesStore<U> |
writeShort(long offset,
short i16)
Writes a short integer at the specified non-negative offset.
|
@NotNull HeapBytesStore<U> |
writeVolatileByte(long offset,
byte i8)
Writes a volatile byte at the specified non-negative offset.
|
@NotNull HeapBytesStore<U> |
writeVolatileInt(long offset,
int i32)
Writes a volatile integer at the specified non-negative offset.
|
@NotNull HeapBytesStore<U> |
writeVolatileLong(long offset,
long i64)
Writes a volatile long integer at the specified non-negative offset.
|
@NotNull HeapBytesStore<U> |
writeVolatileShort(long offset,
short i16)
Writes a volatile short at the specified non-negative offset.
|
canReleaseInBackground, internalNumberBuffer, peekUnsignedByte, readPosition, readRemaining, start, writeRemaining
addReferenceChangeListener, assertReferencesReleased, backgroundPerformRelease, 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, addAndGetInt, addAndGetIntNotAtomic, addAndGetLong, addAndGetShortNotAtomic, addAndGetUnsignedByteNotAtomic, byteCheckSum, byteCheckSum, bytesForRead, bytesForWrite, bytesStore, charAt, cipher, cipher, compareAndSwapDouble, compareAndSwapFloat, contentEquals, copyTo, copyTo, elasticByteBuffer, empty, endsWith, equalBytes, follow, from, from, from, hash, inside, inside, isClear, isEmpty, isEqual, isImmutableEmptyByteStore, lazyNativeBytesStoreWithFixedCapacity, length, nativePointer, nativeStore, nativeStoreFrom, nativeStoreWithFixedCapacity, readWrite, realCapacity, safeLimit, startsWith, startsWith, subSequence, to8bitString, toDebugString, toDebugString, wrap, writeMaxInt, writeMaxLong, zeroOut
canReadDirect, canReadDirect, compareUtf8, copyTo, copyTo, createCharToString, fastHash, findByte, parseLong, peekVolatileInt, printable, readBoolean, readIncompleteLong, readUnsignedByte, readUnsignedInt, readUnsignedInt24, readUnsignedShort, readUtf8, readUtf8Limited, readUtf8Limited, readVolatileDouble, readVolatileFloat, subBytes, toByteArray, toTemporaryDirectByteBuffer
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 static <T> HeapBytesStore<T> forFields(Object o, String groupName, int padding)
BytesStore
o
- the object that contains the fieldsgroupName
- the group name of the fieldspadding
- the padding to be used@NotNull public static @NotNull HeapBytesStore<byte[]> wrap(byte[] byteArray)
BytesStore
byteArray
- the byte array to be wrapped@NotNull public static @NotNull HeapBytesStore<ByteBuffer> wrap(@NotNull @NotNull ByteBuffer bb)
BytesStore
bb
- the ByteBuffer to be wrappedBytesStore.follow(ByteBuffer)
public boolean isDirectMemory()
BytesStore
public void move(long from, long to, long length) throws BufferUnderflowException, ArithmeticException
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 movedArithmeticException
- if the move would result in an index overflow@NotNull public @NotNull String toString()
toString
in interface CharSequence
toString
in class net.openhft.chronicle.core.io.AbstractReferenceCounted
@NotNull public @NotNull BytesStore<HeapBytesStore<U>,U> copy()
BytesStore
protected void performRelease()
performRelease
in class net.openhft.chronicle.core.io.AbstractReferenceCounted
public long capacity()
BytesStore
public U underlyingObject()
public boolean compareAndSwapInt(long offset, int expected, int value)
RandomDataInput
offset
- to perform CASexpected
- valuevalue
- to setpublic void testAndSetInt(long offset, int expected, int value) throws IllegalStateException
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.IllegalStateException
- if this RandomDataOutput has been previously released.public boolean compareAndSwapLong(long offset, long expected, long value)
RandomDataInput
offset
- to perform CASexpected
- valuevalue
- to setpublic 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 byte readByte(long offset) throws BufferUnderflowException
RandomDataInput
offset
- the location from where the byte value is read.BufferUnderflowException
- if the offset is outside the bounds of the byte source.public short readShort(long offset) throws BufferUnderflowException
RandomDataInput
offset
- the location from where the short value is read.BufferUnderflowException
- if the offset is outside the bounds of the byte source.public int readInt(long offset) throws BufferUnderflowException
RandomDataInput
offset
- the location from where the 32-bit integer value is read.BufferUnderflowException
- if the offset is outside the bounds of the byte source.public long readLong(long offset) throws BufferUnderflowException
RandomDataInput
offset
- the location from where the long value is read.BufferUnderflowException
- if the offset is outside the bounds of the byte source.public float readFloat(long offset) throws BufferUnderflowException
RandomDataInput
offset
- the location from where the float value is read.BufferUnderflowException
- if the offset is beyond the limits of the byte source.public double readDouble(long offset) throws BufferUnderflowException
RandomDataInput
offset
- the location from where the double value is read.BufferUnderflowException
- if the offset is beyond the limits of the byte source.public byte readVolatileByte(long offset) throws BufferUnderflowException
RandomDataInput
offset
- the location from where the byte value is read.BufferUnderflowException
- if the offset is beyond the limits of the byte source.public short readVolatileShort(long offset) throws BufferUnderflowException
RandomDataInput
offset
- the location from where the short value is read.BufferUnderflowException
- if the offset is beyond the limits of the byte source.public int readVolatileInt(long offset) throws BufferUnderflowException
RandomDataInput
offset
- the location from where the int value is read.BufferUnderflowException
- if the offset is beyond the limits of the byte source.public long readVolatileLong(long offset) throws BufferUnderflowException
RandomDataInput
offset
- the location from where the long value is read.BufferUnderflowException
- if the offset is beyond the limits of the byte source.public 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)
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.@NotNull public @NotNull HeapBytesStore<U> writeByte(long offset, byte b) throws BufferOverflowException
RandomDataOutput
offset
- The non-negative position within the data stream to write the byte to.b
- The byte value to write.BufferOverflowException
- If the specified offset exceeds the available capacity.@NotNull public @NotNull HeapBytesStore<U> writeShort(long offset, short i16) throws BufferOverflowException
RandomDataOutput
offset
- The non-negative position within the data stream to write the short integer to.i16
- The short integer value to write.BufferOverflowException
- If the specified offset exceeds the available capacity.@NotNull public @NotNull HeapBytesStore<U> writeInt(long offset, int i32) throws BufferOverflowException
RandomDataOutput
offset
- The non-negative position within the data stream to write the integer to.i32
- The integer value to write.BufferOverflowException
- If the specified offset exceeds the available capacity.@NotNull public @NotNull HeapBytesStore<U> writeOrderedInt(long offset, int i32) throws BufferOverflowException
RandomDataOutput
offset
- The non-negative position within the data stream to write the integer to.i32
- The integer value to write.BufferOverflowException
- If the specified offset exceeds the available capacity.@NotNull public @NotNull HeapBytesStore<U> writeLong(long offset, long i64) throws BufferOverflowException
RandomDataOutput
offset
- The non-negative position within the data stream to write the long integer to.i64
- The long integer value to write.BufferOverflowException
- If the specified offset exceeds the available capacity.@NotNull public @NotNull HeapBytesStore<U> writeOrderedLong(long offset, long i) throws BufferOverflowException
RandomDataOutput
offset
- The non-negative position within the data stream to write the long integer to.i
- The long integer value to write.BufferOverflowException
- If the specified offset exceeds the available capacity.@NotNull public @NotNull HeapBytesStore<U> writeFloat(long offset, float f) throws BufferOverflowException
RandomDataOutput
offset
- The non-negative position within the data stream to write the float to.f
- The float value to write.BufferOverflowException
- If the specified offset exceeds the available capacity.@NotNull public @NotNull HeapBytesStore<U> writeDouble(long offset, double d) throws BufferOverflowException
RandomDataOutput
offset
- The non-negative position within the data stream to write the double to.d
- The double value to write.BufferOverflowException
- If the specified offset exceeds the available capacity.@NotNull public @NotNull HeapBytesStore<U> writeVolatileByte(long offset, byte i8) throws BufferOverflowException
RandomDataOutput
offset
- The non-negative position within the data stream to write the byte to.i8
- The byte value to write.BufferOverflowException
- If the specified offset exceeds the available capacity.@NotNull public @NotNull HeapBytesStore<U> writeVolatileShort(long offset, short i16) throws BufferOverflowException
RandomDataOutput
offset
- The non-negative position within the data stream to write the short to.i16
- The short value to write.BufferOverflowException
- If the specified offset exceeds the available capacity.@NotNull public @NotNull HeapBytesStore<U> writeVolatileInt(long offset, int i32) throws BufferOverflowException
RandomDataOutput
offset
- The non-negative position within the data stream to write the integer to.i32
- The integer value to write.BufferOverflowException
- If the specified offset exceeds the available capacity.@NotNull public @NotNull HeapBytesStore<U> writeVolatileLong(long offset, long i64) throws BufferOverflowException
RandomDataOutput
offset
- The non-negative position within the data stream to write the long integer to.i64
- The long integer value to write.BufferOverflowException
- If the specified offset exceeds the available capacity.@NotNull public @NotNull HeapBytesStore<U> write(long offsetInRDO, byte[] byteArray, int offset, int length) throws BufferOverflowException
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.BufferOverflowException
- if the capacity of this data output was exceeded.public void write(long offsetInRDO, @NotNull @NotNull ByteBuffer bytes, int offset, int length) throws BufferOverflowException
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.BufferOverflowException
- if the capacity of this data output was exceeded.@NotNull public @NotNull HeapBytesStore<U> write(long writeOffset, @NotNull @NotNull RandomDataInput bytes, long readOffset, long length) throws IllegalStateException, BufferUnderflowException, BufferOverflowException
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.IllegalStateException
- if this data output has been previously released.BufferUnderflowException
- if the source does not have enough data to fill the length.BufferOverflowException
- if the capacity of this data output was exceeded.public long addressForRead(long offset) throws UnsupportedOperationException
offset
- within this buffer. addressForRead(start()) is the actual addressForRead of the first byte.UnsupportedOperationException
- if the underlying buffer is on the heappublic long addressForWrite(long offset) throws UnsupportedOperationException
offset
- within this buffer. addressForRead(start()) is the actual addressForRead of the first byte.UnsupportedOperationException
- if the underlying buffer is on the heappublic 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.public void nativeRead(long position, long address, long size)
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.public void nativeWrite(long address, long position, long size)
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.public boolean sharedMemory()
public int hashCode()
hashCode
in class AbstractBytesStore<HeapBytesStore<U>,U>
public boolean equals(Object obj)
equals
in class AbstractBytesStore<HeapBytesStore<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, IllegalStateException
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.IllegalStateException
- if the buffer has been closed.public ByteOrder byteOrder()
Copyright © 2023. All rights reserved.