Skip to content

Commit ba7266c

Browse files
committed
Revert "[Backport release-2.26] Add serialization and API changes for post_array_schema_from_rest. (#5237) (#5261)"
This reverts commit 6460a8b.
1 parent ef35123 commit ba7266c

25 files changed

+125
-646
lines changed

test/src/unit-capi-config.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ void check_save_to_file() {
231231
ss << "rest.curl.retry_errors true\n";
232232
ss << "rest.curl.verbose false\n";
233233
ss << "rest.http_compressor any\n";
234-
ss << "rest.load_enumerations_on_array_open false\n";
234+
ss << "rest.load_enumerations_on_array_open true\n";
235235
ss << "rest.load_metadata_on_array_open true\n";
236236
ss << "rest.load_non_empty_domain_on_array_open true\n";
237237
ss << "rest.retry_count 25\n";

test/src/unit-enumerations.cc

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,69 +1119,6 @@ TEST_CASE_METHOD(
11191119
REQUIRE(schema->is_enumeration_loaded("test_enmr") == true);
11201120
}
11211121

1122-
TEST_CASE_METHOD(
1123-
EnumerationFx,
1124-
"Array - Load All Enumerations - All Schemas",
1125-
"[enumeration][array][load-all-enumerations][all-schemas]") {
1126-
create_array();
1127-
auto array = get_array(QueryType::READ);
1128-
auto schema = array->array_schema_latest_ptr();
1129-
REQUIRE(schema->is_enumeration_loaded("test_enmr") == false);
1130-
std::string schema_name_1 = schema->name();
1131-
1132-
// Evolve once to add an enumeration.
1133-
auto ase = make_shared<ArraySchemaEvolution>(HERE(), memory_tracker_);
1134-
std::vector<std::string> var_values{"one", "two", "three"};
1135-
auto var_enmr = create_enumeration(
1136-
var_values, false, Datatype::STRING_ASCII, "ase_var_enmr");
1137-
ase->add_enumeration(var_enmr);
1138-
auto attr4 = make_shared<Attribute>(HERE(), "attr4", Datatype::UINT16);
1139-
attr4->set_enumeration_name("ase_var_enmr");
1140-
CHECK_NOTHROW(ase->evolve_schema(schema));
1141-
// Apply evolution to the array and reopen.
1142-
CHECK_NOTHROW(Array::evolve_array_schema(
1143-
ctx_.resources(), uri_, ase.get(), array->get_encryption_key()));
1144-
CHECK(array->reopen().ok());
1145-
CHECK_NOTHROW(array->load_all_enumerations());
1146-
auto all_schemas = array->array_schemas_all();
1147-
schema = array->array_schema_latest_ptr();
1148-
std::string schema_name_2 = schema->name();
1149-
1150-
// Check all schemas.
1151-
CHECK(all_schemas[schema_name_1]->is_enumeration_loaded("test_enmr") == true);
1152-
CHECK(all_schemas[schema_name_2]->is_enumeration_loaded("test_enmr") == true);
1153-
CHECK(
1154-
all_schemas[schema_name_2]->is_enumeration_loaded("ase_var_enmr") ==
1155-
true);
1156-
1157-
// Evolve a second time to drop an enumeration.
1158-
ase = make_shared<ArraySchemaEvolution>(HERE(), memory_tracker_);
1159-
ase->drop_enumeration("test_enmr");
1160-
ase->drop_attribute("attr1");
1161-
CHECK_NOTHROW(ase->evolve_schema(schema));
1162-
// Apply evolution to the array and reopen.
1163-
CHECK_NOTHROW(Array::evolve_array_schema(
1164-
ctx_.resources(), uri_, ase.get(), array->get_encryption_key()));
1165-
CHECK(array->reopen().ok());
1166-
CHECK_NOTHROW(array->load_all_enumerations());
1167-
all_schemas = array->array_schemas_all();
1168-
schema = array->array_schema_latest_ptr();
1169-
std::string schema_name_3 = schema->name();
1170-
1171-
// Check all schemas.
1172-
CHECK(all_schemas[schema_name_1]->is_enumeration_loaded("test_enmr") == true);
1173-
CHECK(all_schemas[schema_name_2]->is_enumeration_loaded("test_enmr") == true);
1174-
CHECK(
1175-
all_schemas[schema_name_2]->is_enumeration_loaded("ase_var_enmr") ==
1176-
true);
1177-
CHECK_THROWS_WITH(
1178-
all_schemas[schema_name_3]->is_enumeration_loaded("test_enmr"),
1179-
Catch::Matchers::ContainsSubstring("No enumeration named"));
1180-
CHECK(
1181-
all_schemas[schema_name_3]->is_enumeration_loaded("ase_var_enmr") ==
1182-
true);
1183-
}
1184-
11851122
TEST_CASE_METHOD(
11861123
EnumerationFx,
11871124
"Array - Load All Enumerations - Repeated",

test/src/unit-request-handlers.cc

Lines changed: 14 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232

3333
#ifdef TILEDB_SERIALIZATION
3434

35-
#include "test/support/src/helpers.h"
3635
#include "test/support/src/mem_helpers.h"
3736
#include "test/support/tdb_catch.h"
3837
#include "tiledb/api/c_api/buffer/buffer_api_internal.h"
@@ -42,7 +41,6 @@
4241
#include "tiledb/sm/c_api/tiledb_serialization.h"
4342
#include "tiledb/sm/c_api/tiledb_struct_def.h"
4443
#include "tiledb/sm/cpp_api/tiledb"
45-
#include "tiledb/sm/cpp_api/tiledb_experimental"
4644
#include "tiledb/sm/crypto/encryption_key.h"
4745
#include "tiledb/sm/enums/array_type.h"
4846
#include "tiledb/sm/enums/encryption_type.h"
@@ -69,7 +67,6 @@ struct RequestHandlerFx {
6967
Config cfg_;
7068
Context ctx_;
7169
EncryptionKey enc_key_;
72-
shared_ptr<ArraySchema> schema_;
7370
};
7471

7572
struct HandleLoadArraySchemaRequestFx : RequestHandlerFx {
@@ -78,17 +75,11 @@ struct HandleLoadArraySchemaRequestFx : RequestHandlerFx {
7875
}
7976

8077
virtual shared_ptr<ArraySchema> create_schema() override;
81-
82-
std::tuple<
83-
shared_ptr<ArraySchema>,
84-
std::unordered_map<std::string, shared_ptr<ArraySchema>>>
85-
call_handler(
78+
shared_ptr<ArraySchema> call_handler(
8679
serialization::LoadArraySchemaRequest req, SerializationType stype);
8780

8881
shared_ptr<const Enumeration> create_string_enumeration(
8982
std::string name, std::vector<std::string>& values);
90-
91-
shared_ptr<ArraySchema> schema_add_attribute(const std::string& attr_name);
9283
};
9384

9485
struct HandleQueryPlanRequestFx : RequestHandlerFx {
@@ -125,23 +116,15 @@ struct HandleConsolidationPlanRequestFx : RequestHandlerFx {
125116

126117
TEST_CASE_METHOD(
127118
HandleLoadArraySchemaRequestFx,
128-
"tiledb_handle_load_array_schema_request - no enumerations",
119+
"tiledb_handle_load_array_schema_request - default request",
129120
"[request_handler][load_array_schema][default]") {
130121
auto stype = GENERATE(SerializationType::JSON, SerializationType::CAPNP);
131122

132123
create_array();
133-
auto schema_response =
134-
call_handler(serialization::LoadArraySchemaRequest(cfg_), stype);
135-
auto schema = std::get<0>(schema_response);
124+
auto schema =
125+
call_handler(serialization::LoadArraySchemaRequest(false), stype);
136126
REQUIRE(schema->has_enumeration("enmr"));
137127
REQUIRE(schema->get_loaded_enumeration_names().size() == 0);
138-
tiledb::test::schema_equiv(*schema, *schema_);
139-
140-
// We did not evolve the schema so there should only be one.
141-
auto all_schemas = std::get<1>(schema_response);
142-
REQUIRE(all_schemas.size() == 1);
143-
tiledb::test::schema_equiv(
144-
*all_schemas.find(schema->name())->second, *schema_);
145128
}
146129

147130
TEST_CASE_METHOD(
@@ -151,57 +134,12 @@ TEST_CASE_METHOD(
151134
auto stype = GENERATE(SerializationType::JSON, SerializationType::CAPNP);
152135

153136
create_array();
154-
REQUIRE(cfg_.set("rest.load_enumerations_on_array_open", "true").ok());
155-
auto schema_response =
156-
call_handler(serialization::LoadArraySchemaRequest(cfg_), stype);
157-
auto schema = std::get<0>(schema_response);
137+
auto schema =
138+
call_handler(serialization::LoadArraySchemaRequest(true), stype);
158139
REQUIRE(schema->has_enumeration("enmr"));
159140
REQUIRE(schema->get_loaded_enumeration_names().size() == 1);
160141
REQUIRE(schema->get_loaded_enumeration_names()[0] == "enmr");
161142
REQUIRE(schema->get_enumeration("enmr") != nullptr);
162-
tiledb::test::schema_equiv(*schema, *schema_);
163-
164-
// We did not evolve the schema so there should only be one.
165-
auto all_schemas = std::get<1>(schema_response);
166-
REQUIRE(all_schemas.size() == 1);
167-
tiledb::test::schema_equiv(
168-
*all_schemas.find(schema->name())->second, *schema_);
169-
}
170-
171-
TEST_CASE_METHOD(
172-
HandleLoadArraySchemaRequestFx,
173-
"tiledb_handle_load_array_schema_request - multiple schemas",
174-
"[request_handler][load_array_schema][schema-evolution]") {
175-
auto stype = GENERATE(SerializationType::JSON, SerializationType::CAPNP);
176-
std::string load_enums = GENERATE("true", "false");
177-
178-
create_array();
179-
180-
std::vector<shared_ptr<ArraySchema>> all_schemas{schema_};
181-
all_schemas.push_back(schema_add_attribute("b"));
182-
all_schemas.push_back(schema_add_attribute("c"));
183-
all_schemas.push_back(schema_add_attribute("d"));
184-
185-
REQUIRE(cfg_.set("rest.load_enumerations_on_array_open", load_enums).ok());
186-
auto schema_response =
187-
call_handler(serialization::LoadArraySchemaRequest(cfg_), stype);
188-
auto schema = std::get<0>(schema_response);
189-
if (load_enums == "true") {
190-
REQUIRE(schema->has_enumeration("enmr"));
191-
REQUIRE(schema->get_loaded_enumeration_names().size() == 1);
192-
REQUIRE(schema->get_loaded_enumeration_names()[0] == "enmr");
193-
REQUIRE(schema->get_enumeration("enmr") != nullptr);
194-
}
195-
// The latest schema should be equal to the last applied evolution.
196-
tiledb::test::schema_equiv(*schema, *all_schemas.back());
197-
198-
// Validate schemas returned from the request in the order they were created.
199-
auto r_all_schemas = std::get<1>(schema_response);
200-
std::map<std::string, shared_ptr<ArraySchema>> resp(
201-
r_all_schemas.begin(), r_all_schemas.end());
202-
for (int i = 0; const auto& s : resp) {
203-
tiledb::test::schema_equiv(*s.second, *all_schemas[i++]);
204-
}
205143
}
206144

207145
TEST_CASE_METHOD(
@@ -408,9 +346,7 @@ TEST_CASE_METHOD(
408346
RequestHandlerFx::RequestHandlerFx(const std::string uri)
409347
: memory_tracker_(tiledb::test::create_test_memory_tracker())
410348
, uri_(uri)
411-
, ctx_(cfg_)
412-
, schema_(make_shared<ArraySchema>(
413-
ArrayType::DENSE, ctx_.resources().ephemeral_memory_tracker())) {
349+
, ctx_(cfg_) {
414350
delete_array();
415351
throw_if_not_ok(enc_key_.set_key(EncryptionType::NO_ENCRYPTION, nullptr, 0));
416352
}
@@ -469,28 +405,9 @@ HandleLoadArraySchemaRequestFx::create_string_enumeration(
469405
tiledb::test::create_test_memory_tracker());
470406
}
471407

472-
shared_ptr<ArraySchema> HandleLoadArraySchemaRequestFx::schema_add_attribute(
473-
const std::string& attr_name) {
474-
tiledb::Context ctx;
475-
tiledb::ArraySchemaEvolution ase(ctx);
476-
auto attr = tiledb::Attribute::create<int32_t>(ctx, attr_name);
477-
ase.add_attribute(attr);
478-
// Evolve and update the original schema member variable.
479-
schema_ = ase.ptr()->array_schema_evolution_->evolve_schema(schema_);
480-
// Apply the schema evolution.
481-
Array::evolve_array_schema(
482-
this->ctx_.resources(),
483-
this->uri_,
484-
ase.ptr()->array_schema_evolution_,
485-
this->enc_key_);
486-
487-
// Return the new evolved schema for validation.
488-
return schema_;
489-
}
490-
491408
shared_ptr<ArraySchema> HandleLoadArraySchemaRequestFx::create_schema() {
492409
// Create a schema to serialize
493-
schema_ =
410+
auto schema =
494411
make_shared<ArraySchema>(HERE(), ArrayType::SPARSE, memory_tracker_);
495412
auto dim =
496413
make_shared<Dimension>(HERE(), "dim1", Datatype::INT32, memory_tracker_);
@@ -499,23 +416,20 @@ shared_ptr<ArraySchema> HandleLoadArraySchemaRequestFx::create_schema() {
499416

500417
auto dom = make_shared<Domain>(HERE(), memory_tracker_);
501418
throw_if_not_ok(dom->add_dimension(dim));
502-
throw_if_not_ok(schema_->set_domain(dom));
419+
throw_if_not_ok(schema->set_domain(dom));
503420

504421
std::vector<std::string> values = {"pig", "cow", "chicken", "dog", "cat"};
505422
auto enmr = create_string_enumeration("enmr", values);
506-
schema_->add_enumeration(enmr);
423+
schema->add_enumeration(enmr);
507424

508425
auto attr = make_shared<Attribute>(HERE(), "attr", Datatype::INT32);
509426
attr->set_enumeration_name("enmr");
510-
throw_if_not_ok(schema_->add_attribute(attr));
427+
throw_if_not_ok(schema->add_attribute(attr));
511428

512-
return schema_;
429+
return schema;
513430
}
514431

515-
std::tuple<
516-
shared_ptr<ArraySchema>,
517-
std::unordered_map<std::string, shared_ptr<ArraySchema>>>
518-
HandleLoadArraySchemaRequestFx::call_handler(
432+
shared_ptr<ArraySchema> HandleLoadArraySchemaRequestFx::call_handler(
519433
serialization::LoadArraySchemaRequest req, SerializationType stype) {
520434
// If this looks weird, its because we're using the public C++ API to create
521435
// these objets instead of the internal APIs elsewhere in this test suite.
@@ -537,7 +451,7 @@ HandleLoadArraySchemaRequestFx::call_handler(
537451
REQUIRE(rval == TILEDB_OK);
538452

539453
return serialization::deserialize_load_array_schema_response(
540-
uri_, stype, resp_buf->buffer(), memory_tracker_);
454+
stype, resp_buf->buffer(), memory_tracker_);
541455
}
542456

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

test/support/src/helpers.cc

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1621,26 +1621,6 @@ void read_sparse_v11(
16211621
tiledb_query_free(&query);
16221622
}
16231623

1624-
void schema_equiv(
1625-
const sm::ArraySchema& schema1, const sm::ArraySchema& schema2) {
1626-
CHECK(schema1.array_type() == schema2.array_type());
1627-
CHECK(schema1.attributes().size() == schema2.attributes().size());
1628-
for (unsigned int i = 0; i < schema2.attribute_num(); i++) {
1629-
auto a = schema1.attribute(i);
1630-
auto b = schema2.attribute(i);
1631-
CHECK(a->cell_val_num() == b->cell_val_num());
1632-
CHECK(a->name() == b->name());
1633-
CHECK(a->type() == b->type());
1634-
CHECK(a->nullable() == b->nullable());
1635-
CHECK(a->get_enumeration_name() == b->get_enumeration_name());
1636-
}
1637-
CHECK(schema1.capacity() == schema2.capacity());
1638-
CHECK(schema1.cell_order() == schema2.cell_order());
1639-
CHECK(schema1.tile_order() == schema2.tile_order());
1640-
CHECK(schema1.allows_dups() == schema2.allows_dups());
1641-
CHECK(schema1.array_uri().to_string() == schema2.array_uri().to_string());
1642-
}
1643-
16441624
template void check_subarray<int8_t>(
16451625
tiledb::sm::Subarray& subarray, const SubarrayRanges<int8_t>& ranges);
16461626
template void check_subarray<uint8_t>(

test/support/src/helpers.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -957,15 +957,6 @@ void write_sparse_v11(
957957
*/
958958
void read_sparse_v11(
959959
tiledb_ctx_t* ctx, const std::string& array_name, uint64_t timestamp);
960-
961-
/**
962-
* Helper function to test two array schemas are equivalent.
963-
*
964-
* @param schema1 Expected array schema.
965-
* @param schema2 Actual array schema.
966-
*/
967-
void schema_equiv(
968-
const sm::ArraySchema& schema1, const sm::ArraySchema& schema2);
969960
} // namespace tiledb::test
970961

971962
#endif

tiledb/api/c_api/config/config_api_external.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -743,17 +743,13 @@ TILEDB_EXPORT void tiledb_config_free(tiledb_config_t** config) TILEDB_NOEXCEPT;
743743
* If true, array non empty domain will be loaded and sent to server together
744744
* with the open array <br>
745745
* **Default**: true
746-
* - `rest.load_enumerations_on_array_open` <br>
747-
* If true, enumerations will be loaded and sent to server together with
748-
* the open array.
749-
* **Default**: false
750746
* - `rest.use_refactored_array_open` <br>
751747
* If true, the new REST routes and APIs for opening an array
752748
* will be used <br>
753749
* **Default**: true
754750
* - `rest.use_refactored_array_open_and_query_submit` <br>
755751
* If true, the new REST routes and APIs for opening an array and submitting
756-
* a query will be used <br>
752+
* a query will be used <br>
757753
* **Default**: true
758754
* - `rest.curl.buffer_size` <br>
759755
* Set curl buffer size for REST requests <br>

0 commit comments

Comments
 (0)