Skip to content

Commit

Permalink
debug sandboxpass, CI pass at 3.11, CI fail at 3.8 [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
johnkerl committed Aug 29, 2024
1 parent a2fc155 commit b43f5f7
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 16 deletions.
6 changes: 6 additions & 0 deletions libtiledbsoma/src/utils/arrow_adapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,12 @@ class ArrowAdapter {
template <typename T>
static Dimension _create_dim_aux(
std::shared_ptr<Context> ctx, std::string name, T* b) {
std::cout << "\n";
std::cout << "5. CDX BEGIN\n";
std::cout << "name=" << name << ",sizeof=" << sizeof(T)
<< ",b0=" << b[0] << ",b1=" << b[1] << ",b2=" << b[2];
std::cout << "5. CDX END\n";

return Dimension::create<T>(*ctx, name, {b[0], b[1]}, b[2]);
}

Expand Down
68 changes: 52 additions & 16 deletions libtiledbsoma/test/common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,16 @@ create_arrow_schema_and_index_columns(

// Create index-column info only, no schema involving the attrs
ArrowTable create_column_index_info(const std::vector<DimInfo>& dim_infos) {
std::cout << "\n";
std::cout << "2. CCII BEGIN\n";
for (auto it : dim_infos) {
std::cout << "name=" << it.name
<< ",tiledb_datatype=" << it.tiledb_datatype
<< ",dim_max=" << it.dim_max
<< ",use_current_domain=" << it.use_current_domain << "\n";
}
std::cout << "2. CCII END\n";

auto index_cols_info_schema = _create_index_cols_info_schema(dim_infos);
auto index_cols_info_array = _create_index_cols_info_array(dim_infos);

Expand Down Expand Up @@ -181,6 +191,16 @@ static std::unique_ptr<ArrowArray> _create_index_cols_info_array(
index_cols_info_array->release = &ArrowAdapter::release_array;
index_cols_info_array->children = new ArrowArray*[ndim];

std::cout << "\n";
std::cout << "3. CICIA BEGIN\n";
for (auto it : dim_infos) {
std::cout << "name=" << it.name
<< ",tiledb_datatype=" << it.tiledb_datatype
<< ",dim_max=" << it.dim_max
<< ",use_current_domain=" << it.use_current_domain << "\n";
}
std::cout << "3. CICIA END\n";

for (int i = 0; i < ndim; i++) {
const DimInfo& info = dim_infos[i];

Expand All @@ -194,54 +214,70 @@ static std::unique_ptr<ArrowArray> _create_index_cols_info_array(
dim_array->release = &ArrowAdapter::release_array;
dim_array->buffers = new const void*[2];
dim_array->buffers[0] = nullptr;
dim_array->buffers[1] = malloc(sizeof(int64_t) * n); // XXX TEMP
dim_array->n_children = 0; // leaf node
dim_array->n_children = 0; // leaf node
index_cols_info_array->children[i] = dim_array;

void* vsrc = nullptr;
size_t nbytes = 0;

// The full user-level SOMA API supports many more index types.
// Here we support enough types to verify we've got variant-indexed
// SOMADataFrame objects baseline-tested in C++, then defer exhaustive
// loop-over-all-datatypes handling to Python and R.
if (info.tiledb_datatype == TILEDB_INT64) {
size_t nbytes = n * sizeof(int64_t);
dim_array->buffers[1] = malloc(nbytes);
if (info.use_current_domain) {
// domain big; current_domain small
int64_t dom[] = {0, CORE_DOMAIN_MAX, 1, 0, info.dim_max};
vsrc = (void*)&dom[0];

std::cout << "\n";
std::cout << "4a. CICIA BEGIN\n";
std::cout << "name=" << info.name
<< ",sizeof=" << sizeof(int64_t) << ",b0=" << dom[0]
<< ",b1=" << dom[1] << ",b2=" << dom[2]
<< ",b3=" << dom[3] << ",b4=" << dom[4] << "\n";
std::cout << "4a. CICIA END\n";

void* vsrc = (void*)&dom[0];
std::memcpy((void*)dim_array->buffers[1], vsrc, nbytes);
} else {
// domain small; current_domain feature not being used
int64_t dom[] = {0, info.dim_max, 1};
vsrc = (void*)&dom[0];

std::cout << "\n";
std::cout << "4b. CICIA BEGIN\n";
std::cout << "name=" << info.name
<< ",sizeof=" << sizeof(int64_t) << ",b0=" << dom[0]
<< ",b1=" << dom[1] << ",b2=" << dom[2] << "\n";
std::cout << "4b. CICIA END\n";
void* vsrc = (void*)&dom[0];
std::memcpy((void*)dim_array->buffers[1], vsrc, nbytes);
}
nbytes = n * sizeof(int64_t);

} else if (info.tiledb_datatype == TILEDB_UINT32) {
size_t nbytes = n * sizeof(uint32_t);
dim_array->buffers[1] = malloc(nbytes);
if (info.use_current_domain) {
// domain big; current_domain small
uint32_t dom[] = {
0, (uint32_t)CORE_DOMAIN_MAX, 1, 0, (uint32_t)info.dim_max};
vsrc = (void*)&dom[0];
void* vsrc = (void*)&dom[0];
std::memcpy((void*)dim_array->buffers[1], vsrc, nbytes);
} else {
// domain small; current_domain feature not being used
int64_t dom[] = {0, info.dim_max, 1};
vsrc = (void*)&dom[0];
void* vsrc = (void*)&dom[0];
std::memcpy((void*)dim_array->buffers[1], vsrc, nbytes);
}
nbytes = n * sizeof(int64_t);

} else if (info.tiledb_datatype == TILEDB_STRING_ASCII) {
// Domain not supported in core. See arrow_adapter for more info.
vsrc = nullptr;
nbytes = 0;
// Domain specification for strings is not supported in core. See
// arrow_adapter for more info.
dim_array->buffers[1] = nullptr;

} else {
throw TileDBSOMAError(
"Unsupported datatype encountered in unit test. You can add a "
"new type if you like!");
}

std::memcpy((void*)dim_array->buffers[1], vsrc, nbytes);
}

return index_cols_info_array;
Expand Down
12 changes: 12 additions & 0 deletions libtiledbsoma/test/unit_soma_collection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,18 @@ TEST_CASE("SOMACollection: add SOMASparseNDArray") {
.dim_max = DIM_MAX,
.use_current_domain = use_current_domain}});

// ----------------------------------------------------------------
std::cout << "1. TEST_CASE BEGIN\n";
for (auto it : dim_infos) {
std::cout << "name=" << it.name
<< ",tiledb_datatype=" << it.tiledb_datatype
<< ",dim_max=" << it.dim_max
<< ",use_current_domain=" << it.use_current_domain
<< "\n";
}
std::cout << "1. TEST_CASE END\n";
// ----------------------------------------------------------------

auto index_columns = helper::create_column_index_info(dim_infos);

std::map<std::string, SOMAGroupEntry> expected_map{
Expand Down

0 comments on commit b43f5f7

Please sign in to comment.