MCPcopy Create free account
hub / github.com/TileDB-Inc/TileDB / evolve_array_schema

Method evolve_array_schema

tiledb/sm/array/array.cc:114–176  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

112/* ********************************* */
113
114void Array::evolve_array_schema(
115 ContextResources& resources,
116 const URI& array_uri,
117 ArraySchemaEvolution* schema_evolution,
118 const EncryptionKey& encryption_key) {
119 // Check array schema
120 if (schema_evolution == nullptr) {
121 throw ArrayException("Cannot evolve array; Empty schema evolution");
122 }
123
124 if (array_uri.is_tiledb()) {
125 throw_if_not_ok(
126 resources.rest_client()->post_array_schema_evolution_to_rest(
127 array_uri, schema_evolution));
128 return;
129 }
130
131 // Load URIs from the array directory
132 tiledb::sm::ArrayDirectory array_dir{
133 resources,
134 array_uri,
135 0,
136 UINT64_MAX,
137 tiledb::sm::ArrayDirectoryMode::SCHEMA_ONLY};
138
139 // Check if array exists
140 if (!is_array(resources, array_uri)) {
141 throw ArrayException(
142 "Cannot evolve array; '" + array_uri.to_string() + "' does not exist");
143 }
144
145 auto&& array_schema = array_dir.load_array_schema_latest(
146 encryption_key, resources.ephemeral_memory_tracker());
147
148 // Load required enumerations before evolution.
149 auto enmr_names = schema_evolution->enumeration_names_to_extend();
150 if (enmr_names.size() > 0) {
151 std::unordered_set<std::string> enmr_path_set;
152 for (auto name : enmr_names) {
153 enmr_path_set.insert(array_schema->get_enumeration_path_name(name));
154 }
155 std::vector<std::string> enmr_paths;
156 for (auto path : enmr_path_set) {
157 enmr_paths.emplace_back(path);
158 }
159
160 auto loaded_enmrs = array_dir.load_enumerations_from_paths(
161 enmr_paths, encryption_key, resources.create_memory_tracker());
162
163 for (auto enmr : loaded_enmrs) {
164 array_schema->store_enumeration(enmr);
165 }
166 }
167
168 // Evolve schema
169 auto array_schema_evolved = schema_evolution->evolve_schema(array_schema);
170 try {
171 store_array_schema(resources, array_schema_evolved, encryption_key);

Callers

nothing calls this directly

Calls 15

ArrayExceptionClass · 0.85
throw_if_not_okFunction · 0.85
is_arrayFunction · 0.85
store_array_schemaFunction · 0.85
is_tiledbMethod · 0.80
to_stringMethod · 0.80
create_memory_trackerMethod · 0.80
store_enumerationMethod · 0.80

Tested by

no test coverage detected