Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix re-loading enumerations from the REST server #4335

Merged
merged 1 commit into from
Sep 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions tiledb/sm/array/array.cc
Original file line number Diff line number Diff line change
Expand Up @@ -590,10 +590,13 @@ std::vector<shared_ptr<const Enumeration>> Array::get_enumerations(
throw ArrayException("Unable to load enumerations; Array is not open.");
}

// Dedupe the requested list of enumeration names
std::unordered_set<std::string> deduped;
// Dedupe requested names and filter out anything already loaded.
std::unordered_set<std::string> enmrs_to_load;
for (auto& enmr_name : enumeration_names) {
deduped.insert(enmr_name);
if (array_schema_latest_->is_enumeration_loaded(enmr_name)) {
continue;
}
enmrs_to_load.insert(enmr_name);
}

std::vector<shared_ptr<const Enumeration>> loaded;
Expand All @@ -605,19 +608,22 @@ std::vector<shared_ptr<const Enumeration>> Array::get_enumerations(
"Error loading enumerations; "
"Remote array with no REST client.");
}

std::vector<std::string> names_to_load;
for (auto& enmr_name : enmrs_to_load) {
names_to_load.push_back(enmr_name);
}

loaded = rest_client->post_enumerations_from_rest(
array_uri_,
timestamp_start_,
timestamp_end_opened_at_,
this,
enumeration_names);
names_to_load);
} else {
// Create a vector of paths to be loaded.
std::vector<std::string> paths_to_load;
for (auto& enmr_name : deduped) {
if (array_schema_latest_->is_enumeration_loaded(enmr_name)) {
continue;
}
for (auto& enmr_name : enmrs_to_load) {
auto path = array_schema_latest_->get_enumeration_path_name(enmr_name);
paths_to_load.push_back(path);
}
Expand Down
Loading