Skip to content

Commit

Permalink
[c++] Methodize timestamped-schema-evolution factory (#2909)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnkerl authored Aug 19, 2024
1 parent f95f21f commit 95cd876
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
21 changes: 13 additions & 8 deletions libtiledbsoma/src/soma/soma_array.cc
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,18 @@ uint64_t SOMAArray::_get_max_capacity(tiledb_datatype_t index_type) {
}
}

ArraySchemaEvolution SOMAArray::_make_se() {
ArraySchemaEvolution se(*ctx_->tiledb_ctx());
if (timestamp_.has_value()) {
// ArraySchemaEvolution requires us to pair (t2, t2) even if our range
// is (t1, t2).
auto v = timestamp_.value();
TimestampRange tr(v.second, v.second);
se.set_timestamp_range(tr);
}
return se;
}

void SOMAArray::set_column_data(
std::string_view name,
uint64_t num_elems,
Expand Down Expand Up @@ -738,14 +750,7 @@ ArrowTable SOMAArray::_cast_table(

// Go through all columns in the ArrowTable and cast the values to what is
// in the ArraySchema on disk
ArraySchemaEvolution se(*ctx_->tiledb_ctx());
if (timestamp_.has_value()) {
// ArraySchemaEvolution requires us to pair (t2, t2) even if our range
// is (t1, t2).
auto v = timestamp_.value();
TimestampRange tr(v.second, v.second);
se.set_timestamp_range(tr);
}
ArraySchemaEvolution se = _make_se();
bool evolve_schema = false;
for (auto i = 0; i < arrow_schema->n_children; ++i) {
auto orig_arrow_sch_ = arrow_schema->children[i];
Expand Down
7 changes: 7 additions & 0 deletions libtiledbsoma/src/soma/soma_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,13 @@ class SOMAArray : public SOMAObject {

uint64_t _get_max_capacity(tiledb_datatype_t index_type);

/**
* Convenience function for creating an ArraySchemaEvolution object
* referencing this array's context pointer, along with its open-at
* timestamp (if any).
*/
ArraySchemaEvolution _make_se();

bool _extend_enumeration(
ArrowSchema* value_schema,
ArrowArray* value_array,
Expand Down

0 comments on commit 95cd876

Please sign in to comment.