Skip to content

Commit b00936b

Browse files
committed
Fix REST CI segfault.
1 parent ddd3ac9 commit b00936b

File tree

4 files changed

+17
-16
lines changed

4 files changed

+17
-16
lines changed

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,14 @@ TEST_CASE_METHOD(
5858
"[rest][array-schema][simple-load]") {
5959
create_array();
6060

61-
auto config = ctx_.config();
62-
config.set("rest.load_enumerations_on_array_open", "false");
63-
vfs_test_setup_.update_config(config.ptr().get());
64-
ctx_ = vfs_test_setup_.ctx();
65-
6661
ArraySchema schema = Array::load_schema(ctx_, uri_);
6762
auto matcher = Catch::Matchers::ContainsSubstring(
6863
"Enumeration 'my_enum' is not loaded.");
6964
REQUIRE_THROWS_WITH(
7065
ArraySchemaExperimental::get_enumeration(ctx_, schema, "my_enum"),
7166
matcher);
7267

73-
// Schema was constructed prior to creating the array, the array URI is empty.
68+
// schema_ was constructed prior to creating the array, so array URI is empty.
7469
// Set the schema's array_uri without opening the array.
7570
schema_.ptr()->array_schema_->set_array_uri(sm::URI(uri_));
7671
test::schema_equiv(
@@ -88,6 +83,9 @@ TEST_CASE_METHOD(
8883
REQUIRE_NOTHROW(
8984
ArraySchemaExperimental::get_enumeration(ctx_, schema, "my_enum"));
9085

86+
// schema_ was constructed prior to creating the array, so array URI is empty.
87+
// Set the schema's array_uri without opening the array.
88+
schema_.ptr()->array_schema_->set_array_uri(sm::URI(uri_));
9189
test::schema_equiv(
9290
*schema.ptr()->array_schema_, *schema_.ptr()->array_schema_);
9391
}

tiledb/sm/array_schema/array_schema_operations.cc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,16 +130,16 @@ void store_array_schema(
130130
}
131131

132132
shared_ptr<ArraySchema> load_array_schema(
133-
const Context& ctx, const URI& uri, const Config* config) {
133+
const Context& ctx, const URI& uri, const Config& config) {
134134
// Check array name
135135
if (uri.is_invalid()) {
136136
throw std::runtime_error("Failed to load array schema; Invalid array URI");
137137
}
138138

139139
if (uri.is_tiledb()) {
140140
auto& rest_client = ctx.rest_client();
141-
auto array_schema_response = rest_client.post_array_schema_from_rest(
142-
config ? *config : ctx.resources().config(), uri, 0, UINT64_MAX);
141+
auto array_schema_response =
142+
rest_client.post_array_schema_from_rest(config, uri, 0, UINT64_MAX);
143143
return std::move(std::get<0>(array_schema_response));
144144
} else {
145145
// Create key
@@ -161,9 +161,10 @@ shared_ptr<ArraySchema> load_array_schema(
161161
auto&& array_schema_latest =
162162
array_dir->load_array_schema_latest(key, tracker);
163163

164-
bool incl_enums = config->get<bool>(
164+
// Load enumerations if config option is set.
165+
bool incl_enums = config.get<bool>(
165166
"rest.load_enumerations_on_array_open", Config::must_find);
166-
if (config && incl_enums) {
167+
if (incl_enums) {
167168
std::vector<std::string> enmr_paths_to_load;
168169
auto enmr_names = array_schema_latest->get_enumeration_names();
169170
for (auto& name : enmr_names) {

tiledb/sm/array_schema/array_schema_operations.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ void store_array_schema(
7777
* @param config TileDB Config. If null, the context config will be used.
7878
*/
7979
shared_ptr<ArraySchema> load_array_schema(
80-
const Context& ctx, const URI& uri, const Config* config = nullptr);
80+
const Context& ctx, const URI& uri, const Config& config);
8181

8282
} // namespace tiledb::sm
8383

tiledb/sm/c_api/tiledb.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -490,8 +490,9 @@ int32_t tiledb_array_schema_load(
490490
throw CAPIStatusException("Failed to allocate TileDB array schema object");
491491
}
492492

493+
// Use a default constructed config to load the schema with default options.
493494
(*array_schema)->array_schema_ =
494-
load_array_schema(ctx->context(), sm::URI(array_uri));
495+
load_array_schema(ctx->context(), sm::URI(array_uri), sm::Config());
495496

496497
return TILEDB_OK;
497498
}
@@ -511,10 +512,11 @@ int32_t tiledb_array_schema_load_with_options(
511512
throw CAPIStatusException("Failed to allocate TileDB array schema object");
512513
}
513514

514-
// Check array name
515-
tiledb::sm::URI uri(array_uri);
515+
// Use passed config or context config to load the schema with set options.
516516
(*array_schema)->array_schema_ = load_array_schema(
517-
ctx->context(), uri, config ? &config->config() : nullptr);
517+
ctx->context(),
518+
sm::URI(array_uri),
519+
config ? config->config() : ctx->config());
518520

519521
return TILEDB_OK;
520522
}

0 commit comments

Comments
 (0)