Skip to content

Commit

Permalink
Swap shared_ptr with const reference, hide internal columns when open…
Browse files Browse the repository at this point in the history
…ing an array for read unless explicity specify them
  • Loading branch information
XanthosXanthopoulos committed Nov 1, 2024
1 parent fbac212 commit b77de49
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
19 changes: 19 additions & 0 deletions libtiledbsoma/src/soma/soma_array.cc
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,25 @@ void SOMAArray::reset(

if (!column_names.empty()) {
mq_->select_columns(column_names);
} else {
// Hide internal columns if any
std::vector<std::string> columns;
for (const auto& dim : this->tiledb_schema()->domain().dimensions()) {
columns.push_back(dim.name());
}

for (size_t i = 0; i < this->tiledb_schema()->attribute_num(); ++i) {
columns.push_back(this->tiledb_schema()->attribute(i).name());
}
auto is_internal = [](std::string name) {
return name.rfind(SOMA_GEOMETRY_DIMENSION_PREFIX, 0) == 0;
};

auto internal_end = std::remove_if(
columns.begin(), columns.end(), is_internal);
columns.erase(internal_end, columns.end());

mq_->select_columns(columns);
}

switch (result_order) {
Expand Down
10 changes: 4 additions & 6 deletions libtiledbsoma/src/utils/arrow_adapter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ std::unique_ptr<ArrowSchema> ArrowAdapter::arrow_schema_from_tiledb_array(
} else if constexpr (std::is_same_v<T, Attribute>) {
child = arrow_schema->children[i] =
arrow_schema_from_tiledb_attribute(
arg, ctx, tiledb_array)
arg, *ctx, *tiledb_array)
.release();
}
},
Expand Down Expand Up @@ -425,9 +425,7 @@ std::unique_ptr<ArrowSchema> ArrowAdapter::arrow_schema_from_tiledb_dimension(
}

std::unique_ptr<ArrowSchema> ArrowAdapter::arrow_schema_from_tiledb_attribute(
Attribute& attribute,
std::shared_ptr<Context> ctx,
std::shared_ptr<Array> tiledb_array) {
Attribute& attribute, const Context& ctx, const Array& tiledb_array) {
std::unique_ptr<ArrowSchema> arrow_schema = std::make_unique<ArrowSchema>();
arrow_schema->format = strdup(
ArrowAdapter::to_arrow_format(attribute.type()).data());
Expand All @@ -454,10 +452,10 @@ std::unique_ptr<ArrowSchema> ArrowAdapter::arrow_schema_from_tiledb_attribute(
arrow_schema->name));

auto enmr_name = AttributeExperimental::get_enumeration_name(
*ctx, attribute);
ctx, attribute);
if (enmr_name.has_value()) {
auto enmr = ArrayExperimental::get_enumeration(
*ctx, *tiledb_array, attribute.name());
ctx, tiledb_array, attribute.name());
auto dict = (ArrowSchema*)malloc(sizeof(ArrowSchema));
dict->format = strdup(
ArrowAdapter::to_arrow_format(enmr.type(), false).data());
Expand Down
4 changes: 1 addition & 3 deletions libtiledbsoma/src/utils/arrow_adapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,7 @@ class ArrowAdapter {
* @return ArrowSchema
*/
static std::unique_ptr<ArrowSchema> arrow_schema_from_tiledb_attribute(
Attribute& attribute,
std::shared_ptr<Context> ctx,
std::shared_ptr<Array> tiledb_array);
Attribute& attribute, const Context& ctx, const Array& tiledb_array);

/**
* @brief Get members of the TileDB Schema in the form of a PlatformConfig
Expand Down

0 comments on commit b77de49

Please sign in to comment.