Package io.tiledb.java.api
Class ArraySchema
- java.lang.Object
-
- io.tiledb.java.api.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
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 Summary
Constructors Modifier Constructor Description ArraySchema(Context ctx, ArrayType type)
Creates a new TileDB ArraySchema objectprotected
ArraySchema(Context ctx, SWIGTYPE_p_p_tiledb_array_schema_t schemapp)
ArraySchema(Context ctx, java.lang.String uri)
Loads the ArraySchema of an existing array with the given URI string.ArraySchema(Context ctx, java.lang.String uri, EncryptionType encryption_type, byte[] key)
Loads the encrypted ArraySchema of an existing array with the given URI string.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAttribute(Attribute attr)
Adds an Attribute to the array.void
check()
Validates the schema, throws a TileDBError if the ArraySchema is invalid.void
close()
Free's native TileDB resources associated with the ArraySchema objectvoid
dump()
Dumps the array schema in an ASCII representation to STDOUT.void
dump(java.lang.String filename)
Dumps the array schema text representation to a file.int
getAllowDups()
Checks wether duplicate coordinates are allowed in the array schemaArrayType
getArrayType()
Returns the type of the TileDB ArrayAttribute
getAttribute(long index)
Get an Attribute by indexAttribute
getAttribute(java.lang.String name)
Get an Attribute by namelong
getAttributeNum()
java.util.HashMap<java.lang.String,Attribute>
getAttributes()
Get all Attributes of the array.long
getCapacity()
Returns the tile capacity for the array.Layout
getCellOrder()
Returns the cell layout for the array schema.FilterList
getCoordsFilterList()
Returns a copy of the FilterList of the coordinates.Context
getCtx()
Domain
getDomain()
FilterList
getOffsetsFilterList()
Returns a copy of the FilterList of the offsets.protected SWIGTYPE_p_tiledb_array_schema_t
getSchemap()
SWIGTYPE_p_p_tiledb_array_schema_t
getSchemapp()
Layout
getTileOrder()
Returns the tile layout order.Pair<java.lang.Long,java.lang.Long>
getTimestampRange()
Get timestamp range of schema.FilterList
getValidityFilterList()
Retrieves the filter list used for validity maps.long
getVersion()
Returns the array schema version.boolean
hasAttribute(java.lang.String name)
Checks if the ArraySchema has the given attribute with nameboolean
isSparse()
Returns true if the array schema describes a sparse arrayvoid
setAllowDups(int allowsDups)
Sets whether the array can allow coordinate duplicates or not.void
setCapacity(long capacity)
Sets the tile capacity.void
setCapacity(java.math.BigInteger capacity)
Sets the tile capacity.ArraySchema
setCellOrder(Layout layout)
Sets the cell order for the array schema.ArraySchema
setCoodsFilterList(FilterList filterList)
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).void
setDomain(Domain domain)
Sets the array Domain.ArraySchema
setOffsetsFilterList(FilterList filterList)
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).ArraySchema
setTileOrder(Layout layout)
Sets the tile order.ArraySchema
setValidityFilterList(FilterList filterList)
Sets the filter list to use for the validity array of nullable attribute values.java.lang.String
toString()
-
-
-
Constructor Detail
-
ArraySchema
public ArraySchema(Context ctx, ArrayType type) throws TileDBError
Creates a new TileDB ArraySchema objectExample:
Context ctx = new Context(); ArraySchema schema = new ArraySchema(ctx, TILEDB_SPARSE);
- Parameters:
ctx
- TileDB contexttype
- Array type, sparse or dense- Throws:
TileDBError
- A TileDB exception
-
ArraySchema
protected ArraySchema(Context ctx, SWIGTYPE_p_p_tiledb_array_schema_t schemapp)
-
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 contexturi
- 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 contexturi
- URI of TileDB Arrayencryption_type
- Encryption type of the array schemakey
- 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
-
setTileOrder
public ArraySchema setTileOrder(Layout layout) throws TileDBError
Sets the tile order.- Parameters:
layout
- tile 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
-
getDomain
public Domain getDomain() throws TileDBError
- Returns:
- The array Domain object.
- 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
-
setValidityFilterList
public ArraySchema setValidityFilterList(FilterList filterList) throws TileDBError
Sets the filter list to use for the validity array of nullable attribute values.- Parameters:
filterList
- FilterList to use- Returns:
- This ArraySchema instance
- Throws:
TileDBError
-
getValidityFilterList
public FilterList getValidityFilterList() throws TileDBError
Retrieves the filter list used for validity maps.- Returns:
- coordinates FilterList
- Throws:
TileDBError
-
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
-
getTimestampRange
public Pair<java.lang.Long,java.lang.Long> getTimestampRange() throws TileDBError
Get timestamp range of schema.- Returns:
- timestamp range of schema
- Throws:
TileDBError
-
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
-
getVersion
public long getVersion() throws TileDBError
Returns the array schema version.- Returns:
- the array schema version
- Throws:
TileDBError
-
getSchemap
protected SWIGTYPE_p_tiledb_array_schema_t getSchemap()
-
getSchemapp
public SWIGTYPE_p_p_tiledb_array_schema_t getSchemapp()
-
getCtx
public Context getCtx()
- Returns:
- The schema Context.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.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 interfacejava.lang.AutoCloseable
-
-