From 686495627f7abbf680ce9af1c095f6f8d60553b2 Mon Sep 17 00:00:00 2001 From: "Paul J. Davis" Date: Fri, 8 Sep 2023 14:17:45 -0500 Subject: [PATCH] Fix bug in Array::get_enumerations (#4335) 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 (cherry picked from commit f124d5ff70e44d20926c2141c2f2d01829acc506) --- tiledb/sm/array/array.cc | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/tiledb/sm/array/array.cc b/tiledb/sm/array/array.cc index 23f045b70a1..ea629cd3ca0 100644 --- a/tiledb/sm/array/array.cc +++ b/tiledb/sm/array/array.cc @@ -590,10 +590,13 @@ std::vector> Array::get_enumerations( throw ArrayException("Unable to load enumerations; Array is not open."); } - // Dedupe the requested list of enumeration names - std::unordered_set deduped; + // Dedupe requested names and filter out anything already loaded. + std::unordered_set 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> loaded; @@ -605,19 +608,22 @@ std::vector> Array::get_enumerations( "Error loading enumerations; " "Remote array with no REST client."); } + + std::vector 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 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); }