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

Function read_array2

examples/cpp_api/array_schema_evolution.cc:138–175  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

136}
137
138void read_array2(const Context& ctx) {
139 // Prepare the array for reading
140 Array array(ctx, array_uri, TILEDB_READ);
141
142 // Prepare the vector that will hold the result.
143 // We take an upper bound on the result size, as we do not
144 // know a priori how big it is (since the array is sparse)
145 std::vector<int> a_data(4);
146 std::vector<uint32_t> b_data(4);
147 std::vector<int> coords_rows(4);
148 std::vector<int> coords_cols(4);
149
150 // Prepare the query
151 Subarray subarray(ctx, array);
152 subarray.add_range(0, 1, 4).add_range(1, 1, 4);
153 Query query(ctx, array, TILEDB_READ);
154 query.set_subarray(subarray)
155 .set_layout(TILEDB_ROW_MAJOR)
156 .set_data_buffer("a", a_data)
157 .set_data_buffer("b", b_data)
158 .set_data_buffer("rows", coords_rows)
159 .set_data_buffer("cols", coords_cols);
160
161 // Submit the query and close the array.
162 query.submit();
163 array.close();
164
165 // Print out the results.
166 auto result_num = (int)query.result_buffer_elements()["a"].second;
167 for (int r = 0; r < result_num; r++) {
168 int i = coords_rows[r];
169 int j = coords_cols[r];
170 int a = a_data[r];
171 int b = b_data[r];
172 std::cout << "Cell (" << i << ", " << j << ") has data " << a << ", " << b
173 << "\n";
174 }
175}
176
177void array_schema_evolve(const Context& ctx) {
178 ArraySchemaEvolution schemaEvolution = ArraySchemaEvolution(ctx);

Callers 1

mainFunction · 0.85

Calls 7

add_rangeMethod · 0.45
set_data_bufferMethod · 0.45
set_layoutMethod · 0.45
set_subarrayMethod · 0.45
submitMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected