Skip to content

Commit

Permalink
Migrate APIs out of StorageManager: delete_group. (#4955)
Browse files Browse the repository at this point in the history
Migrate APIs out of `StorageManager`: `delete_group`.

---
[sc-46728]

---
TYPE: NO_HISTORY
DESC: Migrate APIs out of StorageManager: delete_group
  • Loading branch information
bekadavis9 authored May 10, 2024
1 parent 474fc1e commit 7387605
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 41 deletions.
22 changes: 21 additions & 1 deletion tiledb/sm/group/group.cc
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,27 @@ void Group::delete_group(const URI& uri, bool recursive) {
}
}
}
storage_manager_->delete_group(uri.c_str());

auto& vfs = resources_.vfs();
auto& compute_tp = resources_.compute_tp();
auto group_dir = GroupDirectory(
&vfs, &compute_tp, uri, 0, std::numeric_limits<uint64_t>::max());

// Delete the group detail, group metadata and group files
vfs.remove_files(&compute_tp, group_dir.group_detail_uris());
vfs.remove_files(&compute_tp, group_dir.group_meta_uris());
vfs.remove_files(&compute_tp, group_dir.group_meta_uris_to_vacuum());
vfs.remove_files(&compute_tp, group_dir.group_meta_vac_uris_to_vacuum());
vfs.remove_files(&compute_tp, group_dir.group_file_uris());

// Delete all tiledb child directories
// Note: using vfs().ls() here could delete user data
std::vector<URI> dirs;
auto parent_dir = group_dir.uri().c_str();
for (auto group_dir_name : constants::group_dir_names) {
dirs.emplace_back(URI(parent_dir + group_dir_name));
}
vfs.remove_dirs(&compute_tp, dirs);
}
// Clear metadata and other pending changes to avoid patching a deleted group.
metadata_.clear();
Expand Down
8 changes: 5 additions & 3 deletions tiledb/sm/group/group.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,13 @@ class Group {
void clear();

/**
* Deletes data from and closes a group opened in MODIFY_EXCLUSIVE mode.
*
* Note: if recursive == false, data added to the group will be left as-is.
* Handles local and remote deletion of data from a group with the given URI.
*
* @param uri The address of the group to be deleted.
* @pre The group must be opened in MODIFY_EXCLUSIVE mode.
* @note If recursive == false, data added to the group will be left as-is.
*
* @param uri The URI of the group to be deleted.
* @param recursive True if all data inside the group is to be deleted.
*/
void delete_group(const URI& uri, bool recursive = false);
Expand Down
30 changes: 0 additions & 30 deletions tiledb/sm/storage_manager/storage_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -221,36 +221,6 @@ void StorageManagerCanonical::delete_fragments(
}));
}

void StorageManagerCanonical::delete_group(const char* group_name) {
if (group_name == nullptr) {
throw Status_StorageManagerError(
"[delete_group] Group name cannot be null");
}

auto group_dir = GroupDirectory(
vfs(),
compute_tp(),
URI(group_name),
0,
std::numeric_limits<uint64_t>::max());

// Delete the group detail, group metadata and group files
vfs()->remove_files(compute_tp(), group_dir.group_detail_uris());
vfs()->remove_files(compute_tp(), group_dir.group_meta_uris());
vfs()->remove_files(compute_tp(), group_dir.group_meta_uris_to_vacuum());
vfs()->remove_files(compute_tp(), group_dir.group_meta_vac_uris_to_vacuum());
vfs()->remove_files(compute_tp(), group_dir.group_file_uris());

// Delete all tiledb child directories
// Note: using vfs()->ls() here could delete user data
std::vector<URI> dirs;
auto parent_dir = group_dir.uri().c_str();
for (auto group_dir_name : constants::group_dir_names) {
dirs.emplace_back(URI(parent_dir + group_dir_name));
}
vfs()->remove_dirs(compute_tp(), dirs);
}

Status StorageManagerCanonical::array_create(
const URI& array_uri,
const shared_ptr<ArraySchema>& array_schema,
Expand Down
7 changes: 0 additions & 7 deletions tiledb/sm/storage_manager/storage_manager_canonical.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,6 @@ class StorageManagerCanonical {
void delete_fragments(
const char* array_name, uint64_t timestamp_start, uint64_t timestamp_end);

/**
* Cleans up the group data.
*
* @param group_name The name of the group whose data is to be deleted.
*/
void delete_group(const char* group_name);

/**
* Creates a TileDB array storing its schema.
*
Expand Down

0 comments on commit 7387605

Please sign in to comment.