-
Notifications
You must be signed in to change notification settings - Fork 185
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
Remove serialization non C.41 constructors from Subarray. #4685
base: dev
Are you sure you want to change the base?
Changes from all commits
7464c41
fc6c31f
1f98d52
3ac3cf3
cff8cdc
6c79915
b6009a6
b86a687
712fa4b
c9e4726
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 |
---|---|---|
|
@@ -463,50 +463,119 @@ TEST_CASE( | |
Array array_r(ctx, array_name, TILEDB_READ); | ||
Subarray subarray(ctx, array_r); | ||
|
||
// If read_range_oob_error is false, the range will be cropped with a | ||
// warning and the query will succeed. | ||
auto read_range_oob_error = GENERATE(true, false); | ||
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. The structure of these out-of-bounds tests is overly complicated.
|
||
auto expected = TILEDB_ERR; | ||
int fill_val = tiledb::sm::constants::empty_int32; | ||
std::vector<int> expected_data(16, fill_val); | ||
expected_data[0] = 1; | ||
expected_data[1] = 2; | ||
expected_data[4] = 3; | ||
expected_data[5] = 4; | ||
SECTION("- Upper bound OOB") { | ||
int range[] = {0, 100}; | ||
auto r = Range(&range[0], &range[1], sizeof(int)); | ||
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. There's a
This constructor allows |
||
CHECK(subarray.ptr().get()->subarray_->add_range_unsafe(0, r).ok()); | ||
if (read_range_oob_error) { | ||
CHECK_FALSE( | ||
subarray.ptr() | ||
.get() | ||
->subarray_->add_range(0, std::move(r), read_range_oob_error) | ||
.ok()); | ||
} else { | ||
CHECK(subarray.ptr() | ||
.get() | ||
->subarray_->add_range(0, std::move(r), read_range_oob_error) | ||
.ok()); | ||
// The subarray will warn and crop to full domain ranges. | ||
expected = TILEDB_OK; | ||
} | ||
} | ||
|
||
SECTION("- Lower bound OOB") { | ||
int range[] = {-1, 2}; | ||
auto r = Range(&range[0], &range[1], sizeof(int)); | ||
CHECK(subarray.ptr().get()->subarray_->add_range_unsafe(0, r).ok()); | ||
if (read_range_oob_error) { | ||
CHECK_FALSE( | ||
subarray.ptr() | ||
.get() | ||
->subarray_->add_range(0, std::move(r), read_range_oob_error) | ||
.ok()); | ||
} else { | ||
// Warn and crop dim0 to [0, 2] with [0, 3] implicitly set on dim1. | ||
CHECK(subarray.ptr() | ||
.get() | ||
->subarray_->add_range(0, std::move(r), read_range_oob_error) | ||
.ok()); | ||
expected_data.resize(12); | ||
expected = TILEDB_OK; | ||
} | ||
} | ||
|
||
SECTION("- Second range OOB") { | ||
int range[] = {1, 4}; | ||
auto r = Range(&range[0], &range[1], sizeof(int)); | ||
CHECK(subarray.ptr().get()->subarray_->add_range_unsafe(0, r).ok()); | ||
int range2[] = {10, 20}; | ||
auto r2 = Range(&range2[0], &range2[1], sizeof(int)); | ||
CHECK(subarray.ptr().get()->subarray_->add_range_unsafe(1, r2).ok()); | ||
if (read_range_oob_error) { | ||
CHECK_FALSE( | ||
subarray.ptr() | ||
.get() | ||
->subarray_->add_range(0, std::move(r), read_range_oob_error) | ||
.ok()); | ||
CHECK_FALSE( | ||
subarray.ptr() | ||
.get() | ||
->subarray_->add_range(1, std::move(r2), read_range_oob_error) | ||
.ok()); | ||
} else { | ||
// Warn and crop dim0 to [1, 3] and dim1 to [3, 3] | ||
CHECK(subarray.ptr() | ||
.get() | ||
->subarray_->add_range(0, std::move(r), read_range_oob_error) | ||
.ok()); | ||
CHECK(subarray.ptr() | ||
.get() | ||
->subarray_->add_range(1, std::move(r2), read_range_oob_error) | ||
.ok()); | ||
expected_data = {fill_val, fill_val, fill_val}; | ||
expected = TILEDB_OK; | ||
} | ||
} | ||
|
||
SECTION("- Valid ranges") { | ||
int range[] = {0, 1}; | ||
auto r = Range(&range[0], &range[1], sizeof(int)); | ||
CHECK(subarray.ptr().get()->subarray_->add_range_unsafe(0, r).ok()); | ||
CHECK(subarray.ptr().get()->subarray_->add_range_unsafe(1, r).ok()); | ||
CHECK(subarray.ptr() | ||
.get() | ||
->subarray_->add_range(0, std::move(r), read_range_oob_error) | ||
.ok()); | ||
CHECK(subarray.ptr() | ||
.get() | ||
->subarray_->add_range(1, std::move(r), read_range_oob_error) | ||
.ok()); | ||
expected_data = data_w; | ||
expected = TILEDB_OK; | ||
} | ||
|
||
Query query(ctx, array_r); | ||
query.set_subarray(subarray); | ||
query.set_config(cfg); | ||
|
||
std::vector<int> a(4); | ||
query.set_data_buffer("a", a); | ||
tiledb::test::ServerQueryBuffers buffers; | ||
CHECK( | ||
submit_query_wrapper( | ||
ctx, array_name, &query, buffers, true, query_v2, false) == expected); | ||
|
||
if (expected == TILEDB_OK) { | ||
CHECK(query.query_status() == tiledb::Query::Status::COMPLETE); | ||
CHECK(a == std::vector<int>{1, 2, 3, 4}); | ||
// If the Subarray threw an exception when adding OOB ranges it will be unset. | ||
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. Huh? There's no exception handling in the code as written. |
||
if (!read_range_oob_error || expected == TILEDB_OK) { | ||
Query query(ctx, array_r); | ||
query.set_subarray(subarray); | ||
query.set_config(cfg); | ||
|
||
std::vector<int> a(expected_data.size()); | ||
query.set_data_buffer("a", a); | ||
tiledb::test::ServerQueryBuffers buffers; | ||
CHECK( | ||
submit_query_wrapper( | ||
ctx, array_name, &query, buffers, true, query_v2, false) == | ||
expected); | ||
|
||
if (expected == TILEDB_OK) { | ||
CHECK(query.query_status() == tiledb::Query::Status::COMPLETE); | ||
CHECK(a == expected_data); | ||
} | ||
} | ||
|
||
if (vfs.is_dir(array_name)) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,7 @@ | |
*/ | ||
|
||
#include "test/support/src/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_serialization.h" | ||
#include "tiledb/sm/c_api/tiledb_struct_def.h" | ||
|
@@ -204,11 +205,15 @@ void tiledb_subarray_serialize( | |
.ok()); | ||
// Deserialize | ||
tiledb_subarray_t* deserialized_subarray; | ||
auto layout = (*subarray)->subarray_->layout(); | ||
auto stats = ctx->storage_manager()->stats()->create_child("Subarray"); | ||
shared_ptr<Logger> dummy_logger = make_shared<Logger>(HERE(), ""); | ||
|
||
tiledb::test::require_tiledb_ok( | ||
ctx, tiledb_subarray_alloc(ctx, array, &deserialized_subarray)); | ||
REQUIRE(tiledb::sm::serialization::subarray_from_capnp( | ||
builder, deserialized_subarray->subarray_) | ||
.ok()); | ||
*deserialized_subarray->subarray_ = | ||
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. This pointer should be check against |
||
tiledb::sm::serialization::subarray_from_capnp( | ||
builder, array->array_.get(), layout, stats, dummy_logger); | ||
*subarray = deserialized_subarray; | ||
#endif | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is too short to be easily comprehensible. It requires knowing what the badly-named-from-the-beginning parameter
read_range_oob_error
does, which is only changeable through a configuration variable. It's worth expanding on that here.