Skip to content

Commit

Permalink
Post-rebase fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
bekadavis9 committed Jun 6, 2024
1 parent b402392 commit 0e4e4d4
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
47 changes: 47 additions & 0 deletions tiledb/sm/group/group.cc
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,53 @@ void Group::set_metadata_loaded(const bool metadata_loaded) {
metadata_loaded_ = metadata_loaded;
}

Status Group::consolidate_metadata(
ContextResources& resources, const char* group_name, const Config& config) {
// Check group URI
URI group_uri(group_name);
if (group_uri.is_invalid()) {
throw GroupException("Cannot consolidate group metadata; Invalid URI");
}
// Check if group exists
ObjectType obj_type;
throw_if_not_ok(object_type(resources, group_uri, &obj_type));

if (obj_type != ObjectType::GROUP) {
throw GroupException(
"Cannot consolidate group metadata; Group does not exist");
}

// Consolidate
// Encryption credentials are loaded by Group from config
StorageManager sm(resources, resources.logger(), config);
auto consolidator =
Consolidator::create(ConsolidationMode::GROUP_META, config, &sm);
return consolidator->consolidate(
group_name, EncryptionType::NO_ENCRYPTION, nullptr, 0);
}

void Group::vacuum_metadata(
ContextResources& resources, const char* group_name, const Config& config) {
// Check group URI
URI group_uri(group_name);
if (group_uri.is_invalid()) {
throw GroupException("Cannot vacuum group metadata; Invalid URI");
}

// Check if group exists
ObjectType obj_type;
throw_if_not_ok(object_type(resources, group_uri, &obj_type));

if (obj_type != ObjectType::GROUP) {
throw GroupException("Cannot vacuum group metadata; Group does not exist");
}

StorageManager sm(resources, resources.logger(), config);
auto consolidator =
Consolidator::create(ConsolidationMode::GROUP_META, config, &sm);
consolidator->vacuum(group_name);
}

const EncryptionKey* Group::encryption_key() const {
return encryption_key_.get();
}
Expand Down
31 changes: 31 additions & 0 deletions tiledb/sm/group/group.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,37 @@ class Group {
*/
void set_metadata_loaded(const bool metadata_loaded);

/**
* Consolidates the metadata of a group into a single file.
*
* @param resources The context resources.
* @param group_name The name of the group whose metadata will be
* consolidated.
* @param config Configuration parameters for the consolidation
* (`nullptr` means default, which will use the config associated with
* this instance).
* @return Status
*/
static Status consolidate_metadata(
ContextResources& resources,
const char* group_name,
const Config& config);

/**
* Vacuums the consolidated metadata files of a group.
*
* @param resources The context resources.
* @param group_name The name of the group whose metadata will be
* vacuumed.
* @param config Configuration parameters for vacuuming
* (`nullptr` means default, which will use the config associated with
* this instance).
*/
static void vacuum_metadata(
ContextResources& resources,
const char* group_name,
const Config& config);

/** Returns a constant pointer to the encryption key. */
const EncryptionKey* encryption_key() const;

Expand Down

0 comments on commit 0e4e4d4

Please sign in to comment.