Skip to content

Commit 87db931

Browse files
committed
Changes to loading enumerations.
1 parent c75791a commit 87db931

File tree

7 files changed

+24
-12
lines changed

7 files changed

+24
-12
lines changed

test/src/unit-capi-config.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ void check_save_to_file() {
230230
ss << "rest.curl.buffer_size 524288\n";
231231
ss << "rest.curl.verbose false\n";
232232
ss << "rest.http_compressor any\n";
233-
ss << "rest.load_enumerations_on_array_open true\n";
233+
ss << "rest.load_enumerations_on_array_open false\n";
234234
ss << "rest.load_metadata_on_array_open true\n";
235235
ss << "rest.load_non_empty_domain_on_array_open true\n";
236236
ss << "rest.retry_count 25\n";

tiledb/api/c_api/config/config_api_external.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,10 @@ TILEDB_EXPORT void tiledb_config_free(tiledb_config_t** config) TILEDB_NOEXCEPT;
740740
* If true, array non empty domain will be loaded and sent to server together
741741
* with the open array <br>
742742
* **Default**: true
743+
* - `rest.load_enumerations_on_array_open` <br>
744+
* If true, enumerations will be loaded and sent to server together with
745+
* the open array.
746+
* **Default**: false
743747
* - `rest.use_refactored_array_open` <br>
744748
* If true, the new REST routes and APIs for opening an array
745749
* will be used <br>

tiledb/sm/array/array.cc

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -804,19 +804,21 @@ void Array::encryption_type(
804804

805805
shared_ptr<const Enumeration> Array::get_enumeration(
806806
const std::string& enumeration_name) {
807-
return get_enumerations({enumeration_name})[0];
807+
return get_enumerations(
808+
{enumeration_name}, opened_array_->array_schema_latest_ptr())[0];
808809
}
809810

810811
std::vector<shared_ptr<const Enumeration>> Array::get_enumerations(
811-
const std::vector<std::string>& enumeration_names) {
812+
const std::vector<std::string>& enumeration_names,
813+
shared_ptr<ArraySchema> schema) {
812814
if (!is_open_) {
813815
throw ArrayException("Unable to load enumerations; Array is not open.");
814816
}
815817

816818
// Dedupe requested names and filter out anything already loaded.
817819
std::unordered_set<std::string> enmrs_to_load;
818820
for (auto& enmr_name : enumeration_names) {
819-
if (array_schema_latest().is_enumeration_loaded(enmr_name)) {
821+
if (schema->is_enumeration_loaded(enmr_name)) {
820822
continue;
821823
}
822824
enmrs_to_load.insert(enmr_name);
@@ -850,7 +852,7 @@ std::vector<shared_ptr<const Enumeration>> Array::get_enumerations(
850852
// Create a vector of paths to be loaded.
851853
std::vector<std::string> paths_to_load;
852854
for (auto& enmr_name : enmrs_to_load) {
853-
auto path = array_schema_latest().get_enumeration_path_name(enmr_name);
855+
auto path = schema->get_enumeration_path_name(enmr_name);
854856
paths_to_load.push_back(path);
855857
}
856858

@@ -861,14 +863,14 @@ std::vector<shared_ptr<const Enumeration>> Array::get_enumerations(
861863

862864
// Store the loaded enumerations in the schema
863865
for (auto& enmr : loaded) {
864-
opened_array_->array_schema_latest_ptr()->store_enumeration(enmr);
866+
schema->store_enumeration(enmr);
865867
}
866868
}
867869

868870
// Return the requested list of enumerations
869871
std::vector<shared_ptr<const Enumeration>> ret(enumeration_names.size());
870872
for (size_t i = 0; i < enumeration_names.size(); i++) {
871-
ret[i] = array_schema_latest().get_enumeration(enumeration_names[i]);
873+
ret[i] = schema->get_enumeration(enumeration_names[i]);
872874
}
873875
return ret;
874876
}
@@ -878,7 +880,9 @@ void Array::load_all_enumerations() {
878880
throw ArrayException("Unable to load all enumerations; Array is not open.");
879881
}
880882
// Load all enumerations, discarding the returned list of loaded enumerations.
881-
get_enumerations(array_schema_latest().get_enumeration_names());
883+
for (const auto& schema : array_schemas_all()) {
884+
get_enumerations(schema.second->get_enumeration_names(), schema.second);
885+
}
882886
}
883887

884888
bool Array::is_empty() const {

tiledb/sm/array/array.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,10 +589,12 @@ class Array {
589589
* loaded before this function returns.
590590
*
591591
* @param enumeration_names The names of the enumerations.
592+
* @param schema The ArraySchema to store loaded enumerations in.
592593
* @return std::vector<shared_ptr<const Enumeration>> The loaded enumerations.
593594
*/
594595
std::vector<shared_ptr<const Enumeration>> get_enumerations(
595-
const std::vector<std::string>& enumeration_names);
596+
const std::vector<std::string>& enumeration_names,
597+
shared_ptr<ArraySchema> schema);
596598

597599
/** Load all enumerations for the array. */
598600
void load_all_enumerations();

tiledb/sm/array/array_directory.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ shared_ptr<ArraySchema> ArrayDirectory::load_array_schema_latest(
123123
auto&& array_schema = load_array_schema_from_uri(
124124
resources_.get(), schema_uri, encryption_key, memory_tracker);
125125

126-
array_schema->set_array_uri(uri_);
126+
array_schema->set_array_uri(uri_.remove_trailing_slash());
127127

128128
return std::move(array_schema);
129129
}

tiledb/sm/c_api/tiledb.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3936,7 +3936,9 @@ capi_return_t tiledb_handle_load_enumerations_request(
39363936
tiledb::sm::serialization::deserialize_load_enumerations_request(
39373937
static_cast<tiledb::sm::SerializationType>(serialization_type),
39383938
request->buffer());
3939-
auto enumerations = array->array_->get_enumerations(enumeration_names);
3939+
auto enumerations = array->array_->get_enumerations(
3940+
enumeration_names,
3941+
array->array_->opened_array()->array_schema_latest_ptr());
39403942

39413943
tiledb::sm::serialization::serialize_load_enumerations_response(
39423944
enumerations,

tiledb/sm/config/config.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ const std::string Config::REST_RETRY_DELAY_FACTOR = "1.25";
9191
const std::string Config::REST_CURL_BUFFER_SIZE = "524288";
9292
const std::string Config::REST_CAPNP_TRAVERSAL_LIMIT = "2147483648";
9393
const std::string Config::REST_CURL_VERBOSE = "false";
94-
const std::string Config::REST_LOAD_ENUMERATIONS_ON_ARRAY_OPEN = "true";
94+
const std::string Config::REST_LOAD_ENUMERATIONS_ON_ARRAY_OPEN = "false";
9595
const std::string Config::REST_LOAD_METADATA_ON_ARRAY_OPEN = "true";
9696
const std::string Config::REST_LOAD_NON_EMPTY_DOMAIN_ON_ARRAY_OPEN = "true";
9797
const std::string Config::REST_USE_REFACTORED_ARRAY_OPEN = "true";

0 commit comments

Comments
 (0)