Creating the Array Schema

After creating the dimensions, domain and attributes, you can create the array schema as follows:

#include <tiledb/tiledb.h>

// ... create context ctx
// ... create domain dom
// ... create attributes attr1, attr2

tiledb_array_schema_t* schema;

// Create array schema for a dense array
tiledb_array_schema_alloc(ctx, TILEDB_DENSE, &schema);
// Or, create array schema for a sparse array
// tiledb_array_schema_alloc(ctx, TILEDB_SPARSE, &schema);

// Add domain and attributes to the schema
tiledb_array_schema_set_domain(ctx, schema, domain);
tiledb_array_schema_add_attribute(ctx, schema, attr1);
tiledb_array_schema_add_attribute(ctx, schema, attr2);

// ...

// Delete array schema
tiledb_array_schema_free(&schema);

When creating the array schema, the dimension and attribute names must be unique.

Setting the Tile and Cell order

You can set the tile and cell order as follows. The tile order may be set to row-major or column-major; the cell order may be set to row-major, column-major, or hilbert.

// The tile and order can be TILEDB_ROW_MAJOR or TILEDB_COL_MAJOR
tiledb_array_schema_set_tile_order(ctx, schema, TILEDB_ROW_MAJOR);
tiledb_array_schema_set_cell_order(ctx, schema, TILEDB_COL_MAJOR);

Setting the Data Tile Capacity

You can set the data tile capacity (applicable to sparse fragments), as follows:

tiledb_array_schema_set_capacity(ctx, schema, 1000000);

Allowing Duplicates

Sparse arrays may allow multiple cells with the same coordinates to exist (dense arrays do not allow duplicates). By default, duplicates are not allowed. You can specify that a sparse array allows duplicates as follows:

#import <tiledb/tiledb.h>

// ... create array schema

tiledb_array_schema_set_allows_dups(ctx, array_schema, 1);

When duplicates are allowed, checking for duplicates and deduplication are disabled.

Checking Correctness

You can check if the array schema is set properly as follows:

#import <tiledb/tiledb.h>

// ... create context ctx 
// ... create array schema

// Test correctness
int rc = tiledb_array_schema_check(ctx, schema);
// rc == TILEDB_OK if correct
// rc == TILEDB_ERR if incorrect

Last updated