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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbyte[]booleancompareAndSwapInt(long offset, int expect, int newVal) booleancompareAndSwapLong(long offset, long expect, long newVal) voidcopyTo(BasicBytez other, long otherByteIndex, long myByteIndex, long lenBytes) booleanbyteget(long byteIndex) voidgetArr(long byteIndex, byte[] target, int elemoff, int numElems) copy to a byte arrayintintbyte[]getBase()booleangetBool(long byteIndex) voidgetBooleanArr(long byteIndex, boolean[] target, int elemoff, int numElems) see getArrbooleangetBoolVolatile(long byteIndex) chargetChar(long byteIndex) voidgetCharArr(long byteIndex, char[] target, int elemoff, int numElems) see getArrchargetCharVolatile(long byteIndex) doublegetDouble(long byteIndex) voidgetDoubleArr(long byteIndex, double[] target, int elemoff, int numElems) see getArrdoublegetDoubleVolatile(long byteIndex) floatgetFloat(long byteIndex) voidgetFloatArr(long byteIndex, float[] target, int elemoff, int numElems) see getArrfloatgetFloatVolatile(long byteIndex) intgetInt(long byteIndex) voidgetIntArr(long byteIndex, int[] target, int elemoff, int numElems) see getArrintgetIntVolatile(long byteIndex) longgetLong(long byteIndex) voidgetLongArr(long byteIndex, long[] target, int elemoff, int numElems) see getArrlonggetLongVolatile(long byteIndex) longgetOff()longshortgetShort(long byteIndex) voidgetShortArr(long byteIndex, short[] target, int elemoff, int numElems) see getArrshortgetShortVolatile(long byteIndex) bytegetVolatile(long byteIndex) inthashCode()longlength()newInstance(long size) voidput(long byteIndex, byte value) voidputBool(long byteIndex, boolean val) voidputBoolVolatile(long byteIndex, boolean value) voidputChar(long byteIndex, char c) voidputCharVolatile(long byteIndex, char c) voidputDouble(long byteIndex, double d) voidputDoubleVolatile(long byteIndex, double d) voidputFloat(long byteIndex, float f) voidputFloatVolatile(long byteIndex, float f) voidputInt(long byteIndex, int i) voidputIntVolatile(long byteIndex, int i) voidputLong(long byteIndex, long l) voidputLongVolatile(long byteIndex, long l) voidputShort(long byteIndex, short s) voidputShortVolatile(long byteIndex, short s) voidputVolatile(long byteIndex, byte value) voidset(long byteIndex, byte[] source, int elemoff, int numElems) voidsetBase(byte[] base, long offIndex, long len) voidsetBoolean(long byteIndex, boolean[] o, int elemoff, int numElems) voidsetChar(long byteIndex, char[] source, int elemoff, int numElems) voidsetDouble(long byteIndex, double[] source, int elemoff, int numElems) voidsetFloat(long byteIndex, float[] source, int elemoff, int numElems) voidsetInt(long byteIndex, int[] source, int elemoff, int numElems) voidsetLong(long byteIndex, long[] source, int elemoff, int numElems) voidsetShort(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:
getin interfaceBasicBytez- Specified by:
getin interfaceByteSource
-
getBool
public boolean getBool(long byteIndex) - Specified by:
getBoolin interfaceBasicBytez
-
getChar
public char getChar(long byteIndex) - Specified by:
getCharin interfaceBasicBytez
-
getShort
public short getShort(long byteIndex) - Specified by:
getShortin interfaceBasicBytez
-
getInt
public int getInt(long byteIndex) - Specified by:
getIntin interfaceBasicBytez
-
getLong
public long getLong(long byteIndex) - Specified by:
getLongin interfaceBasicBytez
-
getFloat
public float getFloat(long byteIndex) - Specified by:
getFloatin interfaceBasicBytez
-
getDouble
public double getDouble(long byteIndex) - Specified by:
getDoublein interfaceBasicBytez
-
put
public void put(long byteIndex, byte value) - Specified by:
putin interfaceBasicBytez- Specified by:
putin interfaceByteSink
-
putBool
public void putBool(long byteIndex, boolean val) - Specified by:
putBoolin interfaceBasicBytez
-
putChar
public void putChar(long byteIndex, char c) - Specified by:
putCharin interfaceBasicBytez
-
putShort
public void putShort(long byteIndex, short s) - Specified by:
putShortin interfaceBasicBytez
-
putInt
public void putInt(long byteIndex, int i) - Specified by:
putIntin interfaceBasicBytez
-
putLong
public void putLong(long byteIndex, long l) - Specified by:
putLongin interfaceBasicBytez
-
putFloat
public void putFloat(long byteIndex, float f) - Specified by:
putFloatin interfaceBasicBytez
-
putDouble
public void putDouble(long byteIndex, double d) - Specified by:
putDoublein interfaceBasicBytez
-
length
public long length()- Specified by:
lengthin interfaceBasicBytez- Specified by:
lengthin interfaceByteSink- Specified by:
lengthin interfaceByteSource
-
getArr
public void getArr(long byteIndex, byte[] target, int elemoff, int numElems) Description copied from interface:BasicBytezcopy to a byte array- Specified by:
getArrin 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:BasicBytezsee getArr- Specified by:
getCharArrin interfaceBasicBytez
-
getShortArr
public void getShortArr(long byteIndex, short[] target, int elemoff, int numElems) Description copied from interface:BasicBytezsee getArr- Specified by:
getShortArrin interfaceBasicBytez
-
getIntArr
public void getIntArr(long byteIndex, int[] target, int elemoff, int numElems) Description copied from interface:BasicBytezsee getArr- Specified by:
getIntArrin interfaceBasicBytez
-
getLongArr
public void getLongArr(long byteIndex, long[] target, int elemoff, int numElems) Description copied from interface:BasicBytezsee getArr- Specified by:
getLongArrin interfaceBasicBytez
-
getFloatArr
public void getFloatArr(long byteIndex, float[] target, int elemoff, int numElems) Description copied from interface:BasicBytezsee getArr- Specified by:
getFloatArrin interfaceBasicBytez
-
getDoubleArr
public void getDoubleArr(long byteIndex, double[] target, int elemoff, int numElems) Description copied from interface:BasicBytezsee getArr- Specified by:
getDoubleArrin interfaceBasicBytez
-
getBooleanArr
public void getBooleanArr(long byteIndex, boolean[] target, int elemoff, int numElems) Description copied from interface:BasicBytezsee getArr- Specified by:
getBooleanArrin interfaceBasicBytez
-
set
public void set(long byteIndex, byte[] source, int elemoff, int numElems) - Specified by:
setin interfaceBasicBytez
-
setChar
public void setChar(long byteIndex, char[] source, int elemoff, int numElems) - Specified by:
setCharin interfaceBasicBytez
-
setShort
public void setShort(long byteIndex, short[] source, int elemoff, int numElems) - Specified by:
setShortin interfaceBasicBytez
-
setInt
public void setInt(long byteIndex, int[] source, int elemoff, int numElems) - Specified by:
setIntin interfaceBasicBytez
-
setLong
public void setLong(long byteIndex, long[] source, int elemoff, int numElems) - Specified by:
setLongin interfaceBasicBytez
-
setFloat
public void setFloat(long byteIndex, float[] source, int elemoff, int numElems) - Specified by:
setFloatin interfaceBasicBytez
-
setDouble
public void setDouble(long byteIndex, double[] source, int elemoff, int numElems) - Specified by:
setDoublein interfaceBasicBytez
-
setBoolean
public void setBoolean(long byteIndex, boolean[] o, int elemoff, int numElems) - Specified by:
setBooleanin interfaceBasicBytez
-
copyTo
- Specified by:
copyToin interfaceBasicBytez- Specified by:
copyToin interfaceByteSink
-
newInstance
- Specified by:
newInstancein interfaceBasicBytez
-
compareAndSwapInt
public boolean compareAndSwapInt(long offset, int expect, int newVal) - Specified by:
compareAndSwapIntin interfaceBytez
-
compareAndSwapLong
public boolean compareAndSwapLong(long offset, long expect, long newVal) - Specified by:
compareAndSwapLongin interfaceBytez
-
toBytes
public byte[] toBytes(long startIndex, int len) -
asByteArray
public byte[] asByteArray()- Specified by:
asByteArrayin 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:
getBAOffsetIndexin interfaceBytez- Returns:
- the start index inside the byte array returned by asByteArray, not supported by MallocBytez
-
getBALength
public int getBALength()- Specified by:
getBALengthin 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:
getBoolVolatilein interfaceVolatileByteAccess
-
getVolatile
public byte getVolatile(long byteIndex) - Specified by:
getVolatilein interfaceVolatileByteAccess
-
getCharVolatile
public char getCharVolatile(long byteIndex) - Specified by:
getCharVolatilein interfaceVolatileByteAccess
-
getShortVolatile
public short getShortVolatile(long byteIndex) - Specified by:
getShortVolatilein interfaceVolatileByteAccess
-
getIntVolatile
public int getIntVolatile(long byteIndex) - Specified by:
getIntVolatilein interfaceVolatileByteAccess
-
getLongVolatile
public long getLongVolatile(long byteIndex) - Specified by:
getLongVolatilein interfaceVolatileByteAccess
-
getFloatVolatile
public float getFloatVolatile(long byteIndex) - Specified by:
getFloatVolatilein interfaceVolatileByteAccess
-
getDoubleVolatile
public double getDoubleVolatile(long byteIndex) - Specified by:
getDoubleVolatilein interfaceVolatileByteAccess
-
putBoolVolatile
public void putBoolVolatile(long byteIndex, boolean value) - Specified by:
putBoolVolatilein interfaceVolatileByteAccess
-
putVolatile
public void putVolatile(long byteIndex, byte value) - Specified by:
putVolatilein interfaceVolatileByteAccess
-
putCharVolatile
public void putCharVolatile(long byteIndex, char c) - Specified by:
putCharVolatilein interfaceVolatileByteAccess
-
putShortVolatile
public void putShortVolatile(long byteIndex, short s) - Specified by:
putShortVolatilein interfaceVolatileByteAccess
-
putIntVolatile
public void putIntVolatile(long byteIndex, int i) - Specified by:
putIntVolatilein interfaceVolatileByteAccess
-
putLongVolatile
public void putLongVolatile(long byteIndex, long l) - Specified by:
putLongVolatilein interfaceVolatileByteAccess
-
putFloatVolatile
public void putFloatVolatile(long byteIndex, float f) - Specified by:
putFloatVolatilein interfaceVolatileByteAccess
-
putDoubleVolatile
public void putDoubleVolatile(long byteIndex, double d) - Specified by:
putDoubleVolatilein 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
-