@@ -1410,9 +1410,9 @@ static constexpr std::string getLabelFromType()
14101410}
14111411
14121412template <typename ... C>
1413- static constexpr auto hasColumnForKey (framework::pack<C...>, std::string const & key)
1413+ static constexpr auto hasColumnForKey (framework::pack<C...>, std::string_view key)
14141414{
1415- auto caseInsensitiveCompare = [](const std::string_view& str1, const std::string & str2) {
1415+ auto caseInsensitiveCompare = [](const std::string_view& str1, const std::string_view & str2) {
14161416 return std::ranges::equal (
14171417 str1, str2,
14181418 [](char c1, char c2) {
@@ -1424,43 +1424,31 @@ static constexpr auto hasColumnForKey(framework::pack<C...>, std::string const&
14241424}
14251425
14261426template <TableRef ref>
1427- static constexpr std::pair<bool , std::string> hasKey (std::string const & key)
1427+ static constexpr std::pair<bool , std::string> hasKey (std::string_view key)
14281428{
14291429 return {hasColumnForKey (typename aod::MetadataTrait<o2::aod::Hash<ref.desc_hash >>::metadata::columns{}, key), aod::label<ref>()};
14301430}
14311431
14321432template <TableRef ref>
1433- static constexpr std::pair<bool , framework::ConcreteDataMatcher> hasKeyM (std::string const & key)
1433+ static constexpr std::pair<bool , framework::ConcreteDataMatcher> hasKeyM (std::string_view key)
14341434{
14351435 return {hasColumnForKey (typename aod::MetadataTrait<o2::aod::Hash<ref.desc_hash >>::metadata::columns{}, key), aod::matcher<ref>()};
14361436}
14371437
1438- template <typename ... C>
1439- static constexpr auto haveKey (framework::pack<C...>, std::string const & key)
1440- {
1441- return std::vector{hasKey<C>(key)...};
1442- }
1443-
14441438void notFoundColumn (const char * label, const char * key);
14451439void missingOptionalPreslice (const char * label, const char * key);
14461440
14471441template <with_originals T, bool OPT = false >
1448- static constexpr std::string getLabelFromTypeForKey (std::string const & key)
1442+ static constexpr std::string getLabelFromTypeForKey (std::string_view key)
14491443{
1450- if constexpr (T::originals.size () == 1 ) {
1451- auto locate = hasKey<T::originals[0 ]>(key);
1452- if (locate.first ) {
1453- return locate.second ;
1454- }
1455- } else {
1456- auto locate = [&]<size_t ... Is>(std::index_sequence<Is...>) {
1457- return std::vector{hasKey<T::originals[Is]>(key)...};
1458- }(std::make_index_sequence<T::originals.size ()>{});
1459- auto it = std::find_if (locate.begin (), locate.end (), [](auto const & x) { return x.first ; });
1460- if (it != locate.end ()) {
1461- return it->second ;
1462- }
1444+ auto locate = []<size_t ... Is>(std::index_sequence<Is...>, std::string_view key) {
1445+ return std::array{hasKey<T::originals[Is]>(key)...} |
1446+ std::views::filter ([](auto const & x) { return x.first ; });
1447+ }(std::make_index_sequence<T::originals.size ()>{}, key);
1448+ if (!locate.empty ()) {
1449+ return locate.front ().second ;
14631450 }
1451+
14641452 if constexpr (!OPT) {
14651453 notFoundColumn (getLabelFromType<std::decay_t <T>>().data (), key.data ());
14661454 } else {
@@ -1470,22 +1458,16 @@ static constexpr std::string getLabelFromTypeForKey(std::string const& key)
14701458}
14711459
14721460template <with_originals T, bool OPT = false >
1473- static constexpr framework::ConcreteDataMatcher getMatcherFromTypeForKey (std::string const & key)
1461+ static constexpr framework::ConcreteDataMatcher getMatcherFromTypeForKey (std::string_view key)
14741462{
1475- if constexpr (T::originals.size () == 1 ) {
1476- auto locate = hasKeyM<T::originals[0 ]>(key);
1477- if (locate.first ) {
1478- return locate.second ;
1479- }
1480- } else {
1481- auto locate = [&]<size_t ... Is>(std::index_sequence<Is...>) {
1482- return std::vector{hasKeyM<T::originals[Is]>(key)...};
1483- }(std::make_index_sequence<T::originals.size ()>{});
1484- auto it = std::find_if (locate.begin (), locate.end (), [](auto const & x) { return x.first ; });
1485- if (it != locate.end ()) {
1486- return it->second ;
1487- }
1463+ auto locate = []<size_t ... Is>(std::index_sequence<Is...>, std::string_view key) {
1464+ return std::array{hasKeyM<T::originals[Is]>(key)...} |
1465+ std::views::filter ([](auto const & x) { return x.first ; });
1466+ }(std::make_index_sequence<T::originals.size ()>{}, key);
1467+ if (!locate.empty ()) {
1468+ return locate.front ().second ;
14881469 }
1470+
14891471 if constexpr (!OPT) {
14901472 notFoundColumn (getLabelFromType<std::decay_t <T>>().data (), key.data ());
14911473 } else {
@@ -1521,7 +1503,7 @@ consteval static bool relatedBySortedIndex()
15211503
15221504namespace o2 ::framework
15231505{
1524-
1506+ // / tracks origin in bindingKey matcher to handle the correct arguments
15251507struct PreslicePolicyBase {
15261508 const std::string binding;
15271509 Entry bindingKey;
@@ -1547,7 +1529,7 @@ struct PreslicePolicyGeneral : public PreslicePolicyBase {
15471529template <typename T>
15481530concept is_preslice_policy = std::derived_from<T, PreslicePolicyBase>;
15491531
1550- template <typename T, is_preslice_policy Policy, bool OPT = false >
1532+ template <soa::is_table T, is_preslice_policy Policy, bool OPT = false >
15511533struct PresliceBase : public Policy {
15521534 constexpr static bool optional = OPT;
15531535 using target_t = T;
@@ -1580,13 +1562,13 @@ struct PresliceBase : public Policy {
15801562 }
15811563};
15821564
1583- template <typename T>
1565+ template <soa::is_table T>
15841566using PresliceUnsorted = PresliceBase<T, PreslicePolicyGeneral, false >;
1585- template <typename T>
1567+ template <soa::is_table T>
15861568using PresliceUnsortedOptional = PresliceBase<T, PreslicePolicyGeneral, true >;
1587- template <typename T>
1569+ template <soa::is_table T>
15881570using Preslice = PresliceBase<T, PreslicePolicySorted, false >;
1589- template <typename T>
1571+ template <soa::is_table T>
15901572using PresliceOptional = PresliceBase<T, PreslicePolicySorted, true >;
15911573
15921574template <typename T>
@@ -1741,10 +1723,13 @@ auto doFilteredSliceBy(T const* table, o2::framework::PresliceBase<C, framework:
17411723 return prepareFilteredSlice (table, slice, offset);
17421724}
17431725
1726+ std::function<framework::ConcreteDataMatcher(framework::ConcreteDataMatcher&&)> originReplacement (header::DataOrigin newOrigin);
1727+
17441728template <soa::is_table T>
17451729auto doSliceByCached (T const * table, framework::expressions::BindingNode const & node, int value, o2::framework::SliceCache& cache)
17461730{
1747- auto localCache = cache.ptr ->getCacheFor ({" " , o2::soa::getMatcherFromTypeForKey<T>(node.name ), node.name });
1731+ auto localCache = cache.ptr ->getCacheFor ({" " , originReplacement (cache.ptr ->newOrigin )(o2::soa::getMatcherFromTypeForKey<T>(node.name )),
1732+ node.name });
17481733 auto [offset, count] = localCache.getSliceFor (value);
17491734 auto t = typename T::self_t ({table->asArrowTable ()->Slice (static_cast <uint64_t >(offset), count)}, static_cast <uint64_t >(offset));
17501735 if (t.tableSize () != 0 ) {
@@ -1756,7 +1741,8 @@ auto doSliceByCached(T const* table, framework::expressions::BindingNode const&
17561741template <soa::is_filtered_table T>
17571742auto doFilteredSliceByCached (T const * table, framework::expressions::BindingNode const & node, int value, o2::framework::SliceCache& cache)
17581743{
1759- auto localCache = cache.ptr ->getCacheFor ({" " , o2::soa::getMatcherFromTypeForKey<T>(node.name ), node.name });
1744+ auto localCache = cache.ptr ->getCacheFor ({" " , originReplacement (cache.ptr ->newOrigin )(o2::soa::getMatcherFromTypeForKey<T>(node.name )),
1745+ node.name });
17601746 auto [offset, count] = localCache.getSliceFor (value);
17611747 auto slice = table->asArrowTable ()->Slice (static_cast <uint64_t >(offset), count);
17621748 return prepareFilteredSlice (table, slice, offset);
@@ -1765,7 +1751,8 @@ auto doFilteredSliceByCached(T const* table, framework::expressions::BindingNode
17651751template <soa::is_table T>
17661752auto doSliceByCachedUnsorted (T const * table, framework::expressions::BindingNode const & node, int value, o2::framework::SliceCache& cache)
17671753{
1768- auto localCache = cache.ptr ->getCacheUnsortedFor ({" " , o2::soa::getMatcherFromTypeForKey<T>(node.name ), node.name });
1754+ auto localCache = cache.ptr ->getCacheUnsortedFor ({" " , originReplacement (cache.ptr ->newOrigin )(o2::soa::getMatcherFromTypeForKey<T>(node.name )),
1755+ node.name });
17691756 if constexpr (soa::is_filtered_table<T>) {
17701757 auto t = typename T::self_t ({table->asArrowTable ()}, localCache.getSliceFor (value));
17711758 if (t.tableSize () != 0 ) {
@@ -1837,12 +1824,6 @@ consteval auto computeOriginals()
18371824 return o2::soa::mergeOriginals<Ts...>();
18381825}
18391826
1840- // template <size_t N, std::array<TableRef, N> refs>
1841- // consteval auto commonOrigin()
1842- // {
1843- // return (refs | std::ranges::views::filter([](TableRef const& r) { return (!(r.origin_hash == "DYN"_h || r.origin_hash == "IDX"_h)); })).front().origin_hash;
1844- // }
1845-
18461827// / A Table class which observes an arrow::Table and provides
18471828// / It is templated on a set of Column / DynamicColumn types.
18481829template <aod::is_aod_hash L, aod::is_aod_hash D, aod::is_origin_hash O, typename ... Ts>
@@ -4285,7 +4266,7 @@ using SmallGroupsUnfiltered = SmallGroupsBase<T, false>;
42854266
42864267template <typename T>
42874268concept is_smallgroups = requires {
4288- []<typename B, bool A>(SmallGroupsBase<B, A>*) {}(std::declval<T *>());
4269+ []<typename B, bool A>(SmallGroupsBase<B, A>*) {}(std::declval<std:: decay_t <T> *>());
42894270};
42904271} // namespace o2::soa
42914272
0 commit comments