Skip to content

Commit

Permalink
Fix bug in Array::get_enumerations (#4335)
Browse files Browse the repository at this point in the history
Ensure we filter enumerations for anything already loaded even when loading from the REST server.

---
TYPE: BUG
DESC: Fix re-loading enumerations from the REST server
  • Loading branch information
davisp authored Sep 8, 2023
1 parent cf11f23 commit f124d5f
Showing 1 changed file with 14 additions and 8 deletions.
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

0 comments on commit f124d5f

Please sign in to comment.