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
      • 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