Skip to content

Commit 7387605

Browse files
authored
Migrate APIs out of StorageManager: delete_group. (#4955)
Migrate APIs out of `StorageManager`: `delete_group`. --- [sc-46728] --- TYPE: NO_HISTORY DESC: Migrate APIs out of StorageManager: delete_group
1 parent 474fc1e commit 7387605

File tree

4 files changed

+26
-41
lines changed

4 files changed

+26
-41
lines changed

tiledb/sm/group/group.cc

+21-1
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,27 @@ void Group::delete_group(const URI& uri, bool recursive) {
332332
}
333333
}
334334
}
335-
storage_manager_->delete_group(uri.c_str());
335+
336+
auto& vfs = resources_.vfs();
337+
auto& compute_tp = resources_.compute_tp();
338+
auto group_dir = GroupDirectory(
339+
&vfs, &compute_tp, uri, 0, std::numeric_limits<uint64_t>::max());
340+
341+
// Delete the group detail, group metadata and group files
342+
vfs.remove_files(&compute_tp, group_dir.group_detail_uris());
343+
vfs.remove_files(&compute_tp, group_dir.group_meta_uris());
344+
vfs.remove_files(&compute_tp, group_dir.group_meta_uris_to_vacuum());
345+
vfs.remove_files(&compute_tp, group_dir.group_meta_vac_uris_to_vacuum());
346+
vfs.remove_files(&compute_tp, group_dir.group_file_uris());
347+
348+
// Delete all tiledb child directories
349+
// Note: using vfs().ls() here could delete user data
350+
std::vector<URI> dirs;
351+
auto parent_dir = group_dir.uri().c_str();
352+
for (auto group_dir_name : constants::group_dir_names) {
353+
dirs.emplace_back(URI(parent_dir + group_dir_name));
354+
}
355+
vfs.remove_dirs(&compute_tp, dirs);
336356
}
337357
// Clear metadata and other pending changes to avoid patching a deleted group.
338358
metadata_.clear();

tiledb/sm/group/group.h

+5-3
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,13 @@ class Group {
127127
void clear();
128128

129129
/**
130-
* Deletes data from and closes a group opened in MODIFY_EXCLUSIVE mode.
131130
*
132-
* Note: if recursive == false, data added to the group will be left as-is.
131+
* Handles local and remote deletion of data from a group with the given URI.
133132
*
134-
* @param uri The address of the group to be deleted.
133+
* @pre The group must be opened in MODIFY_EXCLUSIVE mode.
134+
* @note If recursive == false, data added to the group will be left as-is.
135+
*
136+
* @param uri The URI of the group to be deleted.
135137
* @param recursive True if all data inside the group is to be deleted.
136138
*/
137139
void delete_group(const URI& uri, bool recursive = false);

tiledb/sm/storage_manager/storage_manager.cc

-30
Original file line numberDiff line numberDiff line change
@@ -221,36 +221,6 @@ void StorageManagerCanonical::delete_fragments(
221221
}));
222222
}
223223

224-
void StorageManagerCanonical::delete_group(const char* group_name) {
225-
if (group_name == nullptr) {
226-
throw Status_StorageManagerError(
227-
"[delete_group] Group name cannot be null");
228-
}
229-
230-
auto group_dir = GroupDirectory(
231-
vfs(),
232-
compute_tp(),
233-
URI(group_name),
234-
0,
235-
std::numeric_limits<uint64_t>::max());
236-
237-
// Delete the group detail, group metadata and group files
238-
vfs()->remove_files(compute_tp(), group_dir.group_detail_uris());
239-
vfs()->remove_files(compute_tp(), group_dir.group_meta_uris());
240-
vfs()->remove_files(compute_tp(), group_dir.group_meta_uris_to_vacuum());
241-
vfs()->remove_files(compute_tp(), group_dir.group_meta_vac_uris_to_vacuum());
242-
vfs()->remove_files(compute_tp(), group_dir.group_file_uris());
243-
244-
// Delete all tiledb child directories
245-
// Note: using vfs()->ls() here could delete user data
246-
std::vector<URI> dirs;
247-
auto parent_dir = group_dir.uri().c_str();
248-
for (auto group_dir_name : constants::group_dir_names) {
249-
dirs.emplace_back(URI(parent_dir + group_dir_name));
250-
}
251-
vfs()->remove_dirs(compute_tp(), dirs);
252-
}
253-
254224
Status StorageManagerCanonical::array_create(
255225
const URI& array_uri,
256226
const shared_ptr<ArraySchema>& array_schema,

tiledb/sm/storage_manager/storage_manager_canonical.h

-7
Original file line numberDiff line numberDiff line change
@@ -188,13 +188,6 @@ class StorageManagerCanonical {
188188
void delete_fragments(
189189
const char* array_name, uint64_t timestamp_start, uint64_t timestamp_end);
190190

191-
/**
192-
* Cleans up the group data.
193-
*
194-
* @param group_name The name of the group whose data is to be deleted.
195-
*/
196-
void delete_group(const char* group_name);
197-
198191
/**
199192
* Creates a TileDB array storing its schema.
200193
*

0 commit comments

Comments
 (0)