Package io.tiledb.java.api
Class Attribute
- java.lang.Object
-
- io.tiledb.java.api.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.
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 Summary
Constructors Modifier Constructor Description protected
Attribute(Context ctx, SWIGTYPE_p_p_tiledb_attribute_t attributepp)
Attribute(Context ctx, java.lang.String name, Datatype attrType)
Construct an attribute with name and TileDB Datatype.Attribute(Context ctx, java.lang.String name, java.lang.Class attrType)
Construct an attribute with a name and java class type.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Free's native TileDB resources associated with the Attribute objectprotected SWIGTYPE_p_tiledb_attribute_t
getAttributep()
long
getCellSize()
long
getCellValNum()
Pair<java.lang.Object,java.lang.Integer>
getFillValue()
Gets the default fill value for the input attribute.Pair<java.lang.Object,Pair<java.lang.Integer,java.lang.Boolean>>
getFillValueNullable()
Gets the default fill value for the input, nullable attribute.FilterList
getFilterList()
Gets the list of filtes associated with the attributejava.lang.String
getName()
boolean
getNullable()
* Gets the nullability of an attribute.Datatype
getType()
boolean
isVar()
Attribute
setCellValNum(long size)
Sets the number of Attribute values per cell.Attribute
setCellVar()
Sets the Attribute to have variable length cell representationvoid
setFillValue(NativeArray value, java.math.BigInteger size)
Sets the default fill value for the input attribute.void
setFillValue(java.lang.Object value)
Sets the default fill value for the input attribute.void
setFillValueNullable(NativeArray value, java.math.BigInteger size, boolean valid)
Sets the default fill value for the input, nullable attribute.void
setFillValueNullable(java.lang.Object value, boolean valid)
Sets the default fill value for the input, nullable attribute.Attribute
setFilterList(FilterList filters)
Sets the Attribute FilterList.void
setNullable(boolean isNullable)
* Sets the nullability of an attribute.java.lang.String
toString()
-
-
-
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 contextname
- Name of the attributeattrType
- 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 Contextname
- Name of the attributeattrType
- TileDB Datatype of attribute- Throws:
TileDBError
- A TileDB exception
-
Attribute
protected Attribute(Context ctx, SWIGTYPE_p_p_tiledb_attribute_t attributepp) throws TileDBError
- Throws:
TileDBError
-
-
Method Detail
-
getAttributep
protected SWIGTYPE_p_tiledb_attribute_t getAttributep()
-
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 valuesize
- 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 classjava.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 interfacejava.lang.AutoCloseable
-
-