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

Function create_array

examples/cpp_api/query_condition_sparse.cc:77–96  ·  view source on GitHub ↗

* @brief Function to create the TileDB array used in this example. * The array will be 1D with size 1 with dimension "index". * The bounds on the index will be 0 through 9, inclusive. * * The array has four attributes. The four attributes are * - "a" (type int) * - "b" (type std::string) * - "c" (type int32_t) * - "d" (type float) * * @param ctx The context. */

Source from the content-addressed store, hash-verified

75 * @param ctx The context.
76 */
77void create_array(Context& ctx) {
78 // Creating the domain and the dimensions.
79 Domain domain(ctx);
80 domain.add_dimension(
81 Dimension::create<int32_t>(ctx, "index", {{0, num_elems - 1}}));
82
83 // The array will be sparse.
84 ArraySchema schema(ctx, TILEDB_SPARSE);
85 schema.set_domain(domain).set_order({{TILEDB_ROW_MAJOR}});
86
87 // Adding the attributes of the array to the array schema.
88 Attribute a = Attribute::create<int>(ctx, "a").set_nullable(true);
89 schema.add_attribute(a)
90 .add_attribute(Attribute::create<std::string>(ctx, "b"))
91 .add_attribute(Attribute::create<int32_t>(ctx, "c"))
92 .add_attribute(Attribute::create<float>(ctx, "d"));
93
94 // Create the (empty) array.
95 Array::create(ctx, array_name, schema);
96}
97
98/**
99 * @brief Execute a write on array query_condition_sparse array

Callers 1

mainFunction · 0.70

Calls 4

add_dimensionMethod · 0.45
set_domainMethod · 0.45
set_nullableMethod · 0.45
add_attributeMethod · 0.45

Tested by

no test coverage detected