diff --git a/Framework/Core/include/Framework/ASoA.h b/Framework/Core/include/Framework/ASoA.h index 57b00a06003ad..95a3967d72a70 100644 --- a/Framework/Core/include/Framework/ASoA.h +++ b/Framework/Core/include/Framework/ASoA.h @@ -68,12 +68,6 @@ struct Binding { void accessingInvalidIndexFor(const char* getter); void dereferenceWithWrongType(); -template -auto createFieldsFromColumns(framework::pack) -{ - return std::vector>{C::asArrowField()...}; -} - using SelectionVector = std::vector; template @@ -574,6 +568,19 @@ struct is_index, Ref> : std::true_type { template using is_index_t = is_index; +template +auto createFieldsFromColumns(framework::pack) +{ + std::vector> result; + ([&]() { + if constexpr (soa::is_persistent_v) { + result.push_back(C::asArrowField()); + } + }(), + ...); + return result; +} + struct IndexPolicyBase { /// Position inside the current table int64_t mRowIndex = 0; @@ -775,6 +782,30 @@ struct FilteredIndexPolicy : IndexPolicyBase { template class Table; +template +constexpr auto select_persistent(framework::pack) +{ + return framework::selected_pack{}; +} + +template +constexpr auto select_external_index(framework::pack) +{ + return framework::selected_pack{}; +} + +template +constexpr auto select_internal_index(framework::pack) +{ + return framework::selected_pack{}; +} + +template +constexpr auto select_dynamic(framework::pack) +{ + return framework::selected_pack{}; +} + /// Similar to a pair but not a pair, to avoid /// exposing the second type everywhere. template @@ -789,7 +820,6 @@ struct RowViewCore : public IP, C... { using policy_t = IP; using table_t = o2::soa::Table; using all_columns = framework::pack; - using persistent_columns_t = framework::selected_pack; using dynamic_columns_t = framework::selected_pack; using index_columns_t = framework::selected_pack; constexpr inline static bool has_index_v = framework::pack_size(index_columns_t{}) > 0; @@ -800,7 +830,7 @@ struct RowViewCore : public IP, C... { : IP{policy}, C(columnData[framework::has_type_at_v(all_columns{})])... { - bindIterators(persistent_columns_t{}); + bindIterators(all_columns{}); bindAllDynamicColumns(dynamic_columns_t{}); // In case we have an index column might need to constrain the actual // number of rows in the view to the range provided by the index. @@ -816,7 +846,7 @@ struct RowViewCore : public IP, C... { : IP{static_cast(other)}, C(static_cast(other))... { - bindIterators(persistent_columns_t{}); + bindIterators(all_columns{}); bindAllDynamicColumns(dynamic_columns_t{}); } @@ -824,7 +854,7 @@ struct RowViewCore : public IP, C... { { IP::operator=(static_cast(other)); (void(static_cast(*this) = static_cast(other)), ...); - bindIterators(persistent_columns_t{}); + bindIterators(all_columns{}); bindAllDynamicColumns(dynamic_columns_t{}); } @@ -832,7 +862,7 @@ struct RowViewCore : public IP, C... { { IP::operator=(static_cast(other)); (void(static_cast(*this) = static_cast(other)), ...); - bindIterators(persistent_columns_t{}); + bindIterators(all_columns{}); bindAllDynamicColumns(dynamic_columns_t{}); return *this; } @@ -972,7 +1002,12 @@ struct RowViewCore : public IP, C... { auto bindIterators(framework::pack) { using namespace o2::soa; - (void(PC::mColumnIterator.mCurrentPos = &this->mRowIndex), ...); + ([&]() { + if constexpr (soa::is_persistent_v) { + PC::mColumnIterator.mCurrentPos = &this->mRowIndex; + } + }(), + ...); } template @@ -1069,7 +1104,7 @@ static auto hasColumnForKey(framework::pack, std::string const& key) template static std::pair hasKey(std::string const& key) { - return {hasColumnForKey(typename T::persistent_columns_t{}, key), getLabelFromType()}; + return {hasColumnForKey(typename T::columns{}, key), getLabelFromType()}; } template @@ -1369,6 +1404,9 @@ auto select(T const& t, framework::expressions::Filter const& f) arrow::ChunkedArray* getIndexFromLabel(arrow::Table* table, const char* label); +template +using select_persistent_t = decltype(select_persistent(framework::pack{})); + /// A Table class which observes an arrow::Table and provides /// It is templated on a set of Column / DynamicColumn types. template @@ -1379,7 +1417,6 @@ class Table using table_t = Table; using columns = framework::pack; using column_types = 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; @@ -1538,7 +1575,7 @@ class Table { if constexpr (framework::has_type_conditional_v) { using IC = framework::pack_element_t(external_index_columns_t{}), external_index_columns_t>; - return mColumnChunks[framework::has_type_at(persistent_columns_t{})]; + return mColumnChunks[framework::has_type_at(select_persistent(columns{}))]; } else if constexpr (std::is_same_v) { return nullptr; } else { @@ -2691,7 +2728,6 @@ struct Join : JoinBase { using self_t = Join; using table_t = base; - using persistent_columns_t = typename table_t::persistent_columns_t; using iterator = typename table_t::template RowView, Ts...>; using const_iterator = iterator; using unfiltered_iterator = iterator; @@ -2801,7 +2837,6 @@ struct Concat : ConcatBase { using left_t = T1; using right_t = T2; using table_t = ConcatBase; - using persistent_columns_t = typename table_t::persistent_columns_t; using iterator = typename table_t::template RowView, T1, T2>; using filtered_iterator = typename table_t::template RowViewFiltered, T1, T2>; @@ -2826,7 +2861,6 @@ class FilteredBase : public T using self_t = FilteredBase; using originals = originals_pack_t; using table_t = typename T::table_t; - using persistent_columns_t = typename T::persistent_columns_t; using external_index_columns_t = typename T::external_index_columns_t; template diff --git a/Framework/Core/include/Framework/ASoAHelpers.h b/Framework/Core/include/Framework/ASoAHelpers.h index 932f4fd029298..871dc25dad5c8 100644 --- a/Framework/Core/include/Framework/ASoAHelpers.h +++ b/Framework/Core/include/Framework/ASoAHelpers.h @@ -92,7 +92,7 @@ std::vector groupTable(const T& table, const BP& binningPol selectedRows = table.getSelectedRows(); // vector } - auto persistentColumns = typename BP::persistent_columns_t{}; + auto persistentColumns = o2::soa::select_persistent(framework::pack{}); constexpr auto persistentColumnsCount = pack_size(persistentColumns); auto arrowColumns = o2::soa::row_helpers::getArrowColumns(arrowTable, persistentColumns); auto chunksCount = arrowColumns[0]->num_chunks(); diff --git a/Framework/Core/include/Framework/AnalysisHelpers.h b/Framework/Core/include/Framework/AnalysisHelpers.h index bcea0a1bb7d65..455d7d302b5f3 100644 --- a/Framework/Core/include/Framework/AnalysisHelpers.h +++ b/Framework/Core/include/Framework/AnalysisHelpers.h @@ -124,11 +124,11 @@ struct OutputForTable { /// means of the WritingCursor helper class, from which produces actually /// derives. template -struct Produces : WritingCursor::table> { +struct Produces : WritingCursor::table> { }; template