Skip to content

Commit f322b78

Browse files
committed
Changes from review.
1 parent e1020fc commit f322b78

File tree

13 files changed

+116
-228
lines changed

13 files changed

+116
-228
lines changed

test/regression/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ if (TILEDB_CPP_API)
4848
list(APPEND SOURCES targets/sc-25116.cc)
4949
list(APPEND SOURCES targets/sc-29682.cc)
5050
list(APPEND SOURCES targets/sc-33480.cc)
51-
list(APPEND SOURCES targets/sc-35424.cc)
5251
list(APPEND SOURCES targets/sc-36372.cc)
5352
list(APPEND SOURCES targets/sc-38300.cc)
5453
endif()

test/regression/targets/sc-35424.cc

Lines changed: 0 additions & 165 deletions
This file was deleted.

test/src/cpp-integration-rest-schema-evolution.cc

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,35 @@
1+
/**
2+
* @file cpp-integration-rest-schema-evolution.cc
3+
*
4+
* @section LICENSE
5+
*
6+
* The MIT License
7+
*
8+
* @copyright Copyright (c) 2024 TileDB Inc.
9+
*
10+
* Permission is hereby granted, free of charge, to any person obtaining a copy
11+
* of this software and associated documentation files (the "Software"), to deal
12+
* in the Software without restriction, including without limitation the rights
13+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14+
* copies of the Software, and to permit persons to whom the Software is
15+
* furnished to do so, subject to the following conditions:
16+
*
17+
* The above copyright notice and this permission notice shall be included in
18+
* all copies or substantial portions of the Software.
19+
*
20+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26+
* THE SOFTWARE.
27+
*
28+
* @section DESCRIPTION
29+
*
30+
* Tests the C++ schema evolution API integration with REST server.
31+
*/
32+
133
#include <test/support/src/vfs_helpers.h>
234
#include <test/support/tdb_catch.h>
335
#include "tiledb/sm/c_api/tiledb_struct_def.h"

test/src/unit-request-handlers.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ HandleLoadArraySchemaRequestFx::call_handler(
461461
REQUIRE(rval == TILEDB_OK);
462462

463463
return serialization::deserialize_load_array_schema_response(
464-
stype, resp_buf->buffer(), memory_tracker_);
464+
uri_, stype, resp_buf->buffer(), memory_tracker_);
465465
}
466466

