Skip to content

Commit b06c920

Browse files
committed
update
1 parent a064177 commit b06c920

File tree

1 file changed

+28
-21
lines changed
  • Framework/Core/include/Framework

1 file changed

+28
-21
lines changed

Framework/Core/include/Framework/ASoA.h

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1414,13 +1414,12 @@ struct PreslicePolicyGeneral : public PreslicePolicyBase {
14141414

14151415
template <typename T, typename Policy, bool OPT = false>
14161416
struct PresliceBase : public Policy {
1417-
constexpr static bool sorted = std::same_as<Policy, PreslicePolicySorted>;
14181417
constexpr static bool optional = OPT;
14191418
using target_t = T;
14201419
const std::string binding;
14211420

14221421
PresliceBase(expressions::BindingNode index_)
1423-
: Policy{PreslicePolicyBase{{o2::soa::getLabelFromTypeForKey<T, OPT>(index_.name)}, {binding, index_.name}}, {}}
1422+
: Policy{PreslicePolicyBase{{o2::soa::getLabelFromTypeForKey<T, OPT>(std::string{index_.name})}, std::make_pair(binding, std::string{index_.name})}, {}}
14241423
{
14251424
}
14261425

@@ -1541,39 +1540,47 @@ auto doSliceBy(T const* table, o2::framework::PresliceBase<C, Policy, OPT> const
15411540
return doSliceByHelper(table, selection);
15421541
}
15431542

1544-
template <typename T>
1545-
auto prepareFilteredSlice(T const* table, std::shared_ptr<arrow::Table> slice, uint64_t offset)
1543+
auto sliceSelection(SelectionVector const& mSelectedRows, int64_t nrows, uint64_t offset)
15461544
{
1547-
if (offset >= static_cast<uint64_t>(table->tableSize())) {
1548-
if constexpr (soa::is_filtered_table<T>) {
1549-
Filtered<typename T::base_t> fresult{{{slice}}, SelectionVector{}, 0};
1550-
table->copyIndexBindings(fresult);
1551-
return fresult;
1552-
} else {
1553-
typename T::self_t fresult{{{slice}}, SelectionVector{}, 0};
1554-
table->copyIndexBindings(fresult);
1555-
return fresult;
1556-
}
1557-
}
15581545
auto start = offset;
1559-
auto end = start + slice->num_rows();
1560-
auto mSelectedRows = table->getSelectedRows();
1546+
auto end = start + nrows;
15611547
auto start_iterator = std::lower_bound(mSelectedRows.begin(), mSelectedRows.end(), start);
15621548
auto stop_iterator = std::lower_bound(start_iterator, mSelectedRows.end(), end);
15631549
SelectionVector slicedSelection{start_iterator, stop_iterator};
15641550
std::transform(slicedSelection.begin(), slicedSelection.end(), slicedSelection.begin(),
15651551
[&start](int64_t idx) {
15661552
return idx - static_cast<int64_t>(start);
15671553
});
1568-
if constexpr (soa::is_filtered_table<T>) {
1569-
Filtered<typename T::base_t> fresult{{{slice}}, std::move(slicedSelection), start};
1554+
return slicedSelection;
1555+
}
1556+
1557+
template <soa::is_table T>
1558+
requires(!soa::is_filtered_table<T>)
1559+
auto prepareFilteredSlice(T const* table, std::shared_ptr<arrow::Table> slice, uint64_t offset)
1560+
{
1561+
if (offset >= static_cast<uint64_t>(table->tableSize())) {
1562+
typename T::self_t fresult{{{slice}}, SelectionVector{}, 0};
15701563
table->copyIndexBindings(fresult);
15711564
return fresult;
1572-
} else {
1573-
typename T::self_t fresult{{{slice}}, std::move(slicedSelection), start};
1565+
}
1566+
auto slicedSelection = sliceSelection(table->getSelectedRows(), slice->num_rows(), offset);
1567+
typename T::self_t fresult{{{slice}}, std::move(slicedSelection), offset};
1568+
table->copyIndexBindings(fresult);
1569+
return fresult;
1570+
}
1571+
1572+
template <soa::is_filtered_table T>
1573+
auto prepareFilteredSlice(T const* table, std::shared_ptr<arrow::Table> slice, uint64_t offset)
1574+
{
1575+
if (offset >= static_cast<uint64_t>(table->tableSize())) {
1576+
Filtered<typename T::base_t> fresult{{{slice}}, SelectionVector{}, 0};
15741577
table->copyIndexBindings(fresult);
15751578
return fresult;
15761579
}
1580+
auto slicedSelection = sliceSelection(table->getSelectedRows(), slice->num_rows(), offset);
1581+
Filtered<typename T::base_t> fresult{{{slice}}, std::move(slicedSelection), offset};
1582+
table->copyIndexBindings(fresult);
1583+
return fresult;
15771584
}
15781585

15791586
template <typename T, typename C, bool OPT>

0 commit comments

Comments
 (0)