B
- BytesStore typeU
- Underlying typepublic interface BytesStore<B extends BytesStore<B,U>,U> extends RandomDataInput, RandomDataOutput<B>, net.openhft.chronicle.core.io.ReferenceCounted, CharSequence
charToString
Modifier and Type | Method and Description |
---|---|
default double |
addAndGetDouble(long offset,
double adding)
Perform an atomic add and get operation for a 64-bit double
|
default double |
addAndGetDoubleNotAtomic(long offset,
double adding)
Perform a not atomic add and get operation for a float value.
|
default float |
addAndGetFloat(long offset,
float adding)
Perform an atomic add and get operation for a 32-bit float
|
default float |
addAndGetFloatNotAtomic(long offset,
float adding)
Perform a not atomic add and get operation for a float value.
|
default int |
addAndGetInt(long offset,
int adding)
Perform an atomic add and get operation for a 32-bit int
|
default int |
addAndGetIntNotAtomic(long offset,
int adding)
Perform a not atomic add and get operation for an int value.
|
default long |
addAndGetLong(long offset,
long adding)
Perform an atomic add and get operation for a 64-bit long
|
default short |
addAndGetShortNotAtomic(long offset,
short adding)
Perform a not atomic add and get operation for a short value.
|
default int |
addAndGetUnsignedByteNotAtomic(long offset,
int adding)
Perform a not atomic add and get operation for an unsigned byte value.
|
long |
addressForRead(long offset)
Obtain the underlying addressForRead.
|
default long |
addressForRead(long offset,
int buffer) |
long |
addressForWrite(long offset)
Obtain the underlying addressForRead.
|
long |
addressForWritePosition() |
default int |
byteCheckSum()
Returns the bytes sum of the readable bytes in this BytesStore.
|
default int |
byteCheckSum(long start,
long end)
Returns the bytes sum between the specified indexes; start (inclusive) and end (exclusive).
|
default ByteOrder |
byteOrder() |
default @NotNull Bytes<U> |
bytesForRead()
Returns a Bytes that wraps this ByteStore from the
start to the realCapacity . |
default @NotNull Bytes<U> |
bytesForWrite()
Returns a Bytes that wraps this ByteStore from the
start to the realCapacity . |
default @Nullable BytesStore |
bytesStore() |
long |
capacity() |
default char |
charAt(int index)
Assume ISO-8859-1 encoding, subclasses can override this.
|
default void |
cipher(@NotNull Cipher cipher,
@NotNull Bytes<?> outBytes) |
default void |
cipher(@NotNull Cipher cipher,
@NotNull Bytes<?> outBytes,
@NotNull ByteBuffer using1,
@NotNull ByteBuffer using2) |
default boolean |
compareAndSwapDouble(long offset,
double expected,
double value)
Perform a 64-bit double CAS at a given offset.
|
default boolean |
compareAndSwapFloat(long offset,
float expected,
float value)
Perform a 32-bit float CAS at a given offset.
|
default boolean |
compareAndSwapInt(long offset,
int expected,
int value)
Perform a 32-bit CAS at a given offset.
|
default boolean |
compareAndSwapLong(long offset,
long expected,
long value)
Perform a 64-bit CAS at a given offset.
|
default boolean |
contentEquals(@Nullable BytesStore bytesStore)
Returns if the content of this BytesStore is the same as the content of a specified BytesStore.
|
BytesStore<B,U> |
copy() |
default long |
copyTo(@NotNull BytesStore store)
Returns the number of bytes that were copied from this BytesStore to a destination BytesStore.
|
default void |
copyTo(@NotNull OutputStream out)
Copies the bytes in the BytesStore to an OutputStream object.
|
static BytesStore<?,ByteBuffer> |
elasticByteBuffer(int size,
long maxSize) |
static BytesStore |
empty() |
default boolean |
endsWith(char c)
Returns if the BytesStore ends with a specified character.
|
default boolean |
equalBytes(@NotNull BytesStore bytesStore,
long length)
Returns if a portion of a specified BytesStore matches this BytesStore.
|
static <T> BytesStore<?,T> |
forFields(Object o,
String groupName,
int padding) |
static BytesStore |
from(@NotNull BytesStore cs)
Returns a BytesStore using the bytes in another specified BytesStore.
|
static BytesStore |
from(@NotNull CharSequence cs)
Returns a BytesStore using the bytes in a specified CharSequence.
|
static BytesStore |
from(@NotNull String cs)
Returns a BytesStore using the bytes in a String.
|
default long |
hash(long length) |
default boolean |
inside(long offset)
Returns if a specified offset is inside this BytesStore limits.
|
default boolean |
inside(long offset,
long buffer)
Returns if a number of bytes starting from an offset are inside this ByteStore limits.
|
default boolean |
isClear()
Returns if the
readPosition is at the start and
the writeLimit is at the end . |
boolean |
isDirectMemory() |
default boolean |
isEmpty() |
default boolean |
isEqual(long start,
long length,
String s)
Returns if a specified portion of this BytesStore is equal to a specified String.
|
default boolean |
isImmutableEmptyByteStore()
Deprecated.
|
static BytesStore<?,Void> |
lazyNativeBytesStoreWithFixedCapacity(long capacity) |
default int |
length()
This method is inherited from CharSequence so result should be the length of the contained
chars sequence although it actually returns the number of underlying bytes.
|
default long |
lengthWritten(long startPosition)
Typically this calculates the difference however for HexDumpBytes it's not as simple.
|
void |
move(long from,
long to,
long length) |
static @NotNull PointerBytesStore |
nativePointer() |
static BytesStore<?,Void> |
nativeStore(long capacity)
This is an elastic native store.
|
static BytesStore<?,Void> |
nativeStoreFrom(byte[] bytes)
Creates and returns a new BytesStore that resides in native memory whereby the contents and
size of the native memory is determined by the provided
bytes array. |
static BytesStore<?,Void> |
nativeStoreWithFixedCapacity(long capacity) |
default long |
readLimit()
If the resource is closed, the returned value is unspecified.
|
default long |
readPosition()
Returns the read position.
|
default long |
readRemaining()
Returns the remaining bytes that can be read.
|
default boolean |
readWrite()
Returns if this ByteStore can be both read from and written to.
|
default long |
realCapacity()
Returns the actual capacity that can be potentially read.
|
default long |
realReadRemaining()
If the resource is closed, the returned value is unspecified.
|
default long |
realWriteRemaining()
If the resource is closed, the returned value is unspecified.
|
default long |
safeLimit() |
boolean |
sharedMemory() |
default long |
start() |
default boolean |
startsWith(@Nullable BytesStore bytesStore)
Returns if the content of this BytesStore starts with bytes equal to the content of a specified BytesStore.
|
default boolean |
startsWith(char c)
Returns if the BytesStore starts with a specified character.
|
default @NotNull CharSequence |
subSequence(int start,
int end)
This method constructs a new BytesStore , memory storage type (heap or native) is preserved. |
default @NotNull String |
to8bitString()
Returns the content of this BytesStore in 8bitString format.
|
default @NotNull String |
toDebugString()
By default the maximum length of data shown is 256 characters.
|
default @NotNull String |
toDebugString(long maxLength) |
U |
underlyingObject() |
static BytesStore<?,byte[]> |
wrap(byte[] bytes)
Wraps a byte[].
|
static @NotNull BytesStore<?,ByteBuffer> |
wrap(@NotNull ByteBuffer bb)
Wraps a ByteBuffer which can be either on heap or off heap.
|
static @NotNull PointerBytesStore |
wrap(long address,
long length)
Returns a PointerBytesStore that wraps bytes from a starting address in memory.
|
default long |
writeLimit()
Returns the write limit.
|
default void |
writeMaxInt(long offset,
int atLeast)
Writes an int value at a specified offset if the value is not smaller than the current value at that offset.
|
default void |
writeMaxLong(long offset,
long atLeast)
Writes a long value at a specified offset if the value is not smaller than the current value at that offset.
|
default long |
writePosition()
Returns the write position.
|
default long |
writeRemaining()
If the resource is closed, the returned value is unspecified.
|
default B |
zeroOut(long start,
long end)
Fills the BytesStore with zeros.
|
canReadDirect, canReadDirect, compareUtf8, copyTo, copyTo, createCharToString, fastHash, findByte, nativeRead, parseLong, peekUnsignedByte, peekVolatileInt, printable, read, readBoolean, readByte, readDouble, readFloat, readIncompleteLong, readInt, readLong, readShort, readUnsignedByte, readUnsignedInt, readUnsignedInt24, readUnsignedShort, readUtf8, readUtf8Limited, readUtf8Limited, readVolatileByte, readVolatileDouble, readVolatileFloat, readVolatileInt, readVolatileLong, readVolatileShort, subBytes, testAndSetInt, toByteArray, toTemporaryDirectByteBuffer
append, append, nativeWrite, testAndSetInt, write, write, write, write, write, write8bit, write8bit, writeBoolean, writeByte, writeByte, writeDouble, writeFloat, writeInt, writeInt24, writeLong, writeOrderedDouble, writeOrderedFloat, writeOrderedInt, writeOrderedLong, writeShort, writeUnsignedByte, writeUnsignedInt, writeUnsignedShort, writeUtf8, writeUtf8Limited, writeVolatileByte, writeVolatileDouble, writeVolatileFloat, writeVolatileInt, writeVolatileLong, writeVolatileShort
refCount, release, releaseLast, releaseLast, reserve, reservedBy, reserveTransfer, tryReserve
referenceId, referenceName, temporary
chars, codePoints, toString
default boolean compareAndSwapFloat(long offset, float expected, float value) throws BufferOverflowException, IllegalStateException
RandomDataInput
compareAndSwapFloat
in interface RandomDataInput
compareAndSwapFloat
in interface RandomDataOutput<B extends BytesStore<B,U>>
offset
- to perform CASexpected
- valuevalue
- to setBufferOverflowException
IllegalStateException
default boolean compareAndSwapDouble(long offset, double expected, double value) throws BufferOverflowException, IllegalStateException
RandomDataInput
compareAndSwapDouble
in interface RandomDataInput
compareAndSwapDouble
in interface RandomDataOutput<B extends BytesStore<B,U>>
offset
- to perform CASexpected
- valuevalue
- to setBufferOverflowException
IllegalStateException
default int addAndGetInt(long offset, int adding) throws BufferUnderflowException, IllegalStateException
RandomDataInput
addAndGetInt
in interface RandomDataInput
addAndGetInt
in interface RandomDataOutput<B extends BytesStore<B,U>>
offset
- to add and getadding
- value to add, can be 1BufferUnderflowException
- if the offset is outside the limits of the BytesIllegalStateException
- if releaseddefault long addAndGetLong(long offset, long adding) throws BufferUnderflowException, IllegalStateException
RandomDataInput
addAndGetLong
in interface RandomDataInput
addAndGetLong
in interface RandomDataOutput<B extends BytesStore<B,U>>
offset
- to add and getadding
- value to add, can be 1BufferUnderflowException
- if the offset is outside the limits of the BytesIllegalStateException
- if releaseddefault float addAndGetFloat(long offset, float adding) throws BufferUnderflowException, IllegalStateException
RandomDataInput
addAndGetFloat
in interface RandomDataInput
addAndGetFloat
in interface RandomDataOutput<B extends BytesStore<B,U>>
offset
- to add and getadding
- value to add, can be 1BufferUnderflowException
- if the offset is outside the limits of the BytesIllegalStateException
default double addAndGetDouble(long offset, double adding) throws BufferUnderflowException, IllegalStateException
RandomDataInput
addAndGetDouble
in interface RandomDataInput
addAndGetDouble
in interface RandomDataOutput<B extends BytesStore<B,U>>
offset
- to add and getadding
- value to add, can be 1BufferUnderflowException
- if the offset is outside the limits of the BytesIllegalStateException
- if releasedstatic BytesStore from(@NotNull @NotNull CharSequence cs) throws IllegalStateException
cs
- a CharSequence to convertIllegalStateException
static BytesStore from(@NotNull @NotNull BytesStore cs) throws IllegalStateException
cs
- a BytesStoreIllegalStateException
static BytesStore from(@NotNull @NotNull String cs)
cs
- a Stringstatic <T> BytesStore<?,T> forFields(Object o, String groupName, int padding)
static BytesStore<?,byte[]> wrap(byte[] bytes)
bytes
- to wrap@NotNull static @NotNull BytesStore<?,ByteBuffer> wrap(@NotNull @NotNull ByteBuffer bb)
bb
- the ByteBuffer to wrapstatic BytesStore<?,Void> nativeStore(long capacity)
capacity
- of the bufferstatic BytesStore<?,Void> nativeStoreWithFixedCapacity(long capacity)
static BytesStore<?,Void> lazyNativeBytesStoreWithFixedCapacity(long capacity)
static BytesStore<?,ByteBuffer> elasticByteBuffer(int size, long maxSize)
static BytesStore<?,Void> nativeStoreFrom(byte[] bytes)
bytes
array.bytes
- the content to initialize the new ByteStorebytes
arrayAssertionError
- if the method fails for any reason@NotNull static @NotNull PointerBytesStore nativePointer()
@NotNull static @NotNull PointerBytesStore wrap(long address, long length)
address
- the start address of PointerBytesStorelength
- the length of PointerBytesStorestatic BytesStore empty()
boolean isDirectMemory()
BytesStore<B,U> copy() throws IllegalStateException
IllegalStateException
@NotNull default @NotNull Bytes<U> bytesForRead() throws IllegalStateException
start
to the realCapacity
.
The returned Bytes is not elastic and can be both read and written using cursors.
IllegalStateException
- if this Bytes has been released@NotNull default @NotNull Bytes<U> bytesForWrite() throws IllegalStateException
start
to the realCapacity
.
The returned Bytes is not elastic and can be both read and written using cursors.
IllegalStateException
- if this BytesStore has been releaseddefault boolean isClear()
readPosition
is at the start
and
the writeLimit
is at the end
.
I.e start() == readPosition() && writeLimit() == capacity()
readPosition
is at the start
and
the writeLimit
is at the end
default long realCapacity()
RandomDataInput
realCapacity
in interface RandomDataInput
long capacity()
@Nullable U underlyingObject()
default boolean inside(long offset)
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
offset
- the specified offset to checktrue
if offset is safedefault boolean inside(long offset, long buffer)
Use this test to determine if an offset is considered safe to write to. Note that it checks we are inside the BytesStore limits *including* the overlap
offset
- the starting index to checkbuffer
- the number of bytes after the offset to checktrue
if the bytes between the offset and offset+buffer are inside the BytesStoredefault long safeLimit()
default long copyTo(@NotNull @NotNull BytesStore store) throws IllegalStateException
Copies the data to another BytesStore as long as space is available in the destination BytesStore.
store
- the BytesStore to copy toIllegalStateException
- if this BytesStore has been releaseddefault void copyTo(@NotNull @NotNull OutputStream out) throws IOException, IllegalStateException
out
- the specified OutputStream that this BytesStore is copied toIllegalStateException
- if this Bytes has been releasedIOException
OutputStream
@NotNull default B zeroOut(long start, long end) throws IllegalStateException
zeroOut
in interface RandomDataOutput<B extends BytesStore<B,U>>
start
- first byte inclusiveend
- last byte exclusiveIllegalStateException
default int length()
length
in interface CharSequence
default char charAt(int index) throws IndexOutOfBoundsException
charAt
in interface CharSequence
IndexOutOfBoundsException
@NotNull default @NotNull CharSequence subSequence(int start, int end)
BytesStore
, memory storage type (heap or native) is preserved.subSequence
in interface CharSequence
@NotNull default @NotNull String toDebugString() throws IllegalStateException
toDebugString(long)
if you want more.IllegalStateException
@NotNull default @NotNull String toDebugString(long maxLength) throws IllegalStateException, ArithmeticException
maxLength
- the maximum length of the outputIllegalStateException
ArithmeticException
@Nullable default @Nullable BytesStore bytesStore()
default boolean equalBytes(@NotNull @NotNull BytesStore bytesStore, long length) throws BufferUnderflowException, IllegalStateException
bytesStore
- the BytesStore to match againstlength
- the length to matchtrue
if the bytes up to min(length, this.length(), bytesStore.length()) matched.BufferUnderflowException
IllegalStateException
default int byteCheckSum() throws net.openhft.chronicle.core.io.IORuntimeException, BufferUnderflowException, IllegalStateException
IllegalStateException
- if the BytesStore has been releasednet.openhft.chronicle.core.io.IORuntimeException
BufferUnderflowException
default int byteCheckSum(long start, long end) throws BufferUnderflowException, IllegalStateException
start
- the index of the first byte to sumend
- the index of the last byte to sumBufferUnderflowException
- if the specified indexes are outside the limits of the BytesStoreIllegalStateException
- if the BytesStore has been releaseddefault boolean endsWith(char c) throws IllegalStateException
c
- the character to look fortrue
if the specified character is the same as the last character of this BytesStoreIllegalStateException
default boolean startsWith(char c) throws IllegalStateException
c
- the character to look fortrue
if the specified character is the same as the first character of this BytesStoreIllegalStateException
default boolean contentEquals(@Nullable @Nullable BytesStore bytesStore) throws IllegalStateException
bytesStore
- the BytesStore to compare withtrue
if this BytesStore and the input BytesStore contain the same dataIllegalStateException
- if this BytesStore has been releaseddefault boolean startsWith(@Nullable @Nullable BytesStore bytesStore) throws IllegalStateException
bytesStore
- the BytesStore to compare withtrue
if the content of this BytesStore starts with bytesStoreIllegalStateException
- if this BytesStore has been released@NotNull default @NotNull String to8bitString()
default int addAndGetUnsignedByteNotAtomic(long offset, int adding) throws BufferUnderflowException, IllegalStateException
offset
- to add and getadding
- value to add, can be 1BufferUnderflowException
IllegalStateException
default short addAndGetShortNotAtomic(long offset, short adding) throws BufferUnderflowException, IllegalStateException
offset
- to add and getadding
- value to add, can be 1BufferUnderflowException
IllegalStateException
default int addAndGetIntNotAtomic(long offset, int adding) throws BufferUnderflowException, IllegalStateException
offset
- to add and getadding
- value to add, can be 1BufferUnderflowException
IllegalStateException
default double addAndGetDoubleNotAtomic(long offset, double adding) throws BufferUnderflowException, IllegalStateException
offset
- to add and getadding
- value to add, can be 1BufferUnderflowException
IllegalStateException
default float addAndGetFloatNotAtomic(long offset, float adding) throws BufferUnderflowException, IllegalStateException
offset
- to add and getadding
- value to add, can be 1BufferUnderflowException
IllegalStateException
void move(long from, long to, long length) throws BufferUnderflowException, IllegalStateException, ArithmeticException
default void writeMaxLong(long offset, long atLeast) throws BufferUnderflowException, IllegalStateException
offset
- the offset to write toatLeast
- the long value that is to be written at offset if it is not less than the current value at offsetBufferUnderflowException
IllegalStateException
default void writeMaxInt(long offset, int atLeast) throws BufferUnderflowException, IllegalStateException
offset
- the offset to write toatLeast
- the int value that is to be written at offset if it is not less than the current value at offsetBufferUnderflowException
IllegalStateException
default boolean isEmpty()
true
if the number of readable bytes of this BytesStore is zero.default void cipher(@NotNull @NotNull Cipher cipher, @NotNull @NotNull Bytes<?> outBytes, @NotNull @NotNull ByteBuffer using1, @NotNull @NotNull ByteBuffer using2) throws IllegalStateException
IllegalStateException
default void cipher(@NotNull @NotNull Cipher cipher, @NotNull @NotNull Bytes<?> outBytes) throws IllegalStateException
IllegalStateException
default boolean readWrite()
This is in contrast to a ByteStore than can only be read.
default long hash(long length)
default boolean isEqual(long start, long length, String s)
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 sdefault boolean compareAndSwapInt(long offset, int expected, int value) throws BufferOverflowException, IllegalStateException
RandomDataInput
compareAndSwapInt
in interface RandomDataInput
compareAndSwapInt
in interface RandomDataOutput<B extends BytesStore<B,U>>
offset
- to perform CASexpected
- valuevalue
- to setBufferOverflowException
IllegalStateException
default boolean compareAndSwapLong(long offset, long expected, long value) throws BufferOverflowException, IllegalStateException
RandomDataInput
compareAndSwapLong
in interface RandomDataInput
compareAndSwapLong
in interface RandomDataOutput<B extends BytesStore<B,U>>
offset
- to perform CASexpected
- valuevalue
- to setBufferOverflowException
IllegalStateException
@Deprecated default boolean isImmutableEmptyByteStore()
default long start()
default long readPosition()
The read position is start() <= readPosition() && readPosition() <= readLimit() && readPosition < safeLimit()
If the resource is closed, the returned value is unspecified.
default long writePosition()
readPosition() <= writePosition() && writePosition() <= writeLimit()
If the resource is closed, the returned value is unspecified.
default long lengthWritten(long startPosition)
If the resource is closed, the returned value is unspecified.
startPosition
- to compare againstdefault long readRemaining()
If the resource is closed, the returned value is unspecified.
default long realReadRemaining()
If the resource is closed, the returned value is unspecified.
default long writeRemaining()
If the resource is closed, the returned value is unspecified.
default long realWriteRemaining()
If the resource is closed, the returned value is unspecified.
default long readLimit()
If the resource is closed, the returned value is unspecified.
default long writeLimit()
If the resource is closed, the returned value is unspecified.
long addressForRead(long offset) throws UnsupportedOperationException, BufferUnderflowException, IllegalStateException
offset
- within this buffer. addressForRead(start()) is the actual addressForRead of the first byte.UnsupportedOperationException
- if the underlying buffer is on the heapBufferUnderflowException
- if the offset is before the start() or the after the capacity()IllegalStateException
default long addressForRead(long offset, int buffer) throws UnsupportedOperationException, BufferUnderflowException, IllegalStateException
long addressForWrite(long offset) throws UnsupportedOperationException, BufferOverflowException, IllegalStateException
offset
- within this buffer. addressForRead(start()) is the actual addressForRead of the first byte.UnsupportedOperationException
- if the underlying buffer is on the heapBufferOverflowException
- if the offset is before the start() or the after the capacity()IllegalStateException
long addressForWritePosition() throws UnsupportedOperationException, BufferOverflowException, IllegalStateException
default ByteOrder byteOrder()
boolean sharedMemory()
Copyright © 2022. All rights reserved.