Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
bekadavis9 committed Feb 23, 2024
1 parent 3a31958 commit 4474b82
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 22 deletions.
15 changes: 7 additions & 8 deletions tiledb/sm/consolidator/array_meta_consolidator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ Status ArrayMetaConsolidator::consolidate(
const void* encryption_key,
uint32_t key_length) {
auto timer_se = stats_->start_timer("consolidate_array_meta");

check_array_uri(array_name);

// Open array for reading
Expand All @@ -86,9 +85,7 @@ Status ArrayMetaConsolidator::consolidate(
QueryType::WRITE, encryption_type, encryption_key, key_length),
throw_if_not_ok(array_for_reads.close()));

// "Swap" the in-memory metadata between the two arrays.
// After that, the array for writes will store the (consolidated by
// the way metadata loading works) metadata of the array for reads
// Copy-assign the read metadata into the metadata of the array for writes
auto& metadata_r = array_for_reads.metadata();
array_for_writes.opened_array()->metadata() = metadata_r;
URI new_uri = metadata_r.get_uri(array_uri);
Expand All @@ -102,21 +99,23 @@ Status ArrayMetaConsolidator::consolidate(
base_uri_size = array_for_reads.array_uri().to_string().size();
}

// Write vacuum file
// Prepare vacuum file
URI vac_uri = URI(new_uri.to_string() + constants::vacuum_file_suffix);
std::stringstream ss;
for (const auto& uri : to_vacuum) {
ss << uri.to_string().substr(base_uri_size) << "\n";
}
auto data = ss.str();
RETURN_NOT_OK(
storage_manager_->vfs()->write(vac_uri, data.c_str(), data.size()));
RETURN_NOT_OK(storage_manager_->vfs()->close_file(vac_uri));

// Close arrays
throw_if_not_ok(array_for_reads.close());
throw_if_not_ok(array_for_writes.close());

// Write vacuum file
RETURN_NOT_OK(
storage_manager_->vfs()->write(vac_uri, data.c_str(), data.size()));
RETURN_NOT_OK(storage_manager_->vfs()->close_file(vac_uri));

return Status::Ok();
}

Expand Down
17 changes: 8 additions & 9 deletions tiledb/sm/consolidator/group_meta_consolidator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ GroupMetaConsolidator::GroupMetaConsolidator(
Status GroupMetaConsolidator::consolidate(
const char* group_name, EncryptionType, const void*, uint32_t) {
auto timer_se = stats_->start_timer("consolidate_group_meta");

check_array_uri(group_name);

// Open group for reading
Expand All @@ -81,29 +80,29 @@ Status GroupMetaConsolidator::consolidate(
group_for_writes.open(QueryType::WRITE),
throw_if_not_ok(group_for_reads.close()));

// "Swap" the in-memory metadata between the two groups.
// After that, the group for writes will store the (consolidated by
// the way metadata loading works) metadata of the group for reads
// Copy-assign the read metadata into the metadata of the group for writes
auto metadata_r = group_for_reads.metadata();
*(group_for_writes.metadata()) = *metadata_r;
URI new_uri = metadata_r->get_uri(group_uri);
const auto& to_vacuum = metadata_r->loaded_metadata_uris();

// Write vacuum file
// Prepare vacuum file
URI vac_uri = URI(new_uri.to_string() + constants::vacuum_file_suffix);
std::stringstream ss;
for (const auto& uri : to_vacuum) {
ss << uri.to_string() << "\n";
}
auto data = ss.str();

// Close groups
throw_if_not_ok(group_for_reads.close());
throw_if_not_ok(group_for_writes.close());

// Write vacuum file
RETURN_NOT_OK(
storage_manager_->vfs()->write(vac_uri, data.c_str(), data.size()));
RETURN_NOT_OK(storage_manager_->vfs()->close_file(vac_uri));

// Close groups
RETURN_NOT_OK(group_for_reads.close());
RETURN_NOT_OK(group_for_writes.close());

return Status::Ok();
}

Expand Down
8 changes: 4 additions & 4 deletions tiledb/sm/metadata/metadata.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ Metadata::Metadata(
build_metadata_index();
}

Metadata::~Metadata() = default;

/* ********************************* */
/* API */
/* ********************************* */
Expand Down Expand Up @@ -139,9 +137,11 @@ void Metadata::generate_uri(const URI& array_uri) {

std::map<std::string, Metadata::MetadataValue> Metadata::deserialize(
const std::vector<shared_ptr<Tile>>& metadata_tiles) {
std::map<std::string, MetadataValue> metadata_map;
if (metadata_tiles.empty()) {
return {};
}

Status st;
std::map<std::string, MetadataValue> metadata_map;
uint32_t key_len;
char del;
size_t value_len;
Expand Down
2 changes: 1 addition & 1 deletion tiledb/sm/metadata/metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class Metadata {
DISABLE_MOVE_AND_MOVE_ASSIGN(Metadata);

/** Destructor. */
~Metadata();
~Metadata() = default;

/* ********************************* */
/* API */
Expand Down

0 comments on commit 4474b82

Please sign in to comment.