Package io.tiledb.java.api
Class NativeArray
- java.lang.Object
-
- io.tiledb.java.api.NativeArray
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public class NativeArray extends java.lang.Object implements java.lang.AutoCloseable
-
-
Constructor Summary
Constructors Modifier Constructor Description NativeArray(Context ctx, int size, Datatype nativeType)Creates an empty native array using a native datatype and a provided sizeNativeArray(Context ctx, int size, java.lang.Class javaType)Creates an empty native array using a java datatype and a provided sizeprotectedNativeArray(Context ctx, Datatype nativeType, SWIGTYPE_p_p_void pointer, int nelements)protectedNativeArray(Context ctx, Datatype nativeType, SWIGTYPE_p_void pointer, int nelements)NativeArray(Context ctx, java.lang.Object buffer, Datatype nativeType)Creates a native array using a native datatype.NativeArray(Context ctx, java.lang.Object buffer, Datatype nativeType, int size)Creates a native array using a native datatype.NativeArray(Context ctx, java.lang.Object buffer, java.lang.Class javaType)Creates a native array using a java datatype.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Free's NativeArray off heap allocated resourcesdoubleArraygetDoubleArray()floatArraygetFloatArray()int16_tArraygetInt16_tArray()int32_tArraygetInt32_tArray()int64_tArraygetInt64_tArray()int8_tArraygetInt8_tArray()java.lang.ObjectgetItem(int index)Returns the item on index position of the native array.java.lang.ClassgetJavaType()protected DatatypegetNativeType()intgetNativeTypeSize()longgetNBytes()intgetSize()uint16_tArraygetUint16_tArray()uint32_tArraygetUint32_tArray()int64_tArraygetUint64_tArray()uint8_tArraygetUint8_tArray()voidsetItem(int index, java.lang.Object value)Sets the item on index position of the native array.longtoCPointer()java.lang.ObjecttoJavaArray()Return a Java array (i.e.java.lang.ObjecttoJavaArray(int elements)Return a Java array (i.e.java.lang.ObjecttoJavaArray(int position, int elements)Return a Java array (i.e.java.lang.StringtoString()SWIGTYPE_p_voidtoVoidPointer()
-
-
-
Constructor Detail
-
NativeArray
public NativeArray(Context ctx, int size, Datatype nativeType) throws TileDBError
Creates an empty native array using a native datatype and a provided size- Parameters:
ctx- A TileDB contextsize- Number of array elementsnativeType- A TileDB datatype- Throws:
TileDBError- A TileDB exception
-
NativeArray
public NativeArray(Context ctx, int size, java.lang.Class javaType) throws TileDBError
Creates an empty native array using a java datatype and a provided size- Parameters:
ctx- A TileDB contextsize- Number of array elementsjavaType- A Java scalar type class- Throws:
TileDBError- A TileDB exception
-
NativeArray
public NativeArray(Context ctx, java.lang.Object buffer, java.lang.Class javaType) throws TileDBError
Creates a native array using a java datatype. It takes as input a Java buffer (i.e long[], int[]) and copies its values to the C native array.- Parameters:
ctx- A TileDB contextbuffer- A Java arrayjavaType- A Java scalar type class- Throws:
TileDBError- A TileDB exception
-
NativeArray
public NativeArray(Context ctx, java.lang.Object buffer, Datatype nativeType, int size) throws TileDBError
Creates a native array using a native datatype. It takes as input a Java buffer (i.e long[], int[]) and copies its values to the C native array.- Parameters:
ctx- A TileDB contextbuffer- A Java arraynativeType- A TileDB datatypesize- The array size- Throws:
TileDBError- A TileDB exception
-
NativeArray
public NativeArray(Context ctx, java.lang.Object buffer, Datatype nativeType) throws TileDBError
Creates a native array using a native datatype. It takes as input a Java buffer (i.e long[], int[]) and copies its values to the C native array.- Parameters:
ctx- A TileDB contextbuffer- A Java arraynativeType- A TileDB datatype- Throws:
TileDBError- A TileDB exception
-
NativeArray
protected NativeArray(Context ctx, Datatype nativeType, SWIGTYPE_p_p_void pointer, int nelements) throws TileDBError
- Throws:
TileDBError
-
NativeArray
protected NativeArray(Context ctx, Datatype nativeType, SWIGTYPE_p_void pointer, int nelements) throws TileDBError
- Throws:
TileDBError
-
-
Method Detail
-
getItem
public java.lang.Object getItem(int index) throws java.lang.ArrayIndexOutOfBoundsException, TileDBErrorReturns the item on index position of the native array.- Parameters:
index- Index of array scalar to return- Returns:
- item A Java scalar
- Throws:
TileDBError- A TileDB exceptionjava.lang.ArrayIndexOutOfBoundsException
-
setItem
public void setItem(int index, java.lang.Object value) throws java.lang.ArrayIndexOutOfBoundsException, TileDBErrorSets the item on index position of the native array.- Parameters:
index- array indexvalue- array value to set at index- Throws:
TileDBError- A TileDB exceptionjava.lang.ArrayIndexOutOfBoundsException
-
toVoidPointer
public SWIGTYPE_p_void toVoidPointer() throws TileDBError
- Throws:
TileDBError
-
toCPointer
public long toCPointer() throws TileDBError- Throws:
TileDBError
-
toJavaArray
public java.lang.Object toJavaArray() throws TileDBErrorReturn a Java array (i.e. int[], long[]) that is a copy of the entire native array- Returns:
- A java array
- Throws:
TileDBError- A TileDB exception
-
toJavaArray
public java.lang.Object toJavaArray(int elements) throws TileDBErrorReturn a Java array (i.e. int[], long[]) that is a copy of the native array values with the given size, starting at position 0- Parameters:
elements- number of elements to return- Returns:
- A java array
- Throws:
TileDBError- A TileDB exception
-
toJavaArray
public java.lang.Object toJavaArray(int position, int elements) throws TileDBErrorReturn a Java array (i.e. int[], long[]) that is a copy of the native array values with the given size, starting at given position- Parameters:
position- position to start copying fromelements- number of elements to return- Returns:
- A java array
- Throws:
TileDBError- A TileDB exception
-
getNativeType
protected Datatype getNativeType()
-
getJavaType
public java.lang.Class getJavaType()
-
getSize
public int getSize()
-
getNativeTypeSize
public int getNativeTypeSize()
-
getNBytes
public long getNBytes()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
close
public void close()
Free's NativeArray off heap allocated resources- Specified by:
closein interfacejava.lang.AutoCloseable
-
getFloatArray
public floatArray getFloatArray()
-
getDoubleArray
public doubleArray getDoubleArray()
-
getInt8_tArray
public int8_tArray getInt8_tArray()
-
getInt16_tArray
public int16_tArray getInt16_tArray()
-
getInt32_tArray
public int32_tArray getInt32_tArray()
-
getInt64_tArray
public int64_tArray getInt64_tArray()
-
getUint8_tArray
public uint8_tArray getUint8_tArray()
-
getUint16_tArray
public uint16_tArray getUint16_tArray()
-
getUint32_tArray
public uint32_tArray getUint32_tArray()
-
getUint64_tArray
public int64_tArray getUint64_tArray()
-
-