Object Management

A TileDB "object" is currently either a TileDB array or a TileDB group. This page describes the supported functionality for managing TileDB objects.

Creating TileDB Groups

TileDB allows you to hierarchically organize your arrays in groups. A group is practically a directory with a special (empty) TileDB file __tiledb_group.tdb. This offers an intuitive and familiar way to store your various TileDB objects in persistent storage. You can create a group simply as follows:

// ... create context ctx

// Create group
tiledb_group_create(ctx, "my_group");

You can hierarchically organize TileDB groups similar to your filesystem directories, i.e., groups can be arbitrarily nested in other groups.

Getting the Object Type

TileDB also allows you to check the object type as follows. If the provided path does not exist or is not a TileDB array or group, it is marked as “invalid”.

// ... create context ctx

tiledb_object_t type;
tiledb_object_type(ctx, "<path>", &type);

TileDB Object

Description

TILEDB_INVALID

Invalid object

TILEDB_GROUP

A TileDB group

TILEDB_ARRAY

A TileDB array

Listing the Object Hierarchy

TileDB offers various ways to list the contents of a group, even recursively in pre-order or post-order traversal, optionally passing a special callback function that will be invoked for every visited object. This is demonstrated in the code snippet below:

// Helper function to print a path and its type
int print_path(const char* path, tiledb_object_t type, void* data) {
  // Simply print the path and type
  (void)data;
  printf("%s ", path);
  switch (type) {
    case TILEDB_ARRAY:
      printf("ARRAY");
      break;
    case TILEDB_GROUP:
      printf("GROUP");
      break;
    default:
      printf("INVALID");
  }
  printf("\n");

  // Always iterate till the end
  return 1;
}

// ... create context ctx

// List children
tiledb_object_ls(ctx, path, print_path, NULL);

// Walk in a path with a pre-order traversal
tiledb_object_walk(ctx, path, TILEDB_PREORDER, print_path, NULL);
// Walk in a path with a post-order traversal
tiledb_object_walk(ctx, path, TILEDB_POSTORDER, print_path, NULL);

Move/Remove Objects

TileDB offers functions for renaming and removing TileDB objects. Note that these functions are “safe”, in the sense that they will not have any effect on “invalid” (i.e., non-TileDB) objects.

You can rename TileDB objects as follows:

// ... create context ctx

tiledb_object_move(ctx, "my_group", "my_group_2");

Moving TileDB objects across different storage backends (e.g., from S3 to local storage, or vice-versa) is currently not supported. However, it will be added in a future version.

You can remove TileDB objects as follows:

// ... create context ctx

tiledb_object_remove(ctx, "my_group_2/dense_array");

Last updated