Skip to content

Commit 8deafae

Browse files
committed
avoid overloaded{}; fix index binding ignored in certain cases
1 parent 3d2a186 commit 8deafae

File tree

2 files changed

+135
-64
lines changed

2 files changed

+135
-64
lines changed

Framework/Core/include/Framework/ASoA.h

Lines changed: 123 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,13 +1144,7 @@ struct TableIterator : IP, C... {
11441144
template <typename... CL, typename TA>
11451145
void doSetCurrentIndex(framework::pack<CL...>, TA* current)
11461146
{
1147-
(framework::overloaded{
1148-
[&current, this]<is_index_column CI>
1149-
requires(!is_self_index_column<CI>)
1150-
() { CI::setCurrent(current); },
1151-
[]<typename CI>() {}}
1152-
.template operator()<CL>(),
1153-
...);
1147+
(doSetCurrentIndexImpl<CL>(current), ...);
11541148
}
11551149

11561150
template <typename CL>
@@ -1163,15 +1157,7 @@ struct TableIterator : IP, C... {
11631157
auto getIndexBindingsImpl(framework::pack<Cs...>) const
11641158
{
11651159
std::vector<o2::soa::Binding> result;
1166-
(framework::overloaded{
1167-
[this, &result]<is_index_column CI>
1168-
requires(!is_self_index_column<CI>)
1169-
() mutable {
1170-
result.emplace_back(CI::getCurrentRaw());
1171-
},
1172-
[]<typename CI>() {}}
1173-
.template operator()<Cs>(),
1174-
...);
1160+
(doGetIndexBindingImpl<Cs>(result), ...);
11751161
return result;
11761162
}
11771163

@@ -1187,32 +1173,22 @@ struct TableIterator : IP, C... {
11871173
}
11881174

11891175
template <typename... Cs>
1190-
void doSetCurrentIndexRaw(framework::pack<Cs...> p, std::vector<o2::soa::Binding>&& ptrs)
1176+
void doSetCurrentIndexRaw(framework::pack<Cs...> p, std::vector<o2::soa::Binding>&& bindings)
11911177
{
1192-
(framework::overloaded{
1193-
[&ptrs, p, this]<is_self_index_column CI>
1194-
requires(!is_self_index_column<CI>)
1195-
() { CI::setCurrentRaw(ptrs[framework::has_type_at_v<CI>(p)]); },
1196-
[]<typename CI>() {}}
1197-
.template operator()<Cs>(),
1198-
...);
1178+
(doSetCurrentIndexRawImpl<Cs>(bindings[framework::has_type_at_v<Cs>(p)]), ...);
11991179
}
12001180

12011181
template <typename... Cs, typename I>
12021182
void doSetCurrentInternal(framework::pack<Cs...>, I const* ptr)
12031183
{
12041184
o2::soa::Binding b;
12051185
b.bind(ptr);
1206-
(framework::overloaded{
1207-
[&ptr, &b, this]<is_self_index_column CI>() { CI::setCurrentRaw(b); },
1208-
[]<typename CI>() {}}
1209-
.template operator()<Cs>(),
1210-
...);
1186+
(doSetCurrentInternalImpl<Cs>(b), ...);
12111187
}
12121188

1213-
void bindExternalIndicesRaw(std::vector<o2::soa::Binding>&& ptrs)
1189+
void bindExternalIndicesRaw(std::vector<o2::soa::Binding>&& bindings)
12141190
{
1215-
doSetCurrentIndexRaw(all_columns{}, std::forward<std::vector<o2::soa::Binding>>(ptrs));
1191+
doSetCurrentIndexRaw(all_columns{}, std::forward<std::vector<o2::soa::Binding>>(bindings));
12161192
}
12171193

12181194
template <typename I>
@@ -1222,6 +1198,78 @@ struct TableIterator : IP, C... {
12221198
}
12231199

12241200
private:
1201+
/// Overloaded helpers for index manipulations
1202+
template <soa::is_index_column CL, typename TA>
1203+
requires(!soa::is_self_index_column<CL>)
1204+
void doSetCurrentIndexImpl(TA* current)
1205+
{
1206+
CL::setCurrent(current);
1207+
}
1208+
1209+
template <soa::is_column CL, typename TA>
1210+
requires(!soa::is_index_column<CL>)
1211+
void doSetCurrentIndexImpl(TA*)
1212+
{
1213+
}
1214+
1215+
template <soa::is_index_column CL>
1216+
requires(!soa::is_self_index_column<CL>)
1217+
auto doGetIndexBindingImpl(std::vector<o2::soa::Binding>& bindings) const
1218+
{
1219+
bindings.emplace_back(CL::getCurrentRaw());
1220+
}
1221+
1222+
template <soa::is_column CL>
1223+
requires(!soa::is_index_column<CL>)
1224+
auto doGetIndexBindingImpl(std::vector<o2::soa::Binding>& bindings) const
1225+
{
1226+
bindings.emplace_back();
1227+
}
1228+
1229+
template <soa::is_index_column CL>
1230+
requires(!soa::is_self_index_column<CL>)
1231+
void doSetCurrentIndexRawImpl(o2::soa::Binding const& b)
1232+
{
1233+
CL::setCurrentRaw(b);
1234+
}
1235+
1236+
template <soa::is_column CL>
1237+
requires(!soa::is_index_column<CL>)
1238+
void doSetCurrentIndexRawImpl(o2::soa::Binding const&)
1239+
{
1240+
}
1241+
1242+
template <soa::is_self_index_column CL>
1243+
void doSetCurrentInternalImpl(o2::soa::Binding const& b)
1244+
{
1245+
CL::setCurrentRaw(b);
1246+
}
1247+
1248+
template <soa::is_column CL>
1249+
requires(!soa::is_self_index_column<CL>)
1250+
void doSetCurrentInternalImpl(o2::soa::Binding const&)
1251+
{
1252+
}
1253+
1254+
///Overloaded helpers for column binding
1255+
template <soa::is_persistent_column CL>
1256+
void doBind()
1257+
{
1258+
CL::mColumnIterator.mCurrentPos = &this->mRowIndex;
1259+
}
1260+
1261+
template <soa::is_dynamic_column CL>
1262+
void doBind()
1263+
{
1264+
bindDynamicColumn<CL>(typename CL::bindings_t{});
1265+
}
1266+
1267+
template <soa::is_column CL>
1268+
requires(!soa::is_persistent_column<CL> && !soa::is_dynamic_column<CL>)
1269+
void doBind()
1270+
{
1271+
}
1272+
12251273
/// Helper to move at the end of columns which actually have an iterator.
12261274
template <typename... PC>
12271275
void doMoveToEnd(framework::pack<PC...>)
@@ -1234,12 +1282,7 @@ struct TableIterator : IP, C... {
12341282
void bind()
12351283
{
12361284
using namespace o2::soa;
1237-
auto f = framework::overloaded{
1238-
[this]<soa::is_persistent_column T>(T*) -> void { T::mColumnIterator.mCurrentPos = &this->mRowIndex; },
1239-
[this]<soa::is_dynamic_column T>(T*) -> void { bindDynamicColumn<T>(typename T::bindings_t{}); },
1240-
[this]<typename T>(T*) -> void {},
1241-
};
1242-
(f(static_cast<C*>(nullptr)), ...);
1285+
(doBind<C>(), ...);
12431286
if constexpr (has_index<C...>) {
12441287
this->setIndices(this->getIndices());
12451288
this->setOffsets(this->getOffsets());
@@ -1399,28 +1442,44 @@ static constexpr std::string getLabelFromTypeForKey(std::string const& key)
13991442
O2_BUILTIN_UNREACHABLE();
14001443
}
14011444

1445+
template <soa::is_index_column CL, typename B>
1446+
requires(!soa::is_self_index_column<CL>)
1447+
consteval static bool hasIndexToImpl()
1448+
{
1449+
return o2::soa::is_binding_compatible_v<B, typename CL::binding_t>();
1450+
}
1451+
1452+
template <soa::is_column CL, typename B>
1453+
requires(!soa::is_index_column<CL>)
1454+
consteval static bool hasIndexToImpl()
1455+
{
1456+
return false;
1457+
}
1458+
14021459
template <typename B, typename... C>
14031460
consteval static bool hasIndexTo(framework::pack<C...>&&)
14041461
{
1405-
return (framework::overloaded{
1406-
[]<is_index_column CI>
1407-
requires(!is_self_index_column<CI>)
1408-
() { return o2::soa::is_binding_compatible_v<B, typename CI::binding_t>(); },
1409-
[]<typename CI>() { return false; }}
1410-
.template operator()<C>() ||
1411-
...);
1462+
return (hasIndexToImpl<C, B>() || ...);
1463+
}
1464+
1465+
template <soa::is_index_column CL, typename B>
1466+
requires(!soa::is_self_index_column<CL>)
1467+
consteval static bool hasSortedIndexToImpl()
1468+
{
1469+
return CL::sorted && o2::soa::is_binding_compatible_v<B, typename CL::binding_t>();
1470+
}
1471+
1472+
template <soa::is_column CL, typename B>
1473+
requires(!soa::is_index_column<CL>)
1474+
consteval static bool hasSortedIndexToImpl()
1475+
{
1476+
return false;
14121477
}
14131478

14141479
template <typename B, typename... C>
14151480
consteval static bool hasSortedIndexTo(framework::pack<C...>&&)
14161481
{
1417-
return (framework::overloaded{
1418-
[]<is_index_column CI>
1419-
requires(!is_self_index_column<CI>)
1420-
() { return (CI::sorted && o2::soa::is_binding_compatible_v<B, typename CI::binding_t>()); },
1421-
[]<typename CI>() {}}
1422-
.template operator()<C>() ||
1423-
...);
1482+
return (hasSortedIndexToImpl<C, B>() || ...);
14241483
}
14251484

14261485
template <typename B, typename Z>
@@ -2087,14 +2146,22 @@ class Table
20872146
doBindInternalIndicesExplicit(columns_t{}, binding);
20882147
}
20892148

2149+
template <soa::is_self_index_column CL>
2150+
void doBindInternalIndicesExplicitImpl(o2::soa::Binding binding)
2151+
{
2152+
static_cast<CL>(mBegin).setCurrentRaw(binding);
2153+
}
2154+
2155+
template <soa::is_column CL>
2156+
requires(!soa::is_self_index_column<CL>)
2157+
void doBindInternalIndicesExplicitImpl(o2::soa::Binding)
2158+
{
2159+
}
2160+
20902161
template <typename... Cs>
20912162
void doBindInternalIndicesExplicit(framework::pack<Cs...>, o2::soa::Binding binding)
20922163
{
2093-
(framework::overloaded{
2094-
[this, &binding]<is_self_index_column CI>() { static_cast<CI>(mBegin).setCurrentRaw(binding); },
2095-
[]<typename CI>() {}}
2096-
.template operator()<Cs>(),
2097-
...);
2164+
(doBindInternalIndicesExplicitImpl<Cs>(binding), ...);
20982165
}
20992166

21002167
void bindExternalIndicesRaw(std::vector<o2::soa::Binding>&& ptrs)

Framework/Core/include/Framework/GroupedCombinations.h

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,22 @@ auto interleaveTuples(std::tuple<T1s...>& t1, std::tuple<T2s...>& t2)
3434
return interleaveTuplesImpl(t1, t2, std::index_sequence_for<T1s...>());
3535
}
3636

37-
template <soa::is_index_column T, typename G>
38-
requires(!soa::is_self_index_column<T>)
37+
template <soa::is_index_column T, soa::is_table G>
38+
requires(!soa::is_self_index_column<T> && o2::soa::is_binding_compatible_v<std::decay_t<G>, typename std::decay_t<T>::binding_t>())
3939
consteval auto isIndexTo()
4040
{
41-
if constexpr (o2::soa::is_binding_compatible_v<G, typename T::binding_t>()) {
42-
return std::true_type{};
43-
} else {
44-
return std::false_type{};
45-
}
41+
return std::true_type{};
4642
}
4743

48-
template <typename T, typename G>
44+
template <soa::is_index_column T, soa::is_table G>
45+
requires(!soa::is_self_index_column<T> && !o2::soa::is_binding_compatible_v<std::decay_t<G>, typename std::decay_t<T>::binding_t>())
46+
consteval auto isIndexTo()
47+
{
48+
return std::false_type{};
49+
}
50+
51+
template <soa::is_column T, soa::is_table G>
52+
requires(!soa::is_index_column<T>)
4953
consteval auto isIndexTo()
5054
{
5155
return std::false_type{};

0 commit comments

Comments
 (0)