Skip to content

Commit

Permalink
Add group member with type (#5336)
Browse files Browse the repository at this point in the history
Add a new `tiledb_group_add_member_with_type` API to avoid checking for
the type of the asset before adding a member to a group for optimization
purposes.

[sc-47918]

---
TYPE: C_API
DESC: Add API to get group member with type

TYPE: CPP_API
DESC: Update add_member API to accept an optional type
  • Loading branch information
ypatia authored Oct 17, 2024
1 parent d632325 commit 8dbab75
Show file tree
Hide file tree
Showing 10 changed files with 548 additions and 301 deletions.
140 changes: 103 additions & 37 deletions test/src/unit-capi-group.cc
Original file line number Diff line number Diff line change
Expand Up @@ -592,18 +592,34 @@ TEST_CASE_METHOD(
rc = tiledb_group_open(ctx_, group2, TILEDB_WRITE);
REQUIRE(rc == TILEDB_OK);

rc =
tiledb_group_add_member(ctx_, group1, array1_uri.c_str(), false, nullptr);
REQUIRE(rc == TILEDB_OK);
rc =
tiledb_group_add_member(ctx_, group1, array2_uri.c_str(), false, nullptr);
REQUIRE(rc == TILEDB_OK);
rc =
tiledb_group_add_member(ctx_, group2, array3_uri.c_str(), false, nullptr);
REQUIRE(rc == TILEDB_OK);
rc =
tiledb_group_add_member(ctx_, group1, group2_uri.c_str(), false, nullptr);
REQUIRE(rc == TILEDB_OK);
bool add_with_type = GENERATE(true, false);
if (add_with_type) {
rc = tiledb_group_add_member_with_type(
ctx_, group1, array1_uri.c_str(), false, nullptr, TILEDB_ARRAY);
REQUIRE(rc == TILEDB_OK);
rc = tiledb_group_add_member_with_type(
ctx_, group1, array2_uri.c_str(), false, nullptr, TILEDB_ARRAY);
REQUIRE(rc == TILEDB_OK);
rc = tiledb_group_add_member_with_type(
ctx_, group2, array3_uri.c_str(), false, nullptr, TILEDB_ARRAY);
REQUIRE(rc == TILEDB_OK);
rc = tiledb_group_add_member_with_type(
ctx_, group1, group2_uri.c_str(), false, nullptr, TILEDB_GROUP);
REQUIRE(rc == TILEDB_OK);
} else {
rc = tiledb_group_add_member(
ctx_, group1, array1_uri.c_str(), false, nullptr);
REQUIRE(rc == TILEDB_OK);
rc = tiledb_group_add_member(
ctx_, group1, array2_uri.c_str(), false, nullptr);
REQUIRE(rc == TILEDB_OK);
rc = tiledb_group_add_member(
ctx_, group2, array3_uri.c_str(), false, nullptr);
REQUIRE(rc == TILEDB_OK);
rc = tiledb_group_add_member(
ctx_, group1, group2_uri.c_str(), false, nullptr);
REQUIRE(rc == TILEDB_OK);
}

// Close group from write mode
rc = tiledb_group_close(ctx_, group1);
Expand Down Expand Up @@ -720,8 +736,16 @@ TEST_CASE_METHOD(
rc = tiledb_group_open(ctx_, group1, TILEDB_WRITE);
REQUIRE(rc == TILEDB_OK);

rc = tiledb_group_add_member(ctx_, group1, array1_uri.c_str(), false, "one");
REQUIRE(rc == TILEDB_OK);
bool add_with_type = GENERATE(true, false);
if (add_with_type) {
rc = tiledb_group_add_member_with_type(
ctx_, group1, array1_uri.c_str(), false, "one", TILEDB_ARRAY);
REQUIRE(rc == TILEDB_OK);
} else {
rc =
tiledb_group_add_member(ctx_, group1, array1_uri.c_str(), false, "one");
REQUIRE(rc == TILEDB_OK);
}

// Close group from write mode
rc = tiledb_group_close(ctx_, group1);
Expand Down Expand Up @@ -755,8 +779,15 @@ TEST_CASE_METHOD(
rc = tiledb_group_remove_member(ctx_, group1, "one");
REQUIRE(rc == TILEDB_OK);
// Add one back with different URI
rc = tiledb_group_add_member(ctx_, group1, array2_uri.c_str(), false, "one");
REQUIRE(rc == TILEDB_OK);
if (add_with_type) {
rc = tiledb_group_add_member_with_type(
ctx_, group1, array2_uri.c_str(), false, "one", TILEDB_ARRAY);
REQUIRE(rc == TILEDB_OK);
} else {
rc =
tiledb_group_add_member(ctx_, group1, array2_uri.c_str(), false, "one");
REQUIRE(rc == TILEDB_OK);
}

// Close group
rc = tiledb_group_close(ctx_, group1);
Expand Down Expand Up @@ -827,15 +858,34 @@ TEST_CASE_METHOD(
rc = tiledb_group_open(ctx_, group2, TILEDB_WRITE);
REQUIRE(rc == TILEDB_OK);

rc = tiledb_group_add_member(ctx_, group1, array1_uri.c_str(), false, "one");
REQUIRE(rc == TILEDB_OK);
rc = tiledb_group_add_member(ctx_, group1, array2_uri.c_str(), false, "two");
REQUIRE(rc == TILEDB_OK);
rc =
tiledb_group_add_member(ctx_, group2, array3_uri.c_str(), false, "three");
REQUIRE(rc == TILEDB_OK);
rc = tiledb_group_add_member(ctx_, group1, group2_uri.c_str(), false, "four");
REQUIRE(rc == TILEDB_OK);
bool add_with_type = GENERATE(true, false);
if (add_with_type) {
rc = tiledb_group_add_member_with_type(
ctx_, group1, array1_uri.c_str(), false, "one", TILEDB_ARRAY);
REQUIRE(rc == TILEDB_OK);
rc = tiledb_group_add_member_with_type(
ctx_, group1, array2_uri.c_str(), false, "two", TILEDB_ARRAY);
REQUIRE(rc == TILEDB_OK);
rc = tiledb_group_add_member_with_type(
ctx_, group2, array3_uri.c_str(), false, "three", TILEDB_ARRAY);
REQUIRE(rc == TILEDB_OK);
rc = tiledb_group_add_member_with_type(
ctx_, group1, group2_uri.c_str(), false, "four", TILEDB_GROUP);
REQUIRE(rc == TILEDB_OK);
} else {
rc =
tiledb_group_add_member(ctx_, group1, array1_uri.c_str(), false, "one");
REQUIRE(rc == TILEDB_OK);
rc =
tiledb_group_add_member(ctx_, group1, array2_uri.c_str(), false, "two");
REQUIRE(rc == TILEDB_OK);
rc = tiledb_group_add_member(
ctx_, group2, array3_uri.c_str(), false, "three");
REQUIRE(rc == TILEDB_OK);
rc = tiledb_group_add_member(
ctx_, group1, group2_uri.c_str(), false, "four");
REQUIRE(rc == TILEDB_OK);
}

// Close group from write mode
rc = tiledb_group_close(ctx_, group1);
Expand Down Expand Up @@ -1186,18 +1236,34 @@ TEST_CASE_METHOD(
rc = tiledb_group_open(ctx_, group2, TILEDB_WRITE);
REQUIRE(rc == TILEDB_OK);

rc = tiledb_group_add_member(
ctx_, group1, array1_relative_uri.c_str(), true, nullptr);
REQUIRE(rc == TILEDB_OK);
rc = tiledb_group_add_member(
ctx_, group1, array2_relative_uri.c_str(), true, nullptr);
REQUIRE(rc == TILEDB_OK);
rc = tiledb_group_add_member(
ctx_, group2, array3_relative_uri.c_str(), true, nullptr);
REQUIRE(rc == TILEDB_OK);
rc =
tiledb_group_add_member(ctx_, group1, group2_uri.c_str(), false, nullptr);
REQUIRE(rc == TILEDB_OK);
bool add_with_type = GENERATE(true, false);
if (add_with_type) {
rc = tiledb_group_add_member_with_type(
ctx_, group1, array1_relative_uri.c_str(), true, nullptr, TILEDB_ARRAY);
REQUIRE(rc == TILEDB_OK);
rc = tiledb_group_add_member_with_type(
ctx_, group1, array2_relative_uri.c_str(), true, nullptr, TILEDB_ARRAY);
REQUIRE(rc == TILEDB_OK);
rc = tiledb_group_add_member_with_type(
ctx_, group2, array3_relative_uri.c_str(), true, nullptr, TILEDB_ARRAY);
REQUIRE(rc == TILEDB_OK);
rc = tiledb_group_add_member_with_type(
ctx_, group1, group2_uri.c_str(), false, nullptr, TILEDB_GROUP);
REQUIRE(rc == TILEDB_OK);
} else {
rc = tiledb_group_add_member(
ctx_, group1, array1_relative_uri.c_str(), true, nullptr);
REQUIRE(rc == TILEDB_OK);
rc = tiledb_group_add_member(
ctx_, group1, array2_relative_uri.c_str(), true, nullptr);
REQUIRE(rc == TILEDB_OK);
rc = tiledb_group_add_member(
ctx_, group2, array3_relative_uri.c_str(), true, nullptr);
REQUIRE(rc == TILEDB_OK);
rc = tiledb_group_add_member(
ctx_, group1, group2_uri.c_str(), false, nullptr);
REQUIRE(rc == TILEDB_OK);
}

// Close group from write mode
rc = tiledb_group_close(ctx_, group1);
Expand Down
Loading

0 comments on commit 8dbab75

Please sign in to comment.