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 sizeprotected
NativeArray(Context ctx, Datatype nativeType, SWIGTYPE_p_p_void pointer, int nelements)
protected
NativeArray(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 void
close()
Free's NativeArray off heap allocated resourcesjava.lang.Object
getItem(int index)
Returns the item on index position of the native array.java.lang.Class
getJavaType()
protected Datatype
getNativeType()
int
getNativeTypeSize()
long
getNBytes()
int
getSize()
void
setItem(int index, java.lang.Object value)
Sets the item on index position of the native array.long
toCPointer()
java.lang.Object
toJavaArray()
Return a Java array (i.e.java.lang.Object
toJavaArray(int elements)
Return a Java array (i.e.java.lang.Object
toJavaArray(int position, int elements)
Return a Java array (i.e.SWIGTYPE_p_void
toVoidPointer()
-
-
-
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, TileDBError
Returns 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, TileDBError
Sets 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 TileDBError
Return 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 TileDBError
Return 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 TileDBError
Return 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()
-
close
public void close()
Free's NativeArray off heap allocated resources- Specified by:
close
in interfacejava.lang.AutoCloseable
-
-