Skip to content

Commit

Permalink
Add query tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ypatia committed Mar 11, 2024
1 parent fc090a9 commit e5cc0a7
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 530 deletions.
48 changes: 14 additions & 34 deletions test/src/unit-capi-nullable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <test/support/tdb_catch.h>
#include "test/support/src/helpers.h"
#include "test/support/src/temporary_local_directory.h"
#include "test/support/src/vfs_helpers.h"
#include "tiledb/api/c_api/vfs/vfs_api_internal.h"
#include "tiledb/sm/c_api/tiledb.h"
#include "tiledb/sm/enums/array_type.h"
Expand All @@ -48,12 +49,6 @@ using namespace tiledb::test;

class NullableArrayFx {
public:
// Serialization parameters
bool serialize_ = false;
bool refactored_query_v2_ = false;
// Buffers to allocate on server side for serialized queries
ServerQueryBuffers server_buffers_;

struct test_dim_t {
test_dim_t(
const string& name,
Expand Down Expand Up @@ -200,8 +195,7 @@ class NullableArrayFx {
const void* subarray);
};

NullableArrayFx::NullableArrayFx()
: serialize_(false) {
NullableArrayFx::NullableArrayFx() {
// Create a config.
tiledb_config_t* config = nullptr;
tiledb_error_t* error = nullptr;
Expand All @@ -224,7 +218,11 @@ NullableArrayFx::~NullableArrayFx() {
}

const string NullableArrayFx::array_path(const string& array_name) {
return temp_dir_.path() + array_name;
if (vfs_test_get_fs_vec()[0]->is_rest()) {
return "tiledb://unit/" + temp_dir_.path() + array_name;
} else {
return temp_dir_.path() + array_name;
}
}

void NullableArrayFx::create_array(
Expand Down Expand Up @@ -410,13 +408,11 @@ void NullableArrayFx::write(
}

// Submit query
rc = submit_query_wrapper(
ctx_,
array_path(array_name),
&query,
server_buffers_,
serialize_,
refactored_query_v2_);
if (layout != TILEDB_GLOBAL_ORDER) {
rc = tiledb_query_submit(ctx_, query);
} else {
rc = tiledb_query_submit_and_finalize(ctx_, query);
}
REQUIRE(rc == TILEDB_OK);

// Clean up
Expand Down Expand Up @@ -517,13 +513,7 @@ void NullableArrayFx::read(
REQUIRE(rc == TILEDB_OK);

// Submit query
rc = submit_query_wrapper(
ctx_,
array_path(array_name),
&query,
server_buffers_,
serialize_,
refactored_query_v2_);
rc = tiledb_query_submit(ctx_, query);
REQUIRE(rc == TILEDB_OK);

// Clean up
Expand Down Expand Up @@ -851,17 +841,7 @@ void NullableArrayFx::do_2d_nullable_test(
TEST_CASE_METHOD(
NullableArrayFx,
"C API: Test 2D array with nullable attributes",
"[capi][2d][nullable]") {
SECTION("no serialization") {
serialize_ = false;
}
#ifdef TILEDB_SERIALIZATION
SECTION("serialization enabled") {
serialize_ = true;
refactored_query_v2_ = GENERATE(true, false);
}
#endif

"[capi][2d][nullable][rest]") {
// Define the attributes.
vector<test_attr_t> attrs;
attrs.emplace_back("a1", TILEDB_INT32, 1, true);
Expand Down
Loading

0 comments on commit e5cc0a7

Please sign in to comment.