|
30 | 30 | * Tests the C++ API for array metadata. |
31 | 31 | */ |
32 | 32 |
|
| 33 | +#include <tiledb/api/c_api/array/array_api_internal.h> |
| 34 | +#include <latch> |
33 | 35 | #include "test/support/src/helpers.h" |
34 | 36 | #include "test/support/src/vfs_helpers.h" |
35 | 37 | #include "tiledb/sm/c_api/tiledb.h" |
@@ -180,6 +182,55 @@ TEST_CASE_METHOD( |
180 | 182 | array.close(); |
181 | 183 | } |
182 | 184 |
|
| 185 | +TEST_CASE_METHOD( |
| 186 | + CPPMetadataFx, |
| 187 | + "C++ API: Metadata write / read at timestamp smr", |
| 188 | + "[cppapi][metadata][timestamp][smr]") { |
| 189 | + create_default_array_1d(); |
| 190 | + Context ctx; |
| 191 | + |
| 192 | + std::vector<uint64_t> a(100); |
| 193 | + std::iota(a.begin(), a.end(), 0); |
| 194 | + std::vector<uint64_t> b(1000); |
| 195 | + std::iota(b.begin(), b.end(), 0); |
| 196 | + |
| 197 | + const auto tp = TemporalPolicy(TimestampStartEnd, 0, 1); |
| 198 | + std::latch latch(2); |
| 199 | + std::string meta[]{"a", "b", "c", "d", "e", "f"}; |
| 200 | + Array array1(ctx, std::string(array_name_), TILEDB_WRITE, tp); |
| 201 | + array1.put_metadata("a", TILEDB_UINT64, 100, a.data()); |
| 202 | + array1.close(); |
| 203 | + |
| 204 | + Array array(ctx, std::string(array_name_), TILEDB_WRITE, tp); |
| 205 | + std::thread t1([&]() { |
| 206 | + for (const auto& x : meta) { |
| 207 | + array.put_metadata(x, TILEDB_UINT64, 1000, b.data()); |
| 208 | + } |
| 209 | + latch.count_down(); |
| 210 | + array.close(); |
| 211 | + }); |
| 212 | + |
| 213 | + std::thread t2([&]() { |
| 214 | + latch.arrive_and_wait(); |
| 215 | + Array read_array(ctx, std::string(array_name_), TILEDB_READ, tp); |
| 216 | + |
| 217 | + for (const auto& x : meta) { |
| 218 | + tiledb_datatype_t type; |
| 219 | + uint32_t value_num = 0; |
| 220 | + const void* data; |
| 221 | + read_array.get_metadata(x, &type, &value_num, &data); |
| 222 | + std::cout << "'value_num':" << value_num << std::endl; |
| 223 | + std::cout << "'" << x << "': "; |
| 224 | + for (size_t i = 0; i < value_num; ++i) { |
| 225 | + std::cout << ((const uint64_t*)data)[i] << ","; |
| 226 | + } |
| 227 | + std::cout << std::endl; |
| 228 | + } |
| 229 | + read_array.close(); |
| 230 | + }); |
| 231 | + t1.join(), t2.join(); |
| 232 | +} |
| 233 | + |
183 | 234 | TEST_CASE_METHOD( |
184 | 235 | CPPMetadataFx, |
185 | 236 | "C++ API: Metadata, write/read", |
|
0 commit comments