Skip to content

Commit 8dbab75

Browse files
authored
Add group member with type (#5336)
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
1 parent d632325 commit 8dbab75

File tree

10 files changed

+548
-301
lines changed

10 files changed

+548
-301
lines changed

test/src/unit-capi-group.cc

Lines changed: 103 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -592,18 +592,34 @@ TEST_CASE_METHOD(
592592
rc = tiledb_group_open(ctx_, group2, TILEDB_WRITE);
593593
REQUIRE(rc == TILEDB_OK);
594594

595-
rc =
596-
tiledb_group_add_member(ctx_, group1, array1_uri.c_str(), false, nullptr);
597-
REQUIRE(rc == TILEDB_OK);
598-
rc =
599-
tiledb_group_add_member(ctx_, group1, array2_uri.c_str(), false, nullptr);
600-
REQUIRE(rc == TILEDB_OK);
601-
rc =
602-
tiledb_group_add_member(ctx_, group2, array3_uri.c_str(), false, nullptr);
603-
REQUIRE(rc == TILEDB_OK);
604-
rc =
605-
tiledb_group_add_member(ctx_, group1, group2_uri.c_str(), false, nullptr);
606-
REQUIRE(rc == TILEDB_OK);
595+
bool add_with_type = GENERATE(true, false);
596+
if (add_with_type) {
597+
rc = tiledb_group_add_member_with_type(
598+
ctx_, group1, array1_uri.c_str(), false, nullptr, TILEDB_ARRAY);
599+
REQUIRE(rc == TILEDB_OK);
600+
rc = tiledb_group_add_member_with_type(
601+
ctx_, group1, array2_uri.c_str(), false, nullptr, TILEDB_ARRAY);
602+
REQUIRE(rc == TILEDB_OK);
603+
rc = tiledb_group_add_member_with_type(
604+
ctx_, group2, array3_uri.c_str(), false, nullptr, TILEDB_ARRAY);
605+
REQUIRE(rc == TILEDB_OK);
606+
rc = tiledb_group_add_member_with_type(
607+
ctx_, group1, group2_uri.c_str(), false, nullptr, TILEDB_GROUP);
608+
REQUIRE(rc == TILEDB_OK);
609+
} else {
610+
rc = tiledb_group_add_member(
611+
ctx_, group1, array1_uri.c_str(), false, nullptr);
612+
REQUIRE(rc == TILEDB_OK);
613+
rc = tiledb_group_add_member(
614+
ctx_, group1, array2_uri.c_str(), false, nullptr);
615+
REQUIRE(rc == TILEDB_OK);
616+
rc = tiledb_group_add_member(
617+
ctx_, group2, array3_uri.c_str(), false, nullptr);
618+
REQUIRE(rc == TILEDB_OK);
619+
rc = tiledb_group_add_member(
620+
ctx_, group1, group2_uri.c_str(), false, nullptr);
621+
REQUIRE(rc == TILEDB_OK);
622+
}
607623

608624
// Close group from write mode
609625
rc = tiledb_group_close(ctx_, group1);
@@ -720,8 +736,16 @@ TEST_CASE_METHOD(
720736
rc = tiledb_group_open(ctx_, group1, TILEDB_WRITE);
721737
REQUIRE(rc == TILEDB_OK);
722738

723-
rc = tiledb_group_add_member(ctx_, group1, array1_uri.c_str(), false, "one");
724-
REQUIRE(rc == TILEDB_OK);
739+
bool add_with_type = GENERATE(true, false);
740+
if (add_with_type) {
741+
rc = tiledb_group_add_member_with_type(
742+
ctx_, group1, array1_uri.c_str(), false, "one", TILEDB_ARRAY);
743+
REQUIRE(rc == TILEDB_OK);
744+
} else {
745+
rc =
746+
tiledb_group_add_member(ctx_, group1, array1_uri.c_str(), false, "one");
747+
REQUIRE(rc == TILEDB_OK);
748+
}
725749

726750
// Close group from write mode
727751
rc = tiledb_group_close(ctx_, group1);
@@ -755,8 +779,15 @@ TEST_CASE_METHOD(
755779
rc = tiledb_group_remove_member(ctx_, group1, "one");
756780
REQUIRE(rc == TILEDB_OK);
757781
// Add one back with different URI
758-
rc = tiledb_group_add_member(ctx_, group1, array2_uri.c_str(), false, "one");
759-
REQUIRE(rc == TILEDB_OK);
782+
if (add_with_type) {
783+
rc = tiledb_group_add_member_with_type(
784+
ctx_, group1, array2_uri.c_str(), false, "one", TILEDB_ARRAY);
785+
REQUIRE(rc == TILEDB_OK);
786+
} else {
787+
rc =
788+
tiledb_group_add_member(ctx_, group1, array2_uri.c_str(), false, "one");
789+
REQUIRE(rc == TILEDB_OK);
790+
}
760791

761792
// Close group
762793
rc = tiledb_group_close(ctx_, group1);
@@ -827,15 +858,34 @@ TEST_CASE_METHOD(
827858
rc = tiledb_group_open(ctx_, group2, TILEDB_WRITE);
828859
REQUIRE(rc == TILEDB_OK);
829860

830-
rc = tiledb_group_add_member(ctx_, group1, array1_uri.c_str(), false, "one");
831-
REQUIRE(rc == TILEDB_OK);
832-
rc = tiledb_group_add_member(ctx_, group1, array2_uri.c_str(), false, "two");
833-
REQUIRE(rc == TILEDB_OK);
834-
rc =
835-
tiledb_group_add_member(ctx_, group2, array3_uri.c_str(), false, "three");
836-
REQUIRE(rc == TILEDB_OK);
837-
rc = tiledb_group_add_member(ctx_, group1, group2_uri.c_str(), false, "four");
838-
REQUIRE(rc == TILEDB_OK);
861+
bool add_with_type = GENERATE(true, false);
862+
if (add_with_type) {
863+
rc = tiledb_group_add_member_with_type(
864+
ctx_, group1, array1_uri.c_str(), false, "one", TILEDB_ARRAY);
865+
REQUIRE(rc == TILEDB_OK);
866+
rc = tiledb_group_add_member_with_type(
867+
ctx_, group1, array2_uri.c_str(), false, "two", TILEDB_ARRAY);
868+
REQUIRE(rc == TILEDB_OK);
869+
rc = tiledb_group_add_member_with_type(
870+
ctx_, group2, array3_uri.c_str(), false, "three", TILEDB_ARRAY);
871+
REQUIRE(rc == TILEDB_OK);
872+
rc = tiledb_group_add_member_with_type(
873+
ctx_, group1, group2_uri.c_str(), false, "four", TILEDB_GROUP);
874+
REQUIRE(rc == TILEDB_OK);
875+
} else {
876+
rc =
877+
tiledb_group_add_member(ctx_, group1, array1_uri.c_str(), false, "one");
878+
REQUIRE(rc == TILEDB_OK);
879+
rc =
880+
tiledb_group_add_member(ctx_, group1, array2_uri.c_str(), false, "two");
881+
REQUIRE(rc == TILEDB_OK);
882+
rc = tiledb_group_add_member(
883+
ctx_, group2, array3_uri.c_str(), false, "three");
884+
REQUIRE(rc == TILEDB_OK);
885+
rc = tiledb_group_add_member(
886+
ctx_, group1, group2_uri.c_str(), false, "four");
887+
REQUIRE(rc == TILEDB_OK);
888+
}
839889

840890
// Close group from write mode
841891
rc = tiledb_group_close(ctx_, group1);
@@ -1186,18 +1236,34 @@ TEST_CASE_METHOD(
11861236
rc = tiledb_group_open(ctx_, group2, TILEDB_WRITE);
11871237
REQUIRE(rc == TILEDB_OK);
11881238

1189-
rc = tiledb_group_add_member(
1190-
ctx_, group1, array1_relative_uri.c_str(), true, nullptr);
1191-
REQUIRE(rc == TILEDB_OK);
1192-
rc = tiledb_group_add_member(
1193-
ctx_, group1, array2_relative_uri.c_str(), true, nullptr);
1194-
REQUIRE(rc == TILEDB_OK);
1195-
rc = tiledb_group_add_member(
1196-
ctx_, group2, array3_relative_uri.c_str(), true, nullptr);
1197-
REQUIRE(rc == TILEDB_OK);
1198-
rc =
1199-
tiledb_group_add_member(ctx_, group1, group2_uri.c_str(), false, nullptr);
1200-
REQUIRE(rc == TILEDB_OK);
1239+
bool add_with_type = GENERATE(true, false);
1240+
if (add_with_type) {
1241+
rc = tiledb_group_add_member_with_type(
1242+
ctx_, group1, array1_relative_uri.c_str(), true, nullptr, TILEDB_ARRAY);
1243+
REQUIRE(rc == TILEDB_OK);
1244+
rc = tiledb_group_add_member_with_type(
1245+
ctx_, group1, array2_relative_uri.c_str(), true, nullptr, TILEDB_ARRAY);
1246+
REQUIRE(rc == TILEDB_OK);
1247+
rc = tiledb_group_add_member_with_type(
1248+
ctx_, group2, array3_relative_uri.c_str(), true, nullptr, TILEDB_ARRAY);
1249+
REQUIRE(rc == TILEDB_OK);
1250+
rc = tiledb_group_add_member_with_type(
1251+
ctx_, group1, group2_uri.c_str(), false, nullptr, TILEDB_GROUP);
1252+
REQUIRE(rc == TILEDB_OK);
1253+
} else {
1254+
rc = tiledb_group_add_member(
1255+
ctx_, group1, array1_relative_uri.c_str(), true, nullptr);
1256+
REQUIRE(rc == TILEDB_OK);
1257+
rc = tiledb_group_add_member(
1258+
ctx_, group1, array2_relative_uri.c_str(), true, nullptr);
1259+
REQUIRE(rc == TILEDB_OK);
1260+
rc = tiledb_group_add_member(
1261+
ctx_, group2, array3_relative_uri.c_str(), true, nullptr);
1262+
REQUIRE(rc == TILEDB_OK);
1263+
rc = tiledb_group_add_member(
1264+
ctx_, group1, group2_uri.c_str(), false, nullptr);
1265+
REQUIRE(rc == TILEDB_OK);
1266+
}
12011267

12021268
// Close group from write mode
12031269
rc = tiledb_group_close(ctx_, group1);

0 commit comments

Comments
 (0)