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

Method read_sparse_array_2D

test/src/unit-capi-sparse_array.cc:351–437  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

349}
350
351int* SparseArrayFx::read_sparse_array_2D(
352 const std::string& array_name,
353 const int64_t domain_0_lo,
354 const int64_t domain_0_hi,
355 const int64_t domain_1_lo,
356 const int64_t domain_1_hi,
357 const tiledb_query_type_t query_type,
358 const tiledb_layout_t query_layout) {
359 // Open array
360 tiledb_array_t* array;
361 int rc = tiledb_array_alloc(ctx_, array_name.c_str(), &array);
362 CHECK(rc == TILEDB_OK);
363 if (encryption_type != TILEDB_NO_ENCRYPTION) {
364 tiledb_config_t* cfg;
365 tiledb_error_t* err = nullptr;
366 rc = tiledb_config_alloc(&cfg, &err);
367 REQUIRE(rc == TILEDB_OK);
368 REQUIRE(err == nullptr);
369 std::string encryption_type_string =
370 encryption_type_str((tiledb::sm::EncryptionType)encryption_type);
371 rc = tiledb_config_set(
372 cfg, "sm.encryption_type", encryption_type_string.c_str(), &err);
373 REQUIRE(rc == TILEDB_OK);
374 REQUIRE(err == nullptr);
375 rc = tiledb_config_set(cfg, "sm.encryption_key", encryption_key, &err);
376 REQUIRE(rc == TILEDB_OK);
377 REQUIRE(err == nullptr);
378 rc = tiledb_array_set_config(ctx_, array, cfg);
379 REQUIRE(rc == TILEDB_OK);
380 tiledb_config_free(&cfg);
381 }
382 rc = tiledb_array_open(ctx_, array, query_type);
383 CHECK(rc == TILEDB_OK);
384
385 // Prepare the buffers that will store the result
386 uint64_t buffer_size = 100 * 1024 * 1024;
387 auto buffer = new int[buffer_size / sizeof(int)];
388 REQUIRE(buffer != nullptr);
389
390 // Create query
391 tiledb_query_t* query;
392 rc = tiledb_query_alloc(ctx_, array, query_type, &query);
393 REQUIRE(rc == TILEDB_OK);
394 rc = tiledb_query_set_data_buffer(
395 ctx_, query, ATTR_NAME.c_str(), buffer, &buffer_size);
396 REQUIRE(rc == TILEDB_OK);
397
398 // Set a subarray
399 int64_t s0[] = {domain_0_lo, domain_0_hi};
400 int64_t s1[] = {domain_1_lo, domain_1_hi};
401 rc = tiledb_query_set_layout(ctx_, query, query_layout);
402 REQUIRE(rc == TILEDB_OK);
403 tiledb_subarray_t* subarray;
404 rc = tiledb_subarray_alloc(ctx_, array, &subarray);
405 CHECK(rc == TILEDB_OK);
406 rc = tiledb_subarray_add_range(ctx_, subarray, 0, &s0[0], &s0[1], nullptr);
407 REQUIRE(rc == TILEDB_OK);
408 rc = tiledb_subarray_add_range(ctx_, subarray, 1, &s1[0], &s1[1], nullptr);

Callers

nothing calls this directly

Calls 15

tiledb_array_allocFunction · 0.85
tiledb_config_allocFunction · 0.85
tiledb_config_setFunction · 0.85
tiledb_array_set_configFunction · 0.85
tiledb_config_freeFunction · 0.85
tiledb_array_openFunction · 0.85
tiledb_query_allocFunction · 0.85
tiledb_query_set_layoutFunction · 0.85
tiledb_subarray_allocFunction · 0.85

Tested by

no test coverage detected