Class Array

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    public class Array
    extends java.lang.Object
    implements java.lang.AutoCloseable
    Class representing a TileDB array object.

    An Array object represents array data in TileDB at some persisted location, e.g. on disk, in an S3 bucket, etc. Once an array has been opened for reading or writing, interact with the data through Query objects.

    Example:
     
       // Create an ArraySchema, add attributes, domain, etc.
       Context ctx = new Context();
       ArraySchema schema = new ArraySchema(...);
       // Create empty array named "my_array" on persistent storage.
       Array.create("my_array", schema);
     
     
    • Constructor Summary

      Constructors 
      Constructor Description
      Array​(Context ctx, java.lang.String uri)
      Constructs an Array object opening the array for reading.
      Array​(Context ctx, java.lang.String uri, QueryType query_type)
      Constructs an Array object, opening the array for the given query type.
      Array​(Context ctx, java.lang.String uri, QueryType query_type, EncryptionType encryption_type, byte[] key)
      Constructs an Array object, opening the encrypted array for the given query type.
    • Constructor Detail

      • Array

        public Array​(Context ctx,
                     java.lang.String uri)
              throws TileDBError
        Constructs an Array object opening the array for reading.
        Example:
         
           Context ctx = new Context();
           Array array new Array(ctx, "s3://bucket-name/array-name");
         
        Parameters:
        ctx - TileDB context
        uri - The array URI
        Throws:
        TileDBError - A TileDB exception
      • Array

        public Array​(Context ctx,
                     java.lang.String uri,
                     QueryType query_type)
              throws TileDBError
        Constructs an Array object, opening the array for the given query type.
        Example:
         
         Context ctx = new Context();
         Array array new Array(ctx, "s3://bucket-name/array-name", TILEDB_READ);
         
         
        Parameters:
        ctx - TileDB context
        uri - The array URI
        query_type - Query type to open the array for.
        Throws:
        TileDBError - A TileDB exception
      • Array

        public Array​(Context ctx,
                     java.lang.String uri,
                     QueryType query_type,
                     EncryptionType encryption_type,
                     byte[] key)
              throws TileDBError
        Constructs an Array object, opening the encrypted array for the given query type.
        Example:
         
         Context ctx = new Context();
         String key = "0123456789abcdeF0123456789abcdeF";
         Array array new Array(ctx, "s3://bucket-name/array-name",
                               TILEDB_READ,
                               TILEDB_AES_256_GCM,
                               key.getBytes(StandardCharsets.UTF_8));
         
         
        Parameters:
        ctx - TileDB context
        uri - The array URI
        query_type - Query type to open the array for
        encryption_type - The encryption type to use
        key - The encryption key to use
        Throws:
        TileDBError - A TileDB exception
    • Method Detail

      • consolidate

        public static void consolidate​(Context ctx,
                                       java.lang.String uri)
                                throws TileDBError
        Consolidates the fragments of an array into a single fragment.

        All queries to the array before consolidation must be finalized before consolidation can begin. Consolidation temporarily aquires an exclusive lock on the array when finalizing the resulting merged fragment.

        Example:
         
           Context ctx = new Context();
           Array.consolidate(ctx, "s3://bucket-name/array-name");
         
         
        Parameters:
        ctx - TileDB context object
        uri - TileDB URI string
        Throws:
        TileDBError - A TileDB exception
      • consolidate

        public static void consolidate​(Context ctx,
                                       java.lang.String uri,
                                       Config config)
                                throws TileDBError
        Consolidates the fragments of an array into a single fragment.

        All queries to the array before consolidation must be finalized before consolidation can begin. Consolidation temporarily aquires an exclusive lock on the array when finalizing the resulting merged fragment.

        Example:
         
           Context ctx = new Context();
           Array.consolidate(ctx, "s3://bucket-name/array-name");
         
         
        Parameters:
        ctx - TileDB context object
        uri - TileDB URI string
        config - A TileDB config object with configuration parameters for the consolidation
        Throws:
        TileDBError - A TileDB exception
      • consolidate

        public static void consolidate​(Context ctx,
                                       java.lang.String uri,
                                       EncryptionType encryption_type,
                                       byte[] key)
                                throws TileDBError
        Consolidates the fragments of an array into a single fragment.

        All queries to the array before consolidation must be finalized before consolidation can begin. Consolidation temporarily aquires an exclusive lock on the array when finalizing the resulting merged fragment.

        Example:
         
           Context ctx = new Context();
           String key = "0123456789abcdeF0123456789abcdeF";
           Array.consolidate(ctx, "s3://bucket-name/array-name",
                             TILEDB_AES_256_GCM,
                             key.getBytes(StandardCharsets.UTF_8));
         
         
        Parameters:
        ctx - A TileDB Context
        uri - URI string to TileDB array
        encryption_type - Encryption type the array is encrypted with
        key - A byte array key to decrypt array
        Throws:
        TileDBError
      • consolidate

        public static void consolidate​(Context ctx,
                                       java.lang.String uri,
                                       EncryptionType encryption_type,
                                       byte[] key,
                                       Config config)
                                throws TileDBError
        Consolidates the fragments of an array into a single fragment.

        All queries to the array before consolidation must be finalized before consolidation can begin. Consolidation temporarily aquires an exclusive lock on the array when finalizing the resulting merged fragment.

        Example:
         
           Context ctx = new Context();
           String key = "0123456789abcdeF0123456789abcdeF";
           Array.consolidate(ctx, "s3://bucket-name/array-name",
                             TILEDB_AES_256_GCM,
                             key.getBytes(StandardCharsets.UTF_8));
         
         
        Parameters:
        ctx - A TileDB Context
        uri - URI string to TileDB array
        encryption_type - Encryption type the array is encrypted with
        key - A byte array key to decrypt array
        config - A TileDB config object with configuration parameters for the consolidation
        Throws:
        TileDBError
      • exists

        public static boolean exists​(Context ctx,
                                     java.lang.String uri)
                              throws TileDBError
        Checks if a given URI is an existing TileDB array object
        Parameters:
        ctx - TileDB context object
        uri - TileDB URI array string
        Returns:
        true if the uri is an array object, false otherwise
        Throws:
        TileDBError
      • create

        public static void create​(java.lang.String uri,
                                  ArraySchema schema)
                           throws TileDBError
        Creates a persisted TileDB array given an input ArraySchema
        Example:
         
           Array.create("my_array", schema);
         
         
        Parameters:
        uri - The array URI string
        schema - The TileDB ArraySchema
        Throws:
        TileDBError - A TileDB exception
      • create

        public static void create​(java.lang.String uri,
                                  ArraySchema schema,
                                  EncryptionType encryption_type,
                                  byte[] key)
                           throws TileDBError
        Creates an encrypted persisted TileDBArray given input ArraySchema and encryption key
        Example:
         
           String key = "0123456789abcdeF0123456789abcdeF";
           Array.create("my_array", schema,
                        TILEDB_AES_256_GCM,
                        key.getBytes(StandardCharsets.UTF_8));
         
         
        Parameters:
        uri - The array URI string
        schema - The TileDB ArraySchema
        encryption_type - The encryption type to use
        key - The encryption key to use
        Throws:
        TileDBError - A TileDB exception
      • nonEmptyDomain

        public java.util.HashMap<java.lang.String,​Pair> nonEmptyDomain()
                                                                      throws TileDBError
        Get the non-empty domain of an array, returning the bounding coordinates for each dimension.
        Returns:
        A HashMap of dimension names and (lower, upper) inclusive bounding coordinate range pair. Empty HashMap if the array has no data.
        Throws:
        TileDBError - A TileDB exception
      • maxBufferElements

        public java.util.HashMap<java.lang.String,​Pair<java.lang.Long,​java.lang.Long>> maxBufferElements​(NativeArray subarray)
                                                                                                              throws TileDBError
        Compute an upper bound on the buffer elements needed to read a subarray.
        Parameters:
        subarray - Domain subarray
        Returns:
        The maximum number of elements for each array attribute. If the Array is sparse, max number of coordinates are also returned. Note that two numbers are returned per attribute. The first is the maximum number of elements in the offset buffer (0 for fixed-sized attributes and coordinates), the second is the maximum number of elements of the value buffer.
        Throws:
        TileDBError - A TileDB exception
      • getCtx

        public Context getCtx()
        Returns:
        The TileDB Context object associated with the Array instance.
      • getUri

        public java.lang.String getUri()
        Returns:
        The URI string of the array
      • getQueryType

        public QueryType getQueryType()
        Returns:
        The TileDB QueryType enum value that the Array instance.
      • close

        public void close()
        Free's the native objects and closes the Array.
        Specified by:
        close in interface java.lang.AutoCloseable