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 resourcesdoubleArray
getDoubleArray()
floatArray
getFloatArray()
int16_tArray
getInt16_tArray()
int32_tArray
getInt32_tArray()
int64_tArray
getInt64_tArray()
int8_tArray
getInt8_tArray()
java.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()
uint16_tArray
getUint16_tArray()
uint32_tArray
getUint32_tArray()
int64_tArray
getUint64_tArray()
uint8_tArray
getUint8_tArray()
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.java.lang.String
toString()
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()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
close
public void close()
Free's NativeArray off heap allocated resources- Specified by:
close
in 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()
-
-