From 97f12ef40059322ae9f177e4993310be3363f288 Mon Sep 17 00:00:00 2001 From: Giulio Eulisse <10544+ktf@users.noreply.github.com> Date: Wed, 29 Jan 2025 09:36:44 +0100 Subject: [PATCH] Revert "DPL Analysis: remove unnecessary instances of selected_pack (#13892)" This reverts commit 53ed758f32eaf659b7a9dc0a7c701fcd300a7544. --- Framework/Core/include/Framework/ASoA.h | 115 ++++++------------ .../Core/include/Framework/Configurable.h | 5 +- .../include/Framework/GroupedCombinations.h | 22 +--- 3 files changed, 41 insertions(+), 101 deletions(-) diff --git a/Framework/Core/include/Framework/ASoA.h b/Framework/Core/include/Framework/ASoA.h index 8ef7ed9539ec7..8af872a64176d 100644 --- a/Framework/Core/include/Framework/ASoA.h +++ b/Framework/Core/include/Framework/ASoA.h @@ -208,6 +208,8 @@ template struct TableMetadata { using columns = framework::pack; using persistent_columns_t = framework::selected_pack; + using external_index_columns_t = framework::selected_pack; + using internal_index_columns_t = framework::selected_pack; template static consteval std::array getMap(framework::pack) @@ -804,6 +806,9 @@ concept is_dynamic_column = requires(C& c) { template concept is_marker_column = requires { &C::mark; }; +template +using is_dynamic_t = std::conditional_t, std::true_type, std::false_type>; + template concept is_column = is_persistent_column || is_dynamic_column || is_indexing_column || is_marker_column; @@ -1026,17 +1031,6 @@ concept can_bind = requires(T&& t) { template concept has_index = (is_indexing_column || ...); -template - requires(!is_self_index_column) -consteval auto getBinding() -> typename C::binding_t -{ -} - -template -consteval auto getBinding() -> void -{ -} - template struct TableIterator : IP, C... { public: @@ -1044,9 +1038,9 @@ struct TableIterator : IP, C... { using policy_t = IP; using all_columns = framework::pack; using persistent_columns_t = framework::selected_pack; - using bindings_pack_t = decltype([](framework::pack) { - return framework::pack())...>{}; - }(all_columns{})); + using external_index_columns_t = framework::selected_pack; + using internal_index_columns_t = framework::selected_pack; + using bindings_pack_t = decltype([](framework::pack) -> framework::pack {}(external_index_columns_t{})); // decltype(extractBindings(external_index_columns_t{})); TableIterator(arrow::ChunkedArray* columnData[sizeof...(C)], IP&& policy) : IP{policy}, @@ -1139,13 +1133,7 @@ struct TableIterator : IP, C... { template void doSetCurrentIndex(framework::pack, TA* current) { - (framework::overloaded{ - [¤t, this] - requires(!is_self_index_column) - () { CI::setCurrent(current); }, - []() {}} - .template operator()(), - ...); + (CL::setCurrent(current), ...); } template @@ -1157,40 +1145,24 @@ struct TableIterator : IP, C... { template auto getIndexBindingsImpl(framework::pack) const { - std::vector result; - (framework::overloaded{ - [this, &result] - requires(!is_self_index_column) - () mutable { - result.emplace_back(CI::getCurrentRaw()); - }, - []() {}} - .template operator()(), - ...); - return result; + return std::vector{static_cast(*this).getCurrentRaw()...}; } auto getIndexBindings() const { - return getIndexBindingsImpl(all_columns{}); + return getIndexBindingsImpl(external_index_columns_t{}); } template void bindExternalIndices(TA*... current) { - (doSetCurrentIndex(all_columns{}, current), ...); + (doSetCurrentIndex(external_index_columns_t{}, current), ...); } template void doSetCurrentIndexRaw(framework::pack p, std::vector&& ptrs) { - (framework::overloaded{ - [&ptrs, p, this] - requires(!is_self_index_column) - () { CI::setCurrentRaw(ptrs[framework::has_type_at_v(p)]); }, - []() {}} - .template operator()(), - ...); + (Cs::setCurrentRaw(ptrs[framework::has_type_at_v(p)]), ...); } template @@ -1198,22 +1170,18 @@ struct TableIterator : IP, C... { { o2::soa::Binding b; b.bind(ptr); - (framework::overloaded{ - [&ptr, &b, this]() { CI::setCurrentRaw(b); }, - []() {}} - .template operator()(), - ...); + (Cs::setCurrentRaw(b), ...); } void bindExternalIndicesRaw(std::vector&& ptrs) { - doSetCurrentIndexRaw(all_columns{}, std::forward>(ptrs)); + doSetCurrentIndexRaw(external_index_columns_t{}, std::forward>(ptrs)); } template void bindInternalIndices(I const* table) { - doSetCurrentInternal(all_columns{}, table); + doSetCurrentInternal(internal_index_columns_t{}, table); } private: @@ -1397,37 +1365,25 @@ static constexpr std::string getLabelFromTypeForKey(std::string const& key) template consteval static bool hasIndexTo(framework::pack&&) { - return (framework::overloaded{ - [] - requires(!is_self_index_column) - () { return o2::soa::is_binding_compatible_v(); }, - []() { return false; }} - .template operator()() || - ...); + return (o2::soa::is_binding_compatible_v() || ...); } template consteval static bool hasSortedIndexTo(framework::pack&&) { - return (framework::overloaded{ - [] - requires(!is_self_index_column) - () { return (CI::sorted && o2::soa::is_binding_compatible_v()); }, - []() {}} - .template operator()() || - ...); + return ((C::sorted && o2::soa::is_binding_compatible_v()) || ...); } template consteval static bool relatedByIndex() { - return hasIndexTo(typename Z::table_t::columns_t{}); + return hasIndexTo(typename Z::table_t::external_index_columns_t{}); } template consteval static bool relatedBySortedIndex() { - return hasSortedIndexTo(typename Z::table_t::columns_t{}); + return hasSortedIndexTo(typename Z::table_t::external_index_columns_t{}); } } // namespace o2::soa @@ -1770,13 +1726,16 @@ class Table using persistent_columns_t = decltype([](framework::pack&&) -> framework::selected_pack {}(columns_t{})); using column_types = decltype([](framework::pack) -> framework::pack {}(persistent_columns_t{})); + using external_index_columns_t = decltype([](framework::pack&&) -> framework::selected_pack {}(columns_t{})); + using internal_index_columns_t = decltype([](framework::pack&&) -> framework::selected_pack {}(columns_t{})); template using base_iterator = decltype(base_iter(columns_t{})); template struct TableIteratorBase : base_iterator { using columns_t = typename Parent::columns_t; - using bindings_pack_t = typename base_iterator::bindings_pack_t; + using external_index_columns_t = typename Parent::external_index_columns_t; + using bindings_pack_t = decltype([](framework::pack) -> framework::pack {}(external_index_columns_t{})); // static constexpr const std::array originals{T::ref...}; static constexpr auto originals = Parent::originals; using policy_t = IP; @@ -1869,7 +1828,7 @@ class Table using decayed = std::decay_t; if constexpr (framework::has_type(bindings_pack_t{})) { // index to another table constexpr auto idx = framework::has_type_at_v(bindings_pack_t{}); - return framework::pack_element_t::getId(); + return framework::pack_element_t::getId(); } else if constexpr (std::same_as) { // self index return this->globalIndex(); } else if constexpr (is_indexing_column) { // soa::Index<> @@ -1879,17 +1838,20 @@ class Table } } - template + template auto getDynamicColumn() const { - return static_cast>(*this).template getDynamicValue(); + using decayed = std::decay_t; + static_assert(is_dynamic_t(), "Requested column is not a dynamic column"); + return static_cast(*this).template getDynamicValue(); } template - requires(is_dynamic_column || is_persistent_column) auto getValue() const { - return static_cast(static_cast>(*this).get()); + using COL = std::decay_t; + static_assert(is_dynamic_t() || soa::is_persistent_column, "Should be persistent or dynamic column with no argument that has a return type convertable to float"); + return static_cast(static_cast(*this).get()); } template @@ -2094,17 +2056,13 @@ class Table void bindInternalIndicesExplicit(o2::soa::Binding binding) { - doBindInternalIndicesExplicit(columns_t{}, binding); + doBindInternalIndicesExplicit(internal_index_columns_t{}, binding); } template void doBindInternalIndicesExplicit(framework::pack, o2::soa::Binding binding) { - (framework::overloaded{ - [this, &binding]() { static_cast(mBegin).setCurrentRaw(binding); }, - []() {}} - .template operator()(), - ...); + (static_cast(mBegin).setCurrentRaw(binding), ...); } void bindExternalIndicesRaw(std::vector&& ptrs) @@ -2121,7 +2079,7 @@ class Table template void copyIndexBindings(T& dest) const { - doCopyIndexBindings(columns_t{}, dest); + doCopyIndexBindings(external_index_columns_t{}, dest); } auto select(framework::expressions::Filter const& f) const @@ -3340,6 +3298,7 @@ class FilteredBase : public T using T::originals; using columns_t = typename T::columns_t; using persistent_columns_t = typename T::persistent_columns_t; + using external_index_columns_t = typename T::external_index_columns_t; using iterator = T::template iterator_template_o; using unfiltered_iterator = T::template iterator_template_o; @@ -3485,7 +3444,7 @@ class FilteredBase : public T template void copyIndexBindings(T1& dest) const { - doCopyIndexBindings(columns_t{}, dest); + doCopyIndexBindings(external_index_columns_t{}, dest); } template diff --git a/Framework/Core/include/Framework/Configurable.h b/Framework/Core/include/Framework/Configurable.h index 930c37e700105..88e50cf3c7c26 100644 --- a/Framework/Core/include/Framework/Configurable.h +++ b/Framework/Core/include/Framework/Configurable.h @@ -83,9 +83,6 @@ struct Configurable : IP { template using MutableConfigurable = Configurable>; -template -concept is_configurable = requires(T& t) { &T::operator typename T::type; }; - using ConfigurableAxis = Configurable, ConfigParamKind::kAxisSpec, ConfigurablePolicyConst, ConfigParamKind::kAxisSpec>>; template @@ -100,7 +97,7 @@ struct ProcessConfigurable : Configurable { }; template -concept is_process_configurable = is_configurable && requires(T& t) { t.process; }; +concept is_process_configurable = base_of_template; #define PROCESS_SWITCH(_Class_, _Name_, _Help_, _Default_) \ decltype(ProcessConfigurable{&_Class_ ::_Name_, #_Name_, _Default_, _Help_}) do##_Name_ = ProcessConfigurable{&_Class_ ::_Name_, #_Name_, _Default_, _Help_}; diff --git a/Framework/Core/include/Framework/GroupedCombinations.h b/Framework/Core/include/Framework/GroupedCombinations.h index 9f450489ac50f..21d8384e3aa6e 100644 --- a/Framework/Core/include/Framework/GroupedCombinations.h +++ b/Framework/Core/include/Framework/GroupedCombinations.h @@ -34,30 +34,14 @@ auto interleaveTuples(std::tuple& t1, std::tuple& t2) return interleaveTuplesImpl(t1, t2, std::index_sequence_for()); } -template - requires(!soa::is_self_index_column) -consteval auto isIndexTo() -{ - if constexpr (o2::soa::is_binding_compatible_v()) { - return std::true_type{}; - } else { - return std::false_type{}; - } -} - -template -consteval auto isIndexTo() -{ - return std::false_type{}; -} - template -using is_index_to_g_t = decltype(isIndexTo()); +using is_index_to_g_t = typename std::conditional(), std::true_type, std::false_type>::type; template expressions::BindingNode getMatchingIndexNode() { - using selected_indices_t = selected_pack_multicondition, typename A::columns_t>; + using external_index_columns_pack = typename A::external_index_columns_t; + using selected_indices_t = selected_pack_multicondition, external_index_columns_pack>; static_assert(pack_size(selected_indices_t{}) == 1, "No matching index column from associated to grouping"); using index_column_t = pack_head_t; return expressions::BindingNode{index_column_t::mLabel, o2::framework::TypeIdHelpers::uniqueId(), expressions::selectArrowType()};