Skip to content

Commit 0399d79

Browse files
committed
extract function
1 parent 6051c0d commit 0399d79

2 files changed

Lines changed: 15 additions & 18 deletions

File tree

Framework/Core/include/Framework/ASoA.h

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1723,15 +1723,12 @@ auto doFilteredSliceBy(T const* table, o2::framework::PresliceBase<C, framework:
17231723
return prepareFilteredSlice(table, slice, offset);
17241724
}
17251725

1726+
std::function<framework::ConcreteDataMatcher(framework::ConcreteDataMatcher&&)> originReplacement(header::DataOrigin newOrigin);
1727+
17261728
template <soa::is_table T>
17271729
auto doSliceByCached(T const* table, framework::expressions::BindingNode const& node, int value, o2::framework::SliceCache& cache)
17281730
{
1729-
auto localCache = cache.ptr->getCacheFor({"", [&o = cache.ptr->newOrigin](framework::ConcreteDataMatcher&& m) {
1730-
if ((m.origin == header::DataOrigin{"AOD"}) && (o != header::DataOrigin{"AOD"})) {
1731-
m.origin = o;
1732-
}
1733-
return m;
1734-
}(o2::soa::getMatcherFromTypeForKey<T>(node.name)),
1731+
auto localCache = cache.ptr->getCacheFor({"", originReplacement(cache.ptr->newOrigin)(o2::soa::getMatcherFromTypeForKey<T>(node.name)),
17351732
node.name});
17361733
auto [offset, count] = localCache.getSliceFor(value);
17371734
auto t = typename T::self_t({table->asArrowTable()->Slice(static_cast<uint64_t>(offset), count)}, static_cast<uint64_t>(offset));
@@ -1744,12 +1741,7 @@ auto doSliceByCached(T const* table, framework::expressions::BindingNode const&
17441741
template <soa::is_filtered_table T>
17451742
auto doFilteredSliceByCached(T const* table, framework::expressions::BindingNode const& node, int value, o2::framework::SliceCache& cache)
17461743
{
1747-
auto localCache = cache.ptr->getCacheFor({"", [&o = cache.ptr->newOrigin](framework::ConcreteDataMatcher&& m) {
1748-
if ((m.origin == header::DataOrigin{"AOD"}) && (o != header::DataOrigin{"AOD"})) {
1749-
m.origin = o;
1750-
}
1751-
return m;
1752-
}(o2::soa::getMatcherFromTypeForKey<T>(node.name)),
1744+
auto localCache = cache.ptr->getCacheFor({"", originReplacement(cache.ptr->newOrigin)(o2::soa::getMatcherFromTypeForKey<T>(node.name)),
17531745
node.name});
17541746
auto [offset, count] = localCache.getSliceFor(value);
17551747
auto slice = table->asArrowTable()->Slice(static_cast<uint64_t>(offset), count);
@@ -1759,12 +1751,7 @@ auto doFilteredSliceByCached(T const* table, framework::expressions::BindingNode
17591751
template <soa::is_table T>
17601752
auto doSliceByCachedUnsorted(T const* table, framework::expressions::BindingNode const& node, int value, o2::framework::SliceCache& cache)
17611753
{
1762-
auto localCache = cache.ptr->getCacheUnsortedFor({"", [&o = cache.ptr->newOrigin](framework::ConcreteDataMatcher&& m) {
1763-
if ((m.origin == header::DataOrigin{"AOD"}) && (o != header::DataOrigin{"AOD"})) {
1764-
m.origin = o;
1765-
}
1766-
return m;
1767-
}(o2::soa::getMatcherFromTypeForKey<T>(node.name)),
1754+
auto localCache = cache.ptr->getCacheUnsortedFor({"", originReplacement(cache.ptr->newOrigin)(o2::soa::getMatcherFromTypeForKey<T>(node.name)),
17681755
node.name});
17691756
if constexpr (soa::is_filtered_table<T>) {
17701757
auto t = typename T::self_t({table->asArrowTable()}, localCache.getSliceFor(value));

Framework/Core/src/ASoA.cxx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,16 @@ void* extractCCDBPayload(char* payload, size_t size, TClass const* cl, const cha
259259
return result;
260260
}
261261

262+
std::function<framework::ConcreteDataMatcher(framework::ConcreteDataMatcher&&)> originReplacement(header::DataOrigin newOrigin)
263+
{
264+
return [newOrigin](framework::ConcreteDataMatcher&& m) {
265+
if ((m.origin == header::DataOrigin{"AOD"}) && (newOrigin != header::DataOrigin{"AOD"})) {
266+
m.origin = newOrigin;
267+
}
268+
return m;
269+
};
270+
}
271+
262272
} // namespace o2::soa
263273

264274
namespace o2::framework

0 commit comments

Comments
 (0)