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

Method add_attribute

tiledb/sm/array_schema/array_schema_evolution.cc:188–214  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

186}
187
188void ArraySchemaEvolution::add_attribute(shared_ptr<const Attribute> attr) {
189 std::lock_guard<std::mutex> lock(mtx_);
190 if (!attr) {
191 throw ArraySchemaEvolutionException(
192 "Cannot add attribute; Input attribute is null");
193 }
194 for (const auto& a : attributes_to_add_) {
195 if (a->name() == attr->name()) {
196 throw ArraySchemaEvolutionException(
197 "Cannot add attribute; Input attribute name is already there");
198 }
199 }
200
201 // Create new attribute and potentially set a default name
202 /*
203 * At present, the container for attributes within the schema evolution
204 * object is based on `unique_ptr`. The argument is `shared_ptr`, since
205 * that's how C API handles and `class Array` store them. It might be better
206 * to change the container type, but until then, we copy the attribute into
207 * a new allocation.
208 */
209 attributes_to_add_.push_back(
210 tdb_unique_ptr<Attribute>(tdb_new(Attribute, *attr)));
211 if (attributes_to_drop_.find(attr->name()) != attributes_to_drop_.end()) {
212 attributes_to_drop_.erase(attr->name());
213 }
214}
215
216std::vector<std::string> ArraySchemaEvolution::attribute_names_to_add() const {
217 std::lock_guard<std::mutex> lock(mtx_);

Callers 1

evolve_schemaMethod · 0.45

Calls 4

nameMethod · 0.45
push_backMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected