public class PointerBytesStore extends NativeBytesStore<Void>
This class represents a view of Bytes over an arbitrary area of memory. It provides methods to set and interact with this area of memory.
WARNING: It is not recommended to use this in conjunction with ElasticBytes. ElasticBytes, by design, can change its underlying data structure's location, which might invalidate or corrupt the memory view held by this PointerBytesStore.
address, limit, maximumLimit, memory
referenceCounted, WARN_COUNT, WARN_NS
charToString
Constructor and Description |
---|
PointerBytesStore()
Default constructor that initializes a PointerBytesStore with no data.
|
Modifier and Type | Method and Description |
---|---|
default long |
addressForRead(long offset,
int buffer)
Retrieves the underlying memory address for reading.
|
default ByteOrder |
byteOrder()
Retrieves the byte order used by the buffer.
|
@NotNull VanillaBytes<Void> |
bytesForWrite()
Returns a new VanillaBytes for writing to this PointerBytesStore.
|
default long |
lengthWritten(long startPosition)
Calculates the length of data written from the given start position.
|
default long |
readLimit()
If the resource is closed, the returned value is unspecified.
|
default long |
realReadRemaining()
Calculates the number of bytes that can be safely read directly.
|
default long |
realWriteRemaining()
Calculates the number of bytes remaining that can be written from the current write position with resizing.
|
long |
safeLimit()
Returns the safe limit of the memory to which this PointerBytesStore can write or read.
|
void |
set(long address,
long capacity)
Sets the memory address and capacity of this PointerBytesStore.
|
long |
start()
Returns the starting address of the memory to which this PointerBytesStore points.
|
default long |
writeLimit()
Retrieves the maximum writable position within the buffer.
|
default long |
writePosition()
Returns the write position.
|
addAndGetInt, addAndGetLong, addressForRead, addressForWrite, addressForWritePosition, appendAndReturnLength, appendUtf8, backgroundPerformRelease, byteCheckSum, byteCheckSum, canReadDirect, capacity, compareAndSwapInt, compareAndSwapLong, copy, copyTo, copyToDirect, elasticByteBuffer, elasticByteBuffer, equals, fastHash, follow, from, from, hashCode, init, isDirectMemory, isEqual, lazyNativeBytesStoreWithFixedCapacity, move, nativeRead, nativeStore, nativeStoreWithFixedCapacity, nativeWrite, peekUnsignedByte, performRelease, read, read8bit, readByte, readDouble, readFloat, readIncompleteLong, readInt, readLong, readShort, readUnsignedByte, readVolatileByte, readVolatileInt, readVolatileLong, readVolatileShort, realCapacity, reverseBytesFrom, setAddress, sharedMemory, testAndSetInt, toString, toTemporaryDirectByteBuffer, translate, underlyingObject, uninit, uninitialized, wrap, write, write, write, write0, write8bit, write8bit, writeByte, writeDouble, writeFloat, writeInt, writeLong, writeOrderedInt, writeOrderedLong, writeShort, writeVolatileByte, writeVolatileInt, writeVolatileLong, writeVolatileShort, zeroOut
canReleaseInBackground, internalNumberBuffer, readPosition, readRemaining, writeRemaining
addReferenceChangeListener, assertReferencesReleased, clearUsedByThread, createdHere, disableReferenceTracing, enableReferenceTracing, refCount, referenceCountedUnmonitored, referenceId, release, releaseLast, removeReferenceChangeListener, reserve, reservedBy, reserveTransfer, singleThreadedCheckDisabled, singleThreadedCheckReset, threadSafetyCheck, throwExceptionIfNotReleased, throwExceptionIfReleased, tryReserve, unmonitor, warnAndReleaseIfNotReleased
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
addAndGetDouble, addAndGetDoubleNotAtomic, addAndGetFloat, addAndGetFloatNotAtomic, addAndGetIntNotAtomic, addAndGetShortNotAtomic, addAndGetUnsignedByteNotAtomic, bytesForRead, bytesStore, charAt, cipher, cipher, compareAndSwapDouble, compareAndSwapFloat, contentEquals, copyTo, empty, endsWith, equalBytes, forFields, from, from, hash, inside, inside, isClear, isEmpty, isImmutableEmptyByteStore, length, nativePointer, nativeStoreFrom, readWrite, startsWith, startsWith, subSequence, to8bitString, toDebugString, toDebugString, wrap, wrap, writeMaxInt, writeMaxLong
canReadDirect, compareUtf8, copyTo, copyTo, createCharToString, findByte, parseLong, peekVolatileInt, printable, readBoolean, readUnsignedInt, readUnsignedInt24, readUnsignedShort, readUtf8, readUtf8Limited, readUtf8Limited, readVolatileDouble, readVolatileFloat, subBytes, toByteArray
append, append, write, write, writeBoolean, writeByte, writeInt24, writeOrderedDouble, writeOrderedFloat, writeUnsignedByte, writeUnsignedInt, writeUnsignedShort, writeUtf8, writeUtf8Limited, writeVolatileDouble, writeVolatileFloat
addReferenceChangeListener, refCount, release, releaseLast, releaseLast, removeReferenceChangeListener, reserve, reservedBy, reserveTransfer, tryReserve
referenceId, referenceName, temporary
chars, codePoints
public PointerBytesStore()
public void set(long address, long capacity) throws IllegalArgumentException
address
- the memory addresscapacity
- the size of the memory to which this PointerBytesStore should pointIllegalArgumentException
- if the capacity is negative@NotNull public @NotNull VanillaBytes<Void> bytesForWrite() throws IllegalStateException
bytesForWrite
in interface BytesStore<NativeBytesStore<Void>,Void>
bytesForWrite
in class NativeBytesStore<Void>
IllegalStateException
- if unable to create VanillaBytes due to incorrect statepublic long safeLimit()
safeLimit
in interface BytesStore<NativeBytesStore<Void>,Void>
safeLimit
in class NativeBytesStore<Void>
public long start()
start
in class AbstractBytesStore<NativeBytesStore<Void>,Void>
public long writePosition()
The write position is readPosition() <= writePosition() && writePosition() <= writeLimit()
If the resource is closed, the returned value is unspecified.
public long lengthWritten(long startPosition)
Typically this calculates the difference however for HexDumpBytes it's not as simple.
If the resource is closed, the returned value is unspecified.
startPosition
- The position to calculate the length from.public long realReadRemaining()
If the resource is closed, the returned value is unspecified.
public long realWriteRemaining()
If the resource is closed, the returned value is unspecified.
public long readLimit()
If the resource is closed, the returned value is unspecified.
public long writeLimit()
If the resource is closed, the returned value is unspecified.
public long addressForRead(long offset, int buffer) throws UnsupportedOperationException, BufferUnderflowException, IllegalStateException
offset
- The offset within this buffer.buffer
- The buffer index.UnsupportedOperationException
- if the underlying buffer is on the heap.BufferUnderflowException
- if the offset is before the start or after the capacity.IllegalStateException
- if the buffer has been closed.public ByteOrder byteOrder()
Copyright © 2023. All rights reserved.