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++] Merges for #1559 #1684

Merged
merged 3 commits into from
Sep 15, 2023
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
10 changes: 5 additions & 5 deletions apis/python/src/tiledbsoma/pytiledbsoma.cc
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ py::object to_table(SOMAArray& sr, std::shared_ptr<ArrayBuffers> array_buffers)
arrays.append(to_array(column));
}else{
arrays.append(pa_dict_from_arrays(
to_array(column),
get_enum(sr, name),
py::none(),
to_array(column),
get_enum(sr, name),
py::none(),
get_enum_is_ordered(sr, name)));
}
}
Expand Down Expand Up @@ -640,11 +640,11 @@ PYBIND11_MODULE(pytiledbsoma, m) {
.def("nnz", &SOMAArray::nnz, py::call_guard<py::gil_scoped_release>())

.def_property_readonly("shape", &SOMAArray::shape)

.def("get_enum", get_enum)

.def("get_enum_is_ordered", get_enum_is_ordered)

.def("get_enum_label_on_attr", &SOMAArray::get_enum_label_on_attr);
}
} // namespace tiledbsoma
2 changes: 1 addition & 1 deletion apis/r/src/rinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ Rcpp::List soma_array_reader(const std::string& uri,
auto buf = sr_data->get()->at(names[i]);

// this is pair of array and schema pointer
auto pp = tdbs::ArrowAdapter::to_arrow(buf);
auto pp = tdbs::ArrowAdapter::to_arrow(buf, true);

memcpy((void*) chldschemaxp, pp.second.get(), sizeof(ArrowSchema));
memcpy((void*) chldarrayxp, pp.first.get(), sizeof(ArrowArray));
Expand Down
2 changes: 1 addition & 1 deletion apis/r/src/riterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ Rcpp::List sr_next(Rcpp::XPtr<tdbs::SOMAArray> sr) {
auto buf = sr_data->get()->at(names[i]);

// this is pair of array and schema pointer
auto pp = tdbs::ArrowAdapter::to_arrow(buf);
auto pp = tdbs::ArrowAdapter::to_arrow(buf, true);

memcpy((void*) chldschemaxp, pp.second.get(), sizeof(ArrowSchema));
memcpy((void*) chldarrayxp, pp.first.get(), sizeof(ArrowArray));
Expand Down
3 changes: 3 additions & 0 deletions libtiledbsoma/src/soma/managed_query.cc
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ std::shared_ptr<ArrayBuffers> ManagedQuery::results() {
auto enumeration = ArrayExperimental::get_enumeration(
*ctx_, *array_, enumname.value());
auto enumvec = enumeration.as_vector<std::string>();
if (!buffers_->contains(attrname)) {
continue;
}
auto colbuf = buffers_->at(attrname);
colbuf->add_enumeration(enumvec);
LOG_DEBUG(fmt::format(
Expand Down
2 changes: 1 addition & 1 deletion libtiledbsoma/src/soma/soma_array.cc
Original file line number Diff line number Diff line change
Expand Up @@ -571,4 +571,4 @@ void SOMAArray::validate(
}
}

} // namespace tiledbsoma
} // namespace tiledbsoma
9 changes: 6 additions & 3 deletions libtiledbsoma/src/utils/arrow_adapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ class ArrowAdapter {
*
* @return auto [Arrow array, Arrow schema]
*/
static auto to_arrow(std::shared_ptr<ColumnBuffer> column) {
static auto to_arrow(
std::shared_ptr<ColumnBuffer> column, bool use_enum = false) {
std::unique_ptr<ArrowSchema> schema = std::make_unique<ArrowSchema>();
std::unique_ptr<ArrowArray> array = std::make_unique<ArrowArray>();

Expand Down Expand Up @@ -153,8 +154,10 @@ class ArrowAdapter {
column->data_to_bitmap();
}

// If we have an enumeration, fill a dictionary
if (column->has_enumeration()) {
// If we have an enumeration, fill a dictionary.
// The Python callpath handles this separately. The R callpath needs us
// to do this. TODO: uniformize this at the callsites.
if (column->has_enumeration() && use_enum) {
auto enumvec = column->get_enumeration();

ArrowSchema* dict_sch = new ArrowSchema;
Expand Down