Class ArraySchema

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    public class ArraySchema
    extends java.lang.Object
    implements java.lang.AutoCloseable
    Array schema describing an array.

    The ArraySchema is an independent description of an array. A schema can be used to create multiple array's, and stores information about its domain, cell types, and compression details. An array schema is composed of:

    • A Domain
    • A set of Attributes
    • Memory layout definitions: tile and cell
    • Compression details for Array level factors like offsets and coordinates
    Example:
    
     Context ctx = new Context();
     ArraySchema schema = new ArraySchema(ctx, TILEDB_SPARSE);
    
     // Create a Domain
     Domain<Integer> domain = new Domain<Integer>(ctx);
    
     // Create Attribute
     Attribute<Integer> a1 = new Attribute<Integer>(ctx, "a1", Integer.class);
    
     schema.setDomain(domain);
     schema.addAttribute(a1);
    
     // Specify tile memory layout
     schema.setTileOrder(TILEDB_GLOBAL_ORDER);
    
     // Specify cell memory layout within each tile
     schema.setCellOrder(TILEDB_GLOBAL_ORDER);
     schema.setCapacity(10); // For sparse, set capacity of each tile
    
     // Make array with schema
     Array my_dense_array = new Array(ctx, "my_array", schema);
    
     // Load schema from array
     ArraySchema s = ArraySchema(ctx, "my_array"); // Load schema from array
     
    • Constructor Detail

      • ArraySchema

        public ArraySchema​(Context ctx,
                           ArrayType type)
                    throws TileDBError
        Creates a new TileDB ArraySchema object
        Example:
         
           Context ctx = new Context();
           ArraySchema schema = new ArraySchema(ctx, TILEDB_SPARSE);
         
         
        Parameters:
        ctx - TileDB context
        type - Array type, sparse or dense
        Throws:
        TileDBError - A TileDB exception
      • ArraySchema

        public ArraySchema​(Context ctx,
                           java.lang.String uri)
                    throws TileDBError
        Loads the ArraySchema of an existing array with the given URI string.
        Example:
         
           Context ctx = new Context();
           ArraySchema schema = new ArraySchema(ctx, "s3://bucket-name/array-name");
         
         
        Parameters:
        ctx - TileDB context
        uri - URI string of array
        Throws:
        TileDBError - A TileDB exception
      • ArraySchema

        public ArraySchema​(Context ctx,
                           java.lang.String uri,
                           EncryptionType encryption_type,
                           byte[] key)
                    throws TileDBError
        Loads the encrypted ArraySchema of an existing array with the given URI string.
        Example:
         
           Context ctx = new Context();
           String key = "0123456789abcdeF0123456789abcdeF";
           ArraySchema schema = new ArraySchema(ctx, "s3://bucket-name/array-name"
                                                TILEDB_AES_GCM_256,
                                                key.getBytes(StandardCharsets.UTF_8));
         
         
        Parameters:
        ctx - TileDB context
        uri - URI of TileDB Array
        encryption_type - Encryption type of the array schema
        key - Encryption key used to decrypt the array schema
        Throws:
        TileDBError - A TileDB exception
    • Method Detail

      • dump

        public void dump()
                  throws TileDBError
        Dumps the array schema in an ASCII representation to STDOUT.
        Throws:
        TileDBError - A TileDB exception
      • dump

        public void dump​(java.lang.String filename)
                  throws TileDBError
        Dumps the array schema text representation to a file.
        Parameters:
        filename - The local file path to save the schema text representation
        Throws:
        TileDBError - A TileDB exception
      • getArrayType

        public ArrayType getArrayType()
                               throws TileDBError
        Returns the type of the TileDB Array
        Returns:
        ArrayType enum value
        Throws:
        TileDBError - A TileDB exception
      • isSparse

        public boolean isSparse()
                         throws TileDBError
        Returns true if the array schema describes a sparse array
        Returns:
        true if the ArrayType is TILEDB_SPARSE
        Throws:
        TileDBError - A TileDB exception
      • getCapacity

        public long getCapacity()
                         throws TileDBError
        Returns the tile capacity for the array. The tile capacity is associated with the array schema.
        Returns:
        The ArraySchema tile capacity
        Throws:
        TileDBError - A TileDB exception
      • setCapacity

        public void setCapacity​(long capacity)
                         throws TileDBError
        Sets the tile capacity.
        Parameters:
        capacity - Capacity value to set
        Throws:
        TileDBError - A TileDB exception
      • setCapacity

        public void setCapacity​(java.math.BigInteger capacity)
                         throws TileDBError
        Sets the tile capacity.
        Parameters:
        capacity - value to set
        Throws:
        TileDBError - A T
      • getTileOrder

        public Layout getTileOrder()
                            throws TileDBError
        Returns the tile layout order.
        Returns:
        The Layout order
        Throws:
        TileDBError - A TileDB exception
      • getCellOrder

        public Layout getCellOrder()
                            throws TileDBError
        Returns the cell layout for the array schema.
        Returns:
        cell Layout order
        Throws:
        TileDBError - A TileDB exception
      • setCellOrder

        public ArraySchema setCellOrder​(Layout layout)
                                 throws TileDBError
        Sets the cell order for the array schema.
        Parameters:
        layout - cell Layout order
        Throws:
        TileDBError - A TileDB exception
      • setDomain

        public void setDomain​(Domain domain)
                       throws TileDBError
        Sets the array Domain.
        Example:
         
           Context ctx = new Context();
           ArraySchema schema = new ArraySchema(ctx, TILEDB_SPARSE);
           // Create a Domain
           Domain domain = new Domain(ctx);
           domain.addDimension(...);
           schema.setDomain(domain);
         
        Parameters:
        domain - Domain to use
        Throws:
        TileDBError - A TileDB exception
      • addAttribute

        public void addAttribute​(Attribute attr)
                          throws TileDBError
        Adds an Attribute to the array.
        Example:
         
           Context ctx = new Context();
           ArraySchema schema = new ArraySchema(ctx, TILEDB_SPARSE);
           Attribute attr = new Attribute(ctx, "a", Integer.class);
           schema.addAttribute(attr);
         
        Parameters:
        attr - The Attribute to add
        Throws:
        TileDBError - A TileDB exception
      • check

        public void check()
                   throws TileDBError
        Validates the schema, throws a TileDBError if the ArraySchema is invalid.
        Throws:
        TileDBError - A TileDB exception
      • getAttributes

        public java.util.HashMap<java.lang.String,​Attribute> getAttributes()
                                                                          throws TileDBError
        Get all Attributes of the array.
        Returns:
        HashMap of attribute names along with the corresponding Attribute objects.
        Throws:
        TileDBError - A TileDB exception
      • getAttributeNum

        public long getAttributeNum()
                             throws TileDBError
        Returns:
        The number of attributes of the array.
        Throws:
        TileDBError - A TileDB exception
      • hasAttribute

        public boolean hasAttribute​(java.lang.String name)
                             throws TileDBError
        Checks if the ArraySchema has the given attribute with name
        Parameters:
        name - The name of the attribute
        Returns:
        True if the array schema has an attribute with the given name
        Throws:
        TileDBError
      • getAttribute

        public Attribute getAttribute​(java.lang.String name)
                               throws TileDBError
        Get an Attribute by name
        Parameters:
        name - The name of the attribute.
        Returns:
        Attribute object.
        Throws:
        TileDBError - A TileDB exception
      • getAttribute

        public Attribute getAttribute​(long index)
                               throws TileDBError
        Get an Attribute by index
        Parameters:
        index - The attribute index.
        Returns:
        Attribute object.
        Throws:
        TileDBError - A TileDB exception
      • setCoodsFilterList

        public ArraySchema setCoodsFilterList​(FilterList filterList)
                                       throws TileDBError
        Sets the FilterList for the coordinates, which is an ordered list of filters that will be used to process and/or transform the coordinate data (such as compression).
        Parameters:
        filterList - FilterList to use
        Returns:
        This ArraySchema instance
        Throws:
        TileDBError - A TileDB exception
      • getCoordsFilterList

        public FilterList getCoordsFilterList()
                                       throws TileDBError
        Returns a copy of the FilterList of the coordinates.
        Returns:
        coordinates FilterList
        Throws:
        TileDBError - A TileDB exception
      • setOffsetsFilterList

        public ArraySchema setOffsetsFilterList​(FilterList filterList)
                                         throws TileDBError
        Sets the FilterList for the offsets, which is an ordered list of filters that will be used to process and/or transform the offsets data (such as compression).
        Parameters:
        filterList - FilterList to use
        Returns:
        This ArraySchema instance
        Throws:
        TileDBError - A TileDB exception
      • getOffsetsFilterList

        public FilterList getOffsetsFilterList()
                                        throws TileDBError
        Returns a copy of the FilterList of the offsets.
        Returns:
        offsets FilterList
        Throws:
        TileDBError - A TileDB exception
      • setAllowDups

        public void setAllowDups​(int allowsDups)
                          throws TileDBError
        Sets whether the array can allow coordinate duplicates or not. Applicable only to sparse arrays (it errors out if set to `1` for dense arrays).
        Parameters:
        allowsDups - The allowDups parameter, which allows duplicate coordinates to be inserted it's set to `1`
        Throws:
        TileDBError
      • getAllowDups

        public int getAllowDups()
                         throws TileDBError
        Checks wether duplicate coordinates are allowed in the array schema
        Returns:
        `1` if duplicate coordinates are allowed in that array schema
        Throws:
        TileDBError
      • getCtx

        public Context getCtx()
        Returns:
        The schema Context.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
        Returns:
        A String representation for the schema.
      • close

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