NB: this is used to implement `tiledb_array_schema_get_enumeration_*` but is defined here instead of array_schema to avoid a circular dependency (array_directory depends on array_schema).
| 2104 | // but is defined here instead of array_schema to avoid a circular dependency |
| 2105 | // (array_directory depends on array_schema). |
| 2106 | void load_enumeration_into_schema( |
| 2107 | Context& ctx, const std::string& enmr_name, ArraySchema& array_schema) { |
| 2108 | if (array_schema.is_enumeration_loaded(enmr_name)) { |
| 2109 | return; |
| 2110 | } |
| 2111 | |
| 2112 | auto tracker = ctx.resources().ephemeral_memory_tracker(); |
| 2113 | |
| 2114 | if (array_schema.array_uri().is_tiledb()) { |
| 2115 | auto rest_client = ctx.resources().rest_client(); |
| 2116 | if (rest_client == nullptr) { |
| 2117 | throw ArrayException( |
| 2118 | "Error loading enumerations; Remote array schema with no REST " |
| 2119 | "client."); |
| 2120 | } |
| 2121 | |
| 2122 | auto ret = rest_client->post_enumerations_from_rest( |
| 2123 | array_schema.array_uri(), |
| 2124 | array_schema.timestamp_start(), |
| 2125 | array_schema.timestamp_end(), |
| 2126 | ctx.resources().config(), |
| 2127 | array_schema, |
| 2128 | {enmr_name}, |
| 2129 | tracker); |
| 2130 | |
| 2131 | // response is a map {schema: [enumerations]} |
| 2132 | // we should be the only schema, and expect only one enumeration |
| 2133 | for (auto enumeration : ret[array_schema.name()]) { |
| 2134 | array_schema.store_enumeration(enumeration); |
| 2135 | } |
| 2136 | } else { |
| 2137 | auto& path = array_schema.get_enumeration_path_name(enmr_name); |
| 2138 | |
| 2139 | // Create key |
| 2140 | tiledb::sm::EncryptionKey key; |
| 2141 | throw_if_not_ok( |
| 2142 | key.set_key(tiledb::sm::EncryptionType::NO_ENCRYPTION, nullptr, 0)); |
| 2143 | |
| 2144 | // Load URIs from the array directory |
| 2145 | tiledb::sm::ArrayDirectory array_dir( |
| 2146 | ctx.resources(), |
| 2147 | array_schema.array_uri(), |
| 2148 | 0, |
| 2149 | UINT64_MAX, |
| 2150 | tiledb::sm::ArrayDirectoryMode::SCHEMA_ONLY); |
| 2151 | |
| 2152 | auto enumeration = array_dir.load_enumeration(path, key, tracker); |
| 2153 | |
| 2154 | array_schema.store_enumeration(enumeration); |
| 2155 | } |
| 2156 | } |
| 2157 | |
| 2158 | } // namespace tiledb::sm |
no test coverage detected