After creating some dimensions, you can create the array domain as follows:
#include<tiledb/tiledb.h>// .. create context `ctx`, and dimensions `dim1`, `dim2`// Create domain and add two dimensionstiledb_domain_t* domain;tiledb_domain_alloc(ctx,&domain);tiledb_domain_add_dimension(ctx, domain, dim1);tiledb_domain_add_dimension(ctx, domain, dim2);// ...// Make sure to free the domain objecttiledb_domain_free(&domain);
#include<tiledb/tiledb>usingnamespace tiledb;// .. create context `ctx`, and dimensions `dim1`, `dim2`// Create domain and add two dimensionsDomaindomain(ctx);domain.add_dimension(dim1) .add_dimension(dim2);
import tiledbimport numpy as np# .. create dimensions dim1, dim2# Create domain with two dimensionsdom = tiledb.Domain(dim1, dim2)
# .. create dimensions `dim1`, `dim2`# Create domain with two dimensionsdom <-tiledb_domain(dims =c(dim1, dim2))
// .. create context `ctx`, and dimensions `dim1`, `dim2`// Create domain and add two dimensionsDomain domain =newDomain(ctx);domain.addDimension(dim1).addDimension(dim2);
import tiledb "github.com/TileDB/TileDB-Go"// .. create context `ctx`, and dimensions `dim1`, `dim2`// Create domain and add two dimensionsdomain, _ := tiledb.NewDomain(ctx)domain.AddDimensions(dim1, dim2)
usingTileDB.CSharp;// Create context `ctx`, and dimensions `dim1` and `dim2`.usingDomaindomain=newDomain(ctx);domain.AddDimension(dimc#1);domain.AddDimension(dim2);
The order of the dimensions as added to the domain is important later when slicing subarrays. Remember to give priority to more selective dimensions, in order to maximize the pruning power during slicing.
When creating the domain, the dimension names must be unique.
Creating Dimensions
Creating a dimension requires specifying a name, the dimension datatype, the dimension domain and the space tile extent. Below you can see an example of creating an int32 dimension called dim with domain [1,4], and tile extent 2.
#include<tiledb/tiledb.h>// Create contexttiledb_ctx_t* ctx;tiledb_ctx_alloc(NULL,&ctx);// Create dimensionint dim_domain[]= {1,4};int tile_extent =2;tiledb_dimension_t* dim;tiledb_dimension_alloc(ctx,"dim", TILEDB_INT32,&dim_domain[0],&tile_extent,&dim);// ...// Create string dimension// No values are accepted for domain and tile extenttiledb_dimension_t* str_dim;tiledb_dimension_alloc(ctx,"str_dim", TILEDB_STRING_ASCII,NULL,NULL,&str_dim);// Make sure to free the dimension and contexttiledb_dimension_free(&dim);tiledb_ctx_free(&ctx);
#include<tiledb/tiledb>usingnamespace tiledb;// Create contextContext ctx;// Create dimensionauto dim = Dimension::create<int32_t>(ctx,"dim", {{1,4}},2);// Or alternatively:int dim_domain[] = {1,4};int tile_extent =2;auto dim = Dimension::create(ctx,"dim", TILEDB_INT32, dim_domain,&tile_extent);// String dimension// No values are accepted for domain and tile extentauto dim = Dimension::create(ctx,"dim", TILEDB_STRING_ASCII,nullptr,nullptr);
import tiledbimport numpy as npdim = tiledb.Dim(name="dim", domain=(1, 4), tile=2, dtype=np.int32)# for string dimensions, the domain and tiling are handled implicitlystr_dim = tiledb.Dim(name="str_dim", tile=None, dtype="ascii")
library(tiledb)# Create dimensiondim <-tiledb_dim("dim1", c(1L, 4L), 2L, "INT32")# String dimenions: no values for domain and extentstrdim <-tiledb_dim("dim2", NULL, NULL, "ASCII")
// Create contexttry(Context ctx =newContext()) {// Create dimensionDimension dim =newDimension(ctx,"dim", TILEDB_INT32,newPair<Integer,Integer>(1,4),2);// String dimension// No values are accepted for domain and tile extentDimension strDim =newDimension(ctx,"strDim",Datatype.TILEDB_STRING_ASCII,null,null);}