U - This represents the underlying type that the byte buffers are intended to represent.public class NativeBytes<U> extends VanillaBytes<U>
The class can be parameterized with a type which represents the underlying type that the byte buffers are intended to represent. This provides a way to use NativeBytes for any type that can be represented as bytes.
| Modifier and Type | Field and Description |
|---|---|
protected long |
capacity |
bytesStore, DISABLE_THREAD_SAFETY, isPresent, readPosition, writeLimitreferenceCounted, WARN_COUNT, WARN_NSDEFAULT_BYTE_BUFFER_CAPACITY, MAX_CAPACITY, MAX_HEAP_CAPACITYcharToStringJAVA9_STRING_CODER_LATIN, JAVA9_STRING_CODER_UTF16| Constructor and Description |
|---|
NativeBytes(@NotNull BytesStore store)
Constructs a new instance of NativeBytes with the specified BytesStore and the store's capacity.
|
NativeBytes(@NotNull BytesStore store,
long capacity)
Constructs a new instance of NativeBytes with the specified BytesStore and capacity.
|
| Modifier and Type | Method and Description |
|---|---|
static boolean |
areNewGuarded()
Checks if new NativeBytes instances will be guarded or not.
|
protected void |
bytesStore(@NotNull BytesStore<Bytes<U>,U> bytesStore) |
void |
bytesStore(@NotNull BytesStore<Bytes<U>,U> byteStore,
long offset,
long length)
Sets the reference to a data type that points to the underlying ByteStore.
|
long |
capacity()
Provides the maximum limit that can be set for the ByteStore.
|
static BytesStore<Bytes<Void>,Void> |
copyOf(@NotNull Bytes<?> bytes)
Deprecated.
This method is to be removed in version x.26.
|
void |
ensureCapacity(long desiredCapacity)
Ensures that this Bytes object has the capacity to accommodate the specified amount of data.
|
boolean |
isElastic()
Checks if this Bytes object is elastic, meaning it can dynamically resize when more data is written
than its current
Bytes.realCapacity(). |
boolean |
isEqual(long start,
long length,
String s)
Returns if a specified portion of this BytesStore is equal to a specified String.
|
protected static <T> long |
maxCapacityFor(@NotNull BytesStore<?,T> bs) |
static @NotNull NativeBytes<Void> |
nativeBytes()
Creates a new instance of NativeBytes with an empty BytesStore and maximum capacity.
|
static @NotNull NativeBytes<Void> |
nativeBytes(long initialCapacity)
Creates a new instance of NativeBytes with a specific initial capacity.
|
long |
readRemaining()
Calculates the number of bytes remaining that can be read from the current read position.
|
static void |
resetNewGuarded()
Resets the guarded state for new NativeBytes instances to its default value.
|
static boolean |
setNewGuarded(boolean guarded)
Sets the guarded state for new NativeBytes instances.
|
static <T> @NotNull NativeBytes<T> |
wrapWithNativeBytes(@NotNull BytesStore<?,T> bs,
long capacity)
Wraps the provided BytesStore with a new instance of NativeBytes with the specified capacity.
|
@NotNull Bytes<U> |
writeByte(byte i8)
Writes a byte to the data stream.
|
protected void |
writeCheckOffset(long offset,
long adding) |
@NotNull Bytes<U> |
writeLong(long i64)
Writes a long integer to the data stream.
|
protected long |
writeOffsetPositionMoved(long adding,
long advance) |
@NotNull NativeBytes |
writeSome(@NotNull Bytes<?> bytes)
Writes data from the specified
Bytes object into the output stream. |
append, append8bit, append8bit, append8bit, append8bit0, appendUtf8, appendUtf8, byteCheckSum, bytesForRead, compareTo, copy, equalBytes, findByte, isEqual, maxSize, offset, optimisedWrite, parseLong, read, read8Bit, readVolatileLong, realCapacity, toString, toString0, toTemporaryDirectByteBuffer, vanillaBytes, wrap, write, write, writeacquireUncheckedInput, addressForRead, addressForWrite, addressForWritePosition, append, append, append, append, append, append, appendAndReturnLength, byteCheckSum, byteCheckSum, bytesStore, canReadDirect, canWriteDirect, clear, clearAndPad, compact, compareAndSwapInt, compareAndSwapLong, copyTo, decimaliser, decimaliser, equals, fpAppend0, fpAppend0, hashCode, internalNumberBuffer, isDirectMemory, isImmutableEmptyByteStore, lastDecimalPlaces, lastDecimalPlaces, lastNumberHadDigits, lastNumberHadDigits, length, lenient, lenient, move, nativeRead, nativeWrite, peekUnsignedByte, peekUnsignedByte, performRelease, prewrite, prewrite, prewriteByte, prewriteInt, prewriteLong, prewriteOffsetPositionMoved, prewriteShort, read, read, readByte, readByte, readCheckOffset, readDouble, readDouble, readFloat, readFloat, readInt, readInt, readLimit, readLimit, readLong, readLong, readOffsetPositionMoved, readPosition, readPosition, readPositionForHeader, readShort, readShort, readSkip, readUnsignedByte, readUnsignedByte, readVolatileByte, readVolatileInt, readVolatileInt, readVolatileLong, readVolatileShort, safeCopySize, start, startsWith, testAndSetInt, uncheckedReadSkipBackOne, uncheckedReadSkipOne, uncheckedReadUnsignedByte, uncheckedWritePosition, underlyingObject, write, write, write, write, write, write, write8bit, write8bit, write8bit, write8bit, writeBoolean, writeByte, writeDouble, writeDouble, writeDoubleAndInt, writeFloat, writeFloat, writeInt, writeInt, writeIntAdv, writeLimit, writeLimit, writeLong, writeLongAdv, writeOffsetPositionMoved, writeOrderedInt, writeOrderedInt, writeOrderedLong, writeOrderedLong, writePosition, writePosition, writeShort, writeShort, writeSkip, writeSome, writeVolatileByte, writeVolatileInt, writeVolatileLong, writeVolatileShortaddReferenceChangeListener, assertReferencesReleased, backgroundPerformRelease, canReleaseInBackground, clearUsedByThread, createdHere, disableReferenceTracing, enableReferenceTracing, refCount, referenceCountedUnmonitored, referenceId, release, releaseLast, removeReferenceChangeListener, reserve, reservedBy, reserveTransfer, singleThreadedCheckDisabled, singleThreadedCheckReset, threadSafetyCheck, throwExceptionIfNotReleased, throwExceptionIfReleased, tryReserve, unmonitor, warnAndReleaseIfNotReleasedclone, finalize, getClass, notify, notifyAll, wait, wait, waitaddress, bytesStore, lock, tryLockallocateDirect, allocateDirect, allocateElasticDirect, allocateElasticDirect, allocateElasticOnHeap, allocateElasticOnHeap, bytesForWrite, copyTo, copyTo, directFrom, elasticByteBuffer, elasticByteBuffer, elasticByteBuffer, elasticHeapByteBuffer, elasticHeapByteBuffer, empty, forFieldGroup, from, from, fromDirect, fromHexString, indexOf, indexOf, isClear, readMarshallableLength16, readWithLength, readWrite, safeLimit, sharedMemory, toHexString, toHexString, toHexString, toString, toString, toString, unchecked, unchecked, unwrite, valueOf, wrapForRead, wrapForRead, wrapForWrite, wrapForWrite, write, writeMarshallableLength16addAndGetDouble, addAndGetDoubleNotAtomic, addAndGetFloat, addAndGetFloatNotAtomic, addAndGetInt, addAndGetIntNotAtomic, addAndGetLong, addAndGetShortNotAtomic, addAndGetUnsignedByteNotAtomic, charAt, cipher, cipher, compareAndSwapDouble, compareAndSwapFloat, contentEquals, elasticByteBuffer, endsWith, follow, forFields, from, hash, inside, inside, isEmpty, lazyNativeBytesStoreWithFixedCapacity, nativePointer, nativeStore, nativeStoreFrom, nativeStoreWithFixedCapacity, startsWith, subSequence, to8bitString, toDebugString, toDebugString, wrap, wrap, wrap, writeMaxInt, writeMaxLong, zeroOutappend, append, write, write, writeBoolean, writeByte, writeInt24, writeOrderedDouble, writeOrderedFloat, writeUnsignedByte, writeUnsignedInt, writeUnsignedShort, writeUtf8, writeUtf8Limited, writeVolatileDouble, writeVolatileFloatchars, codePointsbytesMethodReader, bytesMethodReaderBuilder, readObjectcanReadDirect, compareUtf8, copyTo, createCharToString, fastHash, parseLong, peekVolatileInt, printable, readBoolean, readIncompleteLong, readUnsignedInt, readUnsignedInt24, readUnsignedShort, readUtf8, readUtf8Limited, readUtf8Limited, readVolatileDouble, readVolatileFloat, subBytes, toByteArrayparse8bit, parse8bit, parse8bit, parse8bit, parse8bit, parseBigDecimal, parseBoolean, parseBoolean, parseDouble, parseFlexibleLong, parseFloat, parseInt, parseLongDecimal, parseUtf8, parseUtf8, parseUtf8, reader, skipToinputStream, parseHexLong, parseUtf8, parseUtf8, rawReadByte, rawReadInt, rawReadLong, read, read, read, read, read8bit, read8bit, read8bit, readBigDecimal, readBigInteger, readBoolean, readChar, readEnum, readHistogram, readIncompleteLong, readInt24, readLimitToCapacity, readPositionRemaining, readPositionUnlimited, readStopBit, readStopBitChar, readStopBitDecimal, readStopBitDouble, readUnsignedInt, readUnsignedInt24, readUnsignedShort, readUtf8, readUtf8, readUtf8, readUtf8, readWithLength, readWithLength, readWithLength0, unsafeRead, unsafeReadObject, unsafeReadObjectbytesMethodWriter, writeObjectappend, append, append, append, append8bit, append8bit, appendBase, appendBase16, appendBase16, appendDateMillis, appendDecimal, appendTimeMillis, writerappendUtf8, appendUtf8, appendUtf8, appendUtf8, copyFrom, outputStream, rawWriteByte, rawWriteInt, rawWriteLong, unsafeWrite, unsafeWriteObject, unsafeWriteObject, write, write, write, write8bit, write8bit, write8bit, writeBigDecimal, writeBigInteger, writeChar, writeEnum, writeHistogram, writeInt24, writePositionForHeader, writePositionRemaining, writeStopBit, writeStopBit, writeStopBit, writeStopBitDecimal, writeUnsignedByte, writeUnsignedInt, writeUnsignedInt24, writeUnsignedShort, writeUtf8, writeUtf8, writeWithLengthprependadjustHexDumpIndentation, retainedHexDumpDescription, writeHexDumpDescriptionpublic NativeBytes(@NotNull
@NotNull BytesStore store,
long capacity)
throws IllegalArgumentException,
net.openhft.chronicle.core.io.ClosedIllegalStateException
store - the BytesStore to be used for the newly constructed instancecapacity - the capacity to be used for the newly constructed instancenet.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 wayIllegalArgumentExceptionpublic NativeBytes(@NotNull
@NotNull BytesStore store)
throws IllegalArgumentException,
net.openhft.chronicle.core.io.ClosedIllegalStateException
store - the BytesStore to be used for the newly constructed instancenet.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 wayIllegalArgumentExceptionpublic static boolean areNewGuarded()
public static boolean setNewGuarded(boolean guarded)
guarded - true to turn on guarding for new NativeBytes instances, false to turn it offpublic static void resetNewGuarded()
@NotNull public static @NotNull NativeBytes<Void> nativeBytes()
AssertionError - If there's an error during the wrapping process.@NotNull public static @NotNull NativeBytes<Void> nativeBytes(long initialCapacity) throws IllegalArgumentException
initialCapacity - The initial capacity of the NativeBytes instance.IllegalArgumentException - If the initial capacity is not valid.AssertionError - If there's an error during the wrapping process.@Deprecated public static BytesStore<Bytes<Void>,Void> copyOf(@NotNull @NotNull Bytes<?> bytes) throws net.openhft.chronicle.core.io.ClosedIllegalStateException
bytes - The Bytes to copy.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 static <T> @NotNull NativeBytes<T> wrapWithNativeBytes(@NotNull @NotNull BytesStore<?,T> bs, long capacity) throws net.openhft.chronicle.core.io.ClosedIllegalStateException, IllegalArgumentException
bs - The BytesStore to wrap.capacity - The capacity of the new NativeBytes instance.IllegalArgumentException - If the provided capacity is not valid.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 wayprotected static <T> long maxCapacityFor(@NotNull
@NotNull BytesStore<?,T> bs)
public long capacity()
BytesStorecapacity in interface BytesStore<Bytes<U>,U>capacity in class AbstractBytes<U>protected void writeCheckOffset(long offset,
long adding)
throws BufferOverflowException,
net.openhft.chronicle.core.io.ClosedIllegalStateException,
net.openhft.chronicle.core.io.ThreadingIllegalStateException
writeCheckOffset in class AbstractBytes<U>BufferOverflowExceptionnet.openhft.chronicle.core.io.ClosedIllegalStateExceptionnet.openhft.chronicle.core.io.ThreadingIllegalStateExceptionpublic void ensureCapacity(long desiredCapacity)
throws IllegalArgumentException,
net.openhft.chronicle.core.io.ClosedIllegalStateException,
net.openhft.chronicle.core.io.ThreadingIllegalStateException
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.
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 wayIllegalArgumentExceptionpublic boolean isElastic()
BytesBytes.realCapacity().
Elastic Bytes objects can automatically grow to accommodate additional data, whereas non-elastic ones have a fixed capacity.
public boolean isEqual(long start,
long length,
String s)
BytesStorestart - 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 sprotected void bytesStore(@NotNull
@NotNull BytesStore<Bytes<U>,U> bytesStore)
bytesStore in class AbstractBytes<U>public void bytesStore(@NotNull
@NotNull BytesStore<Bytes<U>,U> byteStore,
long offset,
long length)
throws IllegalStateException,
IllegalArgumentException,
BufferUnderflowException,
net.openhft.chronicle.core.io.ClosedIllegalStateException
ByteablebytesStore in interface Byteable<Bytes<U>,U>bytesStore in class VanillaBytes<U>byteStore - the fixed-point ByteStoreoffset - the offset within the ByteStore, indicating the starting point of the memory sectionlength - the length of the memory section within the ByteStorenet.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 - If the provided arguments are invalidBufferUnderflowException - If the new memory section starts before the start of the ByteStoreIllegalStateException@NotNull public @NotNull NativeBytes writeSome(@NotNull @NotNull Bytes<?> bytes) throws net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
StreamingDataOutputBytes object into the output stream. The amount of data written is
the minimum of the remaining data in the Bytes object and the remaining space in the output stream.
The position of this output stream is updated accordingly, but the read position of the input data is not changed.bytes - the Bytes object 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 wayprotected long writeOffsetPositionMoved(long adding,
long advance)
throws BufferOverflowException,
net.openhft.chronicle.core.io.ClosedIllegalStateException,
net.openhft.chronicle.core.io.ThreadingIllegalStateException
writeOffsetPositionMoved in class AbstractBytes<U>BufferOverflowExceptionnet.openhft.chronicle.core.io.ClosedIllegalStateExceptionnet.openhft.chronicle.core.io.ThreadingIllegalStateException@NotNull public @NotNull Bytes<U> writeByte(byte i8) throws BufferOverflowException, IllegalStateException, net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
StreamingDataOutputwriteByte in interface StreamingDataOutput<Bytes<U>>writeByte in class AbstractBytes<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> writeLong(long i64) throws BufferOverflowException, IllegalStateException, net.openhft.chronicle.core.io.ClosedIllegalStateException, net.openhft.chronicle.core.io.ThreadingIllegalStateException
StreamingDataOutputwriteLong in interface StreamingDataOutput<Bytes<U>>writeLong in class AbstractBytes<U>i64 - The long integer 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 wayIllegalStateExceptionpublic long readRemaining()
If the resource is closed, the returned value is unspecified.
Copyright © 2023. All rights reserved.