Class Attribute

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    public class Attribute
    extends java.lang.Object
    implements java.lang.AutoCloseable
    Describes an Attribute of an Array cell.

    An Attribute specifies a datatype for a particular parameter in each array cell. There are 3 supported Attribute types:

    • Fundamental types: Character, String, Byte, Boolean, Short, Integer, Long, Double and Float.
    • Fixed sized arrays of the above types.
    • Variable length arrays of the above types.
    Example:
    
     Context ctx = new Context();
     Attribute a1 = new Attribute(ctx,"a1",Integer.class);
     Attribute a2 = new Attribute(ctx,"a2",Character.class);
     Attribute a3 = new Attribute(ctx,"a3",Float.class);
    
     // Change compression scheme
     a1.setFilterList(new FilterList(ctx).addFilter(new LZ4Filter(ctx)));
     a2.setCellValNum(TILEDB_VAR_NUM); // Variable sized character attribute (String)
     a3.setCellValNum(2); // 2 floats stored per cell
    
     ArraySchema schema = new ArraySchema(ctx, TILEDB_DENSE);
     schema.setDomain(domain);
     schema.addAttribute(a1);
     schema.addAttribute(a2);
     schema.addAttribute(a3);
     
    • Constructor Detail

      • Attribute

        public Attribute​(Context ctx,
                         java.lang.String name,
                         java.lang.Class attrType)
                  throws TileDBError
        Construct an attribute with a name and java class type. `cellValNum` will be set to 1.
        Parameters:
        ctx - TileDB context
        name - Name of the attribute
        attrType - Java class type of the attribute
        Throws:
        TileDBError - A TileDB exception
      • Attribute

        public Attribute​(Context ctx,
                         java.lang.String name,
                         Datatype attrType)
                  throws TileDBError
        Construct an attribute with name and TileDB Datatype. `cellValNum` will be set to 1.
        Parameters:
        ctx - TileDB Context
        name - Name of the attribute
        attrType - TileDB Datatype of attribute
        Throws:
        TileDBError - A TileDB exception
    • Method Detail

      • getName

        public java.lang.String getName()
                                 throws TileDBError
        Returns:
        The name of the Attribute.
        Throws:
        TileDBError - A TileDB exception
      • getType

        public Datatype getType()
                         throws TileDBError
        Returns:
        The Attribute Enumerated datatype (TileDB type).
        Throws:
        TileDBError - A TileDB exception
      • getCellSize

        public long getCellSize()
                         throws TileDBError
        Returns:
        The size (in bytes) of one cell on this Attribute.
        Throws:
        TileDBError - A TileDB exception
      • getCellValNum

        public long getCellValNum()
                           throws TileDBError
        Returns:
        The number of values stored in each cell. This is equal to the size of the Attribute * sizeof(attributeType). For variable size attributes this is TILEDB_VAR_NUM.
        Throws:
        TileDBError - A TileDB exception
      • isVar

        public boolean isVar()
                      throws TileDBError
        Returns:
        True if this is a variable length Attribute.
        Throws:
        TileDBError - A TileDB exception
      • setCellValNum

        public Attribute setCellValNum​(long size)
                                throws TileDBError
        Sets the number of Attribute values per cell.
        Parameters:
        size - The number of values per cell. Use TILEDB_VAR_NUM for variable length.
        Throws:
        TileDBError - A TileDB exception
      • setCellVar

        public Attribute setCellVar()
                             throws TileDBError
        Sets the Attribute to have variable length cell representation
        Returns:
        Attribute
        Throws:
        TileDBError - A TileDB exception
      • setFilterList

        public Attribute setFilterList​(FilterList filters)
                                throws TileDBError
        Sets the Attribute FilterList.
        Parameters:
        filters - A TileDB FilterList
        Throws:
        TileDBError - A TileDB exception
      • getFilterList

        public FilterList getFilterList()
                                 throws TileDBError
        Gets the list of filtes associated with the attribute
        Returns:
        A FilterList instance
        Throws:
        TileDBError - A TileDB exception
      • setFillValue

        public void setFillValue​(NativeArray value,
                                 java.math.BigInteger size)
                          throws TileDBError
        Sets the default fill value for the input attribute. This value will be used for the input attribute whenever querying (1) an empty cell in a dense array, or (2) a non-empty cell (in either dense or sparse array) when values on the input attribute are missing (e.g., if the user writes a subset of the attributes in a write operation).

        Applicable to var-sized attributes.

        Parameters:
        value - The fill value
        size - The fill value size
        Throws:
        TileDBError
      • setFillValue

        public void setFillValue​(java.lang.Object value)
                          throws TileDBError
        Sets the default fill value for the input attribute. This value will be used for the input attribute whenever querying (1) an empty cell in a dense array, or (2) a non-empty cell (in either dense or sparse array) when values on the input attribute are missing (e.g., if the user writes a subset of the attributes in a write operation).

        Applicable to var-sized attributes.

        Parameters:
        value - The fill value
        Throws:
        TileDBError
      • getFillValue

        public Pair<java.lang.Object,​java.lang.Integer> getFillValue()
                                                                    throws TileDBError
        Gets the default fill value for the input attribute. This value will be used for the input attribute whenever querying (1) an empty cell in a dense array, or (2) a non-empty cell (in either dense or sparse array) when values on the input attribute are missing (e.g., if the user writes a subset of the attributes in a write operation).

        Applicable to both fixed-sized and var-sized attributes.

        Returns:
        A pair with the fill value and its size
        Throws:
        TileDBError
      • setFillValueNullable

        public void setFillValueNullable​(NativeArray value,
                                         java.math.BigInteger size,
                                         boolean valid)
                                  throws TileDBError
        Sets the default fill value for the input, nullable attribute. This value will be used for the input attribute whenever querying (1) an empty cell in a dense array, or (2) a non-empty cell (in either dense or sparse array) when values on the input attribute are missing (e.g., if the user writes a subset of the attributes in a write operation).
        Parameters:
        value - The fill value to set.
        size - The fill value size in bytes.
        valid - The validity fill value, zero for a null value and non-zero for a valid attribute.
        Throws:
        TileDBError
      • setFillValueNullable

        public void setFillValueNullable​(java.lang.Object value,
                                         boolean valid)
                                  throws TileDBError
        Sets the default fill value for the input, nullable attribute. This value will be used for the input attribute whenever querying (1) an empty cell in a dense array, or (2) a non-empty cell (in either dense or sparse array) when values on the input attribute are missing (e.g., if the user writes a subset of the attributes in a write operation).
        Parameters:
        value - The fill value to set.
        valid - The validity fill value, zero for a null value and non-zero for a valid attribute.
        Throws:
        TileDBError
      • getFillValueNullable

        public Pair<java.lang.Object,​Pair<java.lang.Integer,​java.lang.Boolean>> getFillValueNullable()
                                                                                                          throws TileDBError
        Gets the default fill value for the input, nullable attribute. This value will be used for the input attribute whenever querying (1) an empty cell in a dense array, or (2) a non-empty cell (in either dense or sparse array) when values on the input attribute are missing (e.g., if the user writes a subset of the attributes in a write operation).

        Applicable to both fixed-sized and var-sized attributes.

        Returns:
        A pair which contains the fill value and a pair with its size and validity field i.e. Pair(5, Pair(4, true))
        Throws:
        TileDBError
      • setNullable

        public void setNullable​(boolean isNullable)
                         throws TileDBError
        * Sets the nullability of an attribute.
        Parameters:
        isNullable - true if the attribute is nullable, false otherwise
        Throws:
        TileDBError
      • getNullable

        public boolean getNullable()
                            throws TileDBError
        * Gets the nullability of an attribute.
        Returns:
        true if the attribute is nullable, false otherwise
        Throws:
        TileDBError
      • toString

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

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