467467
shared_ptr<ArraySchema> HandleQueryPlanRequestFx::create_schema() {

test/src/unit-rest-array-schema-load.cc

Lines changed: 45 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* The MIT License
77
*
8-
* @copyright Copyright (c) 2023 TileDB Inc.
8+
* @copyright Copyright (c) 2024 TileDB Inc.
99
*
1010
* Permission is hereby granted, free of charge, to any person obtaining a copy
1111
* of this software and associated documentation files (the "Software"), to deal
@@ -27,7 +27,7 @@
2727
*
2828
* @section DESCRIPTION
2929
*
30-
* Tests tiledb_array_schema_load* functions via a REST server.
30+
* Tests tiledb_array_schema_load* functions across VFS backends and REST.
3131
*/
3232

3333
#include "test/support/src/vfs_helpers.h"
@@ -40,19 +40,21 @@
4040

4141
using namespace tiledb;
4242

43-
struct RESTArraySchemaLoadFx {
44-
RESTArraySchemaLoadFx();
45-
~RESTArraySchemaLoadFx() = default;
43+
struct ArraySchemaLoadFx {
44+
ArraySchemaLoadFx();
45+
~ArraySchemaLoadFx() = default;
4646

4747
void create_array();
48+
void check_schema(const ArraySchema& schema) const;
4849

4950
test::VFSTestSetup vfs_test_setup_;
5051
std::string uri_;
5152
Context ctx_;
53+
ArraySchema schema_;
5254
};
5355

5456
TEST_CASE_METHOD(
55-
RESTArraySchemaLoadFx,
57+
ArraySchemaLoadFx,
5658
"Simple schema load test",
5759
"[rest][array-schema][simple-load]") {
5860
create_array();
@@ -68,10 +70,12 @@ TEST_CASE_METHOD(
6870
REQUIRE_THROWS_WITH(
6971
ArraySchemaExperimental::get_enumeration(ctx_, schema, "my_enum"),
7072
matcher);
73+
74+
check_schema(schema);
7175
}
7276

7377
TEST_CASE_METHOD(
74-
RESTArraySchemaLoadFx,
78+
ArraySchemaLoadFx,
7579
"Simple schema load with enumerations test",
7680
"[rest][array-schema][simple-load-with-enumerations]") {
7781
create_array();
@@ -80,15 +84,18 @@ TEST_CASE_METHOD(
8084
ArrayExperimental::load_schema_with_enumerations(ctx_, uri_);
8185
REQUIRE_NOTHROW(
8286
ArraySchemaExperimental::get_enumeration(ctx_, schema, "my_enum"));
87+
88+
check_schema(schema);
8389
}
8490

85-
RESTArraySchemaLoadFx::RESTArraySchemaLoadFx()
91+
ArraySchemaLoadFx::ArraySchemaLoadFx()
8692
: vfs_test_setup_()
8793
, uri_(vfs_test_setup_.array_uri("array-schema-load-tests"))
88-
, ctx_(vfs_test_setup_.ctx()) {
94+
, ctx_(vfs_test_setup_.ctx())
95+
, schema_(ctx_, TILEDB_DENSE) {
8996
}
9097

91-
void RESTArraySchemaLoadFx::create_array() {
98+
void ArraySchemaLoadFx::create_array() {
9299
// Create a simple array for testing. This ends up with just five elements in
93100
// the array. dim is an int32_t dimension, attr1 is an enumeration with string
94101
// values and int32_t attribute values. attr2 is a float attribute.
@@ -99,24 +106,45 @@ void RESTArraySchemaLoadFx::create_array() {
99106
// dim = {1, 2, 3, 4, 5}
100107
// attr1 = {"fred", "wilma", "barney", "wilma", "fred"}
101108
// attr2 = {1.0f, 2.0f, 3.0f, 4.0f, 5.0f}
102-
ArraySchema schema(ctx_, TILEDB_DENSE);
103-
104109
auto dim = Dimension::create<int>(ctx_, "dim", {{-100, 100}});
105110
auto dom = Domain(ctx_);
106111
dom.add_dimension(dim);
107-
schema.set_domain(dom);
112+
schema_.set_domain(dom);
108113

109114
// The list of string values in the attr1 enumeration
110115
std::vector<std::string> values = {"fred", "wilma", "barney", "pebbles"};
111116
auto enmr = Enumeration::create(ctx_, "my_enum", values);
112-
ArraySchemaExperimental::add_enumeration(ctx_, schema, enmr);
117+
ArraySchemaExperimental::add_enumeration(ctx_, schema_, enmr);
113118

114119
auto attr1 = Attribute::create<int>(ctx_, "attr1");
115120
AttributeExperimental::set_enumeration_name(ctx_, attr1, "my_enum");
116-
schema.add_attribute(attr1);
121+
schema_.add_attribute(attr1);
117122

118123
auto attr2 = Attribute::create<float>(ctx_, "attr2");
119-
schema.add_attribute(attr2);
124+
schema_.add_attribute(attr2);
125+
126+
Array::create(uri_, schema_);
127+
}
120128

121-
Array::create(uri_, schema);
129+
void ArraySchemaLoadFx::check_schema(const ArraySchema& schema) const {
130+
CHECK(schema.array_type() == schema_.array_type());
131+
CHECK(schema.attributes().size() == schema_.attributes().size());
132+
for (unsigned int i = 0; i < schema.attribute_num(); i++) {
133+
auto a = schema_.attribute(i);
134+
auto b = schema.attribute(i);
135+
CHECK(a.cell_val_num() == b.cell_val_num());
136+
CHECK(a.name() == b.name());
137+
CHECK(a.type() == b.type());
138+
CHECK(a.nullable() == b.nullable());
139+
CHECK(
140+
AttributeExperimental::get_enumeration_name(ctx_, a) ==
141+
AttributeExperimental::get_enumeration_name(ctx_, b));
142+
}
143+
CHECK(schema.capacity() == schema_.capacity());
144+
CHECK(schema.cell_order() == schema_.cell_order());
145+
CHECK(schema.tile_order() == schema_.tile_order());
146+
CHECK(schema.allows_dups() == schema_.allows_dups());
147+
CHECK(
148+
schema.ptr()->array_schema_->array_uri().to_string() ==
149+
sm::URI(uri_).to_string());
122150
}

tiledb/sm/array/array_directory.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ shared_ptr<ArraySchema> ArrayDirectory::load_array_schema_latest(
123123
auto&& array_schema = load_array_schema_from_uri(
124124
resources_.get(), schema_uri, encryption_key, memory_tracker);
125125

126-
array_schema->set_array_uri(uri_);
126+
array_schema->set_array_uri(uri_.remove_trailing_slash());
127127

128128
return std::move(array_schema);
129129
}

0 commit comments

Comments
 (0)