public final class NoBytesStore extends Object implements BytesStore
Modifier and Type | Field and Description |
---|---|
static @NotNull Bytes<?> |
NO_BYTES |
static BytesStore |
NO_BYTES_STORE |
static long |
NO_PAGE |
charToString
Modifier and Type | Method and Description |
---|---|
void |
addReferenceChangeListener(net.openhft.chronicle.core.io.ReferenceChangeListener referenceChangeListener) |
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.
|
default ByteOrder |
byteOrder()
Retrieves the byte order used by the buffer.
|
@NotNull Bytes<?> |
bytesForRead()
Returns a Bytes that wraps this ByteStore from the
start to the realCapacity . |
@NotNull Bytes<?> |
bytesForWrite()
Returns a Bytes that wraps this ByteStore from the
start to the realCapacity . |
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 |
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.
|
boolean |
equalBytes(@NotNull BytesStore bytesStore,
long length)
Returns if a portion of a specified BytesStore matches this BytesStore.
|
boolean |
equals(Object obj) |
int |
hashCode() |
boolean |
inside(long offset)
Returns if a specified offset is inside this BytesStore limits.
|
boolean |
inside(long offset,
long bufferSize)
Returns if a number of bytes starting from an offset are inside this ByteStore limits.
|
byte[] |
internalNumberBuffer() |
boolean |
isDirectMemory()
Checks if this BytesStore uses direct memory.
|
boolean |
isImmutableEmptyByteStore()
Returns if this ByteStore is an immutable empty ByteStore or if it is backed
by an immutable empty ByteStore.
|
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.
|
static <T,B extends BytesStore<B,T>> |
noBytesStore() |
int |
peekUnsignedByte(long offset)
Reads an unsigned byte value from a specific offset.
|
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.
|
default long |
readPosition()
Returns the read position.
|
default long |
readRemaining()
Calculates the number of bytes remaining that can be read from the current read position.
|
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.
|
int |
refCount() |
void |
release(net.openhft.chronicle.core.io.ReferenceOwner owner) |
void |
releaseLast(net.openhft.chronicle.core.io.ReferenceOwner id) |
void |
removeReferenceChangeListener(net.openhft.chronicle.core.io.ReferenceChangeListener referenceChangeListener) |
void |
reserve(net.openhft.chronicle.core.io.ReferenceOwner owner) |
boolean |
reservedBy(net.openhft.chronicle.core.io.ReferenceOwner owner) |
boolean |
sharedMemory()
Checks if the Bytes use shared memory.
|
default long |
start() |
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.
|
String |
toString() |
boolean |
tryReserve(net.openhft.chronicle.core.io.ReferenceOwner owner) |
Void |
underlyingObject() |
@NotNull RandomDataOutput |
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 RandomDataOutput |
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 RandomDataOutput |
writeByte(long offset,
byte i8)
Writes a byte at the specified non-negative offset.
|
@NotNull RandomDataOutput |
writeDouble(long offset,
double d)
Writes a double-precision floating-point value at the specified non-negative offset.
|
@NotNull RandomDataOutput |
writeFloat(long offset,
float d)
Writes a single-precision floating-point value at the specified non-negative offset.
|
@NotNull RandomDataOutput |
writeInt(long offset,
int i)
Writes an integer value at the specified non-negative offset.
|
default long |
writeLimit()
Retrieves the maximum writable position within the buffer.
|
@NotNull RandomDataOutput |
writeLong(long offset,
long i)
Writes a long integer value at the specified non-negative offset.
|
@NotNull RandomDataOutput |
writeOrderedInt(long offset,
int i)
Performs a non-blocking write operation with a memory barrier to ensure order of stores.
|
@NotNull RandomDataOutput |
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.
|
default long |
writeRemaining()
Calculates the number of bytes remaining that can be written from the current write position.
|
@NotNull RandomDataOutput |
writeShort(long offset,
short i)
Writes a short integer at the specified non-negative offset.
|
@NotNull RandomDataOutput |
writeVolatileByte(long offset,
byte i8)
Writes a volatile byte at the specified non-negative offset.
|
@NotNull RandomDataOutput |
writeVolatileInt(long offset,
int i32)
Writes a volatile integer at the specified non-negative offset.
|
@NotNull RandomDataOutput |
writeVolatileLong(long offset,
long i64)
Writes a volatile long integer at the specified non-negative offset.
|
@NotNull RandomDataOutput |
writeVolatileShort(long offset,
short i16)
Writes a volatile short at the specified non-negative offset.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
addAndGetDouble, addAndGetDoubleNotAtomic, addAndGetFloat, addAndGetFloatNotAtomic, addAndGetInt, addAndGetIntNotAtomic, addAndGetLong, addAndGetShortNotAtomic, addAndGetUnsignedByteNotAtomic, byteCheckSum, byteCheckSum, bytesStore, charAt, cipher, cipher, compareAndSwapDouble, compareAndSwapFloat, contentEquals, copyTo, elasticByteBuffer, empty, endsWith, follow, forFields, from, from, from, hash, isClear, isEmpty, isEqual, lazyNativeBytesStoreWithFixedCapacity, length, nativePointer, nativeStore, nativeStoreFrom, nativeStoreWithFixedCapacity, readWrite, realCapacity, safeLimit, startsWith, startsWith, subSequence, to8bitString, toDebugString, toDebugString, wrap, wrap, wrap, writeMaxInt, writeMaxLong, zeroOut
canReadDirect, canReadDirect, compareUtf8, copyTo, copyTo, createCharToString, fastHash, findByte, parseLong, peekVolatileInt, printable, read, readBoolean, readIncompleteLong, readUnsignedByte, readUnsignedInt, readUnsignedInt24, readUnsignedShort, readUtf8, readUtf8Limited, readUtf8Limited, readVolatileDouble, readVolatileFloat, subBytes, toByteArray, toTemporaryDirectByteBuffer
append, append, appendAndReturnLength, write, write, writeBoolean, writeByte, writeInt24, writeOrderedDouble, writeOrderedFloat, writeUnsignedByte, writeUnsignedInt, writeUnsignedShort, writeUtf8, writeUtf8Limited, writeVolatileDouble, writeVolatileFloat
releaseLast, reserveTransfer
referenceId, referenceName, temporary
chars, codePoints
public static final BytesStore NO_BYTES_STORE
public static final long NO_PAGE
@NotNull public static final @NotNull Bytes<?> NO_BYTES
@NotNull public static <T,B extends BytesStore<B,T>> @NotNull BytesStore<B,T> noBytesStore()
public void reserve(net.openhft.chronicle.core.io.ReferenceOwner owner) throws IllegalStateException
reserve
in interface net.openhft.chronicle.core.io.ReferenceCounted
IllegalStateException
public void release(net.openhft.chronicle.core.io.ReferenceOwner owner) throws IllegalStateException
release
in interface net.openhft.chronicle.core.io.ReferenceCounted
IllegalStateException
public void releaseLast(net.openhft.chronicle.core.io.ReferenceOwner id) throws IllegalStateException
releaseLast
in interface net.openhft.chronicle.core.io.ReferenceCounted
IllegalStateException
public int refCount()
refCount
in interface net.openhft.chronicle.core.io.ReferenceCounted
public void addReferenceChangeListener(net.openhft.chronicle.core.io.ReferenceChangeListener referenceChangeListener)
addReferenceChangeListener
in interface net.openhft.chronicle.core.io.ReferenceCounted
public void removeReferenceChangeListener(net.openhft.chronicle.core.io.ReferenceChangeListener referenceChangeListener)
removeReferenceChangeListener
in interface net.openhft.chronicle.core.io.ReferenceCounted
public boolean tryReserve(net.openhft.chronicle.core.io.ReferenceOwner owner)
tryReserve
in interface net.openhft.chronicle.core.io.ReferenceCounted
public boolean reservedBy(net.openhft.chronicle.core.io.ReferenceOwner owner)
reservedBy
in interface net.openhft.chronicle.core.io.ReferenceCounted
@NotNull public @NotNull RandomDataOutput writeByte(long offset, byte i8)
RandomDataOutput
writeByte
in interface RandomDataOutput
offset
- The non-negative position within the data stream to write the byte to.i8
- The byte value to write.@NotNull public @NotNull RandomDataOutput writeShort(long offset, short i)
RandomDataOutput
writeShort
in interface RandomDataOutput
offset
- The non-negative position within the data stream to write the short integer to.i
- The short integer value to write.@NotNull public @NotNull RandomDataOutput writeInt(long offset, int i)
RandomDataOutput
writeInt
in interface RandomDataOutput
offset
- The non-negative position within the data stream to write the integer to.i
- The integer value to write.@NotNull public @NotNull RandomDataOutput writeOrderedInt(long offset, int i)
RandomDataOutput
writeOrderedInt
in interface RandomDataOutput
offset
- The non-negative position within the data stream to write the integer to.i
- The integer value to write.@NotNull public @NotNull RandomDataOutput writeLong(long offset, long i)
RandomDataOutput
writeLong
in interface RandomDataOutput
offset
- The non-negative position within the data stream to write the long integer to.i
- The long integer value to write.@NotNull public @NotNull RandomDataOutput writeOrderedLong(long offset, long i)
RandomDataOutput
writeOrderedLong
in interface RandomDataOutput
offset
- The non-negative position within the data stream to write the long integer to.i
- The long integer value to write.@NotNull public @NotNull RandomDataOutput writeFloat(long offset, float d)
RandomDataOutput
writeFloat
in interface RandomDataOutput
offset
- The non-negative position within the data stream to write the float to.d
- The float value to write.@NotNull public @NotNull RandomDataOutput writeDouble(long offset, double d)
RandomDataOutput
writeDouble
in interface RandomDataOutput
offset
- The non-negative position within the data stream to write the double to.d
- The double value to write.@NotNull public @NotNull RandomDataOutput writeVolatileByte(long offset, byte i8)
RandomDataOutput
writeVolatileByte
in interface RandomDataOutput
offset
- The non-negative position within the data stream to write the byte to.i8
- The byte value to write.@NotNull public @NotNull RandomDataOutput writeVolatileShort(long offset, short i16)
RandomDataOutput
writeVolatileShort
in interface RandomDataOutput
offset
- The non-negative position within the data stream to write the short to.i16
- The short value to write.@NotNull public @NotNull RandomDataOutput writeVolatileInt(long offset, int i32)
RandomDataOutput
writeVolatileInt
in interface RandomDataOutput
offset
- The non-negative position within the data stream to write the integer to.i32
- The integer value to write.@NotNull public @NotNull RandomDataOutput writeVolatileLong(long offset, long i64)
RandomDataOutput
writeVolatileLong
in interface RandomDataOutput
offset
- The non-negative position within the data stream to write the long integer to.i64
- The long integer value to write.@NotNull public @NotNull RandomDataOutput write(long offsetInRDO, byte[] byteArray, int offset, int length)
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()
write
in interface RandomDataOutput
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.public void write(long offsetInRDO, @NotNull @NotNull ByteBuffer bytes, int offset, int length)
RandomDataOutput
Does not update cursors e.g. writePosition()
write
in interface RandomDataOutput
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.@NotNull public @NotNull RandomDataOutput write(long writeOffset, @NotNull @NotNull RandomDataInput bytes, long readOffset, long length)
RandomDataOutput
writePosition()
of this output nor the RandomCommon.readPosition()
of the input.write
in interface RandomDataOutput
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.public byte readByte(long offset)
RandomDataInput
readByte
in interface RandomDataInput
offset
- the location from where the byte value is read.public int peekUnsignedByte(long offset)
RandomDataInput
peekUnsignedByte
in interface RandomDataInput
offset
- the location from where the unsigned byte value is read.public short readShort(long offset)
RandomDataInput
readShort
in interface RandomDataInput
offset
- the location from where the short value is read.public int readInt(long offset)
RandomDataInput
readInt
in interface RandomDataInput
offset
- the location from where the 32-bit integer value is read.public long readLong(long offset)
RandomDataInput
readLong
in interface RandomDataInput
offset
- the location from where the long value is read.public float readFloat(long offset)
RandomDataInput
readFloat
in interface RandomDataInput
offset
- the location from where the float value is read.public double readDouble(long offset)
RandomDataInput
readDouble
in interface RandomDataInput
offset
- the location from where the double value is read.public byte readVolatileByte(long offset) throws BufferUnderflowException
RandomDataInput
readVolatileByte
in interface 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
readVolatileShort
in interface 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
readVolatileInt
in interface 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
readVolatileLong
in interface RandomDataInput
offset
- the location from where the long value is read.BufferUnderflowException
- if the offset is beyond the limits of the byte source.public boolean isDirectMemory()
BytesStore
isDirectMemory
in interface BytesStore
@NotNull public @NotNull BytesStore copy()
BytesStore
copy
in interface BytesStore
@NotNull public @NotNull Bytes<?> bytesForRead() throws IllegalStateException
BytesStore
start
to the realCapacity
.
The returned Bytes is not elastic and can be both read and written using cursors.
bytesForRead
in interface BytesStore
net.openhft.chronicle.core.io.ClosedIllegalStateException
- if this Bytes has been releasedIllegalStateException
- if this Bytes is in an unusable statepublic long capacity()
BytesStore
capacity
in interface BytesStore
public Void underlyingObject()
underlyingObject
in interface BytesStore
public boolean inside(long offset)
BytesStore
Use this test to determine if an offset is considered safe for reading from. Note that it checks we are inside the BytesStore limits *without* including the overlap
inside
in interface BytesStore
offset
- the specified offset to checktrue
if offset is safepublic boolean inside(long offset, long bufferSize)
BytesStore
inside
in interface BytesStore
offset
- the starting index to checkbufferSize
- the number of bytes to be read/writtentrue
if the bytes between the offset and offset+buffer are inside the BytesStorepublic long copyTo(@NotNull @NotNull BytesStore store)
BytesStore
Copies the data to another BytesStore as long as space is available in the destination BytesStore.
copyTo
in interface BytesStore
store
- the BytesStore to copy topublic void nativeWrite(long address, long position, long size)
RandomDataOutput
nativeWrite
in interface 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 long write8bit(long position, @NotNull @NotNull BytesStore bs)
RandomDataOutput
write8bit
in interface 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
write8bit
in interface 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.public void nativeRead(long position, long address, long size)
RandomDataInput
nativeRead
in interface 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 boolean compareAndSwapInt(long offset, int expected, int value)
RandomDataInput
compareAndSwapInt
in interface BytesStore
compareAndSwapInt
in interface RandomDataInput
compareAndSwapInt
in interface RandomDataOutput
offset
- to perform CASexpected
- valuevalue
- to setpublic void testAndSetInt(long offset, int expected, int value)
RandomDataOutput
testAndSetInt
in interface RandomDataInput
testAndSetInt
in interface 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.public boolean compareAndSwapLong(long offset, long expected, long value)
RandomDataInput
compareAndSwapLong
in interface BytesStore
compareAndSwapLong
in interface RandomDataInput
compareAndSwapLong
in interface RandomDataOutput
offset
- to perform CASexpected
- valuevalue
- to setpublic byte[] internalNumberBuffer()
internalNumberBuffer
in interface RandomDataOutput
public boolean equalBytes(@NotNull @NotNull BytesStore bytesStore, long length)
BytesStore
equalBytes
in interface BytesStore
bytesStore
- the BytesStore to match againstlength
- the length to matchtrue
if the bytes up to min(length, this.length(), bytesStore.length()) matched.public void move(long from, long to, long length)
BytesStore
move
in interface 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 movedpublic 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.@NotNull public @NotNull Bytes<?> bytesForWrite()
BytesStore
start
to the realCapacity
.
The returned Bytes is not elastic and can be both read and written using cursors.
bytesForWrite
in interface BytesStore
public boolean sharedMemory()
public boolean isImmutableEmptyByteStore()
BytesStore
isImmutableEmptyByteStore
in interface BytesStore
public String toString()
toString
in interface CharSequence
toString
in class Object
public long start()
public long readPosition()
The read position is start() <= readPosition() && readPosition() <= readLimit() && readPosition < safeLimit()
If the resource is closed, the returned value is unspecified.
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 readRemaining()
If the resource is closed, the returned value is unspecified.
public long realReadRemaining()
If the resource is closed, the returned value is unspecified.
public long writeRemaining()
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.