-
Notifications
You must be signed in to change notification settings - Fork 197
Add support for relative URI remote group members. #5625
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
3fd09e7
83d2aa5
ac56ddd
9bfa0a7
d94c700
db8e655
7fddc58
c4b108f
e5cd8c6
666f193
93914a4
eeb4a6d
8c1f2e1
dee4d35
691f20f
1d39d0c
9b9e8d0
043730c
5055e10
c3b6120
3be3f65
8fbc929
b0b5683
9022729
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1102,38 +1102,66 @@ TEST_CASE( | |
} | ||
|
||
TEST_CASE( | ||
"C++ API: Group with Relative URI members, write/read, rest", | ||
"[cppapi][group][relative][rest]") { | ||
"C++ API: Group add_member with relative URI members, write/read, rest", | ||
"[cppapi][group][add_member][relative][rest]") { | ||
VFSTestSetup vfs_test_setup; | ||
tiledb::Context ctx{vfs_test_setup.ctx()}; | ||
auto group_name{vfs_test_setup.array_uri("groups_relative")}; | ||
auto subgroup_name = group_name + "/subgroup"; | ||
|
||
// Create groups | ||
tiledb::create_group(ctx, group_name); | ||
tiledb::create_group(ctx, subgroup_name); | ||
|
||
// Open group in write mode | ||
{ | ||
auto group = tiledb::Group(ctx, group_name, TILEDB_WRITE); | ||
CHECK_NOTHROW(group.add_member("subgroup", true, "subgroup")); | ||
if (vfs_test_setup.is_rest()) { | ||
CHECK_THROWS_WITH( | ||
group.close(), | ||
Catch::Matchers::ContainsSubstring( | ||
"relative paths are not yet supported for cloud groups")); | ||
} else { | ||
CHECK_NOTHROW(group.close()); | ||
} | ||
if (!vfs_test_setup.is_rest() || vfs_test_setup.is_legacy_rest()) { | ||
SKIP("Relative group URIs are not supported in legacy REST servers"); | ||
} | ||
|
||
if (!vfs_test_setup.is_rest()) { | ||
auto group = tiledb::Group(ctx, group_name, TILEDB_READ); | ||
|
||
auto subgroup_member = group.member("subgroup"); | ||
|
||
CHECK(subgroup_member.type() == tiledb::Object::Type::Group); | ||
CHECK(subgroup_member.name() == "subgroup"); | ||
CHECK(group.is_relative("subgroup")); | ||
auto group_uri{vfs_test_setup.default_storage_uri("groups_relative")}; | ||
// Create parent group using tiledb URI. | ||
REQUIRE_NOTHROW(tiledb::create_group(ctx, group_uri)); | ||
|
||
tiledb::Domain domain(ctx); | ||
domain.add_dimension( | ||
tiledb::Dimension::create<int>(ctx, "rows", {{1, 10}}, 10)); | ||
tiledb::ArraySchema schema(ctx, TILEDB_SPARSE); | ||
schema.set_domain(domain); | ||
schema.add_attribute(tiledb::Attribute::create<int>(ctx, "a1")); | ||
// This adds the new array as a member | ||
auto array_member_uri = group_uri + "/relative_array"; | ||
REQUIRE_NOTHROW(tiledb::Array::create(ctx, array_member_uri, schema)); | ||
// This adds the new group as a member | ||
REQUIRE_NOTHROW(tiledb::create_group(ctx, group_uri + "/relative_group")); | ||
|
||
// REST creates the group in a groupID prefix, we don't know what this ID is. | ||
tiledb::VFS vfs{ctx}; | ||
auto created_group_uri = vfs.ls(vfs_test_setup.default_storage()).back(); | ||
// Creates a new group at a relative backend storage location using S3 URI. | ||
REQUIRE_NOTHROW( | ||
tiledb::create_group(ctx, created_group_uri + "/groups/relative_group")); | ||
|
||
auto group = tiledb::Group(ctx, group_uri, TILEDB_WRITE); | ||
// Attempts to add the same array as a member with the same name. | ||
CHECK_NOTHROW(group.add_member("relative_array", true, "relative_array")); | ||
CHECK_NOTHROW( | ||
group.add_member("relative_array", true, "relative_array_rename")); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Question on spec that is not clear to me today: What does it mean to add a relative array? Relative refers to storage location? If yes, do we support group.add_member("prefix/relative_array", true, "relative_array") ? If yes we should ideally test that this works too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It can be a manual test on the review app too, let's just not forget to check it. |
||
CHECK_NOTHROW(group.add_member("relative_group", true, "relative_group")); | ||
// Add the relative member we created on S3 to the parent group after creation | ||
CHECK_NOTHROW( | ||
group.add_member("groups/relative_group", true, "relative_group_nested")); | ||
CHECK_NOTHROW( | ||
group.add_member("relative_group", true, "relative_group_rename")); | ||
REQUIRE_NOTHROW(group.close()); | ||
|
||
REQUIRE_NOTHROW(group.open(TILEDB_READ)); | ||
tiledb::sm::URI member_uri(array_member_uri); | ||
CHECK(group.member_count() == 5); | ||
for (const std::string name : | ||
{"relative_array", | ||
"relative_array_rename", | ||
"relative_group", | ||
"relative_group_nested", | ||
"relative_group_rename"}) { | ||
auto member = group.member(name); | ||
auto object_type = tiledb::Object::Type::Group; | ||
if (name.find("array") != std::string::npos) { | ||
object_type = tiledb::Object::Type::Array; | ||
} | ||
CHECK(member.type() == object_type); | ||
CHECK(member.name() == name); | ||
CHECK(member.uri() == group_uri + "/" + name); | ||
CHECK(group.is_relative(name)); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -965,6 +965,22 @@ void read_sparse_v11( | |
void schema_equiv( | ||
const sm::ArraySchema& schema1, const sm::ArraySchema& schema2); | ||
|
||
/** | ||
* Helper function to build a tiledb URI using the provided asset path, | ||
* following the randomly generated top-level directory used in all 3.0 REST | ||
* tests. | ||
* | ||
* This helper only applies to 3.0 REST, there is no concept of asset paths in | ||
* legacy REST. | ||
* | ||
* @param uri The URI to update. | ||
* @param path The new asset path to use after the randomly generated top-level | ||
* directory. | ||
* @return The tiledb URI built from the provided asset path. | ||
*/ | ||
std::string build_tiledb_uri( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that's not used anymore and can be removed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's used to create / empty the default storage bucket in REST CI. I could do it inline, it just seemed cleaner to have a helper. Flexible either way though if you'd rather it removed. |
||
const sm::URI& uri, const std::string& path, bool include_storage = false); | ||
|
||
} // namespace tiledb::test | ||
|
||
#endif |
Uh oh!
There was an error while loading. Please reload this page.