@@ -379,7 +379,7 @@ consteval const char* signature()
379379template <soa::TableRef R>
380380constexpr framework::ConcreteDataMatcher matcher ()
381381{
382- return {origin<R>(), header::DataDescription{ description_str (signature<R>())} , R.version };
382+ return {origin<R>(), description (signature<R>()), R.version };
383383}
384384
385385// / hash identification concepts
@@ -1400,6 +1400,12 @@ static constexpr std::pair<bool, std::string> hasKey(std::string const& key)
14001400 return {hasColumnForKey (typename aod::MetadataTrait<o2::aod::Hash<ref.desc_hash >>::metadata::columns{}, key), aod::label<ref>()};
14011401}
14021402
1403+ template <TableRef ref>
1404+ static constexpr std::pair<bool , framework::ConcreteDataMatcher> hasKeyM (std::string const & key)
1405+ {
1406+ return {hasColumnForKey (typename aod::MetadataTrait<o2::aod::Hash<ref.desc_hash >>::metadata::columns{}, key), aod::matcher<ref>()};
1407+ }
1408+
14031409template <typename ... C>
14041410static constexpr auto haveKey (framework::pack<C...>, std::string const & key)
14051411{
@@ -1434,6 +1440,31 @@ static constexpr std::string getLabelFromTypeForKey(std::string const& key)
14341440 O2_BUILTIN_UNREACHABLE ();
14351441}
14361442
1443+ template <with_originals T, bool OPT = false >
1444+ static constexpr framework::ConcreteDataMatcher getMatcherFromTypeForKey (std::string const & key)
1445+ {
1446+ if constexpr (T::originals.size () == 1 ) {
1447+ auto locate = hasKeyM<T::originals[0 ]>(key);
1448+ if (locate.first ) {
1449+ return locate.second ;
1450+ }
1451+ } else {
1452+ auto locate = [&]<size_t ... Is>(std::index_sequence<Is...>) {
1453+ return std::vector{hasKeyM<T::originals[Is]>(key)...};
1454+ }(std::make_index_sequence<T::originals.size ()>{});
1455+ auto it = std::find_if (locate.begin (), locate.end (), [](auto const & x) { return x.first ; });
1456+ if (it != locate.end ()) {
1457+ return it->second ;
1458+ }
1459+ }
1460+ if constexpr (!OPT) {
1461+ notFoundColumn (getLabelFromType<std::decay_t <T>>().data (), key.data ());
1462+ } else {
1463+ return framework::ConcreteDataMatcher{header::DataOrigin{" AOD" }, header::DataDescription{" [MISSING]" }, 0 };
1464+ }
1465+ O2_BUILTIN_UNREACHABLE ();
1466+ }
1467+
14371468template <typename B, typename ... C>
14381469consteval static bool hasIndexTo (framework::pack<C...>&&)
14391470{
@@ -1484,15 +1515,18 @@ struct PreslicePolicyGeneral : public PreslicePolicyBase {
14841515 std::span<const int64_t > getSliceFor (int value) const ;
14851516};
14861517
1487- template <typename T, typename Policy, bool OPT = false >
1518+ template <typename T>
1519+ concept is_preslice_policy = std::derived_from<T, PreslicePolicyBase>;
1520+
1521+ template <typename T, is_preslice_policy Policy, bool OPT = false >
14881522struct PresliceBase : public Policy {
14891523 constexpr static bool optional = OPT;
14901524 using target_t = T;
14911525 using policy_t = Policy;
14921526 const std::string binding;
14931527
14941528 PresliceBase (expressions::BindingNode index_)
1495- : Policy{PreslicePolicyBase{{o2::soa::getLabelFromTypeForKey<T, OPT>(std::string{index_.name })}, Entry (o2::soa::getLabelFromTypeForKey<T, OPT>(std::string{index_.name }), std::string{index_.name })}, {}}
1529+ : Policy{PreslicePolicyBase{{o2::soa::getLabelFromTypeForKey<T, OPT>(std::string{index_.name })}, Entry (o2::soa::getLabelFromTypeForKey<T, OPT>(std::string{index_.name }), o2::soa::getMatcherFromTypeForKey<T, OPT>(std::string{index_. name }), std::string{index_.name })}, {}}
14961530 {
14971531 }
14981532
@@ -1527,7 +1561,7 @@ template <typename T>
15271561using PresliceOptional = PresliceBase<T, PreslicePolicySorted, true >;
15281562
15291563template <typename T>
1530- concept is_preslice = std::derived_from<T, PreslicePolicyBase>;
1564+ concept is_preslice = std::derived_from<T, PreslicePolicyBase> && requires (T) { T::optional; } ;
15311565
15321566// / Can be user to group together a number of Preslice declaration
15331567// / to avoid the limit of 100 data members per task
@@ -1674,10 +1708,10 @@ auto doFilteredSliceBy(T const* table, o2::framework::PresliceBase<C, framework:
16741708 return prepareFilteredSlice (table, slice, offset);
16751709}
16761710
1677- template <typename T>
1711+ template <soa::is_table T>
16781712auto doSliceByCached (T const * table, framework::expressions::BindingNode const & node, int value, o2::framework::SliceCache& cache)
16791713{
1680- auto localCache = cache.ptr ->getCacheFor ({o2::soa::getLabelFromTypeForKey <T>(node.name ), node.name });
1714+ auto localCache = cache.ptr ->getCacheFor ({" " , o2::soa::getMatcherFromTypeForKey <T>(node.name ), node.name });
16811715 auto [offset, count] = localCache.getSliceFor (value);
16821716 auto t = typename T::self_t ({table->asArrowTable ()->Slice (static_cast <uint64_t >(offset), count)}, static_cast <uint64_t >(offset));
16831717 if (t.tableSize () != 0 ) {
@@ -1686,19 +1720,19 @@ auto doSliceByCached(T const* table, framework::expressions::BindingNode const&
16861720 return t;
16871721}
16881722
1689- template <typename T>
1723+ template <soa::is_filtered_table T>
16901724auto doFilteredSliceByCached (T const * table, framework::expressions::BindingNode const & node, int value, o2::framework::SliceCache& cache)
16911725{
1692- auto localCache = cache.ptr ->getCacheFor ({o2::soa::getLabelFromTypeForKey <T>(node.name ), node.name });
1726+ auto localCache = cache.ptr ->getCacheFor ({" " , o2::soa::getMatcherFromTypeForKey <T>(node.name ), node.name });
16931727 auto [offset, count] = localCache.getSliceFor (value);
16941728 auto slice = table->asArrowTable ()->Slice (static_cast <uint64_t >(offset), count);
16951729 return prepareFilteredSlice (table, slice, offset);
16961730}
16971731
1698- template <typename T>
1732+ template <soa::is_table T>
16991733auto doSliceByCachedUnsorted (T const * table, framework::expressions::BindingNode const & node, int value, o2::framework::SliceCache& cache)
17001734{
1701- auto localCache = cache.ptr ->getCacheUnsortedFor ({o2::soa::getLabelFromTypeForKey <T>(node.name ), node.name });
1735+ auto localCache = cache.ptr ->getCacheUnsortedFor ({" " , o2::soa::getMatcherFromTypeForKey <T>(node.name ), node.name });
17021736 if constexpr (soa::is_filtered_table<T>) {
17031737 auto t = typename T::self_t ({table->asArrowTable ()}, localCache.getSliceFor (value));
17041738 if (t.tableSize () != 0 ) {
0 commit comments