Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 31 additions & 31 deletions Framework/Core/include/Framework/ASoA.h
Original file line number Diff line number Diff line change
Expand Up @@ -561,21 +561,21 @@ class ColumnIterator : ChunkingPolicy
mLast = mCurrent + array->length() + (mFirstIndex >> SCALE_FACTOR);
}

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

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

decltype(auto) operator*() const
Expand Down Expand Up @@ -851,7 +851,7 @@ struct FilteredIndexPolicy : IndexPolicyBase {
// which happens below which will properly setup the first index
// by remapping the filtered index 0 to whatever unfiltered index
// it belongs to.
FilteredIndexPolicy(gsl::span<int64_t const> selection, int64_t rows, uint64_t offset = 0)
FilteredIndexPolicy(std::span<int64_t const> selection, int64_t rows, uint64_t offset = 0)
: IndexPolicyBase{-1, offset},
mSelectedRows(selection),
mMaxSelection(selection.size()),
Expand All @@ -860,7 +860,7 @@ struct FilteredIndexPolicy : IndexPolicyBase {
this->setCursor(0);
}

void resetSelection(gsl::span<int64_t const> selection)
void resetSelection(std::span<int64_t const> selection)
{
mSelectedRows = selection;
mMaxSelection = selection.size();
Expand Down Expand Up @@ -944,7 +944,7 @@ struct FilteredIndexPolicy : IndexPolicyBase {
{
this->mRowIndex = O2_BUILTIN_LIKELY(mSelectionRow < mMaxSelection) ? mSelectedRows[mSelectionRow] : -1;
}
gsl::span<int64_t const> mSelectedRows;
std::span<int64_t const> mSelectedRows;
int64_t mSelectionRow = 0;
int64_t mMaxSelection = 0;
int64_t nRows = 0;
Expand Down Expand Up @@ -1428,7 +1428,7 @@ struct PreslicePolicyGeneral : public PreslicePolicyBase {
void updateSliceInfo(SliceInfoUnsortedPtr&& si);

SliceInfoUnsortedPtr sliceInfo;
gsl::span<const int64_t> getSliceFor(int value) const;
std::span<const int64_t> getSliceFor(int value) const;
};

template <typename T, typename Policy, bool OPT = false>
Expand All @@ -1453,7 +1453,7 @@ struct PresliceBase : public Policy {
return Policy::getSliceFor(value, input, offset);
}

gsl::span<const int64_t> getSliceFor(int value) const
std::span<const int64_t> getSliceFor(int value) const
{
if constexpr (OPT) {
if (Policy::isMissing()) {
Expand Down Expand Up @@ -1549,7 +1549,7 @@ auto doSliceBy(T const* table, o2::framework::PresliceBase<C, Policy, OPT> const
}

template <soa::is_filtered_table T>
auto doSliceByHelper(T const* table, gsl::span<const int64_t> const& selection)
auto doSliceByHelper(T const* table, std::span<const int64_t> const& selection)
{
auto t = soa::Filtered<typename T::base_t>({table->asArrowTable()}, selection);
table->copyIndexBindings(t);
Expand All @@ -1560,7 +1560,7 @@ auto doSliceByHelper(T const* table, gsl::span<const int64_t> const& selection)

template <soa::is_table T>
requires(!soa::is_filtered_table<T>)
auto doSliceByHelper(T const* table, gsl::span<const int64_t> const& selection)
auto doSliceByHelper(T const* table, std::span<const int64_t> const& selection)
{
auto t = soa::Filtered<T>({table->asArrowTable()}, selection);
table->copyIndexBindings(t);
Expand All @@ -1581,7 +1581,7 @@ auto doSliceBy(T const* table, o2::framework::PresliceBase<C, Policy, OPT> const
return doSliceByHelper(table, selection);
}

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

template <soa::is_filtered_table T>
auto prepareFilteredSlice(T const* table, std::shared_ptr<arrow::Table> slice, uint64_t offset)
Expand Down Expand Up @@ -2011,7 +2011,7 @@ class Table
return RowViewSentinel{mEnd};
}

filtered_iterator filtered_begin(gsl::span<int64_t const> selection)
filtered_iterator filtered_begin(std::span<int64_t const> selection)
{
// Note that the FilteredIndexPolicy will never outlive the selection which
// is held by the table, so we are safe passing the bare pointer. If it does it
Expand Down Expand Up @@ -3371,15 +3371,15 @@ class FilteredBase : public T
mSelectedRowsCache{std::move(selection)},
mCached{true}
{
mSelectedRows = gsl::span{mSelectedRowsCache};
mSelectedRows = std::span{mSelectedRowsCache};
if (this->tableSize() != 0) {
mFilteredBegin = table_t::filtered_begin(mSelectedRows);
}
resetRanges();
mFilteredBegin.bindInternalIndices(this);
}

FilteredBase(std::vector<std::shared_ptr<arrow::Table>>&& tables, gsl::span<int64_t const> const& selection, uint64_t offset = 0)
FilteredBase(std::vector<std::shared_ptr<arrow::Table>>&& tables, std::span<int64_t const> const& selection, uint64_t offset = 0)
: T{std::move(tables), offset},
mSelectedRows{selection}
{
Expand Down Expand Up @@ -3458,12 +3458,12 @@ class FilteredBase : public T
static inline auto getSpan(gandiva::Selection const& sel)
{
if (sel == nullptr) {
return gsl::span<int64_t const>{};
return std::span<int64_t const>{};
}
auto array = std::static_pointer_cast<arrow::Int64Array>(sel->ToArray());
auto start = array->raw_values();
auto stop = start + array->length();
return gsl::span{start, stop};
return std::span{start, stop};
}

/// Bind the columns which refer to other tables
Expand Down Expand Up @@ -3562,7 +3562,7 @@ class FilteredBase : public T
resetRanges();
}

void sumWithSelection(gsl::span<int64_t const> const& selection)
void sumWithSelection(std::span<int64_t const> const& selection)
{
mCached = true;
SelectionVector rowsUnion;
Expand All @@ -3572,7 +3572,7 @@ class FilteredBase : public T
resetRanges();
}

void intersectWithSelection(gsl::span<int64_t const> const& selection)
void intersectWithSelection(std::span<int64_t const> const& selection)
{
mCached = true;
SelectionVector intersection;
Expand All @@ -3591,7 +3591,7 @@ class FilteredBase : public T
void resetRanges()
{
if (mCached) {
mSelectedRows = gsl::span{mSelectedRowsCache};
mSelectedRows = std::span{mSelectedRowsCache};
}
mFilteredEnd.reset(new RowViewSentinel{static_cast<int64_t>(mSelectedRows.size())});
if (tableSize() == 0) {
Expand All @@ -3601,7 +3601,7 @@ class FilteredBase : public T
}
}

gsl::span<int64_t const> mSelectedRows;
std::span<int64_t const> mSelectedRows;
SelectionVector mSelectedRowsCache;
bool mCached = false;
iterator mFilteredBegin;
Expand Down Expand Up @@ -3637,7 +3637,7 @@ class Filtered : public FilteredBase<T>
Filtered(std::vector<std::shared_ptr<arrow::Table>>&& tables, SelectionVector&& selection, uint64_t offset = 0)
: FilteredBase<T>(std::move(tables), std::forward<SelectionVector>(selection), offset) {}

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

Filtered<T> operator+(SelectionVector const& selection)
Expand All @@ -3647,7 +3647,7 @@ class Filtered : public FilteredBase<T>
return copy;
}

Filtered<T> operator+(gsl::span<int64_t const> const& selection)
Filtered<T> operator+(std::span<int64_t const> const& selection)
{
Filtered<T> copy(*this);
copy.sumWithSelection(selection);
Expand All @@ -3665,7 +3665,7 @@ class Filtered : public FilteredBase<T>
return *this;
}

Filtered<T> operator+=(gsl::span<int64_t const> const& selection)
Filtered<T> operator+=(std::span<int64_t const> const& selection)
{
this->sumWithSelection(selection);
return *this;
Expand All @@ -3683,7 +3683,7 @@ class Filtered : public FilteredBase<T>
return copy;
}

Filtered<T> operator*(gsl::span<int64_t const> const& selection)
Filtered<T> operator*(std::span<int64_t const> const& selection)
{
Filtered<T> copy(*this);
copy.intersectWithSelection(selection);
Expand All @@ -3701,7 +3701,7 @@ class Filtered : public FilteredBase<T>
return *this;
}

Filtered<T> operator*=(gsl::span<int64_t const> const& selection)
Filtered<T> operator*=(std::span<int64_t const> const& selection)
{
this->intersectWithSelection(selection);
return *this;
Expand Down Expand Up @@ -3809,7 +3809,7 @@ class Filtered<Filtered<T>> : public FilteredBase<typename T::table_t>
}
}

Filtered(std::vector<Filtered<T>>&& tables, gsl::span<int64_t const> const& selection, uint64_t offset = 0)
Filtered(std::vector<Filtered<T>>&& tables, std::span<int64_t const> const& selection, uint64_t offset = 0)
: FilteredBase<typename T::table_t>(std::move(extractTablesFromFiltered(tables)), selection, offset)
{
for (auto& table : tables) {
Expand All @@ -3824,7 +3824,7 @@ class Filtered<Filtered<T>> : public FilteredBase<typename T::table_t>
return copy;
}

Filtered<Filtered<T>> operator+(gsl::span<int64_t const> const& selection)
Filtered<Filtered<T>> operator+(std::span<int64_t const> const& selection)
{
Filtered<Filtered<T>> copy(*this);
copy.sumWithSelection(selection);
Expand All @@ -3842,7 +3842,7 @@ class Filtered<Filtered<T>> : public FilteredBase<typename T::table_t>
return *this;
}

Filtered<Filtered<T>> operator+=(gsl::span<int64_t const> const& selection)
Filtered<Filtered<T>> operator+=(std::span<int64_t const> const& selection)
{
this->sumWithSelection(selection);
return *this;
Expand All @@ -3860,7 +3860,7 @@ class Filtered<Filtered<T>> : public FilteredBase<typename T::table_t>
return copy;
}

Filtered<Filtered<T>> operator*(gsl::span<int64_t const> const& selection)
Filtered<Filtered<T>> operator*(std::span<int64_t const> const& selection)
{
Filtered<Filtered<T>> copy(*this);
copy.intersectionWithSelection(selection);
Expand All @@ -3878,7 +3878,7 @@ class Filtered<Filtered<T>> : public FilteredBase<typename T::table_t>
return *this;
}

Filtered<Filtered<T>> operator*=(gsl::span<int64_t const> const& selection)
Filtered<Filtered<T>> operator*=(std::span<int64_t const> const& selection)
{
this->intersectWithSelection(selection);
return *this;
Expand Down Expand Up @@ -3987,7 +3987,7 @@ struct SmallGroupsBase : public Filtered<T> {
SmallGroupsBase(std::vector<std::shared_ptr<arrow::Table>>&& tables, SelectionVector&& selection, uint64_t offset = 0)
: Filtered<T>(std::move(tables), std::forward<SelectionVector>(selection), offset) {}

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

Expand Down
14 changes: 8 additions & 6 deletions Framework/Core/include/Framework/AnalysisHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,19 @@ class TableConsumer;
template <typename T>
concept is_producable = soa::has_metadata<aod::MetadataTrait<T>> || soa::has_metadata<aod::MetadataTrait<typename T::parent_t>>;

template <typename T>
concept is_enumerated_iterator = requires(T t) { t.globalIndex(); };

template <is_producable T>
struct WritingCursor {
public:
using persistent_table_t = decltype([]() { if constexpr (soa::is_iterator<T>) { return typename T::parent_t{nullptr}; } else { return T{nullptr}; } }());
using cursor_t = decltype(std::declval<TableBuilder>().cursor<persistent_table_t>());

template <typename... Ts>
void operator()(Ts... args)
void operator()(Ts&&... args)
requires(sizeof...(Ts) == framework::pack_size(typename persistent_table_t::persistent_columns_t{}))
{
static_assert(sizeof...(Ts) == framework::pack_size(typename persistent_table_t::persistent_columns_t{}), "Argument number mismatch");
++mCount;
cursor(0, extract(args)...);
}
Expand Down Expand Up @@ -167,15 +170,14 @@ struct WritingCursor {
decltype(FFL(std::declval<cursor_t>())) cursor;

private:
template <typename A>
requires requires { &A::globalIndex; }
static decltype(auto) extract(A const& arg)
static decltype(auto) extract(is_enumerated_iterator auto const& arg)
{
return arg.globalIndex();
}

template <typename A>
static decltype(auto) extract(A const& arg)
requires(!is_enumerated_iterator<A>)
static decltype(auto) extract(A&& arg)
{
return arg;
}
Expand Down
4 changes: 2 additions & 2 deletions Framework/Core/include/Framework/ArrowTableSlicingCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ struct SliceInfoPtr {
};

struct SliceInfoUnsortedPtr {
gsl::span<int const> values;
std::span<int const> values;
ListVector const* groups;

gsl::span<int64_t const> getSliceFor(int value) const;
std::span<int64_t const> getSliceFor(int value) const;
};

struct Entry {
Expand Down
6 changes: 3 additions & 3 deletions Framework/Core/include/Framework/GroupSlicer.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,9 @@ struct GroupSlicer {
std::tuple<A...>* mAt;
typename grouping_t::iterator mGroupingElement;
uint64_t position = 0;
gsl::span<int64_t const> groupSelection;
std::array<gsl::span<int64_t const> const*, sizeof...(A)> selections;
std::array<gsl::span<int64_t const>::iterator, sizeof...(A)> starts;
std::span<int64_t const> groupSelection;
std::array<std::span<int64_t const> const*, sizeof...(A)> selections;
std::array<std::span<int64_t const>::iterator, sizeof...(A)> starts;

std::array<SliceInfoPtr, sizeof...(A)> sliceInfos;
std::array<SliceInfoUnsortedPtr, sizeof...(A)> sliceInfosUnsorted;
Expand Down
Loading