Skip to content

Commit

Permalink
Misc fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
XanthosXanthopoulos committed Jan 14, 2025
1 parent 013b43b commit 2401416
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 163 deletions.
2 changes: 1 addition & 1 deletion libtiledbsoma/src/soma/soma_geometry_column.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class SOMAGeometryColumn : public SOMAColumn {
const SOMAContext& ctx,
const std::any& points) const override;

virtual void _set_dim_ranges(
void _set_dim_ranges(
const std::unique_ptr<ManagedQuery>& query,
const SOMAContext& ctx,
const std::any& ranges) const override;
Expand Down
163 changes: 8 additions & 155 deletions libtiledbsoma/src/utils/arrow_adapter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1127,7 +1127,10 @@ ArraySchema ArrowAdapter::tiledb_schema_from_arrow_schema(
}
}

// Unit tests expect dimension order should match the index column schema
// and NOT the arrow schema
for (int64_t i = 0; i < index_column_schema->n_children; ++i) {
LOG_DEBUG(std::format("[ArrowAdapter] child {}", i));
auto column = std::find_if(
columns.begin(), columns.end(), [&](auto col) {
return strcmp(
Expand All @@ -1136,10 +1139,14 @@ ArraySchema ArrowAdapter::tiledb_schema_from_arrow_schema(
});

if (column == columns.end()) {
continue;
throw TileDBSOMAError(std::format(
"[ArrowAdapter][tiledb_schema_from_arrow_schema] Index column "
"{} missing",
index_column_schema->children[i]->name));
}

if ((*column)->tiledb_dimensions().has_value()) {
// Intermediate variable required to avoid lifetime issues
auto dimensions = (*column)->tiledb_dimensions().value();
for (const auto& dimension : dimensions) {
domain.add_dimension(dimension);
Expand Down Expand Up @@ -1577,160 +1584,6 @@ ArrowAdapter::to_arrow(std::shared_ptr<ColumnBuffer> column) {
return std::pair(std::move(array), std::move(schema));
}

void ArrowAdapter::set_current_domain_slot(
tiledb_datatype_t type,
const void* buff,
NDRectangle& ndrect,
std::string name) {
switch (type) {
case TILEDB_STRING_UTF8:
case TILEDB_STRING_ASCII:
// Core domain must not be set for string dims.
// Core current_domain can't _not_ be set for string dims.
// For TileDB-SOMA, we set a broad initial range for string
// dims (because we have to) but there has never been support
// for user specification of domain for string dims, and we do not
// introduce support for user specification of current domain for
// string dims.
throw TileDBSOMAError(
"Internal error: _set_current_domain_slot must not be called "
"for string dimensions.");
break;
case TILEDB_TIME_SEC:
case TILEDB_TIME_MS:
case TILEDB_TIME_US:
case TILEDB_TIME_NS:
case TILEDB_DATETIME_SEC:
case TILEDB_DATETIME_MS:
case TILEDB_DATETIME_US:
case TILEDB_DATETIME_NS: {
auto typed_buf = static_cast<const uint64_t*>(buff);
uint64_t lo = typed_buf[3];
uint64_t hi = typed_buf[4];
ndrect.set_range<uint64_t>(name, lo, hi);
LOG_DEBUG(std::format(
"[ArrowAdapter] {} current_domain uint64_t {} to {}",
name,
lo,
hi));
} break;
case TILEDB_INT8: {
auto typed_buf = static_cast<const int8_t*>(buff);
int8_t lo = typed_buf[3];
int8_t hi = typed_buf[4];
ndrect.set_range<int8_t>(name, lo, hi);
LOG_DEBUG(std::format(
"[ArrowAdapter] {} current_domain int8_t {} to {}",
name,
lo,
hi));
} break;
case TILEDB_UINT8: {
auto typed_buf = static_cast<const uint8_t*>(buff);
uint8_t lo = typed_buf[3];
uint8_t hi = typed_buf[4];
ndrect.set_range<uint8_t>(name, lo, hi);
LOG_DEBUG(std::format(
"[ArrowAdapter] {} current_domain uint8_t {} to {}",
name,
lo,
hi));
} break;
case TILEDB_INT16: {
auto typed_buf = static_cast<const int16_t*>(buff);
int16_t lo = typed_buf[3];
int16_t hi = typed_buf[4];
ndrect.set_range<int16_t>(name, lo, hi);
LOG_DEBUG(std::format(
"[ArrowAdapter] {} current_domain int16_t {} to {}",
name,
lo,
hi));
} break;
case TILEDB_UINT16: {
auto typed_buf = static_cast<const uint16_t*>(buff);
uint16_t lo = typed_buf[3];
uint16_t hi = typed_buf[4];
ndrect.set_range<uint16_t>(name, lo, hi);
LOG_DEBUG(std::format(
"[ArrowAdapter] {} current_domain uint16_t {} to {}",
name,
lo,
hi));
} break;
case TILEDB_INT32: {
auto typed_buf = static_cast<const int32_t*>(buff);
int32_t lo = typed_buf[3];
int32_t hi = typed_buf[4];
ndrect.set_range<int32_t>(name, lo, hi);
LOG_DEBUG(std::format(
"[ArrowAdapter] {} current_domain int32_t {} to {}",
name,
lo,
hi));
} break;
case TILEDB_UINT32: {
auto typed_buf = static_cast<const uint32_t*>(buff);
uint32_t lo = typed_buf[3];
uint32_t hi = typed_buf[4];
ndrect.set_range<uint32_t>(name, lo, hi);
LOG_DEBUG(std::format(
"[ArrowAdapter] {} current_domain uint32_t {} to {}",
name,
lo,
hi));
} break;
case TILEDB_INT64: {
auto typed_buf = static_cast<const int64_t*>(buff);
int64_t lo = typed_buf[3];
int64_t hi = typed_buf[4];
ndrect.set_range<int64_t>(name, lo, hi);
LOG_DEBUG(std::format(
"[ArrowAdapter] {} current_domain int64_t {} to {}",
name,
lo,
hi));
} break;
case TILEDB_UINT64: {
auto typed_buf = static_cast<const uint64_t*>(buff);
uint64_t lo = typed_buf[3];
uint64_t hi = typed_buf[4];
ndrect.set_range<uint64_t>(name, lo, hi);
LOG_DEBUG(std::format(
"[ArrowAdapter] {} current_domain uint64_t {} to {}",
name,
lo,
hi));
} break;
case TILEDB_FLOAT32: {
auto typed_buf = static_cast<const float_t*>(buff);
float lo = typed_buf[3];
float hi = typed_buf[4];
ndrect.set_range<float>(name, lo, hi);
LOG_DEBUG(std::format(
"[ArrowAdapter] {} current_domain float {} to {}",
name,
lo,
hi));
} break;
case TILEDB_FLOAT64: {
auto typed_buf = static_cast<const double_t*>(buff);
double lo = typed_buf[3];
double hi = typed_buf[4];
ndrect.set_range<double>(name, lo, hi);
LOG_DEBUG(std::format(
"[ArrowAdapter] {} current_domain double {} to {}",
name,
lo,
hi));
} break;
default:
throw TileDBSOMAError(std::format(
"ArrowAdapter: Unsupported TileDB dimension: {} ",
tiledb::impl::type_to_str(type)));
}
}

bool ArrowAdapter::arrow_is_var_length_type(const char* format) {
return (
(strcmp(format, "U") == 0) || (strcmp(format, "Z") == 0) ||
Expand Down
5 changes: 4 additions & 1 deletion libtiledbsoma/src/utils/arrow_adapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -859,8 +859,11 @@ class ArrowAdapter {

/**
* Return a copy of the data in a specified column of an arrow table.
* Complex column types are supported. The for each sub column are an
* Complex column types are supported. The type for each sub column is an
* std::array<T, 2> casted as an std::any object.
*
* @tparam Take The number of elements to retrieve
* @tparam Skip The number of elements to skip
*/
template <size_t Take, size_t Skip = 0>
static std::vector<std::any> get_table_any_column_by_name(
Expand Down
8 changes: 2 additions & 6 deletions libtiledbsoma/test/unit_soma_column.cc
Original file line number Diff line number Diff line change
Expand Up @@ -583,9 +583,7 @@ TEST_CASE_METHOD(
columns[1]->set_dim_point<uint32_t>(external_query, *ctx_, 1234);

// Configure query and allocate result buffers
external_query->setup_read();
external_query->submit_read();
auto ext_res = external_query->results();
auto ext_res = external_query->read_next().value();

REQUIRE(ext_res->num_rows() == 1);

Expand All @@ -599,9 +597,7 @@ TEST_CASE_METHOD(
{std::make_pair<std::string, std::string>("apple", "b")}));

// Configure query and allocate result buffers
external_query->setup_read();
external_query->submit_read();
ext_res = external_query->results();
ext_res = external_query->read_next().value();

REQUIRE(ext_res->num_rows() == 1);
}
Expand Down

0 comments on commit 2401416

Please sign in to comment.