public class ChunkedMappedBytes extends CommonMappedBytes
NOTE These Bytes are single Threaded as are all Bytes.
lastActualSize, mappedFile
TRACE
bytesStore, isPresent, readPosition, writeLimit, writePosition
referenceCounted, WARN_COUNT, WARN_NS
DEFAULT_BYTE_BUFFER_CAPACITY, MAX_CAPACITY, MAX_HEAP_CAPACITY
charToString
JAVA9_STRING_CODER_LATIN, JAVA9_STRING_CODER_UTF16
Modifier | Constructor and Description |
---|---|
|
ChunkedMappedBytes(@NotNull MappedFile mappedFile) |
protected |
ChunkedMappedBytes(@NotNull MappedFile mappedFile,
String name) |
Modifier and Type | Method and Description |
---|---|
long |
addressForRead(long offset)
This single-argument version of the call returns an address which is guarateed safe for a contiguous
read up to the overlap size.
|
long |
addressForRead(long offset,
int buffer)
This two-argument version of the call returns an address which is guaranteed safe for a contiguous
read up to the requested buffer size.
|
long |
addressForWrite(long offset)
Obtain the underlying addressForRead.
|
@NotNull Bytes<Void> |
appendUtf8(char[] chars,
int offset,
int length) |
@NotNull Bytes<Void> |
clear()
Set the readPosition= writePosition = start, writeLimit = capacity
|
boolean |
compareAndSwapLong(long offset,
long expected,
long value)
Perform a 64-bit CAS at a given offset.
|
void |
ensureCapacity(long desiredCapacity)
Grows the buffer if the buffer is elastic, if the buffer is not elastic and there is not
enough capacity then this method will throw an
IllegalArgumentException |
boolean |
isElastic()
Returns if this Bytes object is elastic.
|
int |
peekUnsignedByte() |
int |
peekUnsignedByte(long offset)
Read an unsigned byte at an offset, or -1
|
int |
peekVolatileInt() |
protected void |
readCheckOffset(long offset,
long adding,
boolean given) |
@NotNull Bytes<Void> |
readPosition(long position) |
@NotNull Bytes<Void> |
readPositionRemaining(long position,
long remaining) |
@NotNull Bytes<Void> |
readSkip(long bytesToSkip)
Skip a number of bytes by moving the readPosition.
|
byte |
readVolatileByte(long offset)
Read a 8-bit byte from memory with a load barrier.
|
int |
readVolatileInt(long offset)
Read a 32-bit int from memory with a load barrier.
|
long |
readVolatileLong(long offset)
Read a 64-bit long from memory with a load barrier.
|
short |
readVolatileShort(long offset)
Read a 16-bit short from memory with a load barrier.
|
@NotNull Bytes<Void> |
write(@NotNull BytesStore bytes,
long offset,
long length)
Write all data or fail.
|
@NotNull ChunkedMappedBytes |
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. |
@NotNull ChunkedMappedBytes |
write(long writeOffset,
@NotNull RandomDataInput bytes,
long readOffset,
long length)
Copy from RandomDataInput into this.
|
@NotNull Bytes<Void> |
writeByte(byte i8) |
protected void |
writeCheckOffset(long offset,
long adding) |
@NotNull Bytes<Void> |
writeOrderedInt(long offset,
int i)
Perform a non stalling write with a store barrier.
|
@NotNull Bytes<Void> |
writeSkip(long bytesToSkip)
Skip a number of bytes by moving the writePosition.
|
append8bit, appendUtf8, capacity, chunkCount, clearUsedByThread, close, copy, disableThreadSafetyCheck, isBackingFileReadOnly, isClosed, isDirectMemory, mappedFile, performRelease, read8bit, readLimitToCapacity, readStopBit, readStopBitChar, realCapacity, realReadRemaining, release, releaseLast, start, throwExceptionIfClosed, toString, warnAndCloseIfNotClosed, write, write, write, write, write8bit, writePosition, writeStopBit, writeStopBit, writeUtf8, writeUtf8
mappedBytes, mappedBytes, mappedBytes, mappedBytes, mappedBytes, readOnly, sharedMemory, singleMappedBytes, singleMappedBytes, singleMappedBytes
acquireUncheckedInput, addressForWritePosition, append, byteCheckSum, byteCheckSum, byteCheckSum, bytesStore, bytesStore, canReadDirect, canWriteDirect, clearAndPad, compact, compareAndSwapInt, equals, hashCode, lastDecimalPlaces, lastDecimalPlaces, lastNumberHadDigits, lastNumberHadDigits, lenient, lenient, move, nativeRead, nativeWrite, prewrite, prewrite, prewriteByte, prewriteInt, prewriteLong, prewriteOffsetPositionMoved, prewriteShort, read, read, readByte, readByte, readDouble, readDouble, readFloat, readFloat, readInt, readInt, readLimit, readLimit, readLong, readLong, readOffsetPositionMoved, readPosition, readShort, readShort, readUnsignedByte, readUnsignedByte, readVolatileInt, readVolatileLong, safeCopySize, startsWith, testAndSetInt, uncheckedReadSkipBackOne, uncheckedReadSkipOne, uncheckedReadUnsignedByte, uncheckedWritePosition, underlyingObject, write, write8bit, write8bit, write8bit, write8bit, writeByte, writeDouble, writeDouble, writeDoubleAndInt, writeFloat, writeFloat, writeInt, writeInt, writeIntAdv, writeLimit, writeLimit, writeLong, writeLong, writeLongAdv, writeOffsetPositionMoved, writeOffsetPositionMoved, writeOrderedInt, writeOrderedLong, writeOrderedLong, writePosition, writeShort, writeShort, writeSome, writeVolatileByte, writeVolatileInt, writeVolatileLong, writeVolatileShort
assertReferencesReleased, backgroundPerformRelease, canReleaseInBackground, createdHere, disableReferenceTracing, enableReferenceTracing, refCount, referenceId, reserve, reservedBy, reserveTransfer, threadSafetyCheck, throwExceptionIfNotReleased, throwExceptionIfReleased, tryReserve, unmonitor, warnAndReleaseIfNotReleased
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
allocateDirect, allocateDirect, allocateElasticDirect, allocateElasticDirect, allocateElasticOnHeap, allocateElasticOnHeap, bytesForRead, copyTo, copyTo, directFrom, elasticByteBuffer, elasticByteBuffer, elasticByteBuffer, elasticHeapByteBuffer, elasticHeapByteBuffer, forFieldGroup, from, from, fromDirect, fromHexString, indexOf, indexOf, isClear, isEqual, readBigDecimal, readBigInteger, readMarshallableLength16, readWithLength, readWrite, safeLimit, toHexString, toHexString, toHexString, toString, toString, toString, unchecked, unchecked, unwrite, valueOf, wrapForRead, wrapForRead, wrapForWrite, wrapForWrite, write, writeMarshallableLength16
addAndGetDouble, addAndGetDoubleNotAtomic, addAndGetFloat, addAndGetFloatNotAtomic, addAndGetInt, addAndGetIntNotAtomic, addAndGetLong, addAndGetShortNotAtomic, addAndGetUnsignedByteNotAtomic, bytesForWrite, charAt, cipher, cipher, compareAndSwapDouble, compareAndSwapFloat, contentEquals, elasticByteBuffer, empty, endsWith, equalBytes, forFields, from, hash, inside, inside, isEmpty, isEqual, lazyNativeBytesStoreWithFixedCapacity, length, nativePointer, nativeStore, nativeStoreFrom, nativeStoreWithFixedCapacity, 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, compareUtf8, copyTo, copyTo, createCharToString, fastHash, findByte, parseLong, printable, 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, read8bit, read8bit, readBoolean, readChar, readEnum, readHistogram, readIncompleteLong, readInt24, readPositionForHeader, readPositionUnlimited, readStopBitDecimal, readStopBitDouble, readUnsignedInt, readUnsignedInt24, readUnsignedShort, readUtf8, readUtf8, readUtf8, readUtf8, readWithLength, readWithLength, readWithLength0, unsafeRead, unsafeReadObject, unsafeReadObject
bytesMethodWriter, writeObject
append, append, append, append, append, append, append, append, append, append8bit, append8bit, append8bit, append8bit, appendBase, appendBase16, appendBase16, appendDateMillis, appendDecimal, appendTimeMillis, writer
appendUtf8, appendUtf8, appendUtf8, appendUtf8, copyFrom, outputStream, rawWriteByte, rawWriteInt, rawWriteLong, unsafeWrite, unsafeWriteObject, unsafeWriteObject, write, write, write, write, write8bit, write8bit, writeBigDecimal, writeBigInteger, writeBoolean, writeChar, writeEnum, writeHistogram, writeInt24, writePositionForHeader, writePositionRemaining, writeSome, writeStopBit, writeStopBitDecimal, writeUnsignedByte, writeUnsignedInt, writeUnsignedInt24, writeUnsignedShort, writeWithLength
prepend
comment, indent, retainsComments
public ChunkedMappedBytes(@NotNull @NotNull MappedFile mappedFile) throws IllegalStateException
IllegalStateException
protected ChunkedMappedBytes(@NotNull @NotNull MappedFile mappedFile, String name) throws IllegalStateException
IllegalStateException
@NotNull public @NotNull ChunkedMappedBytes write(long offsetInRDO, byte[] byteArray, int offset, int length) throws IllegalStateException, BufferOverflowException
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<Void>>
write
in class AbstractBytes<Void>
offsetInRDO
- non-negative offset to write tobyteArray
- non-null copy from byteArrayoffset
- non-negative copy from offsetlength
- non-negative length to copyIllegalStateException
- if this Bytes object has been previously releasedBufferOverflowException
- if this Bytes object cannot accommodate all the bytes to copy.@NotNull public @NotNull ChunkedMappedBytes write(long writeOffset, @NotNull @NotNull RandomDataInput bytes, long readOffset, long length) throws BufferOverflowException, BufferUnderflowException, IllegalStateException
RandomDataOutput
writePosition()
nor RandomCommon.readPosition()
write
in interface RandomDataOutput<Bytes<Void>>
write
in class AbstractBytes<Void>
writeOffset
- offset to write tobytes
- copy from bytesreadOffset
- copy from offsetBufferOverflowException
IllegalStateException
BufferUnderflowException
@NotNull public @NotNull Bytes<Void> readPositionRemaining(long position, long remaining) throws BufferUnderflowException, IllegalStateException
@NotNull public @NotNull Bytes<Void> readPosition(long position) throws BufferUnderflowException, IllegalStateException
readPosition
in interface StreamingDataInput<Bytes<Void>>
readPosition
in class AbstractBytes<Void>
BufferUnderflowException
IllegalStateException
public long addressForRead(long offset) throws BufferUnderflowException, IllegalStateException
NOTE: If called with an offset which is already in the overlap region this call with therefore prompt a remapping to the new segment, which in turn may unmap the current segment. Any other handles using data in the current segment may therefore result in a memory violation when next used.
If manipulating offsets which may reside in the overlap region, always use the 2-argument version below
addressForRead
in class AbstractBytes<Void>
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()IllegalStateException
public long addressForRead(long offset, int buffer) throws UnsupportedOperationException, BufferUnderflowException, IllegalStateException
NOTE: In contrast to the single-argument version this call will not prompt a remapping if called within the overlap region (provided the full extent remains in the overlap region)
This version is therefore safe to use cooperatively with other handles in a defined sequence of bytes (eg returned from a DocumentContext) regardless of whether the handles span the overlap region
public long addressForWrite(long offset) throws UnsupportedOperationException, BufferOverflowException, IllegalStateException
addressForWrite
in class AbstractBytes<Void>
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
protected void readCheckOffset(long offset, long adding, boolean given) throws BufferUnderflowException, IllegalStateException
readCheckOffset
in class AbstractBytes<Void>
BufferUnderflowException
IllegalStateException
protected void writeCheckOffset(long offset, long adding) throws BufferOverflowException, IllegalStateException
writeCheckOffset
in class AbstractBytes<Void>
BufferOverflowException
IllegalStateException
public void ensureCapacity(long desiredCapacity) throws IllegalArgumentException, IllegalStateException
Bytes
IllegalArgumentException
desiredCapacity
- the capacity that you requiredIllegalArgumentException
- if the buffer is not elastic and there is not enough space or if the
provided desiredCapacity
is negative;IllegalStateException
@NotNull public @NotNull Bytes<Void> writeSkip(long bytesToSkip) throws BufferOverflowException, IllegalStateException
StreamingDataOutput
writeSkip
in interface StreamingDataOutput<Bytes<Void>>
writeSkip
in class CommonMappedBytes
bytesToSkip
- bytes to skip. This can be negative.BufferOverflowException
- if the offset is outside the limits of the BytesIllegalStateException
@NotNull public @NotNull Bytes<Void> readSkip(long bytesToSkip) throws BufferUnderflowException, IllegalStateException
StreamingDataInput
readSkip
in interface StreamingDataInput<Bytes<Void>>
readSkip
in class AbstractBytes<Void>
bytesToSkip
- bytes to skip.BufferUnderflowException
- if the offset is outside the limits of the BytesIllegalStateException
@NotNull public @NotNull Bytes<Void> clear() throws IllegalStateException
StreamingCommon
clear
in interface Bytes<Void>
clear
in interface StreamingCommon<Bytes<Void>>
clear
in class CommonMappedBytes
IllegalStateException
- if this resource has been previously released@NotNull public @NotNull Bytes<Void> writeByte(byte i8) throws BufferOverflowException, IllegalStateException
writeByte
in interface StreamingDataOutput<Bytes<Void>>
writeByte
in class AbstractBytes<Void>
BufferOverflowException
IllegalStateException
public boolean isElastic()
Bytes
Bytes.realCapacity()
.@NotNull public @NotNull Bytes<Void> write(@NotNull @NotNull BytesStore bytes, long offset, long length) throws BufferUnderflowException, BufferOverflowException, IllegalStateException
StreamingDataOutput
Calling this method will update the cursors of this, but not the bytes we read from.
@NotNull public @NotNull Bytes<Void> writeOrderedInt(long offset, int i) throws BufferOverflowException, IllegalStateException
RandomDataOutput
writeOrderedInt
in interface RandomDataOutput<Bytes<Void>>
writeOrderedInt
in class AbstractBytes<Void>
offset
- to write toi
- value to writeBufferOverflowException
- if the capacity was exceededIllegalStateException
public byte readVolatileByte(long offset) throws BufferUnderflowException, IllegalStateException
RandomDataInput
readVolatileByte
in interface RandomDataInput
readVolatileByte
in class AbstractBytes<Void>
offset
- to readBufferUnderflowException
- if the offset is outside the limits of the BytesIllegalStateException
- if releasedpublic short readVolatileShort(long offset) throws BufferUnderflowException, IllegalStateException
RandomDataInput
readVolatileShort
in interface RandomDataInput
readVolatileShort
in class AbstractBytes<Void>
offset
- to readBufferUnderflowException
- if the offset is outside the limits of the BytesIllegalStateException
- if releasedpublic int readVolatileInt(long offset) throws BufferUnderflowException, IllegalStateException
RandomDataInput
readVolatileInt
in interface RandomDataInput
readVolatileInt
in class AbstractBytes<Void>
offset
- to readBufferUnderflowException
- if the offset is outside the limits of the BytesIllegalStateException
- if releasedpublic long readVolatileLong(long offset) throws BufferUnderflowException, IllegalStateException
RandomDataInput
readVolatileLong
in interface RandomDataInput
readVolatileLong
in class AbstractBytes<Void>
offset
- to readBufferUnderflowException
- if the offset is outside the limits of the BytesIllegalStateException
- if releasedpublic int peekUnsignedByte() throws IllegalStateException
peekUnsignedByte
in interface StreamingDataInput<Bytes<Void>>
peekUnsignedByte
in class AbstractBytes<Void>
IllegalStateException
public int peekUnsignedByte(long offset) throws BufferUnderflowException, IllegalStateException
RandomDataInput
peekUnsignedByte
in interface RandomDataInput
peekUnsignedByte
in class AbstractBytes<Void>
offset
- to readIllegalStateException
- if releasedBufferUnderflowException
public int peekVolatileInt() throws IllegalStateException
IllegalStateException
@NotNull public @NotNull Bytes<Void> appendUtf8(char[] chars, int offset, int length) throws BufferOverflowException, IllegalArgumentException, IllegalStateException
public boolean compareAndSwapLong(long offset, long expected, long value) throws BufferOverflowException, IllegalStateException
RandomDataInput
compareAndSwapLong
in interface RandomDataInput
compareAndSwapLong
in interface RandomDataOutput<Bytes<Void>>
compareAndSwapLong
in class AbstractBytes<Void>
offset
- to perform CASexpected
- valuevalue
- to setBufferOverflowException
IllegalStateException
Copyright © 2022. All rights reserved.