Creating the Array Domain

After creating some dimensions, you can create the array domain as follows:

C
C++
Python
R
Java
Go
C
#include <tiledb/tiledb.h>
// .. create context `ctx`, and dimensions `dim1`, `dim2`
// Create domain and add two dimensions
tiledb_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 object
tiledb_domain_free(&domain);
C++
#include <tiledb/tiledb>
// .. create context `ctx`, and dimensions `dim1`, `dim2`
// Create domain and add two dimensions
Domain domain(ctx);
domain.add_dimension(dim1)
.add_dimension(dim2);
Python
import tiledb
import numpy as np
# .. create dimensions dim1, dim2
# Create domain with two dimensions
dom = tiledb.Domain(dim1, dim2)
R
# .. create dimensions `dim1`, `dim2`
# Create domain with two dimensions
dom <- tiledb_domain(dims = c(dim1, dim2))
Java
// .. create context `ctx`, and dimensions `dim1`, `dim2`
// Create domain and add two dimensions
Domain domain = new Domain(ctx);
domain.addDimension(dim1)
.addDimension(dim2);
Go
import tiledb "github.com/TileDB/TileDB-Go"
// .. create context `ctx`, and dimensions `dim1`, `dim2`
// Create domain and add two dimensions
domain, _ := tiledb.NewDomain(ctx)
domain.AddDimensions(dim1, 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.

Currently, the dimensions comprising a domain for both dense and sparse arrays must have the same datatype. We are working on relaxing this constraint for the case of sparse arrays. See our roadmap for updates.