* Example reading data from one dimension label. * * @param ctx TileDB context to call TileDB API with. * @param array_uri URI of the array to read from. */
| 231 | * @param array_uri URI of the array to read from. |
| 232 | */ |
| 233 | void read_timestamp_data(const Context& ctx, const char* array_uri) { |
| 234 | printf("\nRead from dimension label\n"); |
| 235 | |
| 236 | // Open array for reading. |
| 237 | Array array(ctx, array_uri, TILEDB_READ); |
| 238 | |
| 239 | // Create subarray for reading data. |
| 240 | // Note: Since we are only reading a dimension label on dimension 1, any |
| 241 | // ranges set on dimension 0 will be ignored. |
| 242 | Subarray subarray(ctx, array); |
| 243 | subarray.add_range(1, 1, 3); |
| 244 | |
| 245 | // Create buffers to hold the output data. |
| 246 | std::vector<int64_t> timestamp(3); |
| 247 | |
| 248 | // Create the query. |
| 249 | Query query(ctx, array); |
| 250 | query.set_subarray(subarray); |
| 251 | query.set_layout(TILEDB_ROW_MAJOR); |
| 252 | QueryExperimental::set_data_buffer(query, "timestamp", timestamp); |
| 253 | auto status = query.submit(); |
| 254 | // Check the query finished. |
| 255 | if (status != Query::Status::COMPLETE) { |
| 256 | printf("Warning: Read query did not complete.\n"); |
| 257 | } |
| 258 | |
| 259 | // Print results. |
| 260 | for (unsigned j = 0; j < 3; ++j) { |
| 261 | int32_t sample_val = j + 1; |
| 262 | printf(" Cell (--, %d)\n", sample_val); |
| 263 | printf(" * timestamp(%d) = ", sample_val); |
| 264 | print_timestamp(timestamp[j]); |
| 265 | printf("\n"); |
| 266 | } |
| 267 | } |
| 268 | |
| 269 | /** |
| 270 | * Example reading data from the array by the dimension labels. |
no test coverage detected