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++] Methodize timestamped-schema-evolution factory #2909

Merged
merged 1 commit into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
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
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 @@
}
}

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);

Check warning on line 481 in libtiledbsoma/src/soma/soma_array.cc

View check run for this annotation

Codecov / codecov/patch

libtiledbsoma/src/soma/soma_array.cc#L479-L481

Added lines #L479 - L481 were not covered by tests
}
return se;
}

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

// 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
Loading