U
- The type of the object this Bytes can point to.public class UncheckedNativeBytes<U> extends net.openhft.chronicle.core.io.AbstractReferenceCounted implements Bytes<U>, net.openhft.chronicle.bytes.internal.HasUncheckedRandomDataInput, DecimalAppender
This class is intended for use in performance-critical scenarios where the client can ensure that all operations stay within valid bounds, thus avoiding the overhead of bounds checking.
Warning: Using this class improperly can result in IndexOutOfBoundsException being thrown, corruption of data, JVM crashes, or other undefined behavior.
Modifier and Type | Field and Description |
---|---|
protected @NotNull BytesStore<?,U> |
bytesStore |
protected long |
capacity |
protected long |
readPosition |
protected long |
writeLimit |
protected long |
writePosition |
referenceCounted, WARN_COUNT, WARN_NS
DEFAULT_BYTE_BUFFER_CAPACITY, MAX_CAPACITY, MAX_HEAP_CAPACITY
JAVA9_STRING_CODER_LATIN, JAVA9_STRING_CODER_UTF16
Constructor and Description |
---|
UncheckedNativeBytes(@NotNull Bytes<U> underlyingBytes)
Constructs an UncheckedNativeBytes instance by wrapping around the provided Bytes object.
|
Modifier and Type | Method and Description |
---|---|
@NotNull net.openhft.chronicle.bytes.internal.UncheckedRandomDataInput |
acquireUncheckedInput()
Returns a view of a memory segment providing memory read operations with potentially unchecked
memory boundaries.
|
long |
addressForRead(long offset)
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.
|
void |
append(boolean negative,
long mantissa,
int exponent)
Appends a decimal number, represented by its sign, mantissa, and exponent, to a target.
|
@NotNull UncheckedNativeBytes<U> |
append(double d)
Appends a double in decimal notation
|
@NotNull UncheckedNativeBytes<U> |
append(float f)
Appends a float in decimal notation
|
@NotNull Bytes<U> |
append(int value)
Appends an int in decimal to this.
|
@NotNull Bytes<U> |
append(long value)
Appends a long value in decimal.
|
@NotNull Bytes<U> |
append8bit(@NotNull CharSequence cs)
Appends a String to the Bytes in ISO-8859-1.
|
long |
appendAndReturnLength(long writePosition,
boolean negative,
long mantissa,
int exponent,
boolean append0) |
@NotNull Bytes<U> |
appendUtf8(char[] chars,
int offset,
int length)
Appends a UTF-8 encoded CharSequence to this output stream from a specific offset and length.
|
int |
byteCheckSum()
Returns the bytes sum of the readable bytes in this BytesStore.
|
@Nullable BytesStore<?,U> |
bytesStore()
Returns the backing BytesStore that this Bytes object wraps.
|
long |
capacity()
Provides the maximum limit that can be set for the ByteStore.
|
@NotNull Bytes<U> |
clear()
Clears the content of this Bytes object and resets its state.
|
@NotNull Bytes<U> |
clearAndPad(long length)
Clears the buffer and pads it with a specified length to allow prepending later.
|
@NotNull Bytes<U> |
compact()
Compacts this Bytes object by moving the readPosition() to the start(),
adjusting the readLimit()/writePosition() appropriately so that the readRemaining() is unchanged.
|
boolean |
compareAndSwapInt(long offset,
int expected,
int value)
Performs a 32-bit compare-and-swap (CAS) operation at a given offset.
|
boolean |
compareAndSwapLong(long offset,
long expected,
long value)
Performs a 64-bit compare-and-swap (CAS) operation at a given offset.
|
@NotNull BytesStore<Bytes<U>,U> |
copy()
Creates and returns a deep copy of this Bytes object, including the data between
RandomCommon.readPosition() and RandomCommon.readLimit() . |
Decimaliser |
decimaliser()
Gets the Decimaliser currently associated with this ByteStringAppender.
|
Bytes<U> |
decimaliser(Decimaliser decimaliser)
Associates a Decimaliser with this ByteStringAppender.
|
void |
ensureCapacity(long desiredCapacity)
Ensures that this Bytes object has the capacity to accommodate the specified amount of data.
|
boolean |
equals(Object obj) |
boolean |
fpAppend0() |
Bytes<U> |
fpAppend0(boolean append0) |
int |
hashCode() |
boolean |
isDirectMemory()
Checks if this BytesStore uses direct memory.
|
boolean |
isElastic()
Checks if this Bytes object is elastic, meaning it can dynamically resize when more data is written
than its current
Bytes.realCapacity() . |
int |
lastDecimalPlaces()
Returns the number of decimal places in the last parsed floating-point number
(from the
ByteStringParser.parseDouble() or ByteStringParser.parseLongDecimal() methods). |
void |
lastDecimalPlaces(int lastDecimalPlaces)
Sets the number of decimal places in the last parsed number.
|
boolean |
lastNumberHadDigits()
Returns whether the last parsed number had any digits.
|
void |
lastNumberHadDigits(boolean lastNumberHadDigits)
Sets whether the last parsed number had any digits.
|
boolean |
lenient() |
void |
lenient(boolean lenient)
When there is no more data to read, return zero,
false and empty string. |
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.
|
int |
peekUnsignedByte()
Peeks (reads without moving the read pointer) the next unsigned byte from the input stream.
|
int |
peekUnsignedByte(long offset)
Reads an unsigned byte value from a specific offset.
|
protected void |
performRelease() |
@NotNull Bytes<U> |
prewrite(@NotNull byte[] bytes)
Writes a byte array backward in binary format.
|
@NotNull Bytes<U> |
prewrite(@NotNull BytesStore<?,?> bytes)
Writes a BytesStore instance backward in binary format.
|
@NotNull Bytes<U> |
prewriteByte(byte i8)
Writes a byte backward in binary format.
|
@NotNull Bytes<U> |
prewriteInt(int i)
Writes an int (4-byte int) backward in binary format.
|
@NotNull Bytes<U> |
prewriteLong(long i64)
Writes a long (8-byte int) backward in binary format.
|
protected long |
prewriteOffsetPositionMoved(long substracting) |
@NotNull Bytes<U> |
prewriteShort(short i16)
Writes a short (2-byte int) backward in binary format.
|
Bytes<U> |
rawWriteByte(byte i8)
Writes a byte to the data stream without any additional checks or transformations.
|
byte |
readByte()
Reads a byte value from the input stream.
|
byte |
readByte(long offset)
Reads a byte value from a specific offset.
|
double |
readDouble()
Reads a 64-bit floating-point number from the input stream.
|
double |
readDouble(long offset)
Reads a 64-bit floating point value from a specified offset.
|
float |
readFloat()
Reads a 32-bit floating-point number from the input stream.
|
float |
readFloat(long offset)
Reads a 32-bit floating point value from a specified offset.
|
int |
readInt()
Reads a 32-bit integer value from the input stream.
|
int |
readInt(long offset)
Reads a 32-bit integer value from a specific offset.
|
long |
readLimit()
If the resource is closed, the returned value is unspecified.
|
@NotNull Bytes<U> |
readLimit(long limit)
Sets the read limit of this StreamingDataInput.
|
long |
readLong()
Reads a 64-bit long value from the input stream.
|
long |
readLong(long offset)
Reads a 64-bit long value from a specific offset.
|
protected long |
readOffsetPositionMoved(long adding) |
long |
readPosition()
Returns the read position.
|
@NotNull Bytes<U> |
readPosition(long position)
Sets the read position of this StreamingDataInput.
|
short |
readShort()
Reads a 16-bit short value from the input stream.
|
short |
readShort(long offset)
Reads a short value from a specific offset.
|
@NotNull Bytes<U> |
readSkip(long bytesToSkip)
Skips the specified number of bytes by advancing the read position.
|
int |
readUnsignedByte()
Reads the next unsigned 8-bit value from the input stream.
|
int |
readUnsignedByte(long offset)
Reads an unsigned byte value from a specific offset.
|
byte |
readVolatileByte(long offset)
Reads a volatile 8-bit byte value from a specified offset.
|
int |
readVolatileInt()
Reads a volatile (concurrently mutable) integer value from the input stream.
|
int |
readVolatileInt(long offset)
Reads a volatile 32-bit integer value from a specified offset.
|
long |
readVolatileLong()
Reads a volatile (concurrently mutable) long value from the input stream.
|
long |
readVolatileLong(long offset)
Reads a volatile 64-bit long value from a specified offset.
|
short |
readVolatileShort(long offset)
Reads a volatile 16-bit short value from a specified offset.
|
long |
realCapacity()
If this Bytes
Bytes.isElastic() the Bytes.realCapacity() can be
lower than the virtual BytesStore.capacity() . |
long |
realWriteRemaining()
Calculates the number of bytes remaining that can be written from the current write position with resizing.
|
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() |
boolean |
unchecked()
Checks whether this Bytes object operates in an unchecked mode.
|
@NotNull Bytes<U> |
unchecked(boolean unchecked)
Creates and returns a new Bytes which is optionally unchecked as indicated by the provided
unchecked . |
void |
uncheckedReadSkipBackOne()
Unchecked version of readSkip(-1).
|
void |
uncheckedReadSkipOne()
Unchecked version of readSkip(1).
|
int |
uncheckedReadUnsignedByte()
Reads the next unsigned 8-bit value from the input stream without performing boundary checks.
|
U |
underlyingObject() |
void |
unmonitor() |
@NotNull Bytes<U> |
write(byte[] byteArray,
int offset,
int length)
Writes the specified number of bytes from the given
byteArray into the output stream, starting from the
given offset. |
@NotNull Bytes<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 Bytes<U> |
write(long writeOffset,
@NotNull RandomDataInput bytes,
long readOffset,
long length)
Copies a segment from the provided RandomDataInput into this data output.
|
@NotNull Bytes<U> |
write(@NotNull RandomDataInput bytes)
Writes all available data from the specified
RandomDataInput into the output stream. |
@NotNull Bytes<U> |
write(@NotNull RandomDataInput bytes,
long offset,
long length)
Writes the specified number of bytes from the provided
RandomDataInput object into the output stream,
starting from the given read offset. |
Bytes<U> |
write8bit(@Nullable BytesStore<?,?> bs) |
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 Bytes<U> |
write8bit(@NotNull String text,
int start,
int length)
Writes a subsequence of a String as an 8-bit string to the data stream.
|
@NotNull Bytes<U> |
writeByte(byte i8)
Writes a byte to the data stream.
|
@NotNull Bytes<U> |
writeByte(long offset,
byte i)
Writes a byte at the specified non-negative offset.
|
@NotNull Bytes<U> |
writeDouble(double d)
Writes a double-precision floating-point number to the data stream.
|
@NotNull Bytes<U> |
writeDouble(long offset,
double d)
Writes a double-precision floating-point value at the specified non-negative offset.
|
@NotNull Bytes<U> |
writeDoubleAndInt(double d,
int i)
Writes a double-precision floating-point number followed by an integer to the data stream.
|
@NotNull Bytes<U> |
writeFloat(float f)
Writes a floating-point number to the data stream.
|
@NotNull Bytes<U> |
writeFloat(long offset,
float d)
Writes a single-precision floating-point value at the specified non-negative offset.
|
@NotNull Bytes<U> |
writeInt(int i)
Writes an integer to the data stream.
|
@NotNull Bytes<U> |
writeInt(long offset,
int i)
Writes an integer value at the specified non-negative offset.
|
@NotNull Bytes<U> |
writeIntAdv(int i,
int advance)
Writes an integer to the data stream, then advances the write position by the specified amount.
|
long |
writeLimit()
Retrieves the maximum writable position within the buffer.
|
@NotNull Bytes<U> |
writeLimit(long limit)
Sets the limit for writing to the data stream.
|
@NotNull Bytes<U> |
writeLong(long i64)
Writes a long integer to the data stream.
|
@NotNull Bytes<U> |
writeLong(long offset,
long i)
Writes a long integer value at the specified non-negative offset.
|
@NotNull Bytes<U> |
writeLongAdv(long i64,
int advance)
Writes a long integer to the data stream, then advances the write position by the specified amount.
|
protected long |
writeOffsetPositionMoved(long adding) |
protected long |
writeOffsetPositionMoved(long adding,
long advance) |
@NotNull Bytes<U> |
writeOrderedInt(int i)
Writes an integer value to this output stream using an ordered-writing mechanism.
|
@NotNull Bytes<U> |
writeOrderedInt(long offset,
int i)
Performs a non-blocking write operation with a memory barrier to ensure order of stores.
|
@NotNull Bytes<U> |
writeOrderedLong(long i)
Writes a long value to this output stream using an ordered-writing mechanism.
|
@NotNull Bytes<U> |
writeOrderedLong(long offset,
long i)
Performs a non-blocking write operation with a memory barrier to ensure order of stores.
|
long |
writePosition()
Returns the write position.
|
@NotNull Bytes<U> |
writePosition(long position)
Sets the current write position in the data stream.
|
@NotNull Bytes<U> |
writeShort(long offset,
short i)
Writes a short integer at the specified non-negative offset.
|
@NotNull Bytes<U> |
writeShort(short i16)
Writes a short integer to the data stream.
|
@NotNull Bytes<U> |
writeSkip(long bytesToSkip)
Skips a specified number of bytes from the current write position in the data stream.
|
@NotNull Bytes<U> |
writeSome(@NotNull ByteBuffer buffer)
Writes the available data from the provided
ByteBuffer into this Bytes object. |
@NotNull Bytes<U> |
writeVolatileByte(long offset,
byte i8)
Writes a volatile byte at the specified non-negative offset.
|
@NotNull Bytes<U> |
writeVolatileInt(long offset,
int i32)
Writes a volatile integer at the specified non-negative offset.
|
@NotNull Bytes<U> |
writeVolatileLong(long offset,
long i64)
Writes a volatile long integer at the specified non-negative offset.
|
@NotNull Bytes<U> |
writeVolatileShort(long offset,
short i16)
Writes a volatile short at the specified non-negative offset.
|
addReferenceChangeListener, assertReferencesReleased, backgroundPerformRelease, canReleaseInBackground, createdHere, disableReferenceTracing, enableReferenceTracing, refCount, referenceCountedUnmonitored, referenceId, release, releaseLast, removeReferenceChangeListener, reserve, reserveTransfer, singleThreadedCheckDisabled, singleThreadedCheckReset, threadSafetyCheck, throwExceptionIfNotReleased, throwExceptionIfReleased, tryReserve, unmonitor, warnAndReleaseIfNotReleased
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
allocateDirect, allocateDirect, allocateElasticDirect, allocateElasticDirect, allocateElasticOnHeap, allocateElasticOnHeap, bytesForRead, bytesForWrite, copyTo, copyTo, directFrom, elasticByteBuffer, elasticByteBuffer, elasticByteBuffer, elasticHeapByteBuffer, elasticHeapByteBuffer, empty, forFieldGroup, from, from, fromDirect, fromHexString, indexOf, indexOf, isClear, isEqual, readMarshallableLength16, readWithLength, readWrite, safeLimit, sharedMemory, toHexString, toHexString, toHexString, toString, toString, toString, unwrite, valueOf, wrapForRead, wrapForRead, wrapForWrite, wrapForWrite, write, writeMarshallableLength16
addAndGetDouble, addAndGetDoubleNotAtomic, addAndGetFloat, addAndGetFloatNotAtomic, addAndGetInt, addAndGetIntNotAtomic, addAndGetLong, addAndGetShortNotAtomic, addAndGetUnsignedByteNotAtomic, byteCheckSum, charAt, cipher, cipher, compareAndSwapDouble, compareAndSwapFloat, contentEquals, elasticByteBuffer, endsWith, equalBytes, follow, forFields, from, hash, inside, inside, isEmpty, isEqual, lazyNativeBytesStoreWithFixedCapacity, length, nativePointer, nativeStore, nativeStoreFrom, nativeStoreWithFixedCapacity, startsWith, startsWith, subSequence, to8bitString, toDebugString, toDebugString, wrap, wrap, wrap, writeMaxInt, writeMaxLong, zeroOut
append, append, write, write, writeBoolean, writeByte, writeInt24, writeOrderedDouble, writeOrderedFloat, writeUnsignedByte, writeUnsignedInt, writeUnsignedShort, writeUtf8, writeUtf8Limited, writeVolatileDouble, writeVolatileFloat
chars, codePoints
bytesMethodReader, bytesMethodReaderBuilder, readObject
canReadDirect, canReadDirect, compareUtf8, copyTo, copyTo, fastHash, findByte, parseLong, peekVolatileInt, printable, read, readBoolean, readIncompleteLong, readUnsignedInt, readUnsignedInt24, readUnsignedShort, readUtf8, readUtf8Limited, readUtf8Limited, readVolatileDouble, readVolatileFloat, subBytes, toByteArray, toTemporaryDirectByteBuffer
parse8bit, parse8bit, parse8bit, parse8bit, parse8bit, parseBigDecimal, parseBoolean, parseBoolean, parseDouble, parseFlexibleLong, parseFloat, parseInt, parseLong, parseLongDecimal, parseUtf8, parseUtf8, parseUtf8, reader, skipTo
inputStream, parseHexLong, parseUtf8, parseUtf8, rawReadByte, rawReadInt, rawReadLong, read, read, read, read, read, read, read8bit, read8bit, read8bit, readBigDecimal, readBigInteger, readBoolean, readChar, readEnum, readHistogram, readIncompleteLong, readInt24, readLimitToCapacity, readPositionForHeader, readPositionRemaining, readPositionUnlimited, readStopBit, readStopBitChar, readStopBitDecimal, readStopBitDouble, readUnsignedInt, readUnsignedInt24, readUnsignedShort, readUtf8, readUtf8, readUtf8, readUtf8, readWithLength, readWithLength, readWithLength0, unsafeRead, unsafeReadObject, unsafeReadObject
bytesMethodWriter, writeObject
append, append, append, append, append, append, append8bit, append8bit, append8bit, append8bit, appendBase, appendBase16, appendBase16, appendDateMillis, appendDecimal, appendTimeMillis, writer
appendUtf8, appendUtf8, appendUtf8, appendUtf8, appendUtf8, canWriteDirect, copyFrom, outputStream, rawWriteInt, rawWriteLong, unsafeWrite, unsafeWriteObject, unsafeWriteObject, write, write, write, write, write, write8bit, write8bit, write8bit, writeBigDecimal, writeBigInteger, writeBoolean, writeChar, writeEnum, writeHistogram, writeInt24, writePositionForHeader, writePositionRemaining, writeStopBit, writeStopBit, writeStopBit, writeStopBitDecimal, writeUnsignedByte, writeUnsignedInt, writeUnsignedInt24, writeUnsignedShort, writeUtf8, writeUtf8, writeWithLength
prepend
adjustHexDumpIndentation, retainedHexDumpDescription, writeHexDumpDescription
protected final long capacity
@NotNull protected @NotNull BytesStore<?,U> bytesStore
protected long readPosition
protected long writePosition
protected long writeLimit
public UncheckedNativeBytes(@NotNull @NotNull Bytes<U> underlyingBytes) throws IllegalStateException
underlyingBytes
- the Bytes object to wrap aroundnet.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 wayIllegalStateException
public void ensureCapacity(long desiredCapacity) throws IllegalArgumentException, IllegalStateException
Bytes
If this Bytes object is elastic and doesn't have enough capacity, it will be resized. If it is not
elastic and doesn't have enough capacity, a DecoratedBufferOverflowException
will be thrown.
ensureCapacity
in interface Bytes<U>
ensureCapacity
in interface StreamingDataOutput<Bytes<U>>
desiredCapacity
- The minimum capacity, in bytes, that is required.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 wayIllegalArgumentException
IllegalStateException
public boolean unchecked()
Bytes
When a Bytes object is unchecked, it performs minimal or no bounds checking on read and write operations. This can improve performance but may result in undefined behavior if attempting to access out-of-bounds elements.
public boolean isDirectMemory()
BytesStore
isDirectMemory
in interface BytesStore<Bytes<U>,U>
@NotNull public @NotNull Bytes<U> unchecked(boolean unchecked)
Bytes
unchecked
.
This allows bounds checks to be turned off.
Note: this means that the result is no longer elastic, even if this
is elastic.
Note: It is only possible to go from a checked Bytes to an unchecked bytes and not vice versa.
public void move(long from, long to, long length) throws IllegalStateException, BufferUnderflowException
BytesStore
move
in interface BytesStore<Bytes<U>,U>
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 movednet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe way.BufferUnderflowException
- If there's not enough data to be movedIllegalStateException
@NotNull public @NotNull Bytes<U> compact() throws net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
Bytes
This operation is useful to free up space for writing by discarding bytes that have already been read.
NOTE: If the space freed in longs is less than 1/4 the readRemaining, this method does nothing to reduce movement overhead
compact
in interface Bytes<U>
net.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe way@NotNull public @NotNull Bytes<U> readPosition(long position)
StreamingDataInput
readPosition
in interface StreamingDataInput<Bytes<U>>
position
- the new read position, must be non-negative@NotNull public @NotNull Bytes<U> readLimit(long limit)
StreamingDataInput
readLimit
in interface StreamingDataInput<Bytes<U>>
limit
- the new read limit, must be non-negative@NotNull public @NotNull Bytes<U> writePosition(long position)
StreamingDataOutput
writePosition
in interface StreamingDataOutput<Bytes<U>>
position
- The new write position. It must be a non-negative number.@NotNull public @NotNull Bytes<U> readSkip(long bytesToSkip)
StreamingDataInput
readSkip
in interface StreamingDataInput<Bytes<U>>
bytesToSkip
- the number of bytes to skippublic 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 void uncheckedReadSkipOne()
StreamingDataInput
uncheckedReadSkipOne
in interface StreamingDataInput<Bytes<U>>
public void uncheckedReadSkipBackOne()
StreamingDataInput
uncheckedReadSkipBackOne
in interface StreamingDataInput<Bytes<U>>
@NotNull public @NotNull Bytes<U> writeSkip(long bytesToSkip)
StreamingDataOutput
writeSkip
in interface StreamingDataOutput<Bytes<U>>
bytesToSkip
- The number of bytes to skip. This can be a negative number to move the
position backward.@NotNull public @NotNull Bytes<U> writeLimit(long limit)
StreamingDataOutput
writeLimit
in interface StreamingDataOutput<Bytes<U>>
limit
- The new write limit. It must be a non-negative number.@NotNull public @NotNull BytesStore<Bytes<U>,U> copy()
Bytes
RandomCommon.readPosition()
and RandomCommon.readLimit()
.
The copy will have its own separate storage and state, and modifications to the copy will not affect the original Bytes object, and vice versa.
public boolean isElastic()
Bytes
Bytes.realCapacity()
.
Elastic Bytes objects can automatically grow to accommodate additional data, whereas non-elastic ones have a fixed capacity.
protected long readOffsetPositionMoved(long adding)
protected long writeOffsetPositionMoved(long adding)
protected long writeOffsetPositionMoved(long adding, long advance)
protected long prewriteOffsetPositionMoved(long substracting)
@NotNull public @NotNull Bytes<U> write(@NotNull @NotNull RandomDataInput bytes, long offset, long length) throws BufferUnderflowException, BufferOverflowException, IllegalStateException
StreamingDataOutput
RandomDataInput
object into the output stream,
starting from the given read offset.
The position of this output stream is updated accordingly, but the read position of the input data is not changed.write
in interface StreamingDataOutput<Bytes<U>>
bytes
- the RandomDataInput
from which data is read.offset
- the offset at which reading from the RandomDataInput
starts.length
- the number of bytes to write.BufferUnderflowException
- If there is not enough data available in the input.BufferOverflowException
- If there is not enough space left in the output stream.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 wayIllegalStateException
@NotNull public @NotNull Bytes<U> clear()
Bytes
@NotNull public @NotNull Bytes<U> clearAndPad(long length) throws BufferOverflowException
BytesPrepender
clearAndPad
in interface BytesPrepender<Bytes<U>>
length
- the padding lengthBufferOverflowException
- If the length is greater than the difference of capacity() and start()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 realCapacity()
Bytes
Bytes.isElastic()
the Bytes.realCapacity()
can be
lower than the virtual BytesStore.capacity()
.realCapacity
in interface Bytes<U>
realCapacity
in interface BytesStore<Bytes<U>,U>
realCapacity
in interface RandomDataInput
realCapacity
in interface StreamingDataOutput<Bytes<U>>
public long realWriteRemaining()
If the resource is closed, the returned value is unspecified.
public long capacity()
BytesStore
capacity
in interface BytesStore<Bytes<U>,U>
@Nullable public U underlyingObject()
underlyingObject
in interface BytesStore<Bytes<U>,U>
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 boolean compareAndSwapInt(long offset, int expected, int value) throws BufferOverflowException, IllegalStateException
RandomDataOutput
compareAndSwapInt
in interface RandomDataOutput<Bytes<U>>
offset
- the offset at which to perform the CAS operation.expected
- the expected current value.value
- the new value to set if the current value matches the expected value.BufferOverflowException
- If the capacity of this RandomDataOutput was exceeded.net.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe wayIllegalStateException
public void testAndSetInt(long offset, int expected, int value) throws BufferOverflowException, IllegalStateException
RandomDataOutput
testAndSetInt
in interface RandomDataOutput<Bytes<U>>
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.BufferOverflowException
- If the capacity of this RandomDataOutput was exceeded.net.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe wayIllegalStateException
public boolean compareAndSwapLong(long offset, long expected, long value) throws BufferOverflowException, IllegalStateException
RandomDataOutput
compareAndSwapLong
in interface RandomDataOutput<Bytes<U>>
offset
- the offset at which to perform the CAS operation.expected
- the expected current value.value
- the new value to set if the current value matches the expected value.BufferOverflowException
- If the capacity of this RandomDataOutput was exceeded.net.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe wayIllegalStateException
protected void performRelease() throws IllegalStateException
performRelease
in class net.openhft.chronicle.core.io.AbstractReferenceCounted
IllegalStateException
public int readUnsignedByte()
StreamingDataInput
readUnsignedByte
in interface StreamingDataInput<Bytes<U>>
public int uncheckedReadUnsignedByte()
StreamingDataInput
uncheckedReadUnsignedByte
in interface StreamingDataInput<Bytes<U>>
public byte readByte()
StreamingDataInput
readByte
in interface StreamingDataInput<Bytes<U>>
public int peekUnsignedByte()
StreamingDataInput
peekUnsignedByte
in interface StreamingDataInput<Bytes<U>>
public short readShort()
StreamingDataInput
readShort
in interface StreamingDataInput<Bytes<U>>
public int readInt()
StreamingDataInput
readInt
in interface StreamingDataInput<Bytes<U>>
public long readLong()
StreamingDataInput
readLong
in interface StreamingDataInput<Bytes<U>>
public float readFloat()
StreamingDataInput
readFloat
in interface StreamingDataInput<Bytes<U>>
public double readDouble()
StreamingDataInput
readDouble
in interface StreamingDataInput<Bytes<U>>
public int readVolatileInt()
StreamingDataInput
readVolatileInt
in interface StreamingDataInput<Bytes<U>>
public long readVolatileLong()
StreamingDataInput
readVolatileLong
in interface StreamingDataInput<Bytes<U>>
@NotNull public @NotNull Bytes<U> writeByte(long offset, byte i) throws BufferOverflowException, IllegalStateException
RandomDataOutput
writeByte
in interface RandomDataOutput<Bytes<U>>
offset
- The non-negative position within the data stream to write the byte to.i
- The byte value to write.BufferOverflowException
- If the specified offset exceeds the available 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 wayIllegalStateException
public Bytes<U> rawWriteByte(byte i8) throws BufferOverflowException, IllegalStateException
StreamingDataOutput
rawWriteByte
in interface StreamingDataOutput<Bytes<U>>
i8
- The byte to be written.BufferOverflowException
- If there is insufficient space in the buffer.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 wayIllegalStateException
@NotNull public @NotNull Bytes<U> writeShort(long offset, short i) throws BufferOverflowException, IllegalStateException
RandomDataOutput
writeShort
in interface RandomDataOutput<Bytes<U>>
offset
- The non-negative position within the data stream to write the short integer to.i
- The short integer value to write.BufferOverflowException
- If the specified offset exceeds the available 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 wayIllegalStateException
@NotNull public @NotNull Bytes<U> writeInt(long offset, int i) throws BufferOverflowException, IllegalStateException
RandomDataOutput
writeInt
in interface RandomDataOutput<Bytes<U>>
offset
- The non-negative position within the data stream to write the integer to.i
- The integer value to write.BufferOverflowException
- If the specified offset exceeds the available 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 wayIllegalStateException
@NotNull public @NotNull Bytes<U> writeOrderedInt(long offset, int i) throws BufferOverflowException, IllegalStateException
RandomDataOutput
writeOrderedInt
in interface RandomDataOutput<Bytes<U>>
offset
- The non-negative position within the data stream to write the integer to.i
- The integer value to write.BufferOverflowException
- If the specified offset exceeds the available 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 wayIllegalStateException
@NotNull public @NotNull Bytes<U> writeLong(long offset, long i) throws BufferOverflowException, IllegalStateException
RandomDataOutput
writeLong
in interface RandomDataOutput<Bytes<U>>
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.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 wayIllegalStateException
@NotNull public @NotNull Bytes<U> writeOrderedLong(long offset, long i) throws BufferOverflowException, IllegalStateException
RandomDataOutput
writeOrderedLong
in interface RandomDataOutput<Bytes<U>>
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.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 wayIllegalStateException
@NotNull public @NotNull Bytes<U> writeFloat(long offset, float d) throws BufferOverflowException, IllegalStateException
RandomDataOutput
writeFloat
in interface RandomDataOutput<Bytes<U>>
offset
- The non-negative position within the data stream to write the float to.d
- The float value to write.BufferOverflowException
- If the specified offset exceeds the available 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 wayIllegalStateException
@NotNull public @NotNull Bytes<U> writeDouble(long offset, double d) throws BufferOverflowException, IllegalStateException
RandomDataOutput
writeDouble
in interface RandomDataOutput<Bytes<U>>
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.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 wayIllegalStateException
@NotNull public @NotNull Bytes<U> writeVolatileByte(long offset, byte i8) throws BufferOverflowException, IllegalStateException
RandomDataOutput
writeVolatileByte
in interface RandomDataOutput<Bytes<U>>
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.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 wayIllegalStateException
@NotNull public @NotNull Bytes<U> writeVolatileShort(long offset, short i16) throws BufferOverflowException, IllegalStateException
RandomDataOutput
writeVolatileShort
in interface RandomDataOutput<Bytes<U>>
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.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 wayIllegalStateException
@NotNull public @NotNull Bytes<U> writeVolatileInt(long offset, int i32) throws BufferOverflowException, IllegalStateException
RandomDataOutput
writeVolatileInt
in interface RandomDataOutput<Bytes<U>>
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.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 wayIllegalStateException
@NotNull public @NotNull Bytes<U> writeVolatileLong(long offset, long i64) throws BufferOverflowException, IllegalStateException
RandomDataOutput
writeVolatileLong
in interface RandomDataOutput<Bytes<U>>
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.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 wayIllegalStateException
@NotNull public @NotNull Bytes<U> write(long offsetInRDO, byte[] byteArray, int offset, int length) throws BufferOverflowException, IllegalStateException
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<Bytes<U>>
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.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 wayIllegalStateException
public void write(long offsetInRDO, @NotNull @NotNull ByteBuffer bytes, int offset, int length) throws BufferOverflowException, IllegalStateException
RandomDataOutput
Does not update cursors e.g. writePosition()
write
in interface RandomDataOutput<Bytes<U>>
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.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 wayIllegalStateException
@NotNull public @NotNull Bytes<U> write(long writeOffset, @NotNull @NotNull RandomDataInput bytes, long readOffset, long length) throws BufferUnderflowException, BufferOverflowException, IllegalStateException
RandomDataOutput
writePosition()
of this output nor the RandomCommon.readPosition()
of the input.write
in interface RandomDataOutput<Bytes<U>>
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.BufferUnderflowException
- If the source does not have enough data to fill the length.BufferOverflowException
- If the capacity of this data output was exceeded.net.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe wayIllegalStateException
public byte readByte(long offset)
RandomDataInput
readByte
in interface RandomDataInput
offset
- the location from where the byte value is read.public int readUnsignedByte(long offset)
RandomDataInput
readUnsignedByte
in interface RandomDataInput
offset
- the location from where the unsigned 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.@NotNull public @NotNull Bytes<U> writeByte(byte i8)
StreamingDataOutput
writeByte
in interface StreamingDataOutput<Bytes<U>>
i8
- The byte to be written.@NotNull public @NotNull Bytes<U> prewriteByte(byte i8)
BytesPrepender
prewriteByte
in interface BytesPrepender<Bytes<U>>
i8
- the byte to prepend@NotNull public @NotNull Bytes<U> writeShort(short i16) throws IllegalStateException
StreamingDataOutput
writeShort
in interface StreamingDataOutput<Bytes<U>>
i16
- The short integer to be written.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 wayIllegalStateException
@NotNull public @NotNull Bytes<U> prewriteShort(short i16) throws IllegalStateException
BytesPrepender
prewriteShort
in interface BytesPrepender<Bytes<U>>
i16
- the short to prependnet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe way.IllegalStateException
@NotNull public @NotNull Bytes<U> writeInt(int i) throws IllegalStateException
StreamingDataOutput
writeInt
in interface StreamingDataOutput<Bytes<U>>
i
- The integer to be written.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 wayIllegalStateException
@NotNull public @NotNull Bytes<U> writeIntAdv(int i, int advance) throws IllegalStateException
StreamingDataOutput
writeIntAdv
in interface StreamingDataOutput<Bytes<U>>
i
- The integer to be written.advance
- The number of bytes to advance the write position after the integer has been written.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 wayIllegalStateException
@NotNull public @NotNull Bytes<U> prewriteInt(int i) throws IllegalStateException
BytesPrepender
prewriteInt
in interface BytesPrepender<Bytes<U>>
i
- the int to prependnet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe way.IllegalStateException
@NotNull public @NotNull Bytes<U> writeLong(long i64) throws IllegalStateException
StreamingDataOutput
writeLong
in interface StreamingDataOutput<Bytes<U>>
i64
- The long integer to be written.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 wayIllegalStateException
@NotNull public @NotNull Bytes<U> writeLongAdv(long i64, int advance) throws IllegalStateException
StreamingDataOutput
writeLongAdv
in interface StreamingDataOutput<Bytes<U>>
i64
- The long integer to be written.advance
- The number of bytes to advance the write position after the long integer has been written.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 wayIllegalStateException
@NotNull public @NotNull Bytes<U> prewriteLong(long i64) throws IllegalStateException
BytesPrepender
prewriteLong
in interface BytesPrepender<Bytes<U>>
i64
- the long to prependnet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe way.IllegalStateException
@NotNull public @NotNull Bytes<U> writeFloat(float f) throws IllegalStateException
StreamingDataOutput
writeFloat
in interface StreamingDataOutput<Bytes<U>>
f
- The floating-point number to be written.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 wayIllegalStateException
@NotNull public @NotNull Bytes<U> writeDouble(double d) throws IllegalStateException
StreamingDataOutput
writeDouble
in interface StreamingDataOutput<Bytes<U>>
d
- The double-precision floating-point number to be written.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 wayIllegalStateException
@NotNull public @NotNull Bytes<U> writeDoubleAndInt(double d, int i) throws IllegalStateException
StreamingDataOutput
writeDoubleAndInt
in interface StreamingDataOutput<Bytes<U>>
d
- The double-precision floating-point number to be written.i
- The integer to be written.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 wayIllegalStateException
@NotNull public @NotNull Bytes<U> write(byte[] byteArray, int offset, int length) throws BufferOverflowException, IllegalStateException, ArrayIndexOutOfBoundsException
StreamingDataOutput
byteArray
into the output stream, starting from the
given offset. The position of the output stream is updated according to the number of bytes written.write
in interface StreamingDataOutput<Bytes<U>>
byteArray
- the array of bytes to be written.offset
- the start index in the array from where to start writing bytes.length
- the number of bytes to write.BufferOverflowException
- If there is not enough space left in the output stream.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 wayArrayIndexOutOfBoundsException
- If the provided offset
and length
combination is invalid.IllegalStateException
@NotNull public @NotNull Bytes<U> prewrite(@NotNull @NotNull byte[] bytes) throws IllegalStateException, BufferOverflowException
BytesPrepender
prewrite
in interface BytesPrepender<Bytes<U>>
bytes
- the byte array to prependnet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe way.BufferOverflowException
- If the capacity of the underlying buffer was exceededIllegalStateException
@NotNull public @NotNull Bytes<U> prewrite(@NotNull @NotNull BytesStore<?,?> bytes) throws IllegalStateException, BufferOverflowException
BytesPrepender
prewrite
in interface BytesPrepender<Bytes<U>>
bytes
- the BytesStore to prependnet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe way.BufferOverflowException
- If the capacity of the underlying buffer was exceededIllegalStateException
@NotNull public @NotNull Bytes<U> writeSome(@NotNull @NotNull ByteBuffer buffer) throws IllegalStateException
StreamingDataOutput
ByteBuffer
into this Bytes object.
The number of bytes written is constrained by the space available in this Bytes object.
The position of this Bytes object is updated according to the number of bytes written.writeSome
in interface StreamingDataOutput<Bytes<U>>
buffer
- the ByteBuffer from which data is read.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 wayIllegalStateException
@NotNull public @NotNull Bytes<U> writeOrderedInt(int i) throws IllegalStateException
StreamingDataOutput
writeOrderedInt
in interface StreamingDataOutput<Bytes<U>>
i
- The integer value to be written.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 wayIllegalStateException
@NotNull public @NotNull Bytes<U> writeOrderedLong(long i) throws IllegalStateException
StreamingDataOutput
writeOrderedLong
in interface StreamingDataOutput<Bytes<U>>
i
- The long value to be written.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 wayIllegalStateException
public long addressForRead(long offset) throws BufferUnderflowException
offset
- within this buffer. addressForRead(start()) is the actual addressForRead of the first byte.BufferUnderflowException
- If the offset is before the start() or the after the capacity()public long addressForWrite(long offset) throws BufferOverflowException
offset
- within this buffer. addressForRead(start()) is the actual addressForRead of the first byte.BufferOverflowException
- If the offset is before the start() or the after the capacity()public long addressForWritePosition() throws UnsupportedOperationException, BufferOverflowException
UnsupportedOperationException
- If the underlying buffer is on the heap.BufferOverflowException
- If the current write position is before the start or after the capacity.@NotNull public @NotNull String toString()
toString
in interface CharSequence
toString
in class net.openhft.chronicle.core.io.AbstractReferenceCounted
public void lenient(boolean lenient)
StreamingDataInput
false
and empty string.lenient
in interface StreamingDataInput<Bytes<U>>
lenient
- if true, return nothing rather than error.public boolean lenient()
lenient
in interface StreamingDataInput<Bytes<U>>
public void nativeRead(long position, long address, long size) throws IllegalStateException, BufferUnderflowException
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.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 wayBufferUnderflowException
- If the specified position or size exceeds the byte source limits.IllegalStateException
public void nativeWrite(long address, long position, long size) throws IllegalStateException, BufferOverflowException
RandomDataOutput
nativeWrite
in interface RandomDataOutput<Bytes<U>>
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.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 wayBufferOverflowException
- If the capacity of this BytesStore was exceeded.IllegalStateException
@Nullable public @Nullable BytesStore<?,U> bytesStore()
Bytes
The BytesStore represents the underlying storage of bytes that the Bytes object is manipulating.
bytesStore
in interface Bytes<U>
bytesStore
in interface BytesStore<Bytes<U>,U>
public int byteCheckSum() throws net.openhft.chronicle.core.io.IORuntimeException
BytesStore
byteCheckSum
in interface BytesStore<Bytes<U>,U>
net.openhft.chronicle.core.io.IORuntimeException
@NotNull public @NotNull Bytes<U> append8bit(@NotNull @NotNull CharSequence cs) throws BufferOverflowException, BufferUnderflowException, IllegalStateException
ByteStringAppender
append8bit
in interface ByteStringAppender<Bytes<U>>
cs
- the CharSequence to appendBufferOverflowException
- If the string is too large to write in the capacity availableBufferUnderflowException
- If the capacity of the underlying buffer was exceedednet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe way.IllegalStateException
@NotNull public @NotNull Bytes<U> appendUtf8(char[] chars, int offset, int length) throws BufferOverflowException, IllegalArgumentException, IllegalStateException
StreamingDataOutput
appendUtf8
in interface StreamingDataOutput<Bytes<U>>
chars
- The CharSequence to be appended.offset
- The offset from which to start writing the CharSequence.length
- The number of characters from the CharSequence to write.BufferOverflowException
- If there is not enough space left in the output stream.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 wayIllegalArgumentException
IllegalStateException
@NotNull public @NotNull UncheckedNativeBytes<U> append(double d) throws BufferOverflowException, IllegalStateException
ByteStringAppender
append
in interface ByteStringAppender<Bytes<U>>
d
- to appendBufferOverflowException
- If the capacity of the underlying buffer was exceedednet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe way.IllegalStateException
@NotNull public @NotNull UncheckedNativeBytes<U> append(float f) throws BufferOverflowException, IllegalStateException
ByteStringAppender
append
in interface ByteStringAppender<Bytes<U>>
f
- the float number to appendBufferOverflowException
- If the relative append operation exceeds the underlying buffer's capacitynet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe way.IllegalStateException
@NotNull public @NotNull Bytes<U> append(int value) throws BufferOverflowException, IllegalArgumentException, IllegalStateException
ByteStringAppender
append
in interface ByteStringAppender<Bytes<U>>
value
- the integer value to appendBufferOverflowException
- If the relative append operation exceeds the underlying buffer's capacitynet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe way.IllegalArgumentException
IllegalStateException
@NotNull public @NotNull Bytes<U> append(long value) throws BufferOverflowException, IllegalStateException
ByteStringAppender
append
in interface ByteStringAppender<Bytes<U>>
value
- the long number to appendBufferOverflowException
- If the relative append operation exceeds the underlying buffer's capacitynet.openhft.chronicle.core.io.ClosedIllegalStateException
- If the resource has been released or closed.net.openhft.chronicle.core.io.ThreadingIllegalStateException
- If this resource was accessed by multiple threads in an unsafe way.IllegalStateException
public Decimaliser decimaliser()
ByteStringAppender
decimaliser
in interface ByteStringAppender<Bytes<U>>
public Bytes<U> decimaliser(Decimaliser decimaliser)
ByteStringAppender
The Decimaliser is an interface which can be implemented to provide custom logic for rendering decimal numbers in this ByteStringAppender.
decimaliser
in interface ByteStringAppender<Bytes<U>>
decimaliser
- The Decimaliser to be associated with this ByteStringAppender.public boolean fpAppend0()
fpAppend0
in interface ByteStringAppender<Bytes<U>>
public Bytes<U> fpAppend0(boolean append0)
fpAppend0
in interface ByteStringAppender<Bytes<U>>
append0
- Does floating point add .0 to indicate it is a floating point even if redundant.public void append(boolean negative, long mantissa, int exponent)
DecimalAppender
append
in interface DecimalAppender
negative
- Whether the number is negative. true
indicates a negative number,
false
indicates a positive number.mantissa
- The significant digits of the decimal number, represented as a long integer.exponent
- The power of 10 by which the mantissa is scaled to obtain the actual decimal number.public long appendAndReturnLength(long writePosition, boolean negative, long mantissa, int exponent, boolean append0)
appendAndReturnLength
in interface RandomDataOutput<Bytes<U>>
public int lastDecimalPlaces()
ByteStringParser
ByteStringParser.parseDouble()
or ByteStringParser.parseLongDecimal()
methods).lastDecimalPlaces
in interface ByteStringParser<Bytes<U>>
public void lastDecimalPlaces(int lastDecimalPlaces)
ByteStringParser
lastDecimalPlaces
in interface ByteStringParser<Bytes<U>>
lastDecimalPlaces
- the number of decimal places to set, if positive; otherwise 0.public boolean lastNumberHadDigits()
ByteStringParser
lastNumberHadDigits
in interface ByteStringParser<Bytes<U>>
public void lastNumberHadDigits(boolean lastNumberHadDigits)
ByteStringParser
lastNumberHadDigits
in interface ByteStringParser<Bytes<U>>
lastNumberHadDigits
- the new value to set, true if the last parsed number had digits, false otherwise.@NotNull public @NotNull Bytes<U> write(@NotNull @NotNull RandomDataInput bytes) throws IllegalStateException
StreamingDataOutput
RandomDataInput
into the output stream.
The position of this output stream is updated accordingly, but the read position of the input data is not changed.
The operation will fail if there is not enough space left in the output stream.write
in interface StreamingDataOutput<Bytes<U>>
bytes
- the RandomDataInput
from which data is read.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 wayIllegalStateException
public long write8bit(long position, @NotNull @NotNull BytesStore<?,?> bs)
RandomDataOutput
write8bit
in interface RandomDataOutput<Bytes<U>>
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<Bytes<U>>
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 Bytes<U> write8bit(@Nullable @Nullable BytesStore<?,?> bs) throws BufferOverflowException, IllegalStateException, BufferUnderflowException
@NotNull public @NotNull Bytes<U> write8bit(@NotNull @NotNull String text, int start, int length)
StreamingDataOutput
write8bit
in interface StreamingDataOutput<Bytes<U>>
text
- The String to be written.start
- The index of the first char in the String to write.length
- The number of chars from the String to write.@NotNull public @NotNull net.openhft.chronicle.bytes.internal.UncheckedRandomDataInput acquireUncheckedInput()
net.openhft.chronicle.bytes.internal.HasUncheckedRandomDataInput
acquireUncheckedInput
in interface net.openhft.chronicle.bytes.internal.HasUncheckedRandomDataInput
public void unmonitor()
unmonitor
in interface net.openhft.chronicle.core.io.Monitorable
unmonitor
in class net.openhft.chronicle.core.io.AbstractReferenceCounted
Copyright © 2024. All rights reserved.