Package org.nustaq.offheap.bytez.onheap
Class HeapBytez
java.lang.Object
org.nustaq.offheap.bytez.onheap.HeapBytez
- All Implemented Interfaces:
BasicBytez
,ByteSink
,ByteSource
,Bytez
,VolatileByteAccess
byte array abstraction based on heap byte arrays. FIXME: Should be moved to ordinary safe access as it really seems not to make
a big difference.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbyte[]
boolean
compareAndSwapInt
(long offset, int expect, int newVal) boolean
compareAndSwapLong
(long offset, long expect, long newVal) void
copyTo
(BasicBytez other, long otherByteIndex, long myByteIndex, long lenBytes) boolean
byte
get
(long byteIndex) void
getArr
(long byteIndex, byte[] target, int elemoff, int numElems) copy to a byte arrayint
int
byte[]
getBase()
boolean
getBool
(long byteIndex) void
getBooleanArr
(long byteIndex, boolean[] target, int elemoff, int numElems) see getArrboolean
getBoolVolatile
(long byteIndex) char
getChar
(long byteIndex) void
getCharArr
(long byteIndex, char[] target, int elemoff, int numElems) see getArrchar
getCharVolatile
(long byteIndex) double
getDouble
(long byteIndex) void
getDoubleArr
(long byteIndex, double[] target, int elemoff, int numElems) see getArrdouble
getDoubleVolatile
(long byteIndex) float
getFloat
(long byteIndex) void
getFloatArr
(long byteIndex, float[] target, int elemoff, int numElems) see getArrfloat
getFloatVolatile
(long byteIndex) int
getInt
(long byteIndex) void
getIntArr
(long byteIndex, int[] target, int elemoff, int numElems) see getArrint
getIntVolatile
(long byteIndex) long
getLong
(long byteIndex) void
getLongArr
(long byteIndex, long[] target, int elemoff, int numElems) see getArrlong
getLongVolatile
(long byteIndex) long
getOff()
long
short
getShort
(long byteIndex) void
getShortArr
(long byteIndex, short[] target, int elemoff, int numElems) see getArrshort
getShortVolatile
(long byteIndex) byte
getVolatile
(long byteIndex) int
hashCode()
long
length()
newInstance
(long size) void
put
(long byteIndex, byte value) void
putBool
(long byteIndex, boolean val) void
putBoolVolatile
(long byteIndex, boolean value) void
putChar
(long byteIndex, char c) void
putCharVolatile
(long byteIndex, char c) void
putDouble
(long byteIndex, double d) void
putDoubleVolatile
(long byteIndex, double d) void
putFloat
(long byteIndex, float f) void
putFloatVolatile
(long byteIndex, float f) void
putInt
(long byteIndex, int i) void
putIntVolatile
(long byteIndex, int i) void
putLong
(long byteIndex, long l) void
putLongVolatile
(long byteIndex, long l) void
putShort
(long byteIndex, short s) void
putShortVolatile
(long byteIndex, short s) void
putVolatile
(long byteIndex, byte value) void
set
(long byteIndex, byte[] source, int elemoff, int numElems) void
setBase
(byte[] base, long offIndex, long len) void
setBoolean
(long byteIndex, boolean[] o, int elemoff, int numElems) void
setChar
(long byteIndex, char[] source, int elemoff, int numElems) void
setDouble
(long byteIndex, double[] source, int elemoff, int numElems) void
setFloat
(long byteIndex, float[] source, int elemoff, int numElems) void
setInt
(long byteIndex, int[] source, int elemoff, int numElems) void
setLong
(long byteIndex, long[] source, int elemoff, int numElems) void
setShort
(long byteIndex, short[] source, int elemoff, int numElems) slice
(long off, int len) byte[]
toBytes
(long startIndex, int len) toString()
-
Constructor Details
-
HeapBytez
public HeapBytez(byte[] base) -
HeapBytez
public HeapBytez(int size) -
HeapBytez
public HeapBytez(byte[] base, long offIndex) -
HeapBytez
public HeapBytez(byte[] base, long offIndex, long len)
-
-
Method Details
-
setBase
public void setBase(byte[] base, long offIndex, long len) -
slice
-
get
public byte get(long byteIndex) - Specified by:
get
in interfaceBasicBytez
- Specified by:
get
in interfaceByteSource
-
getBool
public boolean getBool(long byteIndex) - Specified by:
getBool
in interfaceBasicBytez
-
getChar
public char getChar(long byteIndex) - Specified by:
getChar
in interfaceBasicBytez
-
getShort
public short getShort(long byteIndex) - Specified by:
getShort
in interfaceBasicBytez
-
getInt
public int getInt(long byteIndex) - Specified by:
getInt
in interfaceBasicBytez
-
getLong
public long getLong(long byteIndex) - Specified by:
getLong
in interfaceBasicBytez
-
getFloat
public float getFloat(long byteIndex) - Specified by:
getFloat
in interfaceBasicBytez
-
getDouble
public double getDouble(long byteIndex) - Specified by:
getDouble
in interfaceBasicBytez
-
put
public void put(long byteIndex, byte value) - Specified by:
put
in interfaceBasicBytez
- Specified by:
put
in interfaceByteSink
-
putBool
public void putBool(long byteIndex, boolean val) - Specified by:
putBool
in interfaceBasicBytez
-
putChar
public void putChar(long byteIndex, char c) - Specified by:
putChar
in interfaceBasicBytez
-
putShort
public void putShort(long byteIndex, short s) - Specified by:
putShort
in interfaceBasicBytez
-
putInt
public void putInt(long byteIndex, int i) - Specified by:
putInt
in interfaceBasicBytez
-
putLong
public void putLong(long byteIndex, long l) - Specified by:
putLong
in interfaceBasicBytez
-
putFloat
public void putFloat(long byteIndex, float f) - Specified by:
putFloat
in interfaceBasicBytez
-
putDouble
public void putDouble(long byteIndex, double d) - Specified by:
putDouble
in interfaceBasicBytez
-
length
public long length()- Specified by:
length
in interfaceBasicBytez
- Specified by:
length
in interfaceByteSink
- Specified by:
length
in interfaceByteSource
-
getArr
public void getArr(long byteIndex, byte[] target, int elemoff, int numElems) Description copied from interface:BasicBytez
copy to a byte array- Specified by:
getArr
in interfaceBasicBytez
- Parameters:
byteIndex
- - offset index in this buffer to start copyingtarget
- - array to copy toelemoff
- - offset in target arraynumElems
- - length to copy to
-
getCharArr
public void getCharArr(long byteIndex, char[] target, int elemoff, int numElems) Description copied from interface:BasicBytez
see getArr- Specified by:
getCharArr
in interfaceBasicBytez
-
getShortArr
public void getShortArr(long byteIndex, short[] target, int elemoff, int numElems) Description copied from interface:BasicBytez
see getArr- Specified by:
getShortArr
in interfaceBasicBytez
-
getIntArr
public void getIntArr(long byteIndex, int[] target, int elemoff, int numElems) Description copied from interface:BasicBytez
see getArr- Specified by:
getIntArr
in interfaceBasicBytez
-
getLongArr
public void getLongArr(long byteIndex, long[] target, int elemoff, int numElems) Description copied from interface:BasicBytez
see getArr- Specified by:
getLongArr
in interfaceBasicBytez
-
getFloatArr
public void getFloatArr(long byteIndex, float[] target, int elemoff, int numElems) Description copied from interface:BasicBytez
see getArr- Specified by:
getFloatArr
in interfaceBasicBytez
-
getDoubleArr
public void getDoubleArr(long byteIndex, double[] target, int elemoff, int numElems) Description copied from interface:BasicBytez
see getArr- Specified by:
getDoubleArr
in interfaceBasicBytez
-
getBooleanArr
public void getBooleanArr(long byteIndex, boolean[] target, int elemoff, int numElems) Description copied from interface:BasicBytez
see getArr- Specified by:
getBooleanArr
in interfaceBasicBytez
-
set
public void set(long byteIndex, byte[] source, int elemoff, int numElems) - Specified by:
set
in interfaceBasicBytez
-
setChar
public void setChar(long byteIndex, char[] source, int elemoff, int numElems) - Specified by:
setChar
in interfaceBasicBytez
-
setShort
public void setShort(long byteIndex, short[] source, int elemoff, int numElems) - Specified by:
setShort
in interfaceBasicBytez
-
setInt
public void setInt(long byteIndex, int[] source, int elemoff, int numElems) - Specified by:
setInt
in interfaceBasicBytez
-
setLong
public void setLong(long byteIndex, long[] source, int elemoff, int numElems) - Specified by:
setLong
in interfaceBasicBytez
-
setFloat
public void setFloat(long byteIndex, float[] source, int elemoff, int numElems) - Specified by:
setFloat
in interfaceBasicBytez
-
setDouble
public void setDouble(long byteIndex, double[] source, int elemoff, int numElems) - Specified by:
setDouble
in interfaceBasicBytez
-
setBoolean
public void setBoolean(long byteIndex, boolean[] o, int elemoff, int numElems) - Specified by:
setBoolean
in interfaceBasicBytez
-
copyTo
- Specified by:
copyTo
in interfaceBasicBytez
- Specified by:
copyTo
in interfaceByteSink
-
newInstance
- Specified by:
newInstance
in interfaceBasicBytez
-
compareAndSwapInt
public boolean compareAndSwapInt(long offset, int expect, int newVal) - Specified by:
compareAndSwapInt
in interfaceBytez
-
compareAndSwapLong
public boolean compareAndSwapLong(long offset, long expect, long newVal) - Specified by:
compareAndSwapLong
in interfaceBytez
-
toBytes
public byte[] toBytes(long startIndex, int len) -
asByteArray
public byte[] asByteArray()- Specified by:
asByteArray
in interfaceBytez
- Returns:
- return the underlying byte array, not supported by MallocBytez !. Use getArr to extract data by copy instead.
-
getBAOffsetIndex
public int getBAOffsetIndex()- Specified by:
getBAOffsetIndex
in interfaceBytez
- Returns:
- the start index inside the byte array returned by asByteArray, not supported by MallocBytez
-
getBALength
public int getBALength()- Specified by:
getBALength
in interfaceBytez
- Returns:
- the length inside the byte array returned by asByteArray, not supported by MallocBytez
-
hashCode
public int hashCode() -
equals
-
getBoolVolatile
public boolean getBoolVolatile(long byteIndex) - Specified by:
getBoolVolatile
in interfaceVolatileByteAccess
-
getVolatile
public byte getVolatile(long byteIndex) - Specified by:
getVolatile
in interfaceVolatileByteAccess
-
getCharVolatile
public char getCharVolatile(long byteIndex) - Specified by:
getCharVolatile
in interfaceVolatileByteAccess
-
getShortVolatile
public short getShortVolatile(long byteIndex) - Specified by:
getShortVolatile
in interfaceVolatileByteAccess
-
getIntVolatile
public int getIntVolatile(long byteIndex) - Specified by:
getIntVolatile
in interfaceVolatileByteAccess
-
getLongVolatile
public long getLongVolatile(long byteIndex) - Specified by:
getLongVolatile
in interfaceVolatileByteAccess
-
getFloatVolatile
public float getFloatVolatile(long byteIndex) - Specified by:
getFloatVolatile
in interfaceVolatileByteAccess
-
getDoubleVolatile
public double getDoubleVolatile(long byteIndex) - Specified by:
getDoubleVolatile
in interfaceVolatileByteAccess
-
putBoolVolatile
public void putBoolVolatile(long byteIndex, boolean value) - Specified by:
putBoolVolatile
in interfaceVolatileByteAccess
-
putVolatile
public void putVolatile(long byteIndex, byte value) - Specified by:
putVolatile
in interfaceVolatileByteAccess
-
putCharVolatile
public void putCharVolatile(long byteIndex, char c) - Specified by:
putCharVolatile
in interfaceVolatileByteAccess
-
putShortVolatile
public void putShortVolatile(long byteIndex, short s) - Specified by:
putShortVolatile
in interfaceVolatileByteAccess
-
putIntVolatile
public void putIntVolatile(long byteIndex, int i) - Specified by:
putIntVolatile
in interfaceVolatileByteAccess
-
putLongVolatile
public void putLongVolatile(long byteIndex, long l) - Specified by:
putLongVolatile
in interfaceVolatileByteAccess
-
putFloatVolatile
public void putFloatVolatile(long byteIndex, float f) - Specified by:
putFloatVolatile
in interfaceVolatileByteAccess
-
putDoubleVolatile
public void putDoubleVolatile(long byteIndex, double d) - Specified by:
putDoubleVolatile
in interfaceVolatileByteAccess
-
getBase
public byte[] getBase() -
getOff
public long getOff()- Returns:
- offset to byte array INCLUDING native bytearray header
-
getOffsetIndex
public long getOffsetIndex()- Returns:
- offset to byte array EXCLUDING native bytearray header
-
toString
-