public class NativeBytesStore<Underlying> extends Object implements BytesStore<NativeBytesStore<Underlying>,Underlying>
Modifier and Type | Field and Description |
---|---|
protected long |
address |
protected net.openhft.chronicle.core.Memory |
memory |
charToString
Constructor and Description |
---|
NativeBytesStore(long address,
long maximumLimit) |
NativeBytesStore(long address,
long maximumLimit,
Runnable deallocator,
boolean elastic) |
Modifier and Type | Method and Description |
---|---|
long |
address(long offset)
Obtain the underlying address.
|
long |
appendUTF(long pos,
char[] chars,
int offset,
int length) |
default ByteOrder |
byteOrder() |
VanillaBytes<Underlying> |
bytesForWrite() |
long |
capacity() |
void |
checkReleased() |
default boolean |
compareAndSwapDouble(long offset,
double expected,
double value)
Perform a 64-bit double CAS at a given offset.
|
default boolean |
compareAndSwapFloat(long offset,
float expected,
float value)
Perform a 32-bit float CAS at a given offset.
|
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.
|
BytesStore<NativeBytesStore<Underlying>,Underlying> |
copy() |
static NativeBytesStore<ByteBuffer> |
elasticByteBuffer() |
static NativeBytesStore<ByteBuffer> |
elasticByteBuffer(int size) |
boolean |
equals(Object obj) |
static NativeBytesStore<Void> |
lazyNativeBytesStoreWithFixedCapacity(long capacity) |
void |
nativeRead(long position,
long address,
long size)
expert level method for copying data to native memory.
|
static NativeBytesStore<Void> |
nativeStore(long capacity)
this is an elastic native store
|
static NativeBytesStore<Void> |
nativeStoreWithFixedCapacity(long capacity) |
void |
nativeWrite(long address,
long position,
long size)
expert level method to copy data from native memory into the BytesStore
|
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
|
long |
readIncompleteLong(long offset)
Read a long which is zero padded (high bytes) if the available bytes is less than 8.
|
int |
readInt(long offset)
Read an int at an offset
|
default long |
readLimit() |
long |
readLong(long offset)
Read a long at an offset
|
default long |
readPosition()
The read position must be start() <= readPosition() && readPosition() <= readLimit() && readPosition < safeLimit()
|
default long |
readRemaining() |
short |
readShort(long offset)
Read a short at an offset
|
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.
|
long |
realCapacity() |
long |
refCount() |
void |
release() |
void |
reserve() |
void |
setAddress(long address) |
long |
start() |
String |
toString() |
Underlying |
underlyingObject() |
static NativeBytesStore<ByteBuffer> |
wrap(ByteBuffer bb)
Wraps a ByteBuffer which can be either on heap or off heap.
|
NativeBytesStore<Underlying> |
write(long offsetInRDO,
byte[] bytes,
int offset,
int length) |
void |
write(long offsetInRDO,
ByteBuffer bytes,
int offset,
int length) |
NativeBytesStore<Underlying> |
write(long offsetInRDO,
RandomDataInput bytes,
long offset,
long length) |
NativeBytesStore<Underlying> |
writeByte(long offset,
byte i8)
Write an unsigned byte at an offset.
|
NativeBytesStore<Underlying> |
writeDouble(long offset,
double d)
Write a double at an offset.
|
NativeBytesStore<Underlying> |
writeFloat(long offset,
float f)
Write a float at an offset.
|
NativeBytesStore<Underlying> |
writeInt(long offset,
int i32)
Write an int at an offset.
|
default long |
writeLimit() |
NativeBytesStore<Underlying> |
writeLong(long offset,
long i64)
Write a long at an offset.
|
NativeBytesStore<Underlying> |
writeOrderedInt(long offset,
int i)
Perform a non stalling write with a store barrier.
|
NativeBytesStore<Underlying> |
writeOrderedLong(long offset,
long i)
Perform a non stalling write with a store barrier.
|
default long |
writePosition()
The read position must be readPosition() <= writePosition() && writePosition() <= writeLimit()
|
default long |
writeRemaining() |
NativeBytesStore<Underlying> |
writeShort(long offset,
short i16)
Write a short at an offset.
|
NativeBytesStore<Underlying> |
zeroOut(long start,
long end)
Fill the BytesStore with zeros
|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
byteCheckSum, bytesForRead, bytesStore, charAt, contentEquals, copyTo, endsWith, equalBytes, from, inside, isClear, length, nativePointer, safeLimit, startsWith, subSequence, to8bitString, toDebugString, wrap, wrap, wrap
addAndGetDouble, addAndGetFloat, addAndGetInt, addAndGetLong, copyTo, createCharToString, parseLong, printable, readBoolean, readUnsignedByte, readUnsignedInt, readUnsignedShort, readVolatileDouble, readVolatileFloat
append, write, write, writeBoolean, writeByte, writeOrderedDouble, writeOrderedFloat, writeUnsignedByte, writeUnsignedInt, writeUnsignedShort
close, release, releaseAll, tryReserve
chars, codePoints
@Nullable protected net.openhft.chronicle.core.Memory memory
protected long address
public NativeBytesStore(long address, long maximumLimit)
public NativeBytesStore(long address, long maximumLimit, @Nullable Runnable deallocator, boolean elastic)
@NotNull public static NativeBytesStore<ByteBuffer> wrap(@NotNull ByteBuffer bb)
BytesStore
wrap
in interface BytesStore<NativeBytesStore<Underlying>,Underlying>
bb
- to wrap@NotNull public static NativeBytesStore<Void> nativeStore(long capacity) throws IllegalArgumentException
capacity
- of the buffer.IllegalArgumentException
@NotNull public static NativeBytesStore<Void> nativeStoreWithFixedCapacity(long capacity) throws IllegalArgumentException
IllegalArgumentException
@NotNull public static NativeBytesStore<Void> lazyNativeBytesStoreWithFixedCapacity(long capacity) throws IllegalArgumentException
IllegalArgumentException
@NotNull public static NativeBytesStore<ByteBuffer> elasticByteBuffer()
@NotNull public static NativeBytesStore<ByteBuffer> elasticByteBuffer(int size)
@NotNull public BytesStore<NativeBytesStore<Underlying>,Underlying> copy() throws IllegalStateException
copy
in interface BytesStore<NativeBytesStore<Underlying>,Underlying>
IllegalStateException
public VanillaBytes<Underlying> bytesForWrite() throws IllegalStateException
bytesForWrite
in interface BytesStore<NativeBytesStore<Underlying>,Underlying>
IllegalStateException
public long realCapacity()
realCapacity
in interface BytesStore<NativeBytesStore<Underlying>,Underlying>
realCapacity
in interface RandomDataInput
public long capacity()
capacity
in interface BytesStore<NativeBytesStore<Underlying>,Underlying>
@Nullable public Underlying underlyingObject()
underlyingObject
in interface BytesStore<NativeBytesStore<Underlying>,Underlying>
@NotNull public NativeBytesStore<Underlying> zeroOut(long start, long end) throws IllegalArgumentException
BytesStore
zeroOut
in interface BytesStore<NativeBytesStore<Underlying>,Underlying>
zeroOut
in interface RandomDataOutput<NativeBytesStore<Underlying>>
start
- first byte inclusiveend
- last byte exclusive.IllegalArgumentException
public boolean compareAndSwapInt(long offset, int expected, int value)
offset
- to perform CASexpected
- valuevalue
- to setpublic boolean compareAndSwapLong(long offset, long expected, long value)
offset
- to perform CASexpected
- valuevalue
- to setpublic long start()
public void reserve() throws IllegalStateException
reserve
in interface net.openhft.chronicle.core.ReferenceCounted
IllegalStateException
public void release() throws IllegalStateException
release
in interface net.openhft.chronicle.core.ReferenceCounted
IllegalStateException
public long refCount()
refCount
in interface net.openhft.chronicle.core.ReferenceCounted
public byte readByte(long offset)
RandomDataInput
readByte
in interface RandomDataInput
offset
- to readpublic void checkReleased()
public 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 int readVolatileInt(long offset)
RandomDataInput
readVolatileInt
in interface RandomDataInput
offset
- to readpublic long readVolatileLong(long offset)
RandomDataInput
readVolatileLong
in interface RandomDataInput
offset
- to read@NotNull public NativeBytesStore<Underlying> writeByte(long offset, byte i8)
RandomDataOutput
writeByte
in interface RandomDataOutput<NativeBytesStore<Underlying>>
offset
- to write toi8
- the value@NotNull public NativeBytesStore<Underlying> writeShort(long offset, short i16)
RandomDataOutput
writeShort
in interface RandomDataOutput<NativeBytesStore<Underlying>>
offset
- to write toi16
- the value@NotNull public NativeBytesStore<Underlying> writeInt(long offset, int i32)
RandomDataOutput
writeInt
in interface RandomDataOutput<NativeBytesStore<Underlying>>
offset
- to write toi32
- the value@NotNull public NativeBytesStore<Underlying> writeOrderedInt(long offset, int i)
RandomDataOutput
writeOrderedInt
in interface RandomDataOutput<NativeBytesStore<Underlying>>
offset
- to write toi
- value to write@NotNull public NativeBytesStore<Underlying> writeLong(long offset, long i64)
RandomDataOutput
writeLong
in interface RandomDataOutput<NativeBytesStore<Underlying>>
offset
- to write toi64
- the value@NotNull public NativeBytesStore<Underlying> writeOrderedLong(long offset, long i)
RandomDataOutput
writeOrderedLong
in interface RandomDataOutput<NativeBytesStore<Underlying>>
offset
- to write toi
- value to write@NotNull public NativeBytesStore<Underlying> writeFloat(long offset, float f)
RandomDataOutput
writeFloat
in interface RandomDataOutput<NativeBytesStore<Underlying>>
offset
- to write tof
- the value@NotNull public NativeBytesStore<Underlying> writeDouble(long offset, double d)
RandomDataOutput
writeDouble
in interface RandomDataOutput<NativeBytesStore<Underlying>>
offset
- to write tod
- the value@NotNull public NativeBytesStore<Underlying> write(long offsetInRDO, byte[] bytes, int offset, int length)
write
in interface RandomDataOutput<NativeBytesStore<Underlying>>
public void write(long offsetInRDO, @NotNull ByteBuffer bytes, int offset, int length)
write
in interface RandomDataOutput<NativeBytesStore<Underlying>>
@NotNull public NativeBytesStore<Underlying> write(long offsetInRDO, @NotNull RandomDataInput bytes, long offset, long length) throws BufferOverflowException, BufferUnderflowException, IORuntimeException
write
in interface RandomDataOutput<NativeBytesStore<Underlying>>
BufferOverflowException
BufferUnderflowException
IORuntimeException
public long address(long offset) throws UnsupportedOperationException
offset
- within this buffer. address(start()) is the actual address of the first byte.UnsupportedOperationException
- if the underlying buffer is on the heap@NotNull public String toString()
toString
in interface CharSequence
toString
in class Object
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 void nativeWrite(long address, long position, long size)
RandomDataOutput
nativeWrite
in interface RandomDataOutput<NativeBytesStore<Underlying>>
address
- in native memory to copy fromposition
- in BytesStore to copy tosize
- in bytespublic long readIncompleteLong(long offset)
RandomDataInput
readIncompleteLong
in interface RandomDataInput
offset
- to read frompublic void setAddress(long address)
public long appendUTF(long pos, char[] chars, int offset, int length)
public long readPosition()
public long writePosition()
public long readRemaining()
public long writeRemaining()
public long readLimit()
public long writeLimit()
public ByteOrder byteOrder()
public boolean compareAndSwapFloat(long offset, float expected, float value) throws BufferOverflowException, IllegalArgumentException, IORuntimeException
offset
- to perform CASexpected
- valuevalue
- to setBufferOverflowException
IllegalArgumentException
IORuntimeException
public boolean compareAndSwapDouble(long offset, double expected, double value) throws BufferOverflowException, IllegalArgumentException, IORuntimeException
offset
- to perform CASexpected
- valuevalue
- to setBufferOverflowException
IllegalArgumentException
IORuntimeException
Copyright © 2015. All rights reserved.