public class SingleMappedBytes extends CommonMappedBytes
CommonMappedBytes to provide a mechanism to wrap memory-mapped data.
This allows for high-performance file I/O operations by loading file segments into memory for
byte-level manipulations.
Note: Instances of this class are not safe for use by multiple concurrent threads.
CommonMappedByteslastActualSize, mappedFileTRACEbytesStore, 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| Modifier | Constructor and Description |
|---|---|
|
SingleMappedBytes(@NotNull MappedFile mappedFile)
Constructs a SingleMappedBytes object wrapping the memory mapped to the specified file.
|
protected |
SingleMappedBytes(@NotNull MappedFile mappedFile,
String name)
Constructs a SingleMappedBytes object wrapping the memory mapped to the specified file and associates it with the specified name.
|
| Modifier and Type | Method and Description |
|---|---|
@NotNull Bytes<Void> |
clear()
Clears the content of this Bytes object and resets its state.
|
boolean |
compareAndSwapLong(long offset,
long expected,
long value)
Perform a 64-bit CAS at a given offset.
|
int |
peekVolatileInt()
Reads a volatile int value from the current reading position.
|
@NotNull Bytes<Void> |
readPositionRemaining(long position,
long remaining)
Sets the read position and limit of this StreamingDataInput based on the specified position and remaining values.
|
Bytes<Void> |
write(@NotNull BytesStore<?,?> bytes)
Writes all available data from the specified
BytesStore into the output stream. |
@NotNull SingleMappedBytes |
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 SingleMappedBytes |
write(long writeOffset,
@NotNull RandomDataInput bytes,
long readOffset,
long length)
Copies a segment from the provided RandomDataInput into this data output.
|
@NotNull Bytes<Void> |
writeSkip(long bytesToSkip)
Skips a specified number of bytes from the current write position in the data stream.
|
append8bit, appendUtf8, capacity, chunkCount, close, copy, disableThreadSafetyCheck, isBackingFileReadOnly, isClosed, isDirectMemory, mappedFile, performRelease, read8bit, readLimitToCapacity, readStopBit, readStopBitChar, readWrite, realCapacity, realReadRemaining, realWriteRemaining, release, releaseLast, singleThreadedCheckDisabled, singleThreadedCheckReset, start, throwExceptionIfClosed, toString, warnAndCloseIfNotClosed, write, write, write, write, write8bit, writePosition, writeStopBit, writeStopBit, writeUtf8, writeUtf8bytesForRead, bytesForWrite, mappedBytes, mappedBytes, mappedBytes, mappedBytes, mappedBytes, mappedBytes, readOnly, sharedMemory, singleMappedBytes, singleMappedBytes, singleMappedBytes, syncacquireUncheckedInput, addressForRead, addressForWrite, addressForWritePosition, append, append, append, append, append, append, appendAndReturnLength, byteCheckSum, byteCheckSum, byteCheckSum, bytesStore, bytesStore, canReadDirect, canWriteDirect, clearAndPad, compact, compareAndSwapInt, copyTo, decimaliser, decimaliser, equals, fpAppend0, fpAppend0, hashCode, internalNumberBuffer, isElastic, isImmutableEmptyByteStore, lastDecimalPlaces, lastDecimalPlaces, lastNumberHadDigits, lastNumberHadDigits, length, lenient, lenient, move, nativeRead, nativeWrite, peekUnsignedByte, peekUnsignedByte, 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, readVolatileLong, readVolatileShort, safeCopySize, startsWith, testAndSetInt, uncheckedReadSkipBackOne, uncheckedReadSkipOne, uncheckedReadUnsignedByte, uncheckedWritePosition, underlyingObject, write, write8bit, write8bit, write8bit, write8bit, writeBoolean, writeByte, writeByte, writeCheckOffset, writeDouble, writeDouble, writeDoubleAndInt, writeFloat, writeFloat, writeInt, writeInt, writeIntAdv, writeLimit, writeLimit, writeLong, writeLong, writeLongAdv, writeOffsetPositionMoved, writeOffsetPositionMoved, writeOrderedInt, writeOrderedInt, writeOrderedLong, writeOrderedLong, writePosition, writeShort, writeShort, writeSome, writeVolatileByte, writeVolatileInt, writeVolatileLong, writeVolatileShortaddReferenceChangeListener, assertReferencesReleased, backgroundPerformRelease, canReleaseInBackground, clearUsedByThread, createdHere, disableReferenceTracing, enableReferenceTracing, refCount, referenceCountedUnmonitored, referenceId, removeReferenceChangeListener, reserve, reservedBy, reserveTransfer, threadSafetyCheck, throwExceptionIfNotReleased, throwExceptionIfReleased, tryReserve, unmonitor, warnAndReleaseIfNotReleasedclone, finalize, getClass, notify, notifyAll, wait, wait, waitallocateDirect, allocateDirect, allocateElasticDirect, allocateElasticDirect, allocateElasticOnHeap, allocateElasticOnHeap, copyTo, copyTo, directFrom, elasticByteBuffer, elasticByteBuffer, elasticByteBuffer, elasticHeapByteBuffer, elasticHeapByteBuffer, empty, ensureCapacity, forFieldGroup, from, from, fromDirect, fromHexString, indexOf, indexOf, isClear, isEqual, readMarshallableLength16, readWithLength, safeLimit, 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, equalBytes, follow, forFields, from, hash, inside, inside, isEmpty, isEqual, 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, findByte, parseLong, printable, readBoolean, readIncompleteLong, readUnsignedInt, readUnsignedInt24, readUnsignedShort, readUtf8, readUtf8Limited, readUtf8Limited, readVolatileDouble, readVolatileFloat, subBytes, toByteArray, toTemporaryDirectByteBufferparse8bit, parse8bit, parse8bit, parse8bit, parse8bit, parseBigDecimal, parseBoolean, parseBoolean, parseDouble, parseFlexibleLong, parseFloat, parseInt, parseLong, parseLongDecimal, parseUtf8, parseUtf8, parseUtf8, reader, skipToinputStream, parseHexLong, parseUtf8, parseUtf8, rawReadByte, rawReadInt, rawReadLong, read, read, read, read, read, read8bit, read8bit, readBigDecimal, readBigInteger, readBoolean, readChar, readEnum, readHistogram, readIncompleteLong, readInt24, readPositionUnlimited, readStopBitDecimal, readStopBitDouble, readUnsignedInt, readUnsignedInt24, readUnsignedShort, readUtf8, readUtf8, readUtf8, readUtf8, readWithLength, readWithLength, readWithLength0, unsafeRead, unsafeReadObject, unsafeReadObjectbytesMethodWriter, writeObjectappend, append, append, append, append, append8bit, append8bit, append8bit, append8bit, appendBase, appendBase16, appendBase16, appendDateMillis, appendDecimal, appendTimeMillis, writerappendUtf8, appendUtf8, appendUtf8, appendUtf8, appendUtf8, copyFrom, outputStream, rawWriteByte, rawWriteInt, rawWriteLong, unsafeWrite, unsafeWriteObject, unsafeWriteObject, write, write, write, write, write8bit, write8bit, writeBigDecimal, writeBigInteger, writeChar, writeEnum, writeHistogram, writeInt24, writePositionForHeader, writePositionRemaining, writeSome, writeStopBit, writeStopBitDecimal, writeUnsignedByte, writeUnsignedInt, writeUnsignedInt24, writeUnsignedShort, writeWithLengthprependadjustHexDumpIndentation, retainedHexDumpDescription, writeHexDumpDescriptionpublic SingleMappedBytes(@NotNull
@NotNull MappedFile mappedFile)
throws IllegalStateException
mappedFile - The MappedFile object to be wrapped.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 wayIllegalStateExceptionprotected SingleMappedBytes(@NotNull
@NotNull MappedFile mappedFile,
String name)
throws IllegalStateException
mappedFile - The MappedFile object to be wrapped.name - The name to be associated with the SingleMappedBytes object.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 SingleMappedBytes write(long offsetInRDO, byte[] byteArray, int offset, int length) throws IllegalStateException, BufferOverflowException
RandomDataOutputbyteArray 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 - 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.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 data output was exceeded.IllegalStateException@NotNull public @NotNull SingleMappedBytes write(long writeOffset, @NotNull @NotNull RandomDataInput bytes, long readOffset, long length) throws BufferOverflowException, BufferUnderflowException, IllegalStateException
RandomDataOutputwritePosition() of this output nor the RandomCommon.readPosition() of the input.write in interface RandomDataOutput<Bytes<Void>>write in class AbstractBytes<Void>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.BufferOverflowException - If the capacity of this data output was exceeded.BufferUnderflowException - If the source does not have enough data to fill the length.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<Void> readPositionRemaining(long position, long remaining) throws BufferUnderflowException, IllegalStateException
StreamingDataInputposition - the new read position, must be non-negativeremaining - the remaining size, which is used to set the read limitBufferUnderflowException - If the new position is greater than the read limitnet.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<Void> writeSkip(long bytesToSkip) throws BufferOverflowException, IllegalStateException
StreamingDataOutputwriteSkip in interface StreamingDataOutput<Bytes<Void>>writeSkip in class CommonMappedBytesbytesToSkip - The number of bytes to skip. This can be a negative number to move the
position backward.BufferOverflowException - If the new position calculated by the skip operation falls
outside the limits of the data 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<Void> clear() throws IllegalStateException
Bytesclear in interface Bytes<Void>clear in interface StreamingCommon<Bytes<Void>>clear in class CommonMappedBytesnet.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 int peekVolatileInt()
throws IllegalStateException
RandomDataInputnet.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 boolean compareAndSwapLong(long offset,
long expected,
long value)
throws BufferOverflowException,
IllegalStateException
RandomDataInputcompareAndSwapLong in interface BytesStore<Bytes<Void>,Void>compareAndSwapLong in interface RandomDataInputcompareAndSwapLong in interface RandomDataOutput<Bytes<Void>>compareAndSwapLong in class AbstractBytes<Void>offset - to perform CASexpected - valuevalue - to setBufferOverflowException - 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 wayIllegalStateExceptionpublic Bytes<Void> write(@NotNull @NotNull BytesStore<?,?> bytes) throws BufferOverflowException, IllegalStateException
StreamingDataOutputBytesStore 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<Void>>write in class AbstractBytes<Void>bytes - the BytesStore from which data is read.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 wayIllegalStateExceptionStreamingDataInput.read(Bytes)Copyright © 2023. All rights reserved.