From ee5b059a12a7b918a8921ea660990387a942536f Mon Sep 17 00:00:00 2001 From: Anton Alkin Date: Mon, 27 Jan 2025 13:12:53 +0100 Subject: [PATCH 1/6] DPL Analysis: refactor Preslice; move some code out of line --- Framework/Core/include/Framework/ASoA.h | 232 +++++++++--------- .../Core/include/Framework/AnalysisHelpers.h | 4 +- .../Core/include/Framework/AnalysisManagers.h | 58 +++-- Framework/Core/src/ASoA.cxx | 33 +++ 4 files changed, 191 insertions(+), 136 deletions(-) diff --git a/Framework/Core/include/Framework/ASoA.h b/Framework/Core/include/Framework/ASoA.h index 8af872a64176d..ce677e6df4b4a 100644 --- a/Framework/Core/include/Framework/ASoA.h +++ b/Framework/Core/include/Framework/ASoA.h @@ -1389,76 +1389,69 @@ consteval static bool relatedBySortedIndex() namespace o2::framework { -template -struct PresliceBase { - constexpr static bool sorted = SORTED; + +struct PreslicePolicyBase { + const std::string binding; + StringPair bindingKey; + + bool isMissing() const; + StringPair const& getBindingKey() const; +}; + +struct PreslicePolicySorted : public PreslicePolicyBase { + void updateSliceInfo(SliceInfoPtr&& si); + + SliceInfoPtr sliceInfo; + std::shared_ptr getSliceFor(int value, std::shared_ptr const& input, uint64_t& offset) const; +}; + +struct PreslicePolicyGeneral : public PreslicePolicyBase { + void updateSliceInfo(SliceInfoUnsortedPtr&& si); + + SliceInfoUnsortedPtr sliceInfo; + gsl::span getSliceFor(int value) const; +}; + +template +struct PresliceBase : public Policy { + constexpr static bool sorted = std::same_as; constexpr static bool optional = OPT; using target_t = T; const std::string binding; PresliceBase(expressions::BindingNode index_) - : binding{o2::soa::getLabelFromTypeForKey(index_.name)}, - bindingKey{binding, index_.name} {} - - void updateSliceInfo(std::conditional_t&& si) - { - sliceInfo = si; - } + : Policy{PreslicePolicyBase{{o2::soa::getLabelFromTypeForKey(index_.name)},{binding, index_.name}}, {}} + {} std::shared_ptr getSliceFor(int value, std::shared_ptr const& input, uint64_t& offset) const { if constexpr (OPT) { - if (isMissing()) { + if (Policy::isMissing()) { return nullptr; } } - if constexpr (SORTED) { - auto [offset_, count] = sliceInfo.getSliceFor(value); - auto output = input->Slice(offset_, count); - offset = static_cast(offset_); - return output; - } else { - static_assert(SORTED, "Wrong method called for unsorted cache"); - } + return Policy::getSliceFor(value, input, offset); } gsl::span getSliceFor(int value) const { if constexpr (OPT) { - if (isMissing()) { + if (Policy::isMissing()) { return {}; } } - if constexpr (!SORTED) { - return sliceInfo.getSliceFor(value); - } else { - static_assert(!SORTED, "Wrong method called for sorted cache"); - } + return Policy::getSliceFor(value); } - - bool isMissing() const - { - return binding == "[MISSING]"; - } - - StringPair const& getBindingKey() const - { - return bindingKey; - } - - std::conditional_t sliceInfo; - - StringPair bindingKey; }; template -using PresliceUnsorted = PresliceBase; +using PresliceUnsorted = PresliceBase; template -using PresliceUnsortedOptional = PresliceBase; +using PresliceUnsortedOptional = PresliceBase; template -using Preslice = PresliceBase; +using Preslice = PresliceBase; template -using PresliceOptional = PresliceBase; +using PresliceOptional = PresliceBase; } // namespace o2::framework @@ -1497,44 +1490,54 @@ static consteval auto extractBindings(framework::pack) SelectionVector selectionToVector(gandiva::Selection const& sel); -template -auto doSliceBy(T const* table, o2::framework::PresliceBase const& container, int value) +template + requires std::same_as && (o2::soa::is_binding_compatible_v()) +auto doSliceBy(T const* table, o2::framework::PresliceBase const& container, int value) { - if constexpr (o2::soa::is_binding_compatible_v()) { - if constexpr (OPT) { - if (container.isMissing()) { - missingOptionalPreslice(getLabelFromType>().data(), container.bindingKey.second.c_str()); - } - } - if constexpr (SORTED) { - uint64_t offset = 0; - auto out = container.getSliceFor(value, table->asArrowTable(), offset); - auto t = typename T::self_t({out}, offset); - table->copyIndexBindings(t); - t.bindInternalIndicesTo(table); - return t; - } else { - auto selection = container.getSliceFor(value); - if constexpr (soa::is_filtered_table) { - auto t = soa::Filtered({table->asArrowTable()}, selection); - table->copyIndexBindings(t); - t.bindInternalIndicesTo(table); - t.intersectWithSelection(table->getSelectedRows()); // intersect filters - return t; - } else { - auto t = soa::Filtered({table->asArrowTable()}, selection); - table->copyIndexBindings(t); - t.bindInternalIndicesTo(table); - return t; - } + if constexpr (OPT) { + if (container.isMissing()) { + missingOptionalPreslice(getLabelFromType>().data(), container.bindingKey.second.c_str()); } - } else { - if constexpr (SORTED) { - static_assert(o2::framework::always_static_assert_v, "Wrong Preslice<> entry used: incompatible type"); - } else { - static_assert(o2::framework::always_static_assert_v, "Wrong PresliceUnsorted<> entry used: incompatible type"); + } + uint64_t offset = 0; + auto out = container.getSliceFor(value, table->asArrowTable(), offset); + auto t = typename T::self_t({out}, offset); + table->copyIndexBindings(t); + t.bindInternalIndicesTo(table); + return t; +} + +template +auto doSliceByHelper(T const* table, gsl::span const& selection) +{ + auto t = soa::Filtered({table->asArrowTable()}, selection); + table->copyIndexBindings(t); + t.bindInternalIndicesTo(table); + t.intersectWithSelection(table->getSelectedRows()); // intersect filters + return t; +} + +template + requires (!soa::is_filtered_table) +auto doSliceByHelper(T const* table, gsl::span const& selection) +{ + auto t = soa::Filtered({table->asArrowTable()}, selection); + table->copyIndexBindings(t); + t.bindInternalIndicesTo(table); + return t; +} + +template + requires std::same_as && (o2::soa::is_binding_compatible_v()) +auto doSliceBy(T const* table, o2::framework::PresliceBase const& container, int value) +{ + if constexpr (OPT) { + if (container.isMissing()) { + missingOptionalPreslice(getLabelFromType>().data(), container.bindingKey.second.c_str()); } } + auto selection = container.getSliceFor(value); + return doSliceByHelper(table, selection); } template @@ -1573,20 +1576,17 @@ auto prepareFilteredSlice(T const* table, std::shared_ptr slice, u } template -auto doFilteredSliceBy(T const* table, o2::framework::PresliceBase const& container, int value) + requires (o2::soa::is_binding_compatible_v()) +auto doFilteredSliceBy(T const* table, o2::framework::PresliceBase const& container, int value) { - if constexpr (o2::soa::is_binding_compatible_v()) { - if constexpr (OPT) { - if (container.isMissing()) { - missingOptionalPreslice(getLabelFromType().data(), container.bindingKey.second.c_str()); - } + if constexpr (OPT) { + if (container.isMissing()) { + missingOptionalPreslice(getLabelFromType().data(), container.bindingKey.second.c_str()); } - uint64_t offset = 0; - auto slice = container.getSliceFor(value, table->asArrowTable(), offset); - return prepareFilteredSlice(table, slice, offset); - } else { - static_assert(o2::framework::always_static_assert_v, "Wrong Preslice<> entry used: incompatible type"); } + uint64_t offset = 0; + auto slice = container.getSliceFor(value, table->asArrowTable(), offset); + return prepareFilteredSlice(table, slice, offset); } template @@ -2099,8 +2099,8 @@ class Table return doSliceByCachedUnsorted(this, node, value, cache); } - template - auto sliceBy(o2::framework::PresliceBase const& container, int value) const + template + auto sliceBy(o2::framework::PresliceBase const& container, int value) const { return doSliceBy(this, container, value); } @@ -3201,8 +3201,8 @@ struct JoinFull : Table, D, o2::aod::Hash<"JOIN"_h>, Ts. return doSliceByCachedUnsorted(this, node, value, cache); } - template - auto sliceBy(o2::framework::PresliceBase const& container, int value) const + template + auto sliceBy(o2::framework::PresliceBase const& container, int value) const { return doSliceBy(this, container, value); } @@ -3463,14 +3463,16 @@ class FilteredBase : public T return doSliceByCachedUnsorted(this, node, value, cache); } - template - auto sliceBy(o2::framework::PresliceBase const& container, int value) const + template + auto sliceBy(o2::framework::PresliceBase const& container, int value) const { - if constexpr (SORTED) { - return doFilteredSliceBy(this, container, value); - } else { - return doSliceBy(this, container, value); - } + return doFilteredSliceBy(this, container, value); + } + + template + auto sliceBy(o2::framework::PresliceBase const& container, int value) const + { + return doSliceBy(this, container, value); } auto select(framework::expressions::Filter const& f) const @@ -3697,14 +3699,16 @@ class Filtered : public FilteredBase return doSliceByCachedUnsorted(this, node, value, cache); } - template - auto sliceBy(o2::framework::PresliceBase const& container, int value) const + template + auto sliceBy(o2::framework::PresliceBase const& container, int value) const { - if constexpr (SORTED) { - return doFilteredSliceBy(this, container, value); - } else { - return doSliceBy(this, container, value); - } + return doFilteredSliceBy(this, container, value); + } + + template + auto sliceBy(o2::framework::PresliceBase const& container, int value) const + { + return doSliceBy(this, container, value); } auto select(framework::expressions::Filter const& f) const @@ -3864,14 +3868,16 @@ class Filtered> : public FilteredBase return doSliceByCachedUnsorted(this, node, value, cache); } - template - auto sliceBy(o2::framework::PresliceBase const& container, int value) const + template + auto sliceBy(o2::framework::PresliceBase const& container, int value) const { - if constexpr (SORTED) { - return doFilteredSliceBy(this, container, value); - } else { - return doSliceBy(this, container, value); - } + return doFilteredSliceBy(this, container, value); + } + + template + auto sliceBy(o2::framework::PresliceBase const& container, int value) const + { + return doSliceBy(this, container, value); } private: diff --git a/Framework/Core/include/Framework/AnalysisHelpers.h b/Framework/Core/include/Framework/AnalysisHelpers.h index d84c9714b2f30..bb7e5e14aaa75 100644 --- a/Framework/Core/include/Framework/AnalysisHelpers.h +++ b/Framework/Core/include/Framework/AnalysisHelpers.h @@ -652,8 +652,8 @@ struct Partition { return mFiltered->sliceByCachedUnsorted(node, value, cache); } - template - [[nodiscard]] auto sliceBy(o2::framework::PresliceBase const& container, int value) const + template + [[nodiscard]] auto sliceBy(o2::framework::PresliceBase const& container, int value) const { return mFiltered->sliceBy(container, value); } diff --git a/Framework/Core/include/Framework/AnalysisManagers.h b/Framework/Core/include/Framework/AnalysisManagers.h index e0dd21708e841..30ebf1799b227 100644 --- a/Framework/Core/include/Framework/AnalysisManagers.h +++ b/Framework/Core/include/Framework/AnalysisManagers.h @@ -645,44 +645,60 @@ struct PresliceManager { } }; -template -struct PresliceManager> { - static bool registerCache(PresliceBase& container, std::vector& bsks, std::vector& bsksU) +template +struct PresliceManager> { + static bool registerCache(PresliceBase& container, std::vector& bsks, std::vector&) + requires std::same_as { if constexpr (OPT) { if (container.binding == "[MISSING]") { return true; } } - if constexpr (SORTED) { - auto locate = std::find_if(bsks.begin(), bsks.end(), [&](auto const& entry) { return (entry.first == container.bindingKey.first) && (entry.second == container.bindingKey.second); }); - if (locate == bsks.end()) { - bsks.emplace_back(container.getBindingKey()); - } - return true; - } else { - auto locate = std::find_if(bsksU.begin(), bsksU.end(), [&](auto const& entry) { return (entry.first == container.bindingKey.first) && (entry.second == container.bindingKey.second); }); - if (locate == bsksU.end()) { - bsksU.emplace_back(container.getBindingKey()); + auto locate = std::find_if(bsks.begin(), bsks.end(), [&](auto const& entry) { return (entry.first == container.bindingKey.first) && (entry.second == container.bindingKey.second); }); + if (locate == bsks.end()) { + bsks.emplace_back(container.getBindingKey()); + } + return true; + } + + static bool registerCache(PresliceBase& container, std::vector&, std::vector& bsksU) + requires std::same_as + { + if constexpr (OPT) { + if (container.binding == "[MISSING]") { + return true; } - return true; } + auto locate = std::find_if(bsksU.begin(), bsksU.end(), [&](auto const& entry) { return (entry.first == container.bindingKey.first) && (entry.second == container.bindingKey.second); }); + if (locate == bsksU.end()) { + bsksU.emplace_back(container.getBindingKey()); + } + return true; } - static bool updateSliceInfo(PresliceBase& container, ArrowTableSlicingCache& cache) + static bool updateSliceInfo(PresliceBase& container, ArrowTableSlicingCache& cache) + requires std::same_as { if constexpr (OPT) { if (container.binding == "[MISSING]") { return true; } } - if constexpr (SORTED) { - container.updateSliceInfo(cache.getCacheFor(container.getBindingKey())); - return true; - } else { - container.updateSliceInfo(cache.getCacheUnsortedFor(container.getBindingKey())); - return true; + container.updateSliceInfo(cache.getCacheFor(container.getBindingKey())); + return true; + } + + static bool updateSliceInfo(PresliceBase& container, ArrowTableSlicingCache& cache) + requires std::same_as + { + if constexpr (OPT) { + if (container.binding == "[MISSING]") { + return true; + } } + container.updateSliceInfo(cache.getCacheUnsortedFor(container.getBindingKey())); + return true; } }; } // namespace o2::framework diff --git a/Framework/Core/src/ASoA.cxx b/Framework/Core/src/ASoA.cxx index a37d0f33891e7..fb0a5e3ec8082 100644 --- a/Framework/Core/src/ASoA.cxx +++ b/Framework/Core/src/ASoA.cxx @@ -177,4 +177,37 @@ std::string strToUpper(std::string&& str) std::transform(str.begin(), str.end(), str.begin(), [](unsigned char c) { return std::toupper(c); }); return str; } + +bool PreslicePolicyBase::isMissing() const +{ + return binding == "[MISSING]"; +} + +StringPair const& PreslicePolicyBase::getBindingKey() const +{ + return bindingKey; +} + +void PreslicePolicySorted::updateSliceInfo(SliceInfoPtr&& si) +{ + sliceInfo = si; +} + +void PreslicePolicyGeneral::updateSliceInfo(SliceInfoUnsortedPtr&& si) +{ + sliceInfo = si; +} + +std::shared_ptr PreslicePolicySorted::getSliceFor(int value, std::shared_ptr const& input, uint64_t& offset) const +{ + auto [offset_, count] = this->sliceInfo.getSliceFor(value); + auto output = input->Slice(offset_, count); + offset = static_cast(offset_); + return output; +} + +gsl::span PreslicePolicyGeneral::getSliceFor(int value) const +{ + return this->sliceInfo.getSliceFor(value); +} } // namespace o2::framework From a0641777b3dea24eed5e8a11b197159da4e3cdce Mon Sep 17 00:00:00 2001 From: Anton Alkin Date: Mon, 27 Jan 2025 13:15:36 +0100 Subject: [PATCH 2/6] format --- Framework/Core/include/Framework/ASoA.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Framework/Core/include/Framework/ASoA.h b/Framework/Core/include/Framework/ASoA.h index ce677e6df4b4a..93be077b1d6ef 100644 --- a/Framework/Core/include/Framework/ASoA.h +++ b/Framework/Core/include/Framework/ASoA.h @@ -1420,8 +1420,9 @@ struct PresliceBase : public Policy { const std::string binding; PresliceBase(expressions::BindingNode index_) - : Policy{PreslicePolicyBase{{o2::soa::getLabelFromTypeForKey(index_.name)},{binding, index_.name}}, {}} - {} + : Policy{PreslicePolicyBase{{o2::soa::getLabelFromTypeForKey(index_.name)}, {binding, index_.name}}, {}} + { + } std::shared_ptr getSliceFor(int value, std::shared_ptr const& input, uint64_t& offset) const { @@ -1518,7 +1519,7 @@ auto doSliceByHelper(T const* table, gsl::span const& selection) } template - requires (!soa::is_filtered_table) + requires(!soa::is_filtered_table) auto doSliceByHelper(T const* table, gsl::span const& selection) { auto t = soa::Filtered({table->asArrowTable()}, selection); @@ -1576,7 +1577,7 @@ auto prepareFilteredSlice(T const* table, std::shared_ptr slice, u } template - requires (o2::soa::is_binding_compatible_v()) + requires(o2::soa::is_binding_compatible_v()) auto doFilteredSliceBy(T const* table, o2::framework::PresliceBase const& container, int value) { if constexpr (OPT) { From b06c920cc0be41f88d4ed104d6d53efb913ca303 Mon Sep 17 00:00:00 2001 From: Anton Alkin Date: Tue, 28 Jan 2025 11:15:03 +0100 Subject: [PATCH 3/6] update --- Framework/Core/include/Framework/ASoA.h | 49 ++++++++++++++----------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/Framework/Core/include/Framework/ASoA.h b/Framework/Core/include/Framework/ASoA.h index 93be077b1d6ef..3c4a6581dd3c6 100644 --- a/Framework/Core/include/Framework/ASoA.h +++ b/Framework/Core/include/Framework/ASoA.h @@ -1414,13 +1414,12 @@ struct PreslicePolicyGeneral : public PreslicePolicyBase { template struct PresliceBase : public Policy { - constexpr static bool sorted = std::same_as; constexpr static bool optional = OPT; using target_t = T; const std::string binding; PresliceBase(expressions::BindingNode index_) - : Policy{PreslicePolicyBase{{o2::soa::getLabelFromTypeForKey(index_.name)}, {binding, index_.name}}, {}} + : Policy{PreslicePolicyBase{{o2::soa::getLabelFromTypeForKey(std::string{index_.name})}, std::make_pair(binding, std::string{index_.name})}, {}} { } @@ -1541,23 +1540,10 @@ auto doSliceBy(T const* table, o2::framework::PresliceBase const return doSliceByHelper(table, selection); } -template -auto prepareFilteredSlice(T const* table, std::shared_ptr slice, uint64_t offset) +auto sliceSelection(SelectionVector const& mSelectedRows, int64_t nrows, uint64_t offset) { - if (offset >= static_cast(table->tableSize())) { - if constexpr (soa::is_filtered_table) { - Filtered fresult{{{slice}}, SelectionVector{}, 0}; - table->copyIndexBindings(fresult); - return fresult; - } else { - typename T::self_t fresult{{{slice}}, SelectionVector{}, 0}; - table->copyIndexBindings(fresult); - return fresult; - } - } auto start = offset; - auto end = start + slice->num_rows(); - auto mSelectedRows = table->getSelectedRows(); + auto end = start + nrows; auto start_iterator = std::lower_bound(mSelectedRows.begin(), mSelectedRows.end(), start); auto stop_iterator = std::lower_bound(start_iterator, mSelectedRows.end(), end); SelectionVector slicedSelection{start_iterator, stop_iterator}; @@ -1565,15 +1551,36 @@ auto prepareFilteredSlice(T const* table, std::shared_ptr slice, u [&start](int64_t idx) { return idx - static_cast(start); }); - if constexpr (soa::is_filtered_table) { - Filtered fresult{{{slice}}, std::move(slicedSelection), start}; + return slicedSelection; +} + +template + requires(!soa::is_filtered_table) +auto prepareFilteredSlice(T const* table, std::shared_ptr slice, uint64_t offset) +{ + if (offset >= static_cast(table->tableSize())) { + typename T::self_t fresult{{{slice}}, SelectionVector{}, 0}; table->copyIndexBindings(fresult); return fresult; - } else { - typename T::self_t fresult{{{slice}}, std::move(slicedSelection), start}; + } + auto slicedSelection = sliceSelection(table->getSelectedRows(), slice->num_rows(), offset); + typename T::self_t fresult{{{slice}}, std::move(slicedSelection), offset}; + table->copyIndexBindings(fresult); + return fresult; +} + +template +auto prepareFilteredSlice(T const* table, std::shared_ptr slice, uint64_t offset) +{ + if (offset >= static_cast(table->tableSize())) { + Filtered fresult{{{slice}}, SelectionVector{}, 0}; table->copyIndexBindings(fresult); return fresult; } + auto slicedSelection = sliceSelection(table->getSelectedRows(), slice->num_rows(), offset); + Filtered fresult{{{slice}}, std::move(slicedSelection), offset}; + table->copyIndexBindings(fresult); + return fresult; } template From 903b1a6105e6cb57e7268537b03b3b06b77e2e41 Mon Sep 17 00:00:00 2001 From: Anton Alkin Date: Tue, 28 Jan 2025 11:27:34 +0100 Subject: [PATCH 4/6] fixup! update --- Framework/Core/include/Framework/ASoA.h | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/Framework/Core/include/Framework/ASoA.h b/Framework/Core/include/Framework/ASoA.h index 3c4a6581dd3c6..06c76f57141fa 100644 --- a/Framework/Core/include/Framework/ASoA.h +++ b/Framework/Core/include/Framework/ASoA.h @@ -1540,19 +1540,7 @@ auto doSliceBy(T const* table, o2::framework::PresliceBase const return doSliceByHelper(table, selection); } -auto sliceSelection(SelectionVector const& mSelectedRows, int64_t nrows, uint64_t offset) -{ - auto start = offset; - auto end = start + nrows; - auto start_iterator = std::lower_bound(mSelectedRows.begin(), mSelectedRows.end(), start); - auto stop_iterator = std::lower_bound(start_iterator, mSelectedRows.end(), end); - SelectionVector slicedSelection{start_iterator, stop_iterator}; - std::transform(slicedSelection.begin(), slicedSelection.end(), slicedSelection.begin(), - [&start](int64_t idx) { - return idx - static_cast(start); - }); - return slicedSelection; -} +auto sliceSelection(SelectionVector const& mSelectedRows, int64_t nrows, uint64_t offset); template requires(!soa::is_filtered_table) From e75ff676450d905a3bb0b97f77b8e03b04db7bc5 Mon Sep 17 00:00:00 2001 From: Anton Alkin Date: Tue, 28 Jan 2025 12:50:54 +0100 Subject: [PATCH 5/6] fixup! update --- Framework/Core/include/Framework/ASoA.h | 19 ++----------------- Framework/Core/src/ASoA.cxx | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/Framework/Core/include/Framework/ASoA.h b/Framework/Core/include/Framework/ASoA.h index 06c76f57141fa..6266a39e04058 100644 --- a/Framework/Core/include/Framework/ASoA.h +++ b/Framework/Core/include/Framework/ASoA.h @@ -1540,22 +1540,7 @@ auto doSliceBy(T const* table, o2::framework::PresliceBase const return doSliceByHelper(table, selection); } -auto sliceSelection(SelectionVector const& mSelectedRows, int64_t nrows, uint64_t offset); - -template - requires(!soa::is_filtered_table) -auto prepareFilteredSlice(T const* table, std::shared_ptr slice, uint64_t offset) -{ - if (offset >= static_cast(table->tableSize())) { - typename T::self_t fresult{{{slice}}, SelectionVector{}, 0}; - table->copyIndexBindings(fresult); - return fresult; - } - auto slicedSelection = sliceSelection(table->getSelectedRows(), slice->num_rows(), offset); - typename T::self_t fresult{{{slice}}, std::move(slicedSelection), offset}; - table->copyIndexBindings(fresult); - return fresult; -} +SelectionVector sliceSelection(gsl::span const& mSelectedRows, int64_t nrows, uint64_t offset); template auto prepareFilteredSlice(T const* table, std::shared_ptr slice, uint64_t offset) @@ -1571,7 +1556,7 @@ auto prepareFilteredSlice(T const* table, std::shared_ptr slice, u return fresult; } -template +template requires(o2::soa::is_binding_compatible_v()) auto doFilteredSliceBy(T const* table, o2::framework::PresliceBase const& container, int value) { diff --git a/Framework/Core/src/ASoA.cxx b/Framework/Core/src/ASoA.cxx index fb0a5e3ec8082..276a592d87895 100644 --- a/Framework/Core/src/ASoA.cxx +++ b/Framework/Core/src/ASoA.cxx @@ -50,6 +50,20 @@ SelectionVector selectionToVector(gandiva::Selection const& sel) return rows; } +SelectionVector sliceSelection(gsl::span const& mSelectedRows, int64_t nrows, uint64_t offset) +{ + auto start = offset; + auto end = start + nrows; + auto start_iterator = std::lower_bound(mSelectedRows.begin(), mSelectedRows.end(), start); + auto stop_iterator = std::lower_bound(start_iterator, mSelectedRows.end(), end); + SelectionVector slicedSelection{start_iterator, stop_iterator}; + std::transform(slicedSelection.begin(), slicedSelection.end(), slicedSelection.begin(), + [&start](int64_t idx) { + return idx - static_cast(start); + }); + return slicedSelection; +} + std::shared_ptr ArrowHelpers::joinTables(std::vector>&& tables) { if (tables.size() == 1) { From 05a7d09203e05a51cdce5cec3edc20481c2af847 Mon Sep 17 00:00:00 2001 From: Anton Alkin Date: Tue, 28 Jan 2025 14:21:08 +0100 Subject: [PATCH 6/6] fixup! update --- Framework/Core/include/Framework/ASoA.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Framework/Core/include/Framework/ASoA.h b/Framework/Core/include/Framework/ASoA.h index 6266a39e04058..65fd12b3e6df3 100644 --- a/Framework/Core/include/Framework/ASoA.h +++ b/Framework/Core/include/Framework/ASoA.h @@ -1419,7 +1419,7 @@ struct PresliceBase : public Policy { const std::string binding; PresliceBase(expressions::BindingNode index_) - : Policy{PreslicePolicyBase{{o2::soa::getLabelFromTypeForKey(std::string{index_.name})}, std::make_pair(binding, std::string{index_.name})}, {}} + : Policy{PreslicePolicyBase{{o2::soa::getLabelFromTypeForKey(std::string{index_.name})}, std::make_pair(o2::soa::getLabelFromTypeForKey(std::string{index_.name}), std::string{index_.name})}, {}} { }