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, waitaddAndGetDouble, 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, zeroOutcanReadDirect, canReadDirect, compareUtf8, copyTo, copyTo, createCharToString, fastHash, findByte, parseLong, peekVolatileInt, printable, read, readBoolean, readIncompleteLong, readUnsignedByte, readUnsignedInt, readUnsignedInt24, readUnsignedShort, readUtf8, readUtf8Limited, readUtf8Limited, readVolatileDouble, readVolatileFloat, subBytes, toByteArray, toTemporaryDirectByteBufferappend, append, appendAndReturnLength, write, write, writeBoolean, writeByte, writeInt24, writeOrderedDouble, writeOrderedFloat, writeUnsignedByte, writeUnsignedInt, writeUnsignedShort, writeUtf8, writeUtf8Limited, writeVolatileDouble, writeVolatileFloatreleaseLast, reserveTransferreferenceId, referenceName, temporarychars, codePointspublic 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.ReferenceCountedIllegalStateExceptionpublic void release(net.openhft.chronicle.core.io.ReferenceOwner owner)
throws IllegalStateException
release in interface net.openhft.chronicle.core.io.ReferenceCountedIllegalStateExceptionpublic void releaseLast(net.openhft.chronicle.core.io.ReferenceOwner id)
throws IllegalStateException
releaseLast in interface net.openhft.chronicle.core.io.ReferenceCountedIllegalStateExceptionpublic int refCount()
refCount in interface net.openhft.chronicle.core.io.ReferenceCountedpublic void addReferenceChangeListener(net.openhft.chronicle.core.io.ReferenceChangeListener referenceChangeListener)
addReferenceChangeListener in interface net.openhft.chronicle.core.io.ReferenceCountedpublic void removeReferenceChangeListener(net.openhft.chronicle.core.io.ReferenceChangeListener referenceChangeListener)
removeReferenceChangeListener in interface net.openhft.chronicle.core.io.ReferenceCountedpublic boolean tryReserve(net.openhft.chronicle.core.io.ReferenceOwner owner)
tryReserve in interface net.openhft.chronicle.core.io.ReferenceCountedpublic 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)
RandomDataOutputwriteByte in interface RandomDataOutputoffset - 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)
RandomDataOutputwriteShort in interface RandomDataOutputoffset - 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)
RandomDataOutputwriteInt in interface RandomDataOutputoffset - 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)
RandomDataOutputwriteOrderedInt in interface RandomDataOutputoffset - 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)
RandomDataOutputwriteLong in interface RandomDataOutputoffset - 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)
RandomDataOutputwriteOrderedLong in interface RandomDataOutputoffset - 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)
RandomDataOutputwriteFloat in interface RandomDataOutputoffset - 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)
RandomDataOutputwriteDouble in interface RandomDataOutputoffset - 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)
RandomDataOutputwriteVolatileByte in interface RandomDataOutputoffset - 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)
RandomDataOutputwriteVolatileShort in interface RandomDataOutputoffset - 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)
RandomDataOutputwriteVolatileInt in interface RandomDataOutputoffset - 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)
RandomDataOutputwriteVolatileLong in interface RandomDataOutputoffset - 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)
RandomDataOutputbyteArray 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 RandomDataOutputoffsetInRDO - 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 RandomDataOutputoffsetInRDO - 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)
RandomDataOutputwritePosition() of this output nor the RandomCommon.readPosition() of the input.write in interface RandomDataOutputwriteOffset - 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)
RandomDataInputreadByte in interface RandomDataInputoffset - the location from where the byte value is read.public int peekUnsignedByte(long offset)
RandomDataInputpeekUnsignedByte in interface RandomDataInputoffset - the location from where the unsigned byte value is read.public short readShort(long offset)
RandomDataInputreadShort in interface RandomDataInputoffset - the location from where the short value is read.public int readInt(long offset)
RandomDataInputreadInt in interface RandomDataInputoffset - the location from where the 32-bit integer value is read.public long readLong(long offset)
RandomDataInputreadLong in interface RandomDataInputoffset - the location from where the long value is read.public float readFloat(long offset)
RandomDataInputreadFloat in interface RandomDataInputoffset - the location from where the float value is read.public double readDouble(long offset)
RandomDataInputreadDouble in interface RandomDataInputoffset - the location from where the double value is read.public byte readVolatileByte(long offset)
throws BufferUnderflowException
RandomDataInputreadVolatileByte in interface RandomDataInputoffset - 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
RandomDataInputreadVolatileShort in interface RandomDataInputoffset - 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
RandomDataInputreadVolatileInt in interface RandomDataInputoffset - 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
RandomDataInputreadVolatileLong in interface RandomDataInputoffset - the location from where the long value is read.BufferUnderflowException - If the offset is beyond the limits of the byte source.public boolean isDirectMemory()
BytesStoreisDirectMemory in interface BytesStore@NotNull public @NotNull BytesStore copy()
BytesStorecopy in interface BytesStore@NotNull public @NotNull Bytes<?> bytesForRead() throws IllegalStateException
BytesStorestart to the realCapacity.
The returned Bytes is not elastic and can be both read and written using cursors.
bytesForRead in interface BytesStorenet.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 wayIllegalStateExceptionpublic long capacity()
BytesStorecapacity in interface BytesStorepublic Void underlyingObject()
underlyingObject in interface BytesStorepublic boolean inside(long offset)
BytesStoreUse 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 BytesStoreoffset - the specified offset to checktrue if offset is safepublic boolean inside(long offset,
long bufferSize)
BytesStoreinside in interface BytesStoreoffset - 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)
BytesStoreCopies the data to another BytesStore as long as space is available in the destination BytesStore.
copyTo in interface BytesStorestore - the BytesStore to copy topublic void nativeWrite(long address,
long position,
long size)
RandomDataOutputnativeWrite in interface RandomDataOutputaddress - 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)
RandomDataOutputwrite8bit in interface RandomDataOutputposition - 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)
RandomDataOutputwrite8bit in interface RandomDataOutputposition - 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)
RandomDataInputnativeRead in interface RandomDataInputposition - 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)
RandomDataInputcompareAndSwapInt in interface BytesStorecompareAndSwapInt in interface RandomDataInputcompareAndSwapInt in interface RandomDataOutputoffset - to perform CASexpected - valuevalue - to setpublic void testAndSetInt(long offset,
int expected,
int value)
RandomDataOutputtestAndSetInt in interface RandomDataInputtestAndSetInt in interface RandomDataOutputoffset - 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)
RandomDataInputcompareAndSwapLong in interface BytesStorecompareAndSwapLong in interface RandomDataInputcompareAndSwapLong in interface RandomDataOutputoffset - to perform CASexpected - valuevalue - to setpublic byte[] internalNumberBuffer()
internalNumberBuffer in interface RandomDataOutputpublic boolean equalBytes(@NotNull
@NotNull BytesStore bytesStore,
long length)
BytesStoreequalBytes in interface BytesStorebytesStore - 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)
BytesStoremove in interface BytesStorefrom - 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()
BytesStorestart to the realCapacity.
The returned Bytes is not elastic and can be both read and written using cursors.
bytesForWrite in interface BytesStorepublic boolean sharedMemory()
public boolean isImmutableEmptyByteStore()
BytesStoreisImmutableEmptyByteStore in interface BytesStorepublic String toString()
toString in interface CharSequencetoString in class Objectpublic 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,
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.