| 151 | } |
| 152 | |
| 153 | std::unordered_map<std::string, shared_ptr<ArraySchema>> |
| 154 | ArrayDirectory::load_all_array_schemas( |
| 155 | const EncryptionKey& encryption_key, |
| 156 | shared_ptr<MemoryTracker> memory_tracker) const { |
| 157 | auto timer_se = |
| 158 | resources_.get().stats().start_timer("sm_load_all_array_schemas"); |
| 159 | |
| 160 | if (uri_.is_invalid()) { |
| 161 | throw ArrayDirectoryException( |
| 162 | "Cannot load all array schemas; Invalid array URI"); |
| 163 | } |
| 164 | |
| 165 | const std::vector<URI>& schema_uris = array_schema_uris(); |
| 166 | if (schema_uris.empty()) { |
| 167 | throw ArrayDirectoryException( |
| 168 | "Cannot get the array schema vector; No array schemas found."); |
| 169 | } |
| 170 | |
| 171 | std::vector<shared_ptr<ArraySchema>> schema_vector; |
| 172 | auto schema_num = schema_uris.size(); |
| 173 | schema_vector.resize(schema_num); |
| 174 | |
| 175 | auto status = parallel_for( |
| 176 | &resources_.get().compute_tp(), 0, schema_num, [&](size_t schema_ith) { |
| 177 | auto& schema_uri = schema_uris[schema_ith]; |
| 178 | try { |
| 179 | auto&& array_schema = load_array_schema_from_uri( |
| 180 | resources_.get(), schema_uri, encryption_key, memory_tracker); |
| 181 | array_schema->set_array_uri(uri_); |
| 182 | schema_vector[schema_ith] = array_schema; |
| 183 | } catch (std::exception& e) { |
| 184 | // TODO: We could throw a nested exception, but converting exceptions |
| 185 | // to statuses loses the inner exception messages. We can revisit this |
| 186 | // when Status gets removed from this module. |
| 187 | throw ArrayDirectoryException(e.what()); |
| 188 | } |
| 189 | |
| 190 | return Status::Ok(); |
| 191 | }); |
| 192 | throw_if_not_ok(status); |
| 193 | |
| 194 | std::unordered_map<std::string, shared_ptr<ArraySchema>> array_schemas; |
| 195 | for (const auto& schema : schema_vector) { |
| 196 | array_schemas[schema->name()] = schema; |
| 197 | } |
| 198 | |
| 199 | return array_schemas; |
| 200 | } |
| 201 | |
| 202 | std::vector<shared_ptr<const Enumeration>> |
| 203 | ArrayDirectory::load_enumerations_from_paths( |
nothing calls this directly
no test coverage detected