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:
C
C++
Python
R
Java
Go
1
// ... create context ctx
2
3
// Create group
4
tiledb_group_create(ctx, "my_group");
Copied!
1
// ... create context ctx
2
3
create_group(ctx, "my_group");
Copied!
1
tiledb.group_create("my_group")
Copied!
1
# ... create context ctx
2
3
tiledb_group_create(ctx, "my_group")
Copied!
1
// ... create context ctx
2
3
Group group = new Group(ctx, "my_group");
Copied!
1
// ... create context ctx
2
3
// Create group
4
tiledb.GroupCreate(ctx, "my_group");
Copied!
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”.
C
C++
Python
R
Java
Go
1
// ... create context ctx
2
3
tiledb_object_t type;
4
tiledb_object_type(ctx, "<path>", &type);
Copied!
1
// ... create context ctx
2
3
auto obj_type = Object::object(ctx, "<path>").type();
Copied!
1
type = tiledb.object_type(path)
Copied!
1
# ... create context ctx
2
3
type <- tiledb_object_type(ctx, "<path>")
Copied!
1
// ... create context ctx
2
3
TileDBObjectType obj_type = new Object(ctx, "<path>").getType();
Copied!
1
// ... create context ctx
2
objType, _ := ObjectType(context, "<path>")
Copied!
C/C++/Java/Go
Python
R
TileDB Object
Description
TILEDB_INVALID
Invalid object
TILEDB_GROUP
A TileDB group
TILEDB_ARRAY
A TileDB array
TileDB Object
Description
None
Invalid object
"group"
A TileDB group
"array"
A TileDB array
TileDB Object
Description
INVALID
Invalid object
GROUP
A TileDB group
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:
C
C++
Python
R
Java
Go
1
// Helper function to print a path and its type
2
int print_path(const char* path, tiledb_object_t type, void* data) {
3
// Simply print the path and type
4
(void)data;
5
printf("%s ", path);
6
switch (type) {
7
case TILEDB_ARRAY:
8
printf("ARRAY");
9
break;
10
case TILEDB_GROUP:
11
printf("GROUP");
12
break;
13
default:
14
printf("INVALID");
15
}
16
printf("\n");
17
18
// Always iterate till the end
19
return 1;
20
}
21
22
// ... create context ctx
23
24
// List children
25
tiledb_object_ls(ctx, path, print_path, NULL);
26
27
// Walk in a path with a pre-order traversal
28
tiledb_object_walk(ctx, path, TILEDB_PREORDER, print_path, NULL);
29
// Walk in a path with a post-order traversal
30
tiledb_object_walk(ctx, path, TILEDB_POSTORDER, print_path, NULL);
Copied!
1
// Helper function to print a path and its type
2
void print_path(const std::string& path, tiledb::Object::Type type) {
3
std::cout << path << " ";
4
switch (type) {
5
case tiledb::Object::Type::Array:
6
std::cout << "ARRAY";
7
break;
8
case tiledb::Object::Type::Group:
9
std::cout << "GROUP";
10
break;
11
default:
12
std::cout << "INVALID";
13
}
14
std::cout << "\n";
15
}
16
17
// ... create context ctx
18
19
// List children
20
tiledb::ObjectIter obj_iter(ctx, path);
21
for (const auto& object : obj_iter)
22
print_path(object.uri(), object.type());
23
24
// Walk in a path with a pre--order traversal
25
obj_iter.set_recursive(); // Default order is TILEDB_POSTORDER
26
for (const auto& object : obj_iter) {
27
print_path(object.uri(), object.type());
28
}
29
30
// Walk in a path with a post--order traversal
31
obj_iter.set_recursive(TILEDB_POSTORDER);
32
for (const auto& object : obj_iter)
33
print_path(object.uri(), object.type());
Copied!
1
# List children
2
tiledb.ls(path, lambda obj_path, obj_type: print(obj_path, obj_type))
3
4
# Walk in a path with a pre-order traversal
5
tiledb.walk(path, lambda obj_path, obj_type: print(obj_path, obj_type)) # Default order is "preorder"
6
7
# Walk in a path with a pre- and post-order traversal
8
tiledb.walk(path, lambda obj_path, obj_type: print(obj_path, obj_type), "postorder")
Copied!
1
# List arrays (defaults to default "PREORDER" traversal)
2
tiledb_object_ls(uri)
3
4
# Walk arrays (with "POSTORDER" traversal) returning a data.frame
5
res <- tiledb_object_walk("<uri>", "POSTORDER")
6
7
# Show the content
8
print(res)
Copied!
1
// ... create context ctx
2
3
// List children
4
System.out.println("List children: ");
5
TileDBObjectIterator obj_iter = new TileDBObjectIterator(ctx, path);
6
for (TileDBObject object : obj_iter.getAllObjects()) System.out.println(object);
7
8
// Walk in a path with a pre- and post-order traversal
9
System.out.println("\nPreorder traversal: ");
10
obj_iter.setRecursive(); // Default order is preorder
11
for (TileDBObject object : obj_iter.getAllObjects()) System.out.println(object);
12
13
System.out.println("\nPostorder traversal: ");
14
obj_iter.setRecursive(TILEDB_POSTORDER);
15
for (TileDBObject object : obj_iter.getAllObjects()) System.out.println(object);
Copied!
1
// ... create context ctx
2
3
GroupCreate(context, "groupPath")
4
GroupCreate(context, "groupPath/arrays")
5
NewArray(context, "groupPath/arrays/array1")
6
7
// List children
8
oL, _ = ObjectLs(context, "groupPath")
9
// oL[0].objectType == TILEDB_GROUP
10
// oL[0].path == "groupPath/arrays"
11
12
// Walk in a path with a pre-order traversal
13
oL, _ := ObjectWalk(context, "groupPath", TILEDB_PREORDER)
14
// len(oL) == 2
15
// oL[0].objectType == TILEDB_GROUP
16
// oL[1].objectType == TILEDB_ARRAY
17
18
// Walk in a path with a post-order traversal
19
oL, _ := ObjectWalk(context, "groupPath", TILEDB_POSTORDER)
Copied!

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:
C
C++
Python
R
Java
Go
1
// ... create context ctx
2
3
tiledb_object_move(ctx, "my_group", "my_group_2");
Copied!
1
// ... create context ctx
2
3
tiledb::Object::move(ctx, "my_group", "my_group_2");
Copied!
1
tiledb.move("my_group", "my_group_2")
Copied!
1
# ... create context ctx
2
3
tiledb_object_mv("my_group", "my_group_2", ctx=ctx);
Copied!
1
// ... create context ctx
2
TileDBObject.move(ctx, "my_group", "my_group2");
Copied!
1
// ... create context ctx
2
ObjectMove(context, "my_group", "my_group_2")
Copied!
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:
C
C++
Python
R
Java
Go
1
// ... create context ctx
2
3
tiledb_object_remove(ctx, "my_group_2/dense_array");
Copied!
1
// ... create context ctx
2
3
tiledb::Object::remove(ctx, "my_group_2/dense_array");
Copied!
1
tiledb.remove("my_group_2/dense_array")
Copied!
1
# ... create context ctx
2
3
tiledb_object_rm("my_group", "my_group_2", ctx=ctx);
Copied!
1
// ... create context ctx
2
TileDBObject.remove(ctx, "my_group2/dense_arrays");
Copied!
1
// ... create context ctx
2
ObjectRemove(context, "my_group_2/dense_array")
Copied!
Last modified 10mo ago