Skip to content

Commit

Permalink
[c++] Match zero-basing for old/new sparse-array shapes
Browse files Browse the repository at this point in the history
  • Loading branch information
johnkerl committed Dec 13, 2024
1 parent e8ef0ac commit 38ba1c4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
24 changes: 13 additions & 11 deletions libtiledbsoma/src/soma/soma_array.cc
Original file line number Diff line number Diff line change
Expand Up @@ -726,12 +726,13 @@ std::vector<int64_t> SOMAArray::shape() {
// * Even after the new-shape feature is fully released, there will be old
// arrays on disk that were created before this feature existed.
// So this is long-term code.
return _get_current_domain().is_empty() ? _tiledb_domain() :
_tiledb_current_domain();
return _get_current_domain().is_empty() ?
_shape_via_tiledb_domain() :
_shape_via_tiledb_current_domain();
}

std::vector<int64_t> SOMAArray::maxshape() {
return _tiledb_domain();
return _shape_via_tiledb_domain();
}

// This is a helper for can_upgrade_shape and can_resize, which have
Expand Down Expand Up @@ -1532,7 +1533,7 @@ void SOMAArray::_set_domain_helper(
schema_evolution.array_evolve(uri_);
}

std::vector<int64_t> SOMAArray::_tiledb_current_domain() {
std::vector<int64_t> SOMAArray::_shape_via_tiledb_current_domain() {
// Variant-indexed dataframes must use a separate path
_check_dims_are_int64();

Expand All @@ -1557,12 +1558,12 @@ std::vector<int64_t> SOMAArray::_tiledb_current_domain() {

for (auto dimension_name : dimension_names()) {
auto range = ndrect.range<int64_t>(dimension_name);
result.push_back(range[1] + 1);
result.push_back(range[1] - range[0] + 1);
}
return result;
}

std::vector<int64_t> SOMAArray::_tiledb_domain() {
std::vector<int64_t> SOMAArray::_shape_via_tiledb_domain() {
// Variant-indexed dataframes must use a separate path
_check_dims_are_int64();

Expand All @@ -1579,15 +1580,16 @@ std::vector<int64_t> SOMAArray::_tiledb_domain() {

std::optional<int64_t> SOMAArray::_maybe_soma_joinid_shape() {
return _get_current_domain().is_empty() ?
_maybe_soma_joinid_tiledb_domain() :
_maybe_soma_joinid_tiledb_current_domain();
_maybe_soma_joinid_shape_via_tiledb_domain() :
_maybe_soma_joinid_shape_via_tiledb_current_domain();
}

std::optional<int64_t> SOMAArray::_maybe_soma_joinid_maxshape() {
return _maybe_soma_joinid_tiledb_domain();
return _maybe_soma_joinid_shape_via_tiledb_domain();
}

std::optional<int64_t> SOMAArray::_maybe_soma_joinid_tiledb_current_domain() {
std::optional<int64_t>
SOMAArray::_maybe_soma_joinid_shape_via_tiledb_current_domain() {
const std::string dim_name = "soma_joinid";

auto dom = schema_->domain();
Expand Down Expand Up @@ -1621,7 +1623,7 @@ std::optional<int64_t> SOMAArray::_maybe_soma_joinid_tiledb_current_domain() {
return std::optional<int64_t>(max);
}

std::optional<int64_t> SOMAArray::_maybe_soma_joinid_tiledb_domain() {
std::optional<int64_t> SOMAArray::_maybe_soma_joinid_shape_via_tiledb_domain() {
const std::string dim_name = "soma_joinid";

auto dom = schema_->domain();
Expand Down
8 changes: 4 additions & 4 deletions libtiledbsoma/src/soma/soma_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -1528,10 +1528,10 @@ class SOMAArray : public SOMAObject {
*
* Here we distinguish between user-side API, and core-side implementation.
*/
std::vector<int64_t> _tiledb_domain();
std::vector<int64_t> _tiledb_current_domain();
std::optional<int64_t> _maybe_soma_joinid_tiledb_current_domain();
std::optional<int64_t> _maybe_soma_joinid_tiledb_domain();
std::vector<int64_t> _shape_via_tiledb_domain();
std::vector<int64_t> _shape_via_tiledb_current_domain();
std::optional<int64_t> _maybe_soma_joinid_shape_via_tiledb_current_domain();
std::optional<int64_t> _maybe_soma_joinid_shape_via_tiledb_domain();

void fill_metadata_cache(std::optional<TimestampRange> timestamp);

Expand Down

0 comments on commit 38ba1c4

Please sign in to comment.