diff --git a/Framework/Core/include/Framework/ASoA.h b/Framework/Core/include/Framework/ASoA.h index c3918f23711b0..a2aa1a794638c 100644 --- a/Framework/Core/include/Framework/ASoA.h +++ b/Framework/Core/include/Framework/ASoA.h @@ -1762,6 +1762,12 @@ class Table using columns_t = decltype(getColumns()); + static constexpr auto column_hashes = [](framework::pack) consteval { + auto hashes = []() consteval { return std::array{CC::hash...}; }.template operator()(); + std::ranges::sort(hashes); + return hashes; + }(columns_t{}); + using persistent_columns_t = decltype([](framework::pack&&) -> framework::selected_pack {}(columns_t{})); using column_types = decltype([](framework::pack) -> framework::pack {}(persistent_columns_t{})); @@ -1945,11 +1951,6 @@ class Table using const_iterator = iterator; using unfiltered_const_iterator = unfiltered_iterator; - static constexpr auto hashes() - { - return [](framework::pack) { return std::set{{C::hash...}}; }(columns_t{}); - } - Table(o2::soa::ArrowTableRef tableRef) : mArrowTableRef(tableRef), mEnd{tableRef.range.size} diff --git a/Framework/Core/include/Framework/AnalysisHelpers.h b/Framework/Core/include/Framework/AnalysisHelpers.h index e4d9682b35302..9a2215dba009a 100644 --- a/Framework/Core/include/Framework/AnalysisHelpers.h +++ b/Framework/Core/include/Framework/AnalysisHelpers.h @@ -953,7 +953,7 @@ auto getTableFromFilter(soa::is_not_filtered_table auto const& table, soa::Selec return std::make_unique>>(std::vector{table.asArrowTableRef()}, std::forward(selection)); } -void initializePartitionCaches(std::set const& hashes, std::shared_ptr const& schema, expressions::Filter const& filter, gandiva::NodePtr& tree, gandiva::FilterPtr& gfilter); +void initializePartitionCaches(const std::span& hashes, std::shared_ptr const& schema, expressions::Filter const& filter, gandiva::NodePtr& tree, gandiva::FilterPtr& gfilter); /// Partition ties directly to the argument type /// in a case with several origins in subscriptions it will get the correct input, as the type contains the origin @@ -975,14 +975,14 @@ struct Partition { setTable(table); } - void intializeCaches(std::set const& hashes, std::shared_ptr const& schema) + void intializeCaches(std::span const& hashes, std::shared_ptr const& schema) { initializePartitionCaches(hashes, schema, filter, tree, gfilter); } void bindTable(T const& table) { - intializeCaches(T::table_t::hashes(), table.asArrowTableRef()->schema()); + intializeCaches(T::table_t::column_hashes, table.asArrowTableRef()->schema()); if (dataframeChanged) { mFiltered = getTableFromFilter(table, soa::selectionToVector(framework::expressions::createSelection(table.asArrowTable(), gfilter))); dataframeChanged = false; diff --git a/Framework/Core/include/Framework/AnalysisTask.h b/Framework/Core/include/Framework/AnalysisTask.h index 1e483d017cc88..b88f8930cc6a9 100644 --- a/Framework/Core/include/Framework/AnalysisTask.h +++ b/Framework/Core/include/Framework/AnalysisTask.h @@ -126,7 +126,7 @@ struct AnalysisDataProcessorBuilder { static void addExpression(int ai, uint32_t hash, std::vector& eInfos) { auto fields = soa::createFieldsFromColumns(typename std::decay_t::persistent_columns_t{}); - eInfos.emplace_back(ai, hash, std::decay_t::hashes(), std::make_shared(fields)); + eInfos.emplace_back(ai, hash, std::span{std::decay_t::column_hashes}, std::make_shared(fields)); } template diff --git a/Framework/Core/include/Framework/Expressions.h b/Framework/Core/include/Framework/Expressions.h index c5f50311a7d19..d6f7cc88f0cbe 100644 --- a/Framework/Core/include/Framework/Expressions.h +++ b/Framework/Core/include/Framework/Expressions.h @@ -39,7 +39,6 @@ class Projector; #include #include #include -#include #include namespace gandiva { @@ -49,7 +48,8 @@ using FilterPtr = std::shared_ptr; using atype = arrow::Type; struct ExpressionInfo { - ExpressionInfo(int ai, size_t hash, std::set&& hs, gandiva::SchemaPtr sc) + template + ExpressionInfo(int ai, size_t hash, T hs, gandiva::SchemaPtr sc) : argumentIndex(ai), processHash(hash), hashes(hs), @@ -58,7 +58,7 @@ struct ExpressionInfo { } int argumentIndex; size_t processHash; - std::set hashes; + std::span hashes; gandiva::SchemaPtr schema; gandiva::NodePtr tree = nullptr; gandiva::FilterPtr filter = nullptr; @@ -681,7 +681,7 @@ using Operations = std::vector; Operations createOperations(Filter const& expression); /// Function to check compatibility of a given arrow schema with operation sequence -bool isTableCompatible(std::set const& hashes, Operations const& specs); +bool isTableCompatible(const std::span& hashes, Operations const& specs); /// Function to create gandiva expression tree from operation sequence gandiva::NodePtr createExpressionTree(Operations const& opSpecs, gandiva::SchemaPtr const& Schema); diff --git a/Framework/Core/src/AnalysisHelpers.cxx b/Framework/Core/src/AnalysisHelpers.cxx index 62229765ddbf8..b902239785835 100644 --- a/Framework/Core/src/AnalysisHelpers.cxx +++ b/Framework/Core/src/AnalysisHelpers.cxx @@ -155,7 +155,7 @@ std::shared_ptr spawnerHelper(std::shared_ptr const& return arrow::Table::Make(newSchema, arrays); } -void initializePartitionCaches(std::set const& hashes, std::shared_ptr const& schema, expressions::Filter const& filter, gandiva::NodePtr& tree, gandiva::FilterPtr& gfilter) +void initializePartitionCaches(std::span const& hashes, std::shared_ptr const& schema, expressions::Filter const& filter, gandiva::NodePtr& tree, gandiva::FilterPtr& gfilter) { if (tree == nullptr) { expressions::Operations ops = createOperations(filter); diff --git a/Framework/Core/src/Expressions.cxx b/Framework/Core/src/Expressions.cxx index 02a862d30032b..a5adb27282afb 100644 --- a/Framework/Core/src/Expressions.cxx +++ b/Framework/Core/src/Expressions.cxx @@ -768,20 +768,19 @@ gandiva::NodePtr createExpressionTree(Operations const& opSpecs, return tree; } -bool isTableCompatible(std::set const& hashes, Operations const& specs) +bool isTableCompatible(std::span const& hashes, Operations const& specs) { - std::set opHashes; + std::vector opHashes; for (auto const& spec : specs) { if (spec.left.datum.index() == 3) { - opHashes.insert(spec.left.hash); + opHashes.emplace_back(spec.left.hash); } if (spec.right.datum.index() == 3) { - opHashes.insert(spec.right.hash); + opHashes.emplace_back(spec.right.hash); } } - return std::includes(hashes.begin(), hashes.end(), - opHashes.begin(), opHashes.end()); + return std::ranges::includes(hashes, opHashes); } void updateExpressionInfos(expressions::Filter const& filter, std::vector& eInfos)