Skip to content

Commit 228d229

Browse files
authored
DPL Analysis: bring exclusive index builder closer to the sparse one (#7296)
1 parent f765494 commit 228d229

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

Framework/Core/include/Framework/AnalysisHelpers.h

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include "Framework/StringHelpers.h"
2222
#include "Framework/Output.h"
2323
#include <string>
24-
#include "Framework/Logger.h"
2524

2625
namespace o2::framework
2726
{
@@ -229,27 +228,35 @@ struct IndexExclusive {
229228

230229
using rest_it_t = decltype(pack_from_tuple(iterators));
231230

232-
int32_t idx = -1;
233-
auto setValue = [&](auto& x) -> bool {
231+
auto setValue = [&](auto& x, int idx) -> bool {
234232
using type = std::decay_t<decltype(x)>;
235233
constexpr auto position = framework::has_type_at_v<type>(rest_it_t{});
236234

237-
lowerBound<Key>(idx, x);
238-
if (x == soa::RowViewSentinel{static_cast<uint64_t>(x.mMaxRow)}) {
239-
return false;
240-
} else if (x.template getId<Key>() != idx) {
241-
return false;
242-
} else {
243-
values[position] = x.globalIndex();
244-
++x;
235+
if constexpr (std::is_same_v<framework::pack_element_t<position, framework::pack<std::decay_t<T>...>>, Key>) {
236+
values[position] = idx;
245237
return true;
238+
} else {
239+
lowerBound<Key>(idx, x);
240+
if (x == soa::RowViewSentinel{static_cast<uint64_t>(x.mMaxRow)}) {
241+
return false;
242+
} else if (x.template getId<Key>() != idx) {
243+
return false;
244+
} else {
245+
values[position] = x.globalIndex();
246+
++x;
247+
return true;
248+
}
246249
}
247250
};
248251

249252
auto first = std::get<first_t>(tables);
250253
for (auto& row : first) {
251-
idx = row.template getId<Key>();
252-
254+
auto idx = -1;
255+
if constexpr (std::is_same_v<first_t, Key>) {
256+
idx = row.globalIndex();
257+
} else {
258+
idx = row.template getId<Key>();
259+
}
253260
if (std::apply(
254261
[](auto&... x) {
255262
return ((x == soa::RowViewSentinel{static_cast<uint64_t>(x.mMaxRow)}) && ...);
@@ -260,7 +267,7 @@ struct IndexExclusive {
260267

261268
auto result = std::apply(
262269
[&](auto&... x) {
263-
std::array<bool, sizeof...(T)> results{setValue(x)...};
270+
std::array<bool, sizeof...(T)> results{setValue(x, idx)...};
264271
return (results[framework::has_type_at_v<std::decay_t<decltype(x)>>(rest_it_t{})] && ...);
265272
},
266273
iterators);

0 commit comments

Comments
 (0)