Class Query

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    public class Query
    extends java.lang.Object
    implements java.lang.AutoCloseable
    Construct and execute read/write queries on a TileDB Array.

    Example:

    
     Query query = new Query(my_dense_array, TILEDB_WRITE);
     query.setLayout(TILEDB_GLOBAL_ORDER);
     query.setBuffer("a1", a1_data);
     NativeArray a1_data = new NativeArray(ctx, new int[] {1,2,3,4}, Integer.class);
     query.setBuffer("a1", a1_data);
     query.submit();
     
    • Method Detail

      • setLayout

        public Query setLayout​(Layout layout)
                        throws TileDBError
        Sets the data layout of the buffers.
        Parameters:
        layout - The layout order to be set.
        Throws:
        TileDBError - A TileDB exception
      • submit

        public QueryStatus submit()
                           throws TileDBError
        Submits the query. Call will block until query is complete.
        Returns:
        The query Status.
        Throws:
        TileDBError - A TileDB exception
      • submitAsync

        public void submitAsync()
                         throws TileDBError
        Submit an async query (non-blocking).
        Throws:
        TileDBError - A TileDB exception
      • submitAsync

        public void submitAsync​(Callback callback)
                         throws TileDBError
        Submit an async query, with callback.
        Parameters:
        callback - Callback function.
        Throws:
        TileDBError - A TileDB exception
      • setSubarray

        public Query setSubarray​(NativeArray subarray)
                          throws TileDBError
        Sets a subarray, defined in the order dimensions were added. Coordinates are inclusive.
        Parameters:
        subarray - The targeted subarray.
        Throws:
        TileDBError - A TileDB exception
      • setBuffer

        public Query setBuffer​(java.lang.String attr,
                               NativeArray buffer)
                        throws TileDBError
        Sets a buffer for a fixed-sized attribute.
        Parameters:
        attr - The attribute name.
        buffer - NativeBuffer to be used for the attribute values.
        Throws:
        TileDBError - A TileDB exception
      • setBuffer

        public Query setBuffer​(java.lang.String attr,
                               NativeArray offsets,
                               NativeArray buffer)
                        throws TileDBError
        Sets a buffer for a variable-sized getAttribute.
        Parameters:
        attr - Attribute name
        offsets - Offsets where a new element begins in the data buffer.
        buffer - Buffer vector with elements of the attribute type.
        Throws:
        TileDBError - A TileDB exception
      • setCoordinates

        public Query setCoordinates​(NativeArray buffer)
                             throws TileDBError
        Set the coordinate buffer
        Parameters:
        buffer - A NativeArray to be used for the coordinates.
        Throws:
        TileDBError - A TileDB exception
      • getCoordinates

        public java.lang.Object getCoordinates()
                                        throws TileDBError
        Get the coordinate result buffer
        Returns:
        The query result coordinate buffer.
        Throws:
        TileDBError - A TileDB exception
      • resultBufferElements

        public java.util.HashMap<java.lang.String,​Pair<java.lang.Long,​java.lang.Long>> resultBufferElements()
                                                                                                                 throws TileDBError
        Returns:
        The number of elements in the result buffers. This is a map from the attribute name to a pair of values.

        The first is number of elements for var size attributes, and the second is number of elements in the data buffer. For fixed sized attributes (and coordinates), the first is always 0.

        Throws:
        TileDBError - A TileDB exception
      • resetBuffers

        public void resetBuffers()
        Clears all attribute buffers.
      • resetBufferSizes

        public void resetBufferSizes()
        Resets all attribute buffer sizes to zero
      • getBuffer

        public java.lang.Object getBuffer​(java.lang.String attr)
                                   throws TileDBError
        Return a Java primitive array object as a copy of the attribute buffer
        Parameters:
        attr - attribute name
        Returns:
        A Java array
        Throws:
        TileDBError - A TileDB exception
      • getVarBuffer

        public long[] getVarBuffer​(java.lang.String attr)
                            throws TileDBError
        Return an array containing offsets for a variable attribute buffer
        Parameters:
        attr - attribute name
        Returns:
        A Java long[] array
        Throws:
        TileDBError - A TileDB exception
      • finalizeQuery

        public Query finalizeQuery()
                            throws TileDBError
        Flushes all internal state of a query object and finalizes the query. This is applicable only to global layout writes. It has no effect for any other query type.
        Returns:
        Finalized query instance
        Throws:
        TileDBError - A TileDB excdeption
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • close

        public void close()
        Free's native TileDB resources associated with the Query object
        Specified by:
        close in interface java.lang.AutoCloseable