public final class SingletonEmptyByteStore extends Object implements EmptyByteStore
Modifier and Type | Field and Description |
---|---|
static EmptyByteStore |
INSTANCE |
charToString
Modifier and Type | Method and Description |
---|---|
long |
addressForRead(long offset)
Obtain the underlying addressForRead.
|
default long |
addressForRead(long offset,
int buffer) |
long |
addressForWrite(long offset)
Obtain the underlying addressForRead.
|
long |
addressForWritePosition() |
default ByteOrder |
byteOrder() |
@NotNull Bytes<Void> |
bytesForRead()
Returns a Bytes that wraps this ByteStore from the
start to the realCapacity . |
@NotNull Bytes<Void> |
bytesForWrite()
Returns a Bytes that wraps this ByteStore from the
start to the realCapacity . |
long |
capacity() |
char |
charAt(int index)
Assume ISO-8859-1 encoding, subclasses can override this.
|
@NotNull IntStream |
chars() |
@NotNull IntStream |
codePoints() |
boolean |
compareAndSwapInt(long offset,
int expected,
int value)
Perform a 32-bit CAS at a given offset.
|
boolean |
compareAndSwapLong(long offset,
long expected,
long value)
Perform a 64-bit CAS at a given offset.
|
@NotNull EmptyByteStore |
copy() |
long |
copyTo(@NotNull BytesStore store)
Returns the number of bytes that were copied from this BytesStore to a destination BytesStore.
|
boolean |
equalBytes(@NotNull BytesStore bytesStore,
long length)
Returns if a portion of a specified BytesStore matches this BytesStore.
|
boolean |
equals(Object obj) |
int |
hashCode() |
boolean |
inside(long offset)
Returns if a specified offset is inside this BytesStore limits.
|
boolean |
inside(long offset,
long buffer)
Returns if a number of bytes starting from an offset are inside this ByteStore limits.
|
boolean |
isDirectMemory() |
boolean |
isImmutableEmptyByteStore()
Returns if this ByteStore is an immutable empty ByteStore or if it is backed
by an immutable empty ByteStore.
|
int |
length()
This method is inherited from CharSequence so result should be the length of the contained
chars sequence although it actually returns the number of underlying bytes.
|
default long |
lengthWritten(long startPosition)
Typically this calculates the difference however for HexDumpBytes it's not as simple.
|
void |
move(long from,
long to,
long length) |
void |
nativeRead(long position,
long address,
long size)
expert level method for copying data to native memory.
|
void |
nativeWrite(long address,
long position,
long size)
expert level method to copy data from native memory into the BytesStore
|
int |
peekUnsignedByte(long offset)
Read an unsigned byte at an offset, or -1
|
byte |
readByte(long offset)
Read byte at an offset
|
double |
readDouble(long offset)
Read a double at an offset
|
float |
readFloat(long offset)
Read a float at an offset
|
int |
readInt(long offset)
Read an int at an offset
|
default long |
readLimit()
If the resource is closed, the returned value is unspecified.
|
long |
readLong(long offset)
Read a long at an offset
|
default long |
readPosition()
Returns the read position.
|
default long |
readRemaining()
Returns the remaining bytes that can be read.
|
short |
readShort(long offset)
Read a short at an offset
|
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.
|
default long |
realReadRemaining()
If the resource is closed, the returned value is unspecified.
|
default long |
realWriteRemaining()
If the resource is closed, the returned value is unspecified.
|
int |
refCount() |
void |
release(net.openhft.chronicle.core.io.ReferenceOwner owner) |
void |
releaseLast(net.openhft.chronicle.core.io.ReferenceOwner id) |
void |
reserve(net.openhft.chronicle.core.io.ReferenceOwner owner) |
boolean |
reservedBy(net.openhft.chronicle.core.io.ReferenceOwner owner) |
boolean |
sharedMemory() |
default long |
start() |
@NotNull CharSequence |
subSequence(int start,
int end)
This method constructs a new BytesStore , memory storage type (heap or native) is preserved. |
void |
testAndSetInt(long offset,
int expected,
int value) |
@NotNull String |
toString() |
boolean |
tryReserve(net.openhft.chronicle.core.io.ReferenceOwner owner) |
Void |
underlyingObject() |
@NotNull EmptyByteStore |
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)
Copy from ByteBuffer into this.
|
@NotNull EmptyByteStore |
write(long writeOffset,
@NotNull RandomDataInput bytes,
long readOffset,
long length)
Copy from RandomDataInput into this.
|
long |
write8bit(long position,
@NotNull BytesStore bs)
Write the stop bit length and copy the BytesStore
|
long |
write8bit(long position,
@NotNull String s,
int start,
int length) |
@NotNull EmptyByteStore |
writeByte(long offset,
byte i8)
Write an unsigned byte at an offset.
|
@NotNull EmptyByteStore |
writeDouble(long offset,
double d)
Write a double at an offset.
|
@NotNull EmptyByteStore |
writeFloat(long offset,
float d)
Write a float at an offset.
|
@NotNull EmptyByteStore |
writeInt(long offset,
int i)
Write an int at an offset.
|
default long |
writeLimit()
Returns the write limit.
|
@NotNull EmptyByteStore |
writeLong(long offset,
long i)
Write a long at an offset.
|
@NotNull EmptyByteStore |
writeOrderedInt(long offset,
int i)
Perform a non stalling write with a store barrier.
|
@NotNull EmptyByteStore |
writeOrderedLong(long offset,
long i)
Perform a non stalling write with a store barrier.
|
default long |
writePosition()
Returns the write position.
|
default long |
writeRemaining()
If the resource is closed, the returned value is unspecified.
|
@NotNull EmptyByteStore |
writeShort(long offset,
short i)
Write a short at an offset.
|
@NotNull EmptyByteStore |
writeVolatileByte(long offset,
byte i8) |
@NotNull EmptyByteStore |
writeVolatileInt(long offset,
int i32) |
@NotNull EmptyByteStore |
writeVolatileLong(long offset,
long i64) |
@NotNull EmptyByteStore |
writeVolatileShort(long offset,
short i16) |
@NotNull EmptyByteStore |
zeroOut(long start,
long end)
Fills the BytesStore with zeros.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
addAndGetDouble, addAndGetDoubleNotAtomic, addAndGetFloat, addAndGetFloatNotAtomic, addAndGetInt, addAndGetIntNotAtomic, addAndGetLong, addAndGetShortNotAtomic, addAndGetUnsignedByteNotAtomic, byteCheckSum, byteCheckSum, bytesStore, cipher, cipher, compareAndSwapDouble, compareAndSwapFloat, contentEquals, copyTo, elasticByteBuffer, empty, endsWith, forFields, from, from, from, hash, isClear, isEmpty, isEqual, lazyNativeBytesStoreWithFixedCapacity, nativePointer, nativeStore, nativeStoreFrom, nativeStoreWithFixedCapacity, readWrite, realCapacity, safeLimit, startsWith, startsWith, to8bitString, toDebugString, toDebugString, wrap, wrap, wrap, writeMaxInt, writeMaxLong
canReadDirect, canReadDirect, compareUtf8, copyTo, copyTo, createCharToString, fastHash, findByte, parseLong, peekVolatileInt, printable, read, readBoolean, readIncompleteLong, readUnsignedByte, readUnsignedInt, readUnsignedInt24, readUnsignedShort, readUtf8, readUtf8Limited, readUtf8Limited, readVolatileDouble, readVolatileFloat, subBytes, toByteArray, toTemporaryDirectByteBuffer
append, append, write, write, writeBoolean, writeByte, writeInt24, writeOrderedDouble, writeOrderedFloat, writeUnsignedByte, writeUnsignedInt, writeUnsignedShort, writeUtf8, writeUtf8Limited, writeVolatileDouble, writeVolatileFloat
public static final EmptyByteStore INSTANCE
public void reserve(net.openhft.chronicle.core.io.ReferenceOwner owner) throws IllegalStateException
reserve
in interface net.openhft.chronicle.core.io.ReferenceCounted
IllegalStateException
public void release(net.openhft.chronicle.core.io.ReferenceOwner owner) throws IllegalStateException
release
in interface net.openhft.chronicle.core.io.ReferenceCounted
IllegalStateException
public void releaseLast(net.openhft.chronicle.core.io.ReferenceOwner id) throws IllegalStateException
releaseLast
in interface net.openhft.chronicle.core.io.ReferenceCounted
IllegalStateException
public int refCount()
refCount
in interface net.openhft.chronicle.core.io.ReferenceCounted
public boolean tryReserve(net.openhft.chronicle.core.io.ReferenceOwner owner)
tryReserve
in interface net.openhft.chronicle.core.io.ReferenceCounted
public boolean reservedBy(net.openhft.chronicle.core.io.ReferenceOwner owner)
reservedBy
in interface net.openhft.chronicle.core.io.ReferenceCounted
@NotNull public @NotNull EmptyByteStore writeByte(long offset, byte i8)
RandomDataOutput
writeByte
in interface RandomDataOutput<EmptyByteStore>
offset
- to write toi8
- the value@NotNull public @NotNull EmptyByteStore writeShort(long offset, short i)
RandomDataOutput
writeShort
in interface RandomDataOutput<EmptyByteStore>
offset
- to write toi
- the value@NotNull public @NotNull EmptyByteStore writeInt(long offset, int i)
RandomDataOutput
writeInt
in interface RandomDataOutput<EmptyByteStore>
offset
- to write toi
- the value@NotNull public @NotNull EmptyByteStore writeOrderedInt(long offset, int i)
RandomDataOutput
writeOrderedInt
in interface RandomDataOutput<EmptyByteStore>
offset
- to write toi
- value to write@NotNull public @NotNull EmptyByteStore writeLong(long offset, long i)
RandomDataOutput
writeLong
in interface RandomDataOutput<EmptyByteStore>
offset
- to write toi
- the value@NotNull public @NotNull EmptyByteStore writeOrderedLong(long offset, long i)
RandomDataOutput
writeOrderedLong
in interface RandomDataOutput<EmptyByteStore>
offset
- to write toi
- value to write@NotNull public @NotNull EmptyByteStore writeFloat(long offset, float d)
RandomDataOutput
writeFloat
in interface RandomDataOutput<EmptyByteStore>
offset
- to write tod
- the value@NotNull public @NotNull EmptyByteStore writeDouble(long offset, double d)
RandomDataOutput
writeDouble
in interface RandomDataOutput<EmptyByteStore>
offset
- to write tod
- the value@NotNull public @NotNull EmptyByteStore writeVolatileByte(long offset, byte i8)
writeVolatileByte
in interface RandomDataOutput<EmptyByteStore>
@NotNull public @NotNull EmptyByteStore writeVolatileShort(long offset, short i16)
writeVolatileShort
in interface RandomDataOutput<EmptyByteStore>
@NotNull public @NotNull EmptyByteStore writeVolatileInt(long offset, int i32)
writeVolatileInt
in interface RandomDataOutput<EmptyByteStore>
@NotNull public @NotNull EmptyByteStore writeVolatileLong(long offset, long i64)
writeVolatileLong
in interface RandomDataOutput<EmptyByteStore>
@NotNull public @NotNull EmptyByteStore write(long offsetInRDO, byte[] byteArray, int offset, int length)
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<EmptyByteStore>
offsetInRDO
- non-negative offset to write tobyteArray
- non-null copy from byteArrayoffset
- non-negative copy from offsetlength
- non-negative length to copypublic void write(long offsetInRDO, @NotNull @NotNull ByteBuffer bytes, int offset, int length)
RandomDataOutput
Does not update cursors e.g. writePosition()
write
in interface RandomDataOutput<EmptyByteStore>
offsetInRDO
- offset to write tobytes
- copy from bytesoffset
- copy from offset@NotNull public @NotNull EmptyByteStore write(long writeOffset, @NotNull @NotNull RandomDataInput bytes, long readOffset, long length)
RandomDataOutput
writePosition()
nor RandomCommon.readPosition()
write
in interface RandomDataOutput<EmptyByteStore>
writeOffset
- offset to write tobytes
- copy from bytesreadOffset
- copy from offsetpublic byte readByte(long offset)
RandomDataInput
readByte
in interface RandomDataInput
offset
- to readpublic int peekUnsignedByte(long offset)
RandomDataInput
peekUnsignedByte
in interface RandomDataInput
offset
- to readpublic short readShort(long offset)
RandomDataInput
readShort
in interface RandomDataInput
offset
- to readpublic int readInt(long offset)
RandomDataInput
readInt
in interface RandomDataInput
offset
- to readpublic long readLong(long offset)
RandomDataInput
readLong
in interface RandomDataInput
offset
- to readpublic float readFloat(long offset)
RandomDataInput
readFloat
in interface RandomDataInput
offset
- to readpublic double readDouble(long offset)
RandomDataInput
readDouble
in interface RandomDataInput
offset
- to readpublic byte readVolatileByte(long offset) throws BufferUnderflowException
RandomDataInput
readVolatileByte
in interface RandomDataInput
offset
- to readBufferUnderflowException
- if the offset is outside the limits of the Bytespublic short readVolatileShort(long offset) throws BufferUnderflowException
RandomDataInput
readVolatileShort
in interface RandomDataInput
offset
- to readBufferUnderflowException
- if the offset is outside the limits of the Bytespublic int readVolatileInt(long offset) throws BufferUnderflowException
RandomDataInput
readVolatileInt
in interface RandomDataInput
offset
- to readBufferUnderflowException
- if the offset is outside the limits of the Bytespublic long readVolatileLong(long offset) throws BufferUnderflowException
RandomDataInput
readVolatileLong
in interface RandomDataInput
offset
- to readBufferUnderflowException
- if the offset is outside the limits of the Bytespublic boolean isDirectMemory()
isDirectMemory
in interface BytesStore<EmptyByteStore,Void>
@NotNull public @NotNull EmptyByteStore copy()
copy
in interface BytesStore<EmptyByteStore,Void>
@NotNull public @NotNull Bytes<Void> bytesForRead() throws IllegalStateException
BytesStore
start
to the realCapacity
.
The returned Bytes is not elastic and can be both read and written using cursors.
bytesForRead
in interface BytesStore<EmptyByteStore,Void>
IllegalStateException
- if this Bytes has been releasedpublic long capacity()
capacity
in interface BytesStore<EmptyByteStore,Void>
public Void underlyingObject()
underlyingObject
in interface BytesStore<EmptyByteStore,Void>
public boolean inside(long offset)
BytesStore
Use this test to determine if an offset is considered safe.
inside
in interface BytesStore<EmptyByteStore,Void>
offset
- the specified offset to checktrue
if offset is safepublic boolean inside(long offset, long buffer)
BytesStore
inside
in interface BytesStore<EmptyByteStore,Void>
offset
- the starting index to checkbuffer
- the number of bytes after the offset to checktrue
if the bytes between the offset and offset+buffer are inside the BytesStorepublic long copyTo(@NotNull @NotNull BytesStore store)
BytesStore
Copies the data to another BytesStore as long as space is available in the destination BytesStore.
copyTo
in interface BytesStore<EmptyByteStore,Void>
store
- the BytesStore to copy topublic void nativeWrite(long address, long position, long size)
RandomDataOutput
nativeWrite
in interface RandomDataOutput<EmptyByteStore>
address
- in native memory to copy fromposition
- in BytesStore to copy tosize
- in bytespublic long write8bit(long position, @NotNull @NotNull BytesStore bs)
RandomDataOutput
write8bit
in interface RandomDataOutput<EmptyByteStore>
position
- to writebs
- to copy.RandomDataOutput
public long write8bit(long position, @NotNull @NotNull String s, int start, int length)
write8bit
in interface RandomDataOutput<EmptyByteStore>
public void nativeRead(long position, long address, long size)
RandomDataInput
nativeRead
in interface RandomDataInput
position
- within the ByteStore to copy.address
- in native memorysize
- in bytespublic boolean compareAndSwapInt(long offset, int expected, int value)
RandomDataInput
compareAndSwapInt
in interface BytesStore<EmptyByteStore,Void>
compareAndSwapInt
in interface RandomDataInput
compareAndSwapInt
in interface RandomDataOutput<EmptyByteStore>
offset
- to perform CASexpected
- valuevalue
- to setpublic void testAndSetInt(long offset, int expected, int value)
testAndSetInt
in interface RandomDataInput
testAndSetInt
in interface RandomDataOutput<EmptyByteStore>
public boolean compareAndSwapLong(long offset, long expected, long value)
RandomDataInput
compareAndSwapLong
in interface BytesStore<EmptyByteStore,Void>
compareAndSwapLong
in interface RandomDataInput
compareAndSwapLong
in interface RandomDataOutput<EmptyByteStore>
offset
- to perform CASexpected
- valuevalue
- to setpublic boolean equalBytes(@NotNull @NotNull BytesStore bytesStore, long length)
BytesStore
equalBytes
in interface BytesStore<EmptyByteStore,Void>
bytesStore
- the BytesStore to match againstlength
- the length to matchtrue
if the bytes up to min(length, this.length(), bytesStore.length()) matched.public void move(long from, long to, long length)
move
in interface BytesStore<EmptyByteStore,Void>
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
@NotNull public @NotNull Bytes<Void> bytesForWrite()
BytesStore
start
to the realCapacity
.
The returned Bytes is not elastic and can be both read and written using cursors.
bytesForWrite
in interface BytesStore<EmptyByteStore,Void>
public boolean sharedMemory()
@NotNull public @NotNull EmptyByteStore zeroOut(long start, long end) throws IllegalStateException
BytesStore
zeroOut
in interface BytesStore<EmptyByteStore,Void>
zeroOut
in interface RandomDataOutput<EmptyByteStore>
start
- first byte inclusiveend
- last byte exclusiveIllegalStateException
public boolean isImmutableEmptyByteStore()
BytesStore
isImmutableEmptyByteStore
in interface BytesStore<EmptyByteStore,Void>
@NotNull public @NotNull String toString()
toString
in interface CharSequence
toString
in class Object
@NotNull public @NotNull IntStream chars()
chars
in interface CharSequence
@NotNull public @NotNull IntStream codePoints()
codePoints
in interface CharSequence
public int length()
BytesStore
length
in interface CharSequence
length
in interface BytesStore<EmptyByteStore,Void>
public char charAt(int index) throws IndexOutOfBoundsException
BytesStore
charAt
in interface CharSequence
charAt
in interface BytesStore<EmptyByteStore,Void>
IndexOutOfBoundsException
@NotNull public @NotNull CharSequence subSequence(int start, int end)
BytesStore
BytesStore
, memory storage type (heap or native) is preserved.subSequence
in interface CharSequence
subSequence
in interface BytesStore<EmptyByteStore,Void>
public long start()
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()
readPosition() <= writePosition() && writePosition() <= writeLimit()
If the resource is closed, the returned value is unspecified.
public long lengthWritten(long startPosition)
If the resource is closed, the returned value is unspecified.
startPosition
- to compare againstpublic long readRemaining()
If the resource is closed, the returned value is unspecified.
public long realReadRemaining()
If the resource is closed, the returned value is unspecified.
public long writeRemaining()
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
public ByteOrder byteOrder()
Copyright © 2022. All rights reserved.