From e746f3ba08abe4843c0d8b1e037b6c02411a04a5 Mon Sep 17 00:00:00 2001 From: XanthosXanthopoulos Date: Tue, 10 Dec 2024 13:11:31 +0200 Subject: [PATCH] Remove unsupported dimension datatypes --- libtiledbsoma/src/soma/soma_dimension.cc | 110 +++++++++-------------- 1 file changed, 41 insertions(+), 69 deletions(-) diff --git a/libtiledbsoma/src/soma/soma_dimension.cc b/libtiledbsoma/src/soma/soma_dimension.cc index bf21fa0b0e..54c16545ae 100644 --- a/libtiledbsoma/src/soma/soma_dimension.cc +++ b/libtiledbsoma/src/soma/soma_dimension.cc @@ -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>(points)); @@ -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>>( @@ -258,11 +252,7 @@ void SOMADimension::_set_current_domain_slot( rectangle.set_range(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>(domain[0]); if (dom[0] == "" && dom[1] == "") { rectangle.set_range(dimension.name(), "", "\x7f"); @@ -397,11 +387,7 @@ std::pair SOMADimension::_can_set_current_domain_slot( return comparator( std::any_cast>(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>(new_domain[0]); if (dom[0] != "" || dom[1] != "") { return std::pair( @@ -519,10 +505,6 @@ std::any SOMADimension::_non_empty_domain_slot(Array& array) const { array.non_empty_domain(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>( array.non_empty_domain_var(dimension.name())); default: @@ -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::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>>(ned); + std::optional>>( + 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>>(ned); } void* fixed_ned = malloc(16); @@ -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 domain = ndrect.range( dimension.name()); return std::make_any>( @@ -889,9 +864,6 @@ ArrowArray* SOMADimension::arrow_domain_slot( domain_slot(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(ctx, array, kind)); default: