Class NativeArray

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    public class NativeArray
    extends java.lang.Object
    implements java.lang.AutoCloseable
    • 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 context
        size - Number of array elements
        nativeType - 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 context
        size - Number of array elements
        javaType - 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 context
        buffer - A Java array
        javaType - 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 context
        buffer - A Java array
        nativeType - A TileDB datatype
        size - 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 context
        buffer - A Java array
        nativeType - A TileDB datatype
        Throws:
        TileDBError - A TileDB exception
    • 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 exception
        java.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 index
        value - array value to set at index
        Throws:
        TileDBError - A TileDB exception
        java.lang.ArrayIndexOutOfBoundsException
      • 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 from
        elements - 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 interface java.lang.AutoCloseable