Skip to content

Commit 9285341

Browse files
committed
DPL Analysis: rework table builder cursor signature logic
1 parent 3c55949 commit 9285341

File tree

8 files changed

+67
-64
lines changed

8 files changed

+67
-64
lines changed

Framework/Core/include/Framework/ASoA.h

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -560,21 +560,21 @@ class ColumnIterator : ChunkingPolicy
560560
mLast = mCurrent + array->length() + (mFirstIndex >> SCALE_FACTOR);
561561
}
562562

563-
decltype(auto) operator*() const
563+
auto operator*() const
564564
requires std::same_as<bool, std::decay_t<T>>
565565
{
566566
checkSkipChunk();
567567
return (*(mCurrent - (mOffset >> SCALE_FACTOR) + ((*mCurrentPos + mOffset) >> SCALE_FACTOR)) & (1 << ((*mCurrentPos + mOffset) & 0x7))) != 0;
568568
}
569569

570-
decltype(auto) operator*() const
570+
auto operator*() const
571571
requires((!std::same_as<bool, std::decay_t<T>>) && std::same_as<arrow_array_for_t<T>, arrow::ListArray>)
572572
{
573573
checkSkipChunk();
574574
auto list = std::static_pointer_cast<arrow::ListArray>(mColumn->chunk(mCurrentChunk));
575575
auto offset = list->value_offset(*mCurrentPos - mFirstIndex);
576576
auto length = list->value_length(*mCurrentPos - mFirstIndex);
577-
return gsl::span{mCurrent + mFirstIndex + offset, mCurrent + mFirstIndex + (offset + length)};
577+
return std::span<unwrap_t<T> const>{mCurrent + mFirstIndex + offset, mCurrent + mFirstIndex + (offset + length)};
578578
}
579579

580580
decltype(auto) operator*() const
@@ -840,7 +840,7 @@ struct FilteredIndexPolicy : IndexPolicyBase {
840840
// which happens below which will properly setup the first index
841841
// by remapping the filtered index 0 to whatever unfiltered index
842842
// it belongs to.
843-
FilteredIndexPolicy(gsl::span<int64_t const> selection, int64_t rows, uint64_t offset = 0)
843+
FilteredIndexPolicy(std::span<int64_t const> selection, int64_t rows, uint64_t offset = 0)
844844
: IndexPolicyBase{-1, offset},
845845
mSelectedRows(selection),
846846
mMaxSelection(selection.size()),
@@ -849,7 +849,7 @@ struct FilteredIndexPolicy : IndexPolicyBase {
849849
this->setCursor(0);
850850
}
851851

852-
void resetSelection(gsl::span<int64_t const> selection)
852+
void resetSelection(std::span<int64_t const> selection)
853853
{
854854
mSelectedRows = selection;
855855
mMaxSelection = selection.size();
@@ -933,7 +933,7 @@ struct FilteredIndexPolicy : IndexPolicyBase {
933933
{
934934
this->mRowIndex = O2_BUILTIN_LIKELY(mSelectionRow < mMaxSelection) ? mSelectedRows[mSelectionRow] : -1;
935935
}
936-
gsl::span<int64_t const> mSelectedRows;
936+
std::span<int64_t const> mSelectedRows;
937937
int64_t mSelectionRow = 0;
938938
int64_t mMaxSelection = 0;
939939
int64_t nRows = 0;
@@ -1417,7 +1417,7 @@ struct PreslicePolicyGeneral : public PreslicePolicyBase {
14171417
void updateSliceInfo(SliceInfoUnsortedPtr&& si);
14181418

14191419
SliceInfoUnsortedPtr sliceInfo;
1420-
gsl::span<const int64_t> getSliceFor(int value) const;
1420+
std::span<const int64_t> getSliceFor(int value) const;
14211421
};
14221422

14231423
template <typename T, typename Policy, bool OPT = false>
@@ -1442,7 +1442,7 @@ struct PresliceBase : public Policy {
14421442
return Policy::getSliceFor(value, input, offset);
14431443
}
14441444

1445-
gsl::span<const int64_t> getSliceFor(int value) const
1445+
std::span<const int64_t> getSliceFor(int value) const
14461446
{
14471447
if constexpr (OPT) {
14481448
if (Policy::isMissing()) {
@@ -1520,7 +1520,7 @@ auto doSliceBy(T const* table, o2::framework::PresliceBase<C, Policy, OPT> const
15201520
}
15211521

15221522
template <soa::is_filtered_table T>
1523-
auto doSliceByHelper(T const* table, gsl::span<const int64_t> const& selection)
1523+
auto doSliceByHelper(T const* table, std::span<const int64_t> const& selection)
15241524
{
15251525
auto t = soa::Filtered<typename T::base_t>({table->asArrowTable()}, selection);
15261526
table->copyIndexBindings(t);
@@ -1531,7 +1531,7 @@ auto doSliceByHelper(T const* table, gsl::span<const int64_t> const& selection)
15311531

15321532
template <soa::is_table T>
15331533
requires(!soa::is_filtered_table<T>)
1534-
auto doSliceByHelper(T const* table, gsl::span<const int64_t> const& selection)
1534+
auto doSliceByHelper(T const* table, std::span<const int64_t> const& selection)
15351535
{
15361536
auto t = soa::Filtered<T>({table->asArrowTable()}, selection);
15371537
table->copyIndexBindings(t);
@@ -1552,7 +1552,7 @@ auto doSliceBy(T const* table, o2::framework::PresliceBase<C, Policy, OPT> const
15521552
return doSliceByHelper(table, selection);
15531553
}
15541554

1555-
SelectionVector sliceSelection(gsl::span<int64_t const> const& mSelectedRows, int64_t nrows, uint64_t offset);
1555+
SelectionVector sliceSelection(std::span<int64_t const> const& mSelectedRows, int64_t nrows, uint64_t offset);
15561556

15571557
template <soa::is_filtered_table T>
15581558
auto prepareFilteredSlice(T const* table, std::shared_ptr<arrow::Table> slice, uint64_t offset)
@@ -1982,7 +1982,7 @@ class Table
19821982
return RowViewSentinel{mEnd};
19831983
}
19841984

1985-
filtered_iterator filtered_begin(gsl::span<int64_t const> selection)
1985+
filtered_iterator filtered_begin(std::span<int64_t const> selection)
19861986
{
19871987
// Note that the FilteredIndexPolicy will never outlive the selection which
19881988
// is held by the table, so we are safe passing the bare pointer. If it does it
@@ -2561,12 +2561,12 @@ consteval auto getIndexTargets()
25612561
_Name_##Ids(_Name_##Ids const& other) = default; \
25622562
_Name_##Ids& operator=(_Name_##Ids const& other) = default; \
25632563
\
2564-
gsl::span<const _Type_> inline getIds() const \
2564+
std::span<const _Type_> inline getIds() const \
25652565
{ \
25662566
return _Getter_##Ids(); \
25672567
} \
25682568
\
2569-
gsl::span<const _Type_> _Getter_##Ids() const \
2569+
std::span<const _Type_> _Getter_##Ids() const \
25702570
{ \
25712571
return *mColumnIterator; \
25722572
} \
@@ -2918,12 +2918,12 @@ consteval auto getIndexTargets()
29182918
_Name_##Ids() = default; \
29192919
_Name_##Ids(_Name_##Ids const& other) = default; \
29202920
_Name_##Ids& operator=(_Name_##Ids const& other) = default; \
2921-
gsl::span<const _Type_> inline getIds() const \
2921+
std::span<const _Type_> inline getIds() const \
29222922
{ \
29232923
return _Getter_##Ids(); \
29242924
} \
29252925
\
2926-
gsl::span<const _Type_> _Getter_##Ids() const \
2926+
std::span<const _Type_> _Getter_##Ids() const \
29272927
{ \
29282928
return *mColumnIterator; \
29292929
} \
@@ -3373,15 +3373,15 @@ class FilteredBase : public T
33733373
mSelectedRowsCache{std::move(selection)},
33743374
mCached{true}
33753375
{
3376-
mSelectedRows = gsl::span{mSelectedRowsCache};
3376+
mSelectedRows = std::span{mSelectedRowsCache};
33773377
if (this->tableSize() != 0) {
33783378
mFilteredBegin = table_t::filtered_begin(mSelectedRows);
33793379
}
33803380
resetRanges();
33813381
mFilteredBegin.bindInternalIndices(this);
33823382
}
33833383

3384-
FilteredBase(std::vector<std::shared_ptr<arrow::Table>>&& tables, gsl::span<int64_t const> const& selection, uint64_t offset = 0)
3384+
FilteredBase(std::vector<std::shared_ptr<arrow::Table>>&& tables, std::span<int64_t const> const& selection, uint64_t offset = 0)
33853385
: T{std::move(tables), offset},
33863386
mSelectedRows{selection}
33873387
{
@@ -3460,12 +3460,12 @@ class FilteredBase : public T
34603460
static inline auto getSpan(gandiva::Selection const& sel)
34613461
{
34623462
if (sel == nullptr) {
3463-
return gsl::span<int64_t const>{};
3463+
return std::span<int64_t const>{};
34643464
}
34653465
auto array = std::static_pointer_cast<arrow::Int64Array>(sel->ToArray());
34663466
auto start = array->raw_values();
34673467
auto stop = start + array->length();
3468-
return gsl::span{start, stop};
3468+
return std::span{start, stop};
34693469
}
34703470

34713471
/// Bind the columns which refer to other tables
@@ -3564,7 +3564,7 @@ class FilteredBase : public T
35643564
resetRanges();
35653565
}
35663566

3567-
void sumWithSelection(gsl::span<int64_t const> const& selection)
3567+
void sumWithSelection(std::span<int64_t const> const& selection)
35683568
{
35693569
mCached = true;
35703570
SelectionVector rowsUnion;
@@ -3574,7 +3574,7 @@ class FilteredBase : public T
35743574
resetRanges();
35753575
}
35763576

3577-
void intersectWithSelection(gsl::span<int64_t const> const& selection)
3577+
void intersectWithSelection(std::span<int64_t const> const& selection)
35783578
{
35793579
mCached = true;
35803580
SelectionVector intersection;
@@ -3593,7 +3593,7 @@ class FilteredBase : public T
35933593
void resetRanges()
35943594
{
35953595
if (mCached) {
3596-
mSelectedRows = gsl::span{mSelectedRowsCache};
3596+
mSelectedRows = std::span{mSelectedRowsCache};
35973597
}
35983598
mFilteredEnd.reset(new RowViewSentinel{static_cast<int64_t>(mSelectedRows.size())});
35993599
if (tableSize() == 0) {
@@ -3603,7 +3603,7 @@ class FilteredBase : public T
36033603
}
36043604
}
36053605

3606-
gsl::span<int64_t const> mSelectedRows;
3606+
std::span<int64_t const> mSelectedRows;
36073607
SelectionVector mSelectedRowsCache;
36083608
bool mCached = false;
36093609
iterator mFilteredBegin;
@@ -3639,7 +3639,7 @@ class Filtered : public FilteredBase<T>
36393639
Filtered(std::vector<std::shared_ptr<arrow::Table>>&& tables, SelectionVector&& selection, uint64_t offset = 0)
36403640
: FilteredBase<T>(std::move(tables), std::forward<SelectionVector>(selection), offset) {}
36413641

3642-
Filtered(std::vector<std::shared_ptr<arrow::Table>>&& tables, gsl::span<int64_t const> const& selection, uint64_t offset = 0)
3642+
Filtered(std::vector<std::shared_ptr<arrow::Table>>&& tables, std::span<int64_t const> const& selection, uint64_t offset = 0)
36433643
: FilteredBase<T>(std::move(tables), selection, offset) {}
36443644

36453645
Filtered<T> operator+(SelectionVector const& selection)
@@ -3649,7 +3649,7 @@ class Filtered : public FilteredBase<T>
36493649
return copy;
36503650
}
36513651

3652-
Filtered<T> operator+(gsl::span<int64_t const> const& selection)
3652+
Filtered<T> operator+(std::span<int64_t const> const& selection)
36533653
{
36543654
Filtered<T> copy(*this);
36553655
copy.sumWithSelection(selection);
@@ -3667,7 +3667,7 @@ class Filtered : public FilteredBase<T>
36673667
return *this;
36683668
}
36693669

3670-
Filtered<T> operator+=(gsl::span<int64_t const> const& selection)
3670+
Filtered<T> operator+=(std::span<int64_t const> const& selection)
36713671
{
36723672
this->sumWithSelection(selection);
36733673
return *this;
@@ -3685,7 +3685,7 @@ class Filtered : public FilteredBase<T>
36853685
return copy;
36863686
}
36873687

3688-
Filtered<T> operator*(gsl::span<int64_t const> const& selection)
3688+
Filtered<T> operator*(std::span<int64_t const> const& selection)
36893689
{
36903690
Filtered<T> copy(*this);
36913691
copy.intersectWithSelection(selection);
@@ -3703,7 +3703,7 @@ class Filtered : public FilteredBase<T>
37033703
return *this;
37043704
}
37053705

3706-
Filtered<T> operator*=(gsl::span<int64_t const> const& selection)
3706+
Filtered<T> operator*=(std::span<int64_t const> const& selection)
37073707
{
37083708
this->intersectWithSelection(selection);
37093709
return *this;
@@ -3811,7 +3811,7 @@ class Filtered<Filtered<T>> : public FilteredBase<typename T::table_t>
38113811
}
38123812
}
38133813

3814-
Filtered(std::vector<Filtered<T>>&& tables, gsl::span<int64_t const> const& selection, uint64_t offset = 0)
3814+
Filtered(std::vector<Filtered<T>>&& tables, std::span<int64_t const> const& selection, uint64_t offset = 0)
38153815
: FilteredBase<typename T::table_t>(std::move(extractTablesFromFiltered(tables)), selection, offset)
38163816
{
38173817
for (auto& table : tables) {
@@ -3826,7 +3826,7 @@ class Filtered<Filtered<T>> : public FilteredBase<typename T::table_t>
38263826
return copy;
38273827
}
38283828

3829-
Filtered<Filtered<T>> operator+(gsl::span<int64_t const> const& selection)
3829+
Filtered<Filtered<T>> operator+(std::span<int64_t const> const& selection)
38303830
{
38313831
Filtered<Filtered<T>> copy(*this);
38323832
copy.sumWithSelection(selection);
@@ -3844,7 +3844,7 @@ class Filtered<Filtered<T>> : public FilteredBase<typename T::table_t>
38443844
return *this;
38453845
}
38463846

3847-
Filtered<Filtered<T>> operator+=(gsl::span<int64_t const> const& selection)
3847+
Filtered<Filtered<T>> operator+=(std::span<int64_t const> const& selection)
38483848
{
38493849
this->sumWithSelection(selection);
38503850
return *this;
@@ -3862,7 +3862,7 @@ class Filtered<Filtered<T>> : public FilteredBase<typename T::table_t>
38623862
return copy;
38633863
}
38643864

3865-
Filtered<Filtered<T>> operator*(gsl::span<int64_t const> const& selection)
3865+
Filtered<Filtered<T>> operator*(std::span<int64_t const> const& selection)
38663866
{
38673867
Filtered<Filtered<T>> copy(*this);
38683868
copy.intersectionWithSelection(selection);
@@ -3880,7 +3880,7 @@ class Filtered<Filtered<T>> : public FilteredBase<typename T::table_t>
38803880
return *this;
38813881
}
38823882

3883-
Filtered<Filtered<T>> operator*=(gsl::span<int64_t const> const& selection)
3883+
Filtered<Filtered<T>> operator*=(std::span<int64_t const> const& selection)
38843884
{
38853885
this->intersectWithSelection(selection);
38863886
return *this;
@@ -3989,7 +3989,7 @@ struct SmallGroupsBase : public Filtered<T> {
39893989
SmallGroupsBase(std::vector<std::shared_ptr<arrow::Table>>&& tables, SelectionVector&& selection, uint64_t offset = 0)
39903990
: Filtered<T>(std::move(tables), std::forward<SelectionVector>(selection), offset) {}
39913991

3992-
SmallGroupsBase(std::vector<std::shared_ptr<arrow::Table>>&& tables, gsl::span<int64_t const> const& selection, uint64_t offset = 0)
3992+
SmallGroupsBase(std::vector<std::shared_ptr<arrow::Table>>&& tables, std::span<int64_t const> const& selection, uint64_t offset = 0)
39933993
: Filtered<T>(std::move(tables), selection, offset) {}
39943994
};
39953995

Framework/Core/include/Framework/AnalysisHelpers.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,16 +119,19 @@ class TableConsumer;
119119
template <typename T>
120120
concept is_producable = soa::has_metadata<aod::MetadataTrait<T>> || soa::has_metadata<aod::MetadataTrait<typename T::parent_t>>;
121121

122+
template <typename T>
123+
concept is_enumerated_iterator = requires (T t) { t.globalIndex(); };
124+
122125
template <is_producable T>
123126
struct WritingCursor {
124127
public:
125128
using persistent_table_t = decltype([]() { if constexpr (soa::is_iterator<T>) { return typename T::parent_t{nullptr}; } else { return T{nullptr}; } }());
126129
using cursor_t = decltype(std::declval<TableBuilder>().cursor<persistent_table_t>());
127130

128131
template <typename... Ts>
129-
void operator()(Ts... args)
132+
void operator()(Ts&&... args)
133+
requires(sizeof...(Ts) == framework::pack_size(typename persistent_table_t::persistent_columns_t{}))
130134
{
131-
static_assert(sizeof...(Ts) == framework::pack_size(typename persistent_table_t::persistent_columns_t{}), "Argument number mismatch");
132135
++mCount;
133136
cursor(0, extract(args)...);
134137
}
@@ -167,15 +170,15 @@ struct WritingCursor {
167170
decltype(FFL(std::declval<cursor_t>())) cursor;
168171

169172
private:
170-
template <typename A>
171-
requires requires { &A::globalIndex; }
173+
template <is_enumerated_iterator A>
172174
static decltype(auto) extract(A const& arg)
173175
{
174176
return arg.globalIndex();
175177
}
176178

177179
template <typename A>
178-
static decltype(auto) extract(A const& arg)
180+
requires(!is_enumerated_iterator<A>)
181+
static decltype(auto) extract(A&& arg)
179182
{
180183
return arg;
181184
}

Framework/Core/include/Framework/ArrowTableSlicingCache.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ namespace o2::framework
2121
using ListVector = std::vector<std::vector<int64_t>>;
2222

2323
struct SliceInfoPtr {
24-
gsl::span<int const> values;
25-
gsl::span<int64_t const> counts;
24+
std::span<int const> values;
25+
std::span<int64_t const> counts;
2626

2727
std::pair<int64_t, int64_t> getSliceFor(int value) const;
2828
};
2929

3030
struct SliceInfoUnsortedPtr {
31-
gsl::span<int const> values;
31+
std::span<int const> values;
3232
ListVector const* groups;
3333

34-
gsl::span<int64_t const> getSliceFor(int value) const;
34+
std::span<int64_t const> getSliceFor(int value) const;
3535
};
3636

3737
struct Entry {

Framework/Core/include/Framework/GroupSlicer.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,9 @@ struct GroupSlicer {
266266
std::tuple<A...>* mAt;
267267
typename grouping_t::iterator mGroupingElement;
268268
uint64_t position = 0;
269-
gsl::span<int64_t const> groupSelection;
270-
std::array<gsl::span<int64_t const> const*, sizeof...(A)> selections;
271-
std::array<gsl::span<int64_t const>::iterator, sizeof...(A)> starts;
269+
std::span<int64_t const> groupSelection;
270+
std::array<std::span<int64_t const> const*, sizeof...(A)> selections;
271+
std::array<std::span<int64_t const>::iterator, sizeof...(A)> starts;
272272

273273
std::array<SliceInfoPtr, sizeof...(A)> sliceInfos;
274274
std::array<SliceInfoUnsortedPtr, sizeof...(A)> sliceInfosUnsorted;

0 commit comments

Comments
 (0)