Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[c++] Fix fast path for SparseNDArray nnz #3229

Merged
merged 1 commit into from
Oct 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions libtiledbsoma/src/soma/soma_array.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1351,17 +1351,19 @@ uint64_t SOMAArray::nnz() {
uint64_t total_cell_num = 0;
std::vector<std::array<uint64_t, 2>> non_empty_domains(fragment_count);

// The loop after this only works if dim 0 is int64 soma_joinid.
// That's the case for _almost_ all SOMADataFrame objects, but
// The loop after this only works if dim 0 is int64 soma_joinid or
// soma_dim_0. That's the case for _almost_ all SOMADataFrame objects, but
// not the "variant-indexed" ones: the SOMA spec only requires
// that soma_joinid be present as a dim or an attr.
// that soma_joinid be present as a dim or an attr. It's true for all
// SOMASparseNDArray objects.
auto dim = tiledb_schema()->domain().dimension(0);
auto dim_name = dim.name();
auto type_code = dim.type();
if (dim_name != "soma_joinid" || type_code != TILEDB_INT64) {
if ((dim_name != "soma_joinid" && dim_name != "soma_dim_0") ||
type_code != TILEDB_INT64) {
LOG_DEBUG(fmt::format(
"[SOMAArray::nnz] dim 0 (type={} name={}) isn't int64 "
"soma_joind: using _nnz_slow",
"soma_joinid or int64 soma_dim_0: using _nnz_slow",
tiledb::impl::type_to_str(type_code),
dim_name));
return _nnz_slow();
Expand Down
Loading