MCPcopy Create free account
hub / github.com/LadybugDB/ladybug / lbug_value_create_struct

Function lbug_value_create_struct

src/c_api/value.cpp:369–392  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

367}
368
369lbug_state lbug_value_create_struct(uint64_t num_fields, const char** field_names,
370 lbug_value** field_values, lbug_value** out_value) {
371 if (out_value == nullptr) {
372 return LbugError;
373 }
374 if (num_fields == 0 || field_names == nullptr || field_values == nullptr) {
375 return LbugError;
376 }
377 auto* c_value = (lbug_value*)calloc(1, sizeof(lbug_value));
378 std::vector<std::unique_ptr<Value>> children;
379 auto struct_fields = std::vector<StructField>{};
380 for (uint64_t i = 0; i < num_fields; ++i) {
381 auto field_name = std::string(field_names[i]);
382 auto field_value = static_cast<Value*>(field_values[i]->_value);
383 auto field_type = field_value->getDataType().copy();
384 struct_fields.emplace_back(std::move(field_name), std::move(field_type));
385 children.push_back(field_value->copy());
386 }
387 auto struct_type = LogicalType::STRUCT(std::move(struct_fields));
388 c_value->_value = new Value(std::move(struct_type), std::move(children));
389 c_value->_is_owned_by_cpp = false;
390 *out_value = c_value;
391 return LbugSuccess;
392}
393
394lbug_state lbug_value_create_map(uint64_t num_fields, lbug_value** keys, lbug_value** values,
395 lbug_value** out_value) {

Callers 2

TEST_FFunction · 0.85
TESTFunction · 0.85

Calls 4

getDataTypeMethod · 0.80
emplace_backMethod · 0.80
copyMethod · 0.45
push_backMethod · 0.45

Tested by 2

TEST_FFunction · 0.68
TESTFunction · 0.68