Skip to content

Commit

Permalink
FragmentInfo CAPI Handle.
Browse files Browse the repository at this point in the history
  • Loading branch information
bekadavis9 committed Sep 10, 2024
1 parent f88b61a commit 0c51d2c
Show file tree
Hide file tree
Showing 5 changed files with 988 additions and 682 deletions.
41 changes: 38 additions & 3 deletions tiledb/api/c_api/fragment_info/fragment_info_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,7 @@ capi_return_t tiledb_fragment_info_get_fragment_name_v2(
uint32_t fid,
tiledb_string_t** name) {
ensure_fragment_info_is_valid(fragment_info);
if (name == nullptr) {
throw std::invalid_argument("Name cannot be null.");
}
ensure_output_pointer_is_valid(name);
*name =
tiledb_string_handle_t::make_handle(fragment_info->fragment_name(fid));
return TILEDB_OK;
Expand All @@ -100,34 +98,39 @@ capi_return_t tiledb_fragment_info_get_fragment_name_v2(
capi_return_t tiledb_fragment_info_get_fragment_num(
tiledb_fragment_info_t* fragment_info, uint32_t* fragment_num) {
ensure_fragment_info_is_valid(fragment_info);
ensure_output_pointer_is_valid(fragment_num);
*fragment_num = fragment_info->fragment_num();
return TILEDB_OK;
}

capi_return_t tiledb_fragment_info_get_fragment_uri(
tiledb_fragment_info_t* fragment_info, uint32_t fid, const char** uri) {
ensure_fragment_info_is_valid(fragment_info);
ensure_output_pointer_is_valid(uri);
throw_if_not_ok(fragment_info->get_fragment_uri(fid, uri));
return TILEDB_OK;
}

capi_return_t tiledb_fragment_info_get_fragment_size(
tiledb_fragment_info_t* fragment_info, uint32_t fid, uint64_t* size) {
ensure_fragment_info_is_valid(fragment_info);
ensure_output_pointer_is_valid(size);
throw_if_not_ok(fragment_info->get_fragment_size(fid, size));
return TILEDB_OK;
}

capi_return_t tiledb_fragment_info_get_dense(
tiledb_fragment_info_t* fragment_info, uint32_t fid, int32_t* dense) {
ensure_fragment_info_is_valid(fragment_info);
ensure_output_pointer_is_valid(dense);
throw_if_not_ok(fragment_info->get_dense(fid, dense));
return TILEDB_OK;
}

capi_return_t tiledb_fragment_info_get_sparse(
tiledb_fragment_info_t* fragment_info, uint32_t fid, int32_t* sparse) {
ensure_fragment_info_is_valid(fragment_info);
ensure_output_pointer_is_valid(sparse);
throw_if_not_ok(fragment_info->get_sparse(fid, sparse));
return TILEDB_OK;
}
Expand All @@ -138,6 +141,8 @@ capi_return_t tiledb_fragment_info_get_timestamp_range(
uint64_t* start,
uint64_t* end) {
ensure_fragment_info_is_valid(fragment_info);
ensure_output_pointer_is_valid(start);
ensure_output_pointer_is_valid(end);
throw_if_not_ok(fragment_info->get_timestamp_range(fid, start, end));
return TILEDB_OK;
}
Expand All @@ -148,6 +153,7 @@ capi_return_t tiledb_fragment_info_get_non_empty_domain_from_index(
uint32_t did,
void* domain) {
ensure_fragment_info_is_valid(fragment_info);
ensure_output_pointer_is_valid(domain);
throw_if_not_ok(fragment_info->get_non_empty_domain(fid, did, domain));
return TILEDB_OK;
}
Expand All @@ -158,6 +164,7 @@ capi_return_t tiledb_fragment_info_get_non_empty_domain_from_name(
const char* dim_name,
void* domain) {
ensure_fragment_info_is_valid(fragment_info);
ensure_output_pointer_is_valid(domain);
throw_if_not_ok(fragment_info->get_non_empty_domain(fid, dim_name, domain));
return TILEDB_OK;
}
Expand All @@ -169,6 +176,8 @@ capi_return_t tiledb_fragment_info_get_non_empty_domain_var_size_from_index(
uint64_t* start_size,
uint64_t* end_size) {
ensure_fragment_info_is_valid(fragment_info);
ensure_output_pointer_is_valid(start_size);
ensure_output_pointer_is_valid(end_size);
throw_if_not_ok(fragment_info->get_non_empty_domain_var_size(
fid, did, start_size, end_size));
return TILEDB_OK;
Expand All @@ -181,6 +190,8 @@ capi_return_t tiledb_fragment_info_get_non_empty_domain_var_size_from_name(
uint64_t* start_size,
uint64_t* end_size) {
ensure_fragment_info_is_valid(fragment_info);
ensure_output_pointer_is_valid(start_size);
ensure_output_pointer_is_valid(end_size);
throw_if_not_ok(fragment_info->get_non_empty_domain_var_size(
fid, dim_name, start_size, end_size));
return TILEDB_OK;
Expand All @@ -193,6 +204,8 @@ capi_return_t tiledb_fragment_info_get_non_empty_domain_var_from_index(
void* start,
void* end) {
ensure_fragment_info_is_valid(fragment_info);
ensure_output_pointer_is_valid(start);
ensure_output_pointer_is_valid(end);
throw_if_not_ok(
fragment_info->get_non_empty_domain_var(fid, did, start, end));
return TILEDB_OK;
Expand All @@ -205,6 +218,8 @@ capi_return_t tiledb_fragment_info_get_non_empty_domain_var_from_name(
void* start,
void* end) {
ensure_fragment_info_is_valid(fragment_info);
ensure_output_pointer_is_valid(start);
ensure_output_pointer_is_valid(end);
throw_if_not_ok(
fragment_info->get_non_empty_domain_var(fid, dim_name, start, end));
return TILEDB_OK;
Expand All @@ -213,6 +228,7 @@ capi_return_t tiledb_fragment_info_get_non_empty_domain_var_from_name(
capi_return_t tiledb_fragment_info_get_mbr_num(
tiledb_fragment_info_t* fragment_info, uint32_t fid, uint64_t* mbr_num) {
ensure_fragment_info_is_valid(fragment_info);
ensure_output_pointer_is_valid(mbr_num);
throw_if_not_ok(fragment_info->get_mbr_num(fid, mbr_num));
return TILEDB_OK;
}
Expand All @@ -224,6 +240,7 @@ capi_return_t tiledb_fragment_info_get_mbr_from_index(
uint32_t did,
void* mbr) {
ensure_fragment_info_is_valid(fragment_info);
ensure_output_pointer_is_valid(mbr);
throw_if_not_ok(fragment_info->get_mbr(fid, mid, did, mbr));
return TILEDB_OK;
}
Expand All @@ -235,6 +252,7 @@ capi_return_t tiledb_fragment_info_get_mbr_from_name(
const char* dim_name,
void* mbr) {
ensure_fragment_info_is_valid(fragment_info);
ensure_output_pointer_is_valid(mbr);
throw_if_not_ok(fragment_info->get_mbr(fid, mid, dim_name, mbr));
return TILEDB_OK;
}
Expand All @@ -247,6 +265,8 @@ capi_return_t tiledb_fragment_info_get_mbr_var_size_from_index(
uint64_t* start_size,
uint64_t* end_size) {
ensure_fragment_info_is_valid(fragment_info);
ensure_output_pointer_is_valid(start_size);
ensure_output_pointer_is_valid(end_size);
throw_if_not_ok(
fragment_info->get_mbr_var_size(fid, mid, did, start_size, end_size));
return TILEDB_OK;
Expand All @@ -260,6 +280,8 @@ capi_return_t tiledb_fragment_info_get_mbr_var_size_from_name(
uint64_t* start_size,
uint64_t* end_size) {
ensure_fragment_info_is_valid(fragment_info);
ensure_output_pointer_is_valid(start_size);
ensure_output_pointer_is_valid(end_size);
throw_if_not_ok(fragment_info->get_mbr_var_size(
fid, mid, dim_name, start_size, end_size));
return TILEDB_OK;
Expand All @@ -273,6 +295,8 @@ capi_return_t tiledb_fragment_info_get_mbr_var_from_index(
void* start,
void* end) {
ensure_fragment_info_is_valid(fragment_info);
ensure_output_pointer_is_valid(start);
ensure_output_pointer_is_valid(end);
throw_if_not_ok(fragment_info->get_mbr_var(fid, mid, did, start, end));
return TILEDB_OK;
}
Expand All @@ -285,55 +309,64 @@ capi_return_t tiledb_fragment_info_get_mbr_var_from_name(
void* start,
void* end) {
ensure_fragment_info_is_valid(fragment_info);
ensure_output_pointer_is_valid(start);
ensure_output_pointer_is_valid(end);
throw_if_not_ok(fragment_info->get_mbr_var(fid, mid, dim_name, start, end));
return TILEDB_OK;
}

capi_return_t tiledb_fragment_info_get_cell_num(
tiledb_fragment_info_t* fragment_info, uint32_t fid, uint64_t* cell_num) {
ensure_fragment_info_is_valid(fragment_info);
ensure_output_pointer_is_valid(cell_num);
throw_if_not_ok(fragment_info->get_cell_num(fid, cell_num));
return TILEDB_OK;
}

capi_return_t tiledb_fragment_info_get_total_cell_num(
tiledb_fragment_info_t* fragment_info, uint64_t* cell_num) {
ensure_fragment_info_is_valid(fragment_info);
ensure_output_pointer_is_valid(cell_num);
throw_if_not_ok(fragment_info->get_total_cell_num(cell_num));
return TILEDB_OK;
}

capi_return_t tiledb_fragment_info_get_version(
tiledb_fragment_info_t* fragment_info, uint32_t fid, uint32_t* version) {
ensure_fragment_info_is_valid(fragment_info);
ensure_output_pointer_is_valid(version);
throw_if_not_ok(fragment_info->get_version(fid, version));
return TILEDB_OK;
}

capi_return_t tiledb_fragment_info_has_consolidated_metadata(
tiledb_fragment_info_t* fragment_info, uint32_t fid, int32_t* has) {
ensure_fragment_info_is_valid(fragment_info);
ensure_output_pointer_is_valid(has);
throw_if_not_ok(fragment_info->has_consolidated_metadata(fid, has));
return TILEDB_OK;
}

capi_return_t tiledb_fragment_info_get_unconsolidated_metadata_num(
tiledb_fragment_info_t* fragment_info, uint32_t* unconsolidated) {
ensure_fragment_info_is_valid(fragment_info);
ensure_output_pointer_is_valid(unconsolidated);
*unconsolidated = fragment_info->unconsolidated_metadata_num();
return TILEDB_OK;
}

capi_return_t tiledb_fragment_info_get_to_vacuum_num(
tiledb_fragment_info_t* fragment_info, uint32_t* to_vacuum_num) {
ensure_fragment_info_is_valid(fragment_info);
ensure_output_pointer_is_valid(to_vacuum_num);
*to_vacuum_num = fragment_info->to_vacuum_num();
return TILEDB_OK;
}

capi_return_t tiledb_fragment_info_get_to_vacuum_uri(
tiledb_fragment_info_t* fragment_info, uint32_t fid, const char** uri) {
ensure_fragment_info_is_valid(fragment_info);
ensure_output_pointer_is_valid(uri);
throw_if_not_ok(fragment_info->get_to_vacuum_uri(fid, uri));
return TILEDB_OK;
}
Expand All @@ -354,6 +387,7 @@ capi_return_t tiledb_fragment_info_get_array_schema_name(
uint32_t fid,
const char** schema_name) {
ensure_fragment_info_is_valid(fragment_info);
ensure_output_pointer_is_valid(schema_name);
throw_if_not_ok(fragment_info->get_array_schema_name(fid, schema_name));
assert(schema_name != nullptr);
return TILEDB_OK;
Expand All @@ -362,6 +396,7 @@ capi_return_t tiledb_fragment_info_get_array_schema_name(
capi_return_t tiledb_fragment_info_dump(
const tiledb_fragment_info_t* fragment_info, FILE* out) {
ensure_fragment_info_is_valid(fragment_info);
ensure_cstream_handle_is_valid(out);
fragment_info->dump(out);
return TILEDB_OK;
}
Expand Down
2 changes: 2 additions & 0 deletions tiledb/api/c_api/fragment_info/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ include(unit_test)

commence(unit_test capi_fragment_info)
this_target_sources(unit_capi_fragment_info.cc)
this_target_compile_definitions(-DTILEDB_TEST_INPUTS_DIR="${CMAKE_SOURCE_DIR}/test/inputs/")
this_target_object_libraries(
capi_fragment_info_stub
tiledb_test_support_lib
)
conclude(unit_test)
Loading

0 comments on commit 0c51d2c

Please sign in to comment.