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.

C
C++
Python
R
Java
Go
C
#include <tiledb/tiledb.h>
// Create context
tiledb_ctx_t* ctx;
tiledb_ctx_alloc(NULL, &ctx);
// Create dimension
int 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);
// ...
// Make sure to free the dimension and context
tiledb_dimension_free(&dim);
tiledb_ctx_free(&ctx);
C++
#include <tiledb/tiledb>
// Create context
Context ctx;
// Create dimension
auto 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);
Python
import tiledb
import numpy as np
dim = tiledb.Dim(name="dim", domain=(1, 4), tile=2, dtype=np.int32)
R
library(tiledb)
# Create dimension
dim <- tiledb_dim("dim", c(1L, 4L), 2L, "INT32")
Java
// Create context
try(Context ctx = new Context()) {
// Create dimension
Dimension dim = new Dimension(ctx, "dim", TILEDB_INT32, new Pair<Integer, Integer>(1, 4), 2);
}
Go
import tiledb "github.com/TileDB/TileDB-Go"
// Create context
ctx, _ := tiledb.NewContext(nil)
// Create dimension
dim, _ := tiledb.NewDimension(ctx, "dim", []int32{1, 4}, int32(2))

Supported Dimension Datatypes:

C/C++/Java/Go
Python
R
C/C++/Java/Go

Datatype

Description

Array Type

TILEDB_INT8

8-bit integer

Dense & Sparse

TILEDB_UINT8

8-bit unsigned integer

Dense & Sparse

TILEDB_INT16

16-bit integer

Dense & Sparse

TILEDB_UINT16

16-bit unsigned integer

Dense & Sparse

TILEDB_INT32

32-bit integer

Dense & Sparse

TILEDB_UINT32

32-bit unsigned integer

Dense & Sparse

TILEDB_INT64

64-bit integer

Dense & Sparse

TILEDB_UINT64

64-bit unsigned integer

Dense & Sparse

TILEDB_FLOAT32

32-bit floating point

Sparse

TILEDB_FLOAT64

64-bit floating point

Sparse

TILEDB_DATETIME_YEAR

Years

Dense & Sparse

TILEDB_DATETIME_MONTH

Months

Dense & Sparse

TILEDB_DATETIME_WEEK

Weeks

Dense & Sparse

TILEDB_DATETIME_DAY

Days

Dense & Sparse

TILEDB_DATETIME_HR

Hours

Dense & Sparse

TILEDB_DATETIME_MIN

Minutes

Dense & Sparse

TILEDB_DATETIME_SEC

Seconds

Dense & Sparse

TILEDB_DATETIME_MS

Milliseconds

Dense & Sparse

TILEDB_DATETIME_US

Microseconds

Dense & Sparse

TILEDB_DATETIME_NS

Nanoseconds

Dense & Sparse

TILEDB_DATETIME_PS

Picoseconds

Dense & Sparse

TILEDB_DATETIME_FS

Femtoseconds

Dense & Sparse

TILEDB_DATETIME_AS

Attoseconds

Dense & Sparse

Python

Datatype

Description

Array Type

np.int8

8-bit integer

Dense & Sparse

np.uint8

8-bit unsigned integer

Dense & Sparse

np.int16

16-bit integer

Dense & Sparse

np.uint16

16-bit unsigned integer

Dense & Sparse

np.int32

32-bit integer

Dense & Sparse

np.uint32

32-bit unsigned integer

Dense & Sparse

np.int64

64-bit integer

Dense & Sparse

np.uint64

64-bit unsigned integer

Dense & Sparse

np.float32

32-bit floating point

Sparse

np.float64

64-bit floating point

Sparse

"datetime64[Y]"

Years

Dense & Sparse

"datetime64['M']

Months

Dense & Sparse

"datetime64['W']"

Weeks

Dense & Sparse

"datetime64['D']"

Days

Dense & Sparse

"datetime64['h']"

Hours

Dense & Sparse

"datetime64['m']"

Minutes

Dense & Sparse

"datetime64['s']"

Seconds

Dense & Sparse

"datetime64['ms']"

Milliseconds

Dense & Sparse

"datetime64['us']"

Microseconds

Dense & Sparse

"datetime64['ns']"

Nanoseconds

Dense & Sparse

"datetime64['ps']"

Picoseconds

Dense & Sparse

"datetime64['fs']"

Femtoseconds

Dense & Sparse

"datetime64['as']"

Attoseconds

Dense & Sparse

R

Datatype

Description

Array Type

"INT8"

8-bit integer

Dense & Sparse

"UINT8"

8-bit unsigned integer

Dense & Sparse

"INT16"

16-bit integer

Dense & Sparse

"UINT16"

16-bit unsigned integer

Dense & Sparse

"INT32"

32-bit integer

Dense & Sparse

"UINT32"

32-bit unsigned integer

Dense & Sparse

"INT64"

64-bit integer

Dense & Sparse

"UINT64"

64-bit unsigned integer

Dense & Sparse

"FLOAT32"

32-bit floating point

Sparse

"FLOAT64"

64-bit floating point

Sparse