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

Function read_array_1d_empty

test/src/unit-cppapi-fill_values.cc:252–296  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

250}
251
252void read_array_1d_empty(
253 const std::string& array_name,
254 int32_t fill_int32 = tiledb::sm::constants::empty_int32,
255 std::string fill_char = std::string() + tiledb::sm::constants::empty_char,
256 std::array<double, 2> fill_double = {
257 {tiledb::sm::constants::empty_float64,
258 tiledb::sm::constants::empty_float64}}) {
259 Context ctx;
260
261 std::vector<int32_t> a1(10);
262 std::vector<char> a2_val(100);
263 std::vector<uint64_t> a2_off(20);
264 std::vector<double> a3(20);
265
266 Array array(ctx, array_name, TILEDB_READ);
267 Query query(ctx, array, TILEDB_READ);
268 CHECK_NOTHROW(query.set_data_buffer("a1", a1));
269 CHECK_NOTHROW(query.set_data_buffer("a2", a2_val));
270 CHECK_NOTHROW(query.set_offsets_buffer("a2", a2_off));
271 CHECK_NOTHROW(query.set_data_buffer("a3", a3));
272 CHECK_NOTHROW(
273 query.set_subarray(Subarray(ctx, array).set_subarray<int32_t>({1, 10})));
274
275 REQUIRE(query.submit() == Query::Status::COMPLETE);
276
277 auto res = query.result_buffer_elements();
278 REQUIRE(res["a1"].second == 10);
279 REQUIRE(res["a2"].first == 10);
280 REQUIRE(res["a2"].second == 10 * fill_char.size());
281 REQUIRE(res["a3"].second == 20);
282
283 uint64_t off = 0;
284 for (size_t i = 0; i < 10; ++i) {
285 CHECK(a1[i] == fill_int32);
286 CHECK(a2_off[i] == off);
287 for (size_t c = 0; c < fill_char.size(); ++c) {
288 CHECK(a2_val[off] == fill_char[c]);
289 ++off;
290 }
291 CHECK(!std::memcmp(&a3[2 * i], &fill_double[0], sizeof(double)));
292 CHECK(!std::memcmp(&a3[2 * i + 1], &fill_double[1], sizeof(double)));
293 }
294
295 array.close();
296}
297
298TEST_CASE(
299 "C++ API: Test fill values, basic errors", "[cppapi][fill-values][basic]") {

Callers 1

Calls 8

SubarrayClass · 0.50
set_data_bufferMethod · 0.45
set_offsets_bufferMethod · 0.45
set_subarrayMethod · 0.45
submitMethod · 0.45
sizeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected