Skip to content

Commit

Permalink
Update Subarray Cap'n Proto serialization to include label ranges (#3961
Browse files Browse the repository at this point in the history
)

This is the third part of the work to add serialization support for dimension labels. It is adding label ranges to the `Subarray` capnp format and `subarray_to/from_capnp` functions.

For now only 1 test is added, but a wrapper test function is provided in this PR and can be used to enhance other existing tests that use label ranges to increase coverage.

After this part is merged, then `Update Query Cap'n Proto to support label queries` is the last (and probably most complex) part of dimension label serialization work left.

---
TYPE: IMPROVEMENT
DESC: Update Subarray Cap'n Proto serialization to include label ranges

---------

Co-authored-by: Julia Dark <[email protected]>
  • Loading branch information
ypatia and jp-dark authored Apr 13, 2023
1 parent 6f1390b commit 7d36c09
Show file tree
Hide file tree
Showing 14 changed files with 1,775 additions and 105 deletions.
17 changes: 17 additions & 0 deletions test/src/test-capi-dense-array-dimension-label.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
* labels.
*/

#include <test/support/tdb_catch.h>
#include "test/support/src/helpers.h"
#include "test/support/src/serialization_wrappers.h"
#include "test/support/src/vfs_helpers.h"
#include "tiledb/api/c_api/context/context_api_internal.h"
#include "tiledb/sm/c_api/tiledb.h"
Expand Down Expand Up @@ -142,6 +144,9 @@ class DenseArrayExample1 : public TemporaryDirectoryFixture {
require_tiledb_ok(tiledb_subarray_alloc(ctx, array, &subarray));
require_tiledb_ok(tiledb_subarray_add_range(
ctx, subarray, 0, &index_start, &index_end, nullptr));
if (serialize_) {
tiledb_subarray_serialize(ctx, array, &subarray);
}

// Create write query.
tiledb_query_t* query;
Expand Down Expand Up @@ -206,6 +211,10 @@ class DenseArrayExample1 : public TemporaryDirectoryFixture {
require_tiledb_ok(tiledb_subarray_add_label_range(
ctx, subarray, "x", &label_start, &label_end, nullptr));

if (serialize_) {
tiledb_subarray_serialize(ctx, array, &subarray);
}

// Create write query.
tiledb_query_t* query;
require_tiledb_ok(tiledb_query_alloc(ctx, array, TILEDB_WRITE, &query));
Expand Down Expand Up @@ -258,6 +267,10 @@ class DenseArrayExample1 : public TemporaryDirectoryFixture {
require_tiledb_ok(tiledb_subarray_add_range(
ctx, subarray, 0, &index_domain_[0], &index_domain_[1], nullptr));

if (serialize_) {
tiledb_subarray_serialize(ctx, array, &subarray);
}

// Define buffer and size values.
std::vector<double> label_data(4);
uint64_t label_data_size{label_data.size() * sizeof(double)};
Expand Down Expand Up @@ -324,6 +337,10 @@ class DenseArrayExample1 : public TemporaryDirectoryFixture {
ctx, subarray, "x", &ranges[2 * r], &ranges[2 * r + 1], nullptr));
}

if (serialize_) {
tiledb_subarray_serialize(ctx, array, &subarray);
}

// Define label buffer and size.
std::vector<double> label_data(expected_label_data.size());
uint64_t label_data_size{label_data.size() * sizeof(double)};
Expand Down
7 changes: 6 additions & 1 deletion test/src/test-capi-sparse-array-dimension-label.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,16 @@
* labels.
*/

#include <test/support/tdb_catch.h>
#include "test/support/src/helpers.h"
#include "test/support/src/serialization_wrappers.h"
#include "test/support/src/vfs_helpers.h"
#include "tiledb/api/c_api/context/context_api_internal.h"
#include "tiledb/sm/c_api/tiledb.h"
#include "tiledb/sm/c_api/tiledb_experimental.h"
#include "tiledb/sm/c_api/tiledb_struct_def.h"
#include "tiledb/sm/enums/encryption_type.h"

#include <test/support/tdb_catch.h>
#include <iostream>
#include <string>

Expand Down Expand Up @@ -249,6 +250,10 @@ class SparseArrayExample1 : public TemporaryDirectoryFixture {
ctx, subarray, "x", &ranges[2 * r], &ranges[2 * r + 1], nullptr));
}

if (serialize_) {
tiledb_subarray_serialize(ctx, array, &subarray);
}

// Define label buffer and size.
std::vector<double> label_data(expected_label_data.size());
uint64_t label_data_size{label_data.size() * sizeof(double)};
Expand Down
Loading

0 comments on commit 7d36c09

Please sign in to comment.