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

Function create_array

examples/cpp_api/quickstart_dimension_labels.cc:100–125  ·  view source on GitHub ↗

* Create a TileDB array with dimension labels. * * * Array Summary: * * Array Type: Dense * * Dimensions: * - x_index: (type=INT32, domain=[0, 5]) * - sample: (type=INT32, domain=[0,3]) * * * Attributes: * - a: (type=INT16) * * * Labels on dimension 'x_index': * - x (order=INCREASING, type=FLOAT64) * - y (order=INCREASING, type=FLOAT64) * * * Labels on dimension

Source from the content-addressed store, hash-verified

98 * @param array_uri The URI to create the array at.
99 */
100void create_array(const Context& ctx, const char* array_uri) {
101 // Create dimensions.
102 auto d1 = Dimension::create<int32_t>(ctx, "x_index", {{0, 5}}, 6);
103 auto d2 = Dimension::create<int32_t>(ctx, "sample", {{0, 3}}, 4);
104
105 // Create the domain.
106 Domain domain(ctx);
107 domain.add_dimensions(d1, d2);
108
109 // Create a single attribute.
110 Attribute a = Attribute::create<int16_t>(ctx, "a");
111
112 // Create array schema.
113 ArraySchema schema(ctx, TILEDB_DENSE);
114 schema.set_cell_order(TILEDB_ROW_MAJOR);
115 schema.set_tile_order(TILEDB_ROW_MAJOR);
116 schema.set_domain(domain);
117 schema.add_attribute(a);
118 ArraySchemaExperimental::add_dimension_label(
119 ctx, schema, 0, "x", TILEDB_INCREASING_DATA, TILEDB_FLOAT64);
120 ArraySchemaExperimental::add_dimension_label(
121 ctx, schema, 0, "y", TILEDB_INCREASING_DATA, TILEDB_FLOAT64);
122 ArraySchemaExperimental::add_dimension_label(
123 ctx, schema, 1, "timestamp", TILEDB_INCREASING_DATA, TILEDB_DATETIME_SEC);
124 Array::create(ctx, array_uri, schema);
125}
126
127/**
128 * Write TileDB array data and label data on the entire array.

Callers 1

mainFunction · 0.70

Calls 4

set_cell_orderMethod · 0.45
set_tile_orderMethod · 0.45
set_domainMethod · 0.45
add_attributeMethod · 0.45

Tested by

no test coverage detected