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:
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”.
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 typeintprint_path(constchar* 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 endreturn1;}// ... create context ctx// List childrentiledb_object_ls(ctx, path, print_path,NULL);// Walk in a path with a pre-order traversaltiledb_object_walk(ctx, path, TILEDB_PREORDER, print_path,NULL);// Walk in a path with a post-order traversaltiledb_object_walk(ctx, path, TILEDB_POSTORDER, print_path,NULL);
// Helper function to print a path and its typevoidprint_path(const std::string& path, tiledb::Object::Type type) { std::cout << path <<" ";switch (type) {case tiledb::Object::Type::Array: std::cout <<"ARRAY";break;case tiledb::Object::Type::Group: std::cout <<"GROUP";break;default: std::cout <<"INVALID"; } std::cout <<"\n";}// ... create context ctx// List childrentiledb::ObjectIterobj_iter(ctx,path);for (constauto& object : obj_iter)print_path(object.uri(),object.type());// Walk in a path with a pre--order traversalobj_iter.set_recursive(); // Default order is TILEDB_POSTORDERfor (constauto& object : obj_iter) {print_path(object.uri(),object.type());}// Walk in a path with a post--order traversalobj_iter.set_recursive(TILEDB_POSTORDER);for (constauto& object : obj_iter)print_path(object.uri(),object.type());
# List childrentiledb.ls(path, lambdaobj_path, obj_type: print(obj_path, obj_type))# Walk in a path with a pre-order traversaltiledb.walk(path, lambdaobj_path, obj_type: print(obj_path, obj_type))# Default order is "preorder"# Walk in a path with a pre- and post-order traversaltiledb.walk(path, lambdaobj_path, obj_type: print(obj_path, obj_type), "postorder")
# List arrays (defaults to default "PREORDER" traversal)tiledb_object_ls(uri)# Walk arrays (with "POSTORDER" traversal) returning a data.frameres <-tiledb_object_walk("<uri>", "POSTORDER")# Show the contentprint(res)
// ... create context ctx// List childrenSystem.out.println("List children: ");TileDBObjectIterator obj_iter =newTileDBObjectIterator(ctx, path);for (TileDBObject object :obj_iter.getAllObjects()) System.out.println(object);// Walk in a path with a pre- and post-order traversalSystem.out.println("\nPreorder traversal: ");obj_iter.setRecursive(); // Default order is preorderfor (TileDBObject object :obj_iter.getAllObjects()) System.out.println(object);System.out.println("\nPostorder traversal: ");obj_iter.setRecursive(TILEDB_POSTORDER);for (TileDBObject object :obj_iter.getAllObjects()) System.out.println(object);
// ... create context ctxGroupCreate(context, "groupPath")GroupCreate(context, "groupPath/arrays")NewArray(context, "groupPath/arrays/array1")// List childrenoL, _ =ObjectLs(context, "groupPath")// oL[0].objectType == TILEDB_GROUP// oL[0].path == "groupPath/arrays"// Walk in a path with a pre-order traversaloL, _ :=ObjectWalk(context, "groupPath", TILEDB_PREORDER)// len(oL) == 2// oL[0].objectType == TILEDB_GROUP// oL[1].objectType == TILEDB_ARRAY// Walk in a path with a post-order traversaloL, _ :=ObjectWalk(context, "groupPath", TILEDB_POSTORDER)
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.
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.