Skip to content

Commit

Permalink
Remove unsupported dimension datatypes
Browse files Browse the repository at this point in the history
  • Loading branch information
XanthosXanthopoulos committed Dec 10, 2024
1 parent 72c9095 commit 29448a2
Showing 1 changed file with 41 additions and 69 deletions.
110 changes: 41 additions & 69 deletions libtiledbsoma/src/soma/soma_dimension.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ void SOMADimension::_set_dim_points(
break;
case TILEDB_STRING_UTF8:
case TILEDB_STRING_ASCII:
case TILEDB_CHAR:
case TILEDB_BLOB:
query->select_points(
dimension.name(),
std::any_cast<std::span<const std::string>>(points));
Expand Down Expand Up @@ -178,10 +176,6 @@ void SOMADimension::_set_dim_ranges(
break;
case TILEDB_STRING_UTF8:
case TILEDB_STRING_ASCII:
case TILEDB_CHAR:
case TILEDB_BLOB:
case TILEDB_GEOM_WKT:
case TILEDB_GEOM_WKB:
query->select_ranges(
dimension.name(),
std::any_cast<std::vector<std::pair<std::string, std::string>>>(
Expand Down Expand Up @@ -258,11 +252,7 @@ void SOMADimension::_set_current_domain_slot(
rectangle.set_range<double_t>(dimension.name(), dom[0], dom[1]);
} break;
case TILEDB_STRING_ASCII:
case TILEDB_STRING_UTF8:
case TILEDB_CHAR:
case TILEDB_BLOB:
case TILEDB_GEOM_WKT:
case TILEDB_GEOM_WKB: {
case TILEDB_STRING_UTF8: {
auto dom = std::any_cast<std::array<std::string, 2>>(domain[0]);
if (dom[0] == "" && dom[1] == "") {
rectangle.set_range(dimension.name(), "", "\x7f");
Expand Down Expand Up @@ -397,11 +387,7 @@ std::pair<bool, std::string> SOMADimension::_can_set_current_domain_slot(
return comparator(
std::any_cast<std::array<double_t, 2>>(new_domain[0]));
case TILEDB_STRING_ASCII:
case TILEDB_STRING_UTF8:
case TILEDB_CHAR:
case TILEDB_BLOB:
case TILEDB_GEOM_WKT:
case TILEDB_GEOM_WKB: {
case TILEDB_STRING_UTF8: {
auto dom = std::any_cast<std::array<std::string, 2>>(new_domain[0]);
if (dom[0] != "" || dom[1] != "") {
return std::pair(
Expand Down Expand Up @@ -519,10 +505,6 @@ std::any SOMADimension::_non_empty_domain_slot(Array& array) const {
array.non_empty_domain<double_t>(dimension.name()));
case TILEDB_STRING_ASCII:
case TILEDB_STRING_UTF8:
case TILEDB_BLOB:
case TILEDB_CHAR:
case TILEDB_GEOM_WKB:
case TILEDB_GEOM_WKT:
return std::make_any<std::pair<std::string, std::string>>(
array.non_empty_domain_var(dimension.name()));
default:
Expand All @@ -537,49 +519,46 @@ std::any SOMADimension::_non_empty_domain_slot_opt(
const SOMAContext& ctx, Array& array) const {
int32_t is_empty;

switch (dimension.type()) {
case TILEDB_STRING_ASCII:
case TILEDB_STRING_UTF8:
case TILEDB_GEOM_WKT: {
void* var_start;
void* var_end;
uint64_t size_start, size_end;
ctx.tiledb_ctx()->handle_error(
tiledb_array_get_non_empty_domain_var_size_from_name(
ctx.tiledb_ctx()->ptr().get(),
array.ptr().get(),
dimension.name().c_str(),
&size_start,
&size_end,
&is_empty));

if (is_empty) {
return std::make_any<
std::optional<std::pair<std::string, std::string>>>(
std::nullopt);
}

var_start = malloc(size_start);
var_end = malloc(size_end);

ctx.tiledb_ctx()->handle_error(
tiledb_array_get_non_empty_domain_var_from_name(
ctx.tiledb_ctx()->ptr().get(),
array.ptr().get(),
dimension.name().c_str(),
var_start,
var_end,
&is_empty));

auto ned = std::make_pair(
std::string((char*)var_start, size_start),
std::string((char*)var_end, size_end));
free(var_start);
free(var_end);

if (dimension.type() == TILEDB_STRING_ASCII ||
dimension.type() == TILEDB_STRING_UTF8) {
void* var_start;
void* var_end;
uint64_t size_start, size_end;
ctx.tiledb_ctx()->handle_error(
tiledb_array_get_non_empty_domain_var_size_from_name(
ctx.tiledb_ctx()->ptr().get(),
array.ptr().get(),
dimension.name().c_str(),
&size_start,
&size_end,
&is_empty));

if (is_empty) {
return std::make_any<
std::optional<std::pair<std::string, std::string>>>(ned);
std::optional<std::pair<std::string, std::string>>>(
std::nullopt);
}

var_start = malloc(size_start);
var_end = malloc(size_end);

ctx.tiledb_ctx()->handle_error(
tiledb_array_get_non_empty_domain_var_from_name(
ctx.tiledb_ctx()->ptr().get(),
array.ptr().get(),
dimension.name().c_str(),
var_start,
var_end,
&is_empty));

auto ned = std::make_pair(
std::string((char*)var_start, size_start),
std::string((char*)var_end, size_end));
free(var_start);
free(var_end);

return std::make_any<
std::optional<std::pair<std::string, std::string>>>(ned);
}

void* fixed_ned = malloc(16);
Expand Down Expand Up @@ -815,11 +794,7 @@ std::any SOMADimension::_core_current_domain_slot(NDRectangle& ndrect) const {
std::make_pair(domain[0], domain[1]));
}
case TILEDB_STRING_UTF8:
case TILEDB_STRING_ASCII:
case TILEDB_CHAR:
case TILEDB_BLOB:
case TILEDB_GEOM_WKT:
case TILEDB_GEOM_WKB: {
case TILEDB_STRING_ASCII: {
std::array<std::string, 2> domain = ndrect.range<std::string>(
dimension.name());
return std::make_any<std::pair<std::string, std::string>>(
Expand Down Expand Up @@ -889,9 +864,6 @@ ArrowArray* SOMADimension::arrow_domain_slot(
domain_slot<float>(ctx, array, kind));
case TILEDB_STRING_ASCII:
case TILEDB_STRING_UTF8:
case TILEDB_CHAR:
case TILEDB_GEOM_WKB:
case TILEDB_GEOM_WKT:
return ArrowAdapter::make_arrow_array_child_string(
domain_slot<std::string>(ctx, array, kind));
default:
Expand Down

0 comments on commit 29448a2

Please sign in to comment.