Skip to content

Commit 55a7168

Browse files
committed
Add tiledb_array_load_enumerations_all_schemas.
1 parent e7fa6a5 commit 55a7168

File tree

8 files changed

+65
-30
lines changed

8 files changed

+65
-30
lines changed

test/src/unit-cppapi-enumerations.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ TEST_CASE_METHOD(
326326
CPPEnumerationFx,
327327
"C API: Array load_all_enumerations - Check nullptr",
328328
"[enumeration][array-load-all-enumerations][rest]") {
329-
auto rc = tiledb_array_load_all_enumerations(ctx_.ptr().get(), nullptr, 0);
329+
auto rc = tiledb_array_load_all_enumerations(ctx_.ptr().get(), nullptr);
330330
REQUIRE(rc != TILEDB_OK);
331331
}
332332

@@ -364,7 +364,7 @@ TEST_CASE_METHOD(
364364
ase.add_attribute(attr4);
365365
ase.array_evolve(uri_);
366366
array.reopen();
367-
ArrayExperimental::load_all_enumerations(ctx_, array, true);
367+
ArrayExperimental::load_enumerations_all_schemas(ctx_, array);
368368
auto all_schemas = array.ptr()->array()->array_schemas_all();
369369
schema = array.load_schema(ctx_, uri_);
370370
std::string schema_name_2 = schema.ptr()->array_schema()->name();
@@ -390,7 +390,7 @@ TEST_CASE_METHOD(
390390
CHECK_NOTHROW(ase2.array_evolve(uri_));
391391
// Apply evolution to the array and reopen.
392392
CHECK_NOTHROW(array.reopen());
393-
CHECK_NOTHROW(ArrayExperimental::load_all_enumerations(ctx_, array, true));
393+
CHECK_NOTHROW(ArrayExperimental::load_enumerations_all_schemas(ctx_, array));
394394
all_schemas = array.ptr()->array()->array_schemas_all();
395395
schema = array.load_schema(ctx_, uri_);
396396
std::string schema_name_3 = schema.ptr()->array_schema()->name();
@@ -426,7 +426,7 @@ TEST_CASE_METHOD(
426426

427427
// Apply evolution to the array and reopen.
428428
CHECK_NOTHROW(array.reopen());
429-
CHECK_NOTHROW(ArrayExperimental::load_all_enumerations(ctx_, array, true));
429+
CHECK_NOTHROW(ArrayExperimental::load_enumerations_all_schemas(ctx_, array));
430430
all_schemas = array.ptr()->array()->array_schemas_all();
431431
schema = array.load_schema(ctx_, uri_);
432432
std::string schema_name_4 = schema.ptr()->array_schema()->name();

tiledb/api/c_api/array/array_api.cc

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -657,10 +657,16 @@ capi_return_t tiledb_array_get_enumeration(
657657
return TILEDB_OK;
658658
}
659659

660-
capi_return_t tiledb_array_load_all_enumerations(
661-
const tiledb_array_t* array, uint8_t all_schemas) {
660+
capi_return_t tiledb_array_load_all_enumerations(const tiledb_array_t* array) {
662661
ensure_array_is_valid(array);
663-
array->load_all_enumerations(all_schemas > 0);
662+
array->load_all_enumerations();
663+
return TILEDB_OK;
664+
}
665+
666+
capi_return_t tiledb_array_load_enumerations_all_schemas(
667+
const tiledb_array_t* array) {
668+
ensure_array_is_valid(array);
669+
array->load_all_enumerations(true);
664670
return TILEDB_OK;
665671
}
666672

@@ -1051,8 +1057,15 @@ CAPI_INTERFACE(
10511057
CAPI_INTERFACE(
10521058
array_load_all_enumerations,
10531059
tiledb_ctx_t* ctx,
1054-
const tiledb_array_t* array,
1055-
uint8_t all_schemas) {
1060+
const tiledb_array_t* array) {
10561061
return api_entry_context<tiledb::api::tiledb_array_load_all_enumerations>(
1057-
ctx, array, all_schemas);
1062+
ctx, array);
1063+
}
1064+
1065+
CAPI_INTERFACE(
1066+
array_load_enumerations_all_schemas,
1067+
tiledb_ctx_t* ctx,
1068+
const tiledb_array_t* array) {
1069+
return api_entry_context<
1070+
tiledb::api::tiledb_array_load_enumerations_all_schemas>(ctx, array);
10581071
}

tiledb/api/c_api/array/array_api_experimental.h

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ TILEDB_EXPORT capi_return_t tiledb_array_get_enumeration(
9090
tiledb_enumeration_t** enumeration) TILEDB_NOEXCEPT;
9191

9292
/**
93-
* Load all enumerations for the array.
93+
* Load all enumerations for the array's latest array schema.
9494
*
9595
* **Example:**
9696
*
@@ -100,14 +100,26 @@ TILEDB_EXPORT capi_return_t tiledb_array_get_enumeration(
100100
*
101101
* @param[in] ctx The TileDB context.
102102
* @param[in] array The TileDB array.
103-
* @param[in] latest_only If non-zero, only load enumerations for the latest
104-
* schema.
105103
* @return `TILEDB_OK` for success and `TILEDB_ERR` for error.
106104
*/
107105
TILEDB_EXPORT capi_return_t tiledb_array_load_all_enumerations(
108-
tiledb_ctx_t* ctx,
109-
const tiledb_array_t* array,
110-
uint8_t all_schemas) TILEDB_NOEXCEPT;
106+
tiledb_ctx_t* ctx, const tiledb_array_t* array) TILEDB_NOEXCEPT;
107+
108+
/**
109+
* Load all enumerations for all schemas in the array.
110+
*
111+
* **Example:**
112+
*
113+
* @code{.c}
114+
* tiledb_array_load_enumerations_all_schemas(ctx, array);
115+
* @endcode
116+
*
117+
* @param[in] ctx The TileDB context.
118+
* @param[in] array The TileDB array.
119+
* @return `TILEDB_OK` for success and `TILEDB_ERR` for error.
120+
*/
121+
TILEDB_EXPORT capi_return_t tiledb_array_load_enumerations_all_schemas(
122+
tiledb_ctx_t* ctx, const tiledb_array_t* array) TILEDB_NOEXCEPT;
111123

112124
#ifdef __cplusplus
113125
}

tiledb/api/c_api/array/array_api_internal.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ struct tiledb_array_handle_t
150150
std::unordered_map<
151151
std::string,
152152
std::vector<shared_ptr<const tiledb::sm::Enumeration>>>
153-
get_all_enumerations() {
154-
return array_->get_all_enumerations();
153+
get_enumerations_all_schemas() {
154+
return array_->get_enumerations_all_schemas();
155155
}
156156

157157
std::vector<shared_ptr<const tiledb::sm::Enumeration>> get_enumerations(

tiledb/sm/array/array.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ shared_ptr<const Enumeration> Array::get_enumeration(
822822
}
823823

824824
std::unordered_map<std::string, std::vector<shared_ptr<const Enumeration>>>
825-
Array::get_all_enumerations() {
825+
Array::get_enumerations_all_schemas() {
826826
if (!is_open_) {
827827
throw ArrayException("Unable to load enumerations; Array is not open.");
828828
}
@@ -977,7 +977,7 @@ void Array::load_all_enumerations(bool all_schemas) {
977977
throw_if_not_ok(config_.set("rest.use_refactored_array_open", "false"));
978978
}
979979

980-
get_all_enumerations();
980+
get_enumerations_all_schemas();
981981
} else {
982982
get_enumerations(array_schema_latest().get_enumeration_names());
983983
}

tiledb/sm/array/array.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ class Array {
569569
EncryptionType* encryption_type);
570570

571571
/**
572-
* Get the enumeration for the given name.
572+
* Get the enumeration for the given name from the latest array schema.
573573
*
574574
* This function retrieves the enumeration for the given name. If the
575575
* corresponding enumeration has not been loaded from storage it is
@@ -587,10 +587,10 @@ class Array {
587587
* @return Map of schema names and a list of all loaded enumerations.
588588
*/
589589
std::unordered_map<std::string, std::vector<shared_ptr<const Enumeration>>>
590-
get_all_enumerations();
590+
get_enumerations_all_schemas();
591591

592592
/**
593-
* Get the enumerations with the given names.
593+
* Get the enumerations with the given names from the latest array schema.
594594
*
595595
* This function retrieves the enumerations with the given names. If the
596596
* corresponding enumerations have not been loaded from storage they are

tiledb/sm/c_api/tiledb.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2202,7 +2202,7 @@ capi_return_t tiledb_handle_load_enumerations_request(
22022202
std::vector<shared_ptr<const tiledb::sm::Enumeration>>>
22032203
enumerations;
22042204
if (enumeration_names.empty()) {
2205-
enumerations = array->get_all_enumerations();
2205+
enumerations = array->get_enumerations_all_schemas();
22062206
} else {
22072207
enumerations[array->array_schema_latest().name()] =
22082208
array->get_enumerations(enumeration_names);

tiledb/sm/cpp_api/array_experimental.h

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,26 @@ class ArrayExperimental {
5959
}
6060

6161
/**
62-
* Load all enumerations for the array.
62+
* Load all enumerations for the array's latest array schema.
6363
*
6464
* @param ctx The context to use.
6565
* @param array The array to load enumerations for.
66-
* @param all_schemas Whether or not to load enumerations on all schemas.
6766
*/
68-
static void load_all_enumerations(
69-
const Context& ctx, const Array& array, bool all_schemas = false) {
70-
ctx.handle_error(tiledb_array_load_all_enumerations(
71-
ctx.ptr().get(), array.ptr().get(), all_schemas ? 1 : 0));
67+
static void load_all_enumerations(const Context& ctx, const Array& array) {
68+
ctx.handle_error(
69+
tiledb_array_load_all_enumerations(ctx.ptr().get(), array.ptr().get()));
70+
}
71+
72+
/**
73+
* Load all enumerations for all schemas in the array.
74+
*
75+
* @param ctx The context to use.
76+
* @param array The array to load enumerations for.
77+
*/
78+
static void load_enumerations_all_schemas(
79+
const Context& ctx, const Array& array) {
80+
ctx.handle_error(tiledb_array_load_enumerations_all_schemas(
81+
ctx.ptr().get(), array.ptr().get()));
7282
}
7383
};
7484

0 commit comments

Comments
 (0)