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);}