Skip to content
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
2 changes: 1 addition & 1 deletion Framework/Core/include/Framework/ASoA.h
Original file line number Diff line number Diff line change
Expand Up @@ -1619,7 +1619,7 @@ auto select(T const& t, framework::expressions::Filter const& f)
return Filtered<T>({t.asArrowTable()}, selectionToVector(framework::expressions::createSelection(t.asArrowTable(), f)));
}

arrow::ChunkedArray* getIndexFromLabel(arrow::Table* table, const char* label);
arrow::ChunkedArray* getIndexFromLabel(arrow::Table* table, std::string_view label);

template <typename D, typename O, typename IP, typename... C>
consteval auto base_iter(framework::pack<C...>&&) -> TableIterator<D, O, IP, C...>
Expand Down
13 changes: 11 additions & 2 deletions Framework/Core/src/ASoA.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,19 @@ std::shared_ptr<arrow::Table> ArrowHelpers::concatTables(std::vector<std::shared
return result;
}

arrow::ChunkedArray* getIndexFromLabel(arrow::Table* table, const char* label)
arrow::ChunkedArray* getIndexFromLabel(arrow::Table* table, std::string_view label)
{
auto field = std::find_if(table->schema()->fields().begin(), table->schema()->fields().end(), [&](std::shared_ptr<arrow::Field> const& f) {
return o2::framework::strToUpper(label) == o2::framework::strToUpper(std::string{f->name()});
auto caseInsensitiveCompare = [](const std::string_view& str1, const std::string& str2) {
return std::ranges::equal(
str1, str2,
[](char c1, char c2) {
return std::tolower(static_cast<unsigned char>(c1)) ==
std::tolower(static_cast<unsigned char>(c2));
});
};

return caseInsensitiveCompare(label, f->name());
});
if (field == table->schema()->fields().end()) {
o2::framework::throw_error(o2::framework::runtime_error_f("Unable to find column with label %s", label));
Expand Down
Loading