12#ifndef O2_FRAMEWORK_ASOA_H_
13#define O2_FRAMEWORK_ASOA_H_
26#include <arrow/table.h>
27#include <arrow/array.h>
28#include <arrow/util/config.h>
29#include <gandiva/selection_vector.h>
32#include <fmt/format.h>
41using ListVector = std::vector<std::vector<int64_t>>;
66 consteval TableRef(uint32_t _label, uint32_t _desc, uint32_t _origin, uint32_t _version)
80 return (this->label_hash ==
other.label_hash) &&
81 (this->desc_hash ==
other.desc_hash) &&
82 (this->origin_hash ==
other.origin_hash) &&
83 (this->version ==
other.version);
88 return this->desc_hash ==
other.desc_hash;
93 return this->desc_hash == _desc_hash;
103template <
size_t N1,
size_t N2, std::array<TableRef, N1> ar1, std::array<TableRef, N2> ar2>
106 constexpr const int duplicates = std::ranges::count_if(ar2.begin(), ar2.end(), [&](
TableRef const&
a) { return std::any_of(ar1.begin(), ar1.end(), [&](TableRef const& e) { return e == a; }); });
107 std::array<TableRef, N1 + N2 - duplicates> out;
109 auto pos = std::copy(ar1.begin(), ar1.end(), out.begin());
110 std::copy_if(ar2.begin(), ar2.end(),
pos, [&](TableRef
const&
a) { return std::none_of(ar1.begin(), ar1.end(), [&](TableRef const& e) { return e == a; }); });
114template <
size_t N1,
size_t N2, std::array<TableRef, N1> ar1, std::array<TableRef, N2> ar2,
typename L>
117 constexpr const int to_remove = std::ranges::count_if(ar1.begin(), ar1.end(), [&](
TableRef const&
a) { return !l(a); });
118 constexpr const int duplicates = std::ranges::count_if(ar2.begin(), ar2.end(), [&](
TableRef const&
a) { return std::any_of(ar1.begin(), ar1.end(), [&](TableRef const& e) { return e == a; }) || !l(
a); });
119 std::array<TableRef, N1 + N2 - duplicates - to_remove> out;
121 auto pos = std::copy_if(ar1.begin(), ar1.end(), out.begin(), [&](TableRef
const&
a) { return l(a); });
122 std::copy_if(ar2.begin(), ar2.end(),
pos, [&](TableRef
const&
a) { return std::none_of(ar1.begin(), ar1.end(), [&](TableRef const& e) { return e == a; }) && l(
a); });
126template <
size_t N, std::array<TableRef, N> ar,
typename L>
129 constexpr const int to_remove = std::ranges::count_if(ar.begin(), ar.end(), [&l](
TableRef const& e) { return l(e); });
130 std::array<
TableRef, N - to_remove> out;
131 std::copy_if(ar.begin(), ar.end(), out.begin(), [&l](
TableRef const& e) { return !l(e); });
135template <
size_t N1,
size_t N2, std::array<TableRef, N1> ar1, std::array<TableRef, N2> ar2>
136consteval auto intersect()
138 constexpr const int duplicates = std::ranges::count_if(ar2.begin(), ar2.end(), [&](
TableRef const&
a) { return std::any_of(ar1.begin(), ar1.end(), [&](TableRef const& e) { return e == a; }); });
139 std::array<TableRef, duplicates> out;
140 std::copy_if(ar1.begin(), ar1.end(), out.begin(), [](TableRef
const&
a) { return std::find(ar2.begin(), ar2.end(), a) != ar2.end(); });
144template <
typename T,
typename... Ts>
146 requires(
sizeof...(Ts) == 1)
149 return merge<T::originals.size(), T1::originals.size(), T::originals, T1::originals>();
152template <
typename T,
typename...
Ts>
154 requires(
sizeof...(Ts) > 1)
157 return merge<T::originals.size(), tail.size(), T::originals, tail>();
160template <
typename T,
typename...
Ts>
161 requires(
sizeof...(Ts) == 1)
162consteval auto intersectOriginals()
165 return intersect<T::originals.size(), T1::originals.size(), T::originals, T1::originals>();
168template <
typename T,
typename...
Ts>
169 requires(
sizeof...(Ts) > 1)
170consteval auto intersectOriginals()
173 return intersect<T::originals.size(), tail.size(), T::originals, tail>();
182concept not_void =
requires { !std::same_as<T, void>; };
199 {
c.setCurrentRaw(
b) } -> std::same_as<bool>;
204using is_external_index_t =
typename std::conditional_t<is_index_column<C>, std::true_type, std::false_type>;
207using is_self_index_t =
typename std::conditional_t<is_self_index_column<C>, std::true_type, std::false_type>;
213template <
typename D,
typename... Cs>
220 template <
typename Key,
typename... PCs>
223 return std::array<bool,
sizeof...(PCs)>{[]() {
224 if constexpr (
requires { PCs::index_targets.size(); }) {
225 return Key::template isIndexTargetOf<PCs::index_targets.size(), PCs::index_targets>();
232 template <
typename Key>
238 template <
typename Key,
size_t N, std::array<
bool, N> map>
241 constexpr const auto pos = std::find(map.begin(), map.end(),
true);
242 if constexpr (
pos != map.end()) {
243 return std::distance(map.begin(),
pos);
259 static constexpr uint32_t
hash = H;
260 static constexpr char const*
const str{
""};
264template <
size_t N, std::array<soa::TableRef, N> ar,
typename Key>
267 constexpr std::array<bool, N>
test = []<
size_t... Is>(std::index_sequence<Is...>) {
268 return std::array<bool, N>{(Key::template hasOriginal<ar[Is]>() || (
o2::aod::MetadataTrait<
o2::aod::Hash<ar[Is].desc_hash>>::metadata::template getIndexPosToKey<Key>() >= 0))...};
269 }(std::make_index_sequence<N>());
270 constexpr int correct = std::ranges::count(
test.begin(),
test.end(),
true);
271 std::array<soa::TableRef, correct> out;
272 std::ranges::copy_if(ar.begin(), ar.end(), out.begin(), [&
test](
soa::TableRef const&
r) { return test[std::distance(ar.begin(), std::find(ar.begin(), ar.end(), r))]; });
277#define O2HASH(_Str_) \
279 struct Hash<_Str_ ""_h> { \
280 static constexpr uint32_t hash = _Str_ ""_h; \
281 static constexpr char const* const str{_Str_}; \
285#define O2ORIGIN(_Str_) \
287 struct Hash<_Str_ ""_h> { \
288 static constexpr header::DataOrigin origin{_Str_}; \
289 static constexpr uint32_t hash = _Str_ ""_h; \
290 static constexpr char const* const str{_Str_}; \
294static inline constexpr uint32_t
version(
const char*
const str)
296 if (
str[0] ==
'\0') {
304 if (
str[
len - 1] ==
'\0') {
307 for (
auto i =
len + 1;
str[
i] !=
'\0'; ++
i) {
314static inline constexpr std::string_view description_str(
const char*
const str)
320 return std::string_view{
str,
len};
330 for (
auto i = 0;
i < 16; ++
i) {
333 std::memcpy(out,
str,
len);
338template <soa::TableRef R>
344template <soa::TableRef R>
350template <soa::TableRef R>
356template <soa::TableRef R>
370template <soa::TableRef R>
371static constexpr auto sourceSpec()
373 return fmt::format(
"{}/{}/{}/{}",
label<R>(), origin_str<R>(), description_str(signature<R>()),
R.version);
379template <aod::is_aod_hash L, aod::is_aod_hash D, aod::is_origin_hash O,
typename... Ts>
384 void const*
ptr =
nullptr;
386 std::span<TableRef const>
refs;
388 template <
typename T>
392 hash = o2::framework::TypeIdHelpers::uniqueId<T>();
393 refs = std::span{T::originals};
396 template <
typename T>
399 if (
hash == o2::framework::TypeIdHelpers::uniqueId<T>()) {
400 return static_cast<T const*
>(
ptr);
406template <
typename... C>
409 return std::vector<std::shared_ptr<arrow::Field>>{C::asArrowField()...};
435template <
typename B,
typename E>
437 constexpr static bool value =
false;
440template <aod::is_aod_hash A, aod::is_aod_hash B>
442 constexpr static bool value =
false;
445template <
typename B,
typename E>
448template <aod::is_aod_hash A, aod::is_aod_hash B>
487template <
typename T,
typename ChunkingPolicy = Chunked>
490 static constexpr char SCALE_FACTOR = std::same_as<std::decay_t<T>,
bool> ? 3 : 0;
506 auto array = getCurrentArray();
521 auto previousArray = getCurrentArray();
525 auto array = getCurrentArray();
532 auto previousArray = getCurrentArray();
536 auto array = getCurrentArray();
558 auto array = getCurrentArray();
564 decltype(
auto)
operator*()
const
565 requires std::same_as<bool, std::decay_t<T>>
571 decltype(
auto)
operator*()
const
572 requires((!std::same_as<bool, std::decay_t<T>>) && std::same_as<
arrow_array_for_t<T>, arrow::ListArray>)
581 decltype(
auto)
operator*()
const
582 requires((!std::same_as<bool, std::decay_t<T>>) && !std::same_as<
arrow_array_for_t<T>, arrow::ListArray>)
604 void checkSkipChunk() const
613 void checkSkipChunk() const
621 void checkSkipChunk() const
622 requires(ChunkingPolicy::
chunked == false)
626 auto getCurrentArray() const
630 mOffset = chunkToUse->offset();
631 chunkToUse = std::dynamic_pointer_cast<arrow::FixedSizeListArray>(chunkToUse)->values();
632 return std::static_pointer_cast<arrow_array_for_t<value_for_t<T>>>(chunkToUse);
635 auto getCurrentArray() const
639 mOffset = chunkToUse->offset();
640 chunkToUse = std::dynamic_pointer_cast<arrow::ListArray>(chunkToUse)->values();
641 mOffset = chunkToUse->offset();
642 return std::static_pointer_cast<arrow_array_for_t<value_for_t<T>>>(chunkToUse);
645 auto getCurrentArray() const
649 mOffset = chunkToUse->offset();
650 return std::static_pointer_cast<arrow_array_for_t<T>>(chunkToUse);
654template <
typename T,
typename INHERIT>
670 static constexpr const char*
const&
columnLabel() {
return INHERIT::mLabel; }
688template <
typename F,
typename INHERIT>
692 static constexpr const char*
const&
columnLabel() {
return INHERIT::mLabel; }
695template <
typename INHERIT>
698 static constexpr const uint32_t
hash = 0;
700 static constexpr const char*
const&
columnLabel() {
return INHERIT::mLabel; }
703template <
typename INHERIT>
706 static constexpr const uint32_t
hash = 0;
708 static constexpr const char*
const&
columnLabel() {
return INHERIT::mLabel; }
711template <
size_t M = 0>
715 constexpr inline static auto value = M;
730 static constexpr const char*
mLabel =
"Marker";
733template <int64_t START = 0, int64_t
END = -1>
736 constexpr inline static int64_t
start = START;
737 constexpr inline static int64_t
end =
END;
797 static constexpr const char*
mLabel =
"Index";
821using is_dynamic_t = std::conditional_t<is_dynamic_column<T>, std::true_type, std::false_type>;
827using is_indexing_t = std::conditional_t<is_indexing_column<T>, std::true_type, std::false_type>;
848 mSelectedRows(selection),
849 mMaxSelection(selection.
size()),
857 mSelectedRows = selection;
858 mMaxSelection = selection.size();
868 [[nodiscard]] std::tuple<int64_t const*, int64_t const*>
871 return std::make_tuple(&
mRowIndex, &mSelectionRow);
874 [[nodiscard]] std::tuple<uint64_t const*>
877 return std::make_tuple(&
mOffset);
884 mMaxSelection = std::min(
end, mMaxSelection);
902 return lh.mSelectionRow == rh.mSelectionRow;
915 this->mSelectionRow = this->mMaxSelection;
921 return mSelectionRow;
924 [[nodiscard]]
auto size()
const
926 return mMaxSelection;
935 inline void updateRow()
939 gsl::span<int64_t const> mSelectedRows;
940 int64_t mSelectionRow = 0;
941 int64_t mMaxSelection = 0;
976 [[nodiscard]] std::tuple<int64_t const*, int64_t const*>
982 [[nodiscard]] std::tuple<uint64_t const*>
985 return std::make_tuple(&
mOffset);
1026template <
typename T>
1031template <
typename C>
1037template <
typename T,
typename B>
1039 { t.B::mColumnIterator };
1042template <
typename...
C>
1045template <
typename D,
typename O,
typename IP,
typename... C>
1073 this->limitRange(this->rangeStart(), this->rangeEnd());
1079 C(static_cast<
C const&>(
other))...
1086 IP::operator=(
static_cast<IP const&
>(
other));
1087 (
void(
static_cast<C&
>(*
this) =
static_cast<C>(
other)), ...);
1093 requires std::same_as<IP, DefaultIndexPolicy>
1095 C(
static_cast<C const&
>(
other))...
1102 this->moveByIndex(1);
1115 this->moveByIndex(-1);
1130 copy.moveByIndex(inc);
1144 template <
typename... CL,
typename TA>
1147 (CL::setCurrent(current), ...);
1150 template <
typename CL>
1153 return CL::getCurrentRaw();
1156 template <
typename... Cs>
1159 return std::vector<o2::soa::Binding>{
static_cast<Cs const&
>(*this).getCurrentRaw()...};
1167 template <
typename... TA>
1173 template <
typename... Cs>
1176 (Cs::setCurrentRaw(ptrs[framework::has_type_at_v<Cs>(p)]), ...);
1179 template <
typename... Cs,
typename I>
1184 (Cs::setCurrentRaw(
b), ...);
1192 template <
typename I>
1200 template <
typename... PC>
1203 (PC::mColumnIterator.moveToEnd(), ...);
1213 [
this]<soa::is_dynamic_column T>(T*) ->
void { bindDynamicColumn<T>(
typename T::bindings_t{}); },
1214 [
this]<
typename T>(
T*) ->
void {},
1216 (
f(
static_cast<C*
>(
nullptr)), ...);
1217 if constexpr (has_index<
C...>) {
1218 this->setIndices(this->getIndices());
1219 this->setOffsets(this->getOffsets());
1223 template <
typename DC,
typename...
B>
1226 DC::boundIterators = std::make_tuple(getDynamicBinding<B>()...);
1234 template <
typename B>
1235 requires(can_bind<self_t, B>)
1236 decltype(
auto) getDynamicBinding()
1238 static_assert(std::same_as<decltype(&(static_cast<B*>(
this)->mColumnIterator)), std::decay_t<
decltype(B::mColumnIterator)>*>,
"foo");
1239 return &(
static_cast<B*
>(
this)->mColumnIterator);
1243 template <
typename B>
1244 decltype(
auto) getDynamicBinding()
1246 return static_cast<std::decay_t<decltype(B::mColumnIterator)
>*>(
nullptr);
1251 static std::shared_ptr<arrow::Table>
joinTables(std::vector<std::shared_ptr<arrow::Table>>&& tables, std::span<const char* const> labels);
1252 static std::shared_ptr<arrow::Table>
concatTables(std::vector<std::shared_ptr<arrow::Table>>&& tables);
1256template <
typename T>
1259template <
typename T>
1261 T::originals.size();
1264template <
typename T>
1269template <
typename T>
1272template <
size_t N1, std::array<TableRef, N1> os1,
size_t N2, std::array<TableRef, N2> os2>
1275 return []<
size_t... Is>(std::index_sequence<Is...>) {
1276 return ([]<
size_t... Ks>(std::index_sequence<Ks...>) {
1277 constexpr auto h = os1[Is].desc_hash;
1280 }(std::make_index_sequence<N2>()) ||
1282 }(std::make_index_sequence<N1>());
1285template <with_originals T, with_originals B>
1288 return is_compatible<T::originals.size(), T::originals, B::originals.size(), B::originals>();
1291template <
typename T,
typename B>
1292using is_binding_compatible = std::conditional_t<is_binding_compatible_v<T, typename B::binding_t>(), std::true_type, std::false_type>;
1294template <
typename L,
typename D,
typename O,
typename Key,
typename H,
typename...
Ts>
1297template <
typename T>
1300template <soa::is_table T>
1301static constexpr std::string getLabelForTable()
1303 return std::string{aod::label<std::decay_t<T>::originals[0]>()};
1306template <soa::is_table T>
1308static constexpr std::string getLabelFromType()
1310 return getLabelForTable<T>();
1313template <soa::is_iterator T>
1314static constexpr std::string getLabelFromType()
1316 return getLabelForTable<typename std::decay_t<T>::parent_t>();
1319template <soa::is_index_table T>
1320static constexpr std::string getLabelFromType()
1322 return getLabelForTable<typename std::decay_t<T>::first_t>();
1324template <soa::with_base_table T>
1325static constexpr std::string getLabelFromType()
1330template <
typename...
C>
1333 return ((C::inherited_t::mLabel ==
key) || ...);
1336template <TableRef ref>
1337static constexpr std::pair<bool, std::string> hasKey(std::string
const&
key)
1342template <
typename...
C>
1345 return std::vector{hasKey<C>(
key)...};
1351template <with_originals T,
bool OPT = false>
1352static constexpr std::string getLabelFromTypeForKey(std::string
const&
key)
1354 if constexpr (T::originals.size() == 1) {
1355 auto locate = hasKey<T::originals[0]>(
key);
1357 return locate.second;
1360 auto locate = [&]<
size_t... Is>(std::index_sequence<Is...>) {
1361 return std::vector{hasKey<T::originals[Is]>(
key)...};
1362 }(std::make_index_sequence<T::originals.size()>{});
1363 auto it = std::find_if(locate.begin(), locate.end(), [](
auto const&
x) { return x.first; });
1364 if (it != locate.end()) {
1368 if constexpr (!OPT) {
1376template <
typename B,
typename...
C>
1379 return (o2::soa::is_binding_compatible_v<B, typename C::binding_t>() || ...);
1382template <
typename B,
typename...
C>
1385 return ((C::sorted && o2::soa::is_binding_compatible_v<B, typename C::binding_t>()) || ...);
1388template <
typename B,
typename Z>
1389consteval static bool relatedByIndex()
1391 return hasIndexTo<B>(
typename Z::table_t::external_index_columns_t{});
1394template <
typename B,
typename Z>
1395consteval static bool relatedBySortedIndex()
1397 return hasSortedIndexTo<B>(
typename Z::table_t::external_index_columns_t{});
1416 std::shared_ptr<arrow::Table>
getSliceFor(
int value, std::shared_ptr<arrow::Table>
const& input, uint64_t&
offset)
const;
1426template <
typename T,
typename Policy,
bool OPT = false>
1434 : Policy{
PreslicePolicyBase{{o2::soa::getLabelFromTypeForKey<T, OPT>(std::string{index_.
name})},
Entry(o2::soa::getLabelFromTypeForKey<T, OPT>(std::string{index_.name}), std::string{index_.name})}, {}}
1440 if constexpr (OPT) {
1441 if (Policy::isMissing()) {
1450 if constexpr (OPT) {
1451 if (Policy::isMissing()) {
1455 return Policy::getSliceFor(
value);
1459template <
typename T>
1461template <
typename T>
1463template <
typename T>
1465template <
typename T>
1468template <
typename T>
1486template <
typename T>
1493template <soa::is_table T>
1495template <
typename T>
1498template <
typename T>
1501template <
typename T>
1504template <
typename T>
1508template <
typename T>
1511template <
typename T>
1514template <
typename T>
1518template <
typename... Is>
1526template <
typename T,
typename C,
typename Policy,
bool OPT>
1527 requires std::same_as<Policy, framework::PreslicePolicySorted> && (o2::soa::is_binding_compatible_v<C, T>())
1530 if constexpr (OPT) {
1531 if (container.isMissing()) {
1537 auto t =
typename T::self_t({out},
offset);
1538 table->copyIndexBindings(t);
1539 t.bindInternalIndicesTo(table);
1543template <soa::is_filtered_table T>
1548 t.bindInternalIndicesTo(table);
1549 t.intersectWithSelection(table->getSelectedRows());
1553template <soa::is_table T>
1559 t.bindInternalIndicesTo(table);
1563template <
typename T,
typename C,
typename Policy,
bool OPT>
1564 requires std::same_as<Policy, framework::PreslicePolicyGeneral> && (o2::soa::is_binding_compatible_v<C, T>())
1567 if constexpr (OPT) {
1568 if (container.isMissing()) {
1578template <soa::is_filtered_table T>
1581 if (
offset >=
static_cast<uint64_t
>(table->tableSize())) {
1592template <soa::is_filtered_table T,
typename C,
bool OPT>
1593 requires(o2::soa::is_binding_compatible_v<C, T>())
1596 if constexpr (OPT) {
1597 if (container.isMissing()) {
1606template <
typename T>
1611 auto t =
typename T::self_t({table->asArrowTable()->Slice(
static_cast<uint64_t
>(
offset),
count)},
static_cast<uint64_t
>(
offset));
1612 table->copyIndexBindings(t);
1616template <
typename T>
1621 auto slice = table->asArrowTable()->Slice(
static_cast<uint64_t
>(
offset),
count);
1625template <
typename T>
1630 auto t =
typename T::self_t({table->asArrowTable()}, localCache.getSliceFor(
value));
1631 t.intersectWithSelection(table->getSelectedRows());
1632 table->copyIndexBindings(t);
1635 auto t =
Filtered<T>({table->asArrowTable()}, localCache.getSliceFor(
value));
1636 table->copyIndexBindings(t);
1641template <with_originals T>
1649template <
typename D,
typename O,
typename IP,
typename...
C>
1686 return std::array<TableRef, 1>{
ref};
1702 static constexpr const auto ref =
TableRef{L::hash, D::hash, O::hash, o2::aod::version(D::str)};
1707 static constexpr const auto originalLabels = []<
size_t N, std::array<TableRef, N> refs,
size_t... Is>(std::index_sequence<Is...>) {
return std::array<const char*, N>{o2::aod::label<refs[Is]>()...}; }.template operator()<
originals.size(),
originals>(std::make_index_sequence<
originals.size()>());
1709 template <
size_t N, std::array<TableRef, N> bindings>
1710 requires(
ref.origin_hash ==
"CONC"_h)
1716 template <
size_t N, std::array<TableRef, N> bindings>
1717 requires(
ref.origin_hash ==
"JOIN"_h)
1722 return std::find(bindings.begin(), bindings.end(),
r) != bindings.end();
1726 template <
size_t N, std::array<TableRef, N> bindings>
1727 requires(!(
ref.origin_hash ==
"CONC"_h ||
ref.origin_hash ==
"JOIN"_h))
1730 return std::find(bindings.begin(), bindings.end(),
self_t::ref) != bindings.end();
1733 template <TableRef r>
1746 template <
typename IP>
1749 template <
typename IP,
typename Parent,
typename... T>
1766 template <
typename P,
typename... Os>
1768 requires(P::ref.desc_hash == Parent::ref.desc_hash)
1774 template <
typename P>
1781 template <
typename P>
1783 requires std::same_as<IP, DefaultIndexPolicy>
1789 template <
typename P,
typename O1,
typename... Os>
1791 requires(P::ref.desc_hash == Parent::ref.desc_hash)
1796 template <
typename P,
typename O1,
typename... Os>
1798 requires(P::ref.desc_hash == Parent::ref.desc_hash)
1803 template <
typename P>
1809 template <
typename P>
1815 template <
typename P>
1817 requires std::same_as<IP, DefaultIndexPolicy>
1824 this->mRowIndex =
other.index;
1827 template <
typename P>
1830 this->mRowIndex =
other.mRowIndex;
1833 template <
typename P,
typename... Os>
1835 requires std::same_as<typename P::table_t, typename Parent::table_t>
1837 this->mRowIndex =
other.mRowIndex;
1840 template <
typename TI>
1843 using decayed = std::decay_t<TI>;
1845 constexpr auto idx = framework::has_type_at_v<decayed>(
bindings_pack_t{});
1847 }
else if constexpr (std::same_as<decayed, Parent>) {
1848 return this->globalIndex();
1850 return this->globalIndex();
1852 return static_cast<int32_t
>(-1);
1856 template <
typename CD,
typename... CDArgs>
1859 using decayed = std::decay_t<CD>;
1861 return static_cast<decayed
>(*this).template getDynamicValue<CDArgs...>();
1864 template <
typename B,
typename CC>
1867 using COL = std::decay_t<CC>;
1869 return static_cast<B>(
static_cast<COL
>(*this).get());
1872 template <
typename B,
typename... CCs>
1875 static_assert(std::same_as<B, float> || std::same_as<B, double>,
"The common return type should be float or double");
1876 return {getValue<B, CCs>()...};
1887 copy.moveByIndex(inc);
1902 template <
typename IP,
typename Parent,
typename... T>
1905 template <
typename IP,
typename Parent>
1908 if constexpr (
sizeof...(Ts) == 0) {
1919 template <
typename IP,
typename Parent>
1936 mEnd{table->num_rows()},
1939 if (mTable->num_rows() == 0) {
1941 mColumnChunks[ci] =
nullptr;
1947 mColumnChunks[ci] = lookups[ci];
1950 mBegin.bindInternalIndices(
this);
1954 Table(std::vector<std::shared_ptr<arrow::Table>>&& tables, uint64_t
offset = 0)
1955 requires(
ref.origin_hash !=
"CONC"_h)
1960 Table(std::vector<std::shared_ptr<arrow::Table>>&& tables, uint64_t
offset = 0)
1961 requires(
ref.origin_hash ==
"CONC"_h)
1966 template <
typename Key>
1970 return std::array<bool,
sizeof...(Cs)>{[]() {
1971 if constexpr (
requires { Cs::index_targets.size(); }) {
1972 return Key::template
isIndexTargetOf<Cs::index_targets.size(), Cs::index_targets>();
1978 constexpr auto pos = std::find(map.begin(), map.end(),
true);
1979 if constexpr (
pos != map.end()) {
1980 return mColumnChunks[std::distance(map.begin(),
pos)];
1982 static_assert(framework::always_static_assert_v<Key>,
"This table does not have an index to given Key");
2012 return filtered_iterator(mColumnChunks, {selection, mTable->num_rows(), mOffset});
2050 return mTable->num_rows();
2060 template <
typename... TA>
2063 mBegin.bindExternalIndices(current...);
2066 template <
typename I>
2069 mBegin.bindInternalIndices(
ptr);
2077 template <
typename... Cs>
2080 (
static_cast<Cs
>(mBegin).setCurrentRaw(binding), ...);
2085 mBegin.bindExternalIndicesRaw(std::forward<std::vector<o2::soa::Binding>>(ptrs));
2088 template <
typename T,
typename... Cs>
2091 dest.bindExternalIndicesRaw(mBegin.getIndexBindings());
2094 template <
typename T>
2117 template <
typename T1,
typename Policy,
bool OPT>
2130 return self_t{mTable->Slice(0, 0), 0};
2134 template <
typename T>
2135 arrow::ChunkedArray* lookupColumn()
2138 auto label = T::columnLabel();
2144 std::shared_ptr<arrow::Table> mTable =
nullptr;
2145 uint64_t mOffset = 0;
2152template <uint32_t
D, soa::is_column...
C>
2158namespace row_helpers
2169 return std::array<std::shared_ptr<arrow::Array>,
sizeof...(Cs)>{
o2::soa::getIndexFromLabel(table, Cs::columnLabel())->chunk(ci)...};
2172template <
typename T, soa::is_persistent_column C>
2173typename C::type
getSingleRowData(arrow::Table* table, T& rowIterator, uint64_t ci = std::numeric_limits<uint64_t>::max(), uint64_t ai = std::numeric_limits<uint64_t>::max(), uint64_t globalIndex = std::numeric_limits<uint64_t>::max())
2175 if (ci == std::numeric_limits<uint64_t>::max() || ai == std::numeric_limits<uint64_t>::max()) {
2176 auto colIterator =
static_cast<C>(rowIterator).getIterator();
2177 ci = colIterator.mCurrentChunk;
2178 ai = *(colIterator.mCurrentPos) - colIterator.mFirstIndex;
2180 return std::static_pointer_cast<o2::soa::arrow_array_for_t<typename C::type>>(
o2::soa::getIndexFromLabel(table, C::columnLabel())->chunk(ci))->raw_values()[ai];
2183template <
typename T, soa::is_dynamic_column C>
2184typename C::type
getSingleRowData(arrow::Table*, T& rowIterator, uint64_t ci = std::numeric_limits<uint64_t>::max(), uint64_t ai = std::numeric_limits<uint64_t>::max(), uint64_t globalIndex = std::numeric_limits<uint64_t>::max())
2186 if (globalIndex != std::numeric_limits<uint64_t>::max() && globalIndex != *std::get<0>(rowIterator.getIndices())) {
2187 rowIterator.setCursor(globalIndex);
2189 return rowIterator.template getDynamicColumn<C>();
2192template <
typename T, soa::is_index_column C>
2193typename C::type
getSingleRowData(arrow::Table*, T& rowIterator, uint64_t ci = std::numeric_limits<uint64_t>::max(), uint64_t ai = std::numeric_limits<uint64_t>::max(), uint64_t globalIndex = std::numeric_limits<uint64_t>::max())
2195 if (globalIndex != std::numeric_limits<uint64_t>::max() && globalIndex != *std::get<0>(rowIterator.getIndices())) {
2196 rowIterator.setCursor(globalIndex);
2198 return rowIterator.template getId<C>();
2201template <
typename T,
typename... Cs>
2202std::tuple<
typename Cs::type...>
getRowData(arrow::Table* table, T rowIterator, uint64_t ci = std::numeric_limits<uint64_t>::max(), uint64_t ai = std::numeric_limits<uint64_t>::max(), uint64_t globalIndex = std::numeric_limits<uint64_t>::max())
2204 return std::make_tuple(getSingleRowData<T, Cs>(table, rowIterator, ci, ai, globalIndex)...);
2209template <
typename R,
typename T,
typename C>
2210R getColumnValue(
const T& rowIterator)
2212 return static_cast<R>(
static_cast<C>(rowIterator).get());
2215template <
typename R,
typename T>
2216using ColumnGetterFunction =
R (*)(
const T&);
2218template <
typename T,
typename R>
2223 { t.get() } -> std::convertible_to<R>;
2226template <
typename T,
typename R>
2228 { t.get() } -> std::convertible_to<R>;
2231template <
typename R,
typename T, persistent_with_common_getter<R> C>
2232ColumnGetterFunction<R, T> createGetterPtr(
const std::string_view& targetColumnLabel)
2234 return targetColumnLabel == C::columnLabel() ? &getColumnValue<R, T, C> :
nullptr;
2237template <
typename R,
typename T, dynamic_with_common_getter<R> C>
2238ColumnGetterFunction<R, T> createGetterPtr(
const std::string_view& targetColumnLabel)
2240 std::string_view columnLabel(C::columnLabel());
2244 if (targetColumnLabel.starts_with(
"f") && targetColumnLabel.substr(1) == columnLabel) {
2245 return &getColumnValue<R, T, C>;
2249 if (targetColumnLabel == columnLabel) {
2250 return &getColumnValue<R, T, C>;
2256template <
typename R,
typename T,
typename... Cs>
2259 ColumnGetterFunction<R, T>
func;
2261 (
void)((
func = createGetterPtr<R, T, Cs>(targetColumnLabel),
func) || ...);
2270template <
typename T,
typename R>
2271using with_common_getter_t =
typename std::conditional<persistent_with_common_getter<T, R> || dynamic_with_common_getter<T, R>, std::true_type, std::false_type>
::type;
2274template <
typename R,
typename T>
2279 if (targetColumnLabel.size() == 0) {
2283 return getColumnGetterByLabel<R, typename T::iterator>(TypesWithCommonGetter{}, targetColumnLabel);
2305template <
typename T>
2306consteval static std::string_view namespace_prefix()
2308 constexpr auto name = o2::framework::type_name<T>();
2309 const auto pos =
name.rfind(std::string_view{
":"});
2310 return name.substr(0,
pos - 1);
2314#define DECLARE_EQUIVALENT_FOR_INDEX(_Base_, _Equiv_) \
2316 struct EquivalentIndexNG<o2::aod::Hash<_Base_::ref.desc_hash>, o2::aod::Hash<_Equiv_::ref.desc_hash>> { \
2317 constexpr static bool value = true; \
2320#define DECLARE_EQUIVALENT_FOR_INDEX_NG(_Base_, _Equiv_) \
2322 struct EquivalentIndexNG<o2::aod::Hash<_Base_ ""_h>, o2::aod::Hash<_Equiv_ ""_h>> { \
2323 constexpr static bool value = true; \
2326#define DECLARE_SOA_COLUMN_FULL(_Name_, _Getter_, _Type_, _Label_) \
2327 struct _Name_ : o2::soa::Column<_Type_, _Name_> { \
2328 static constexpr const char* mLabel = _Label_; \
2329 static constexpr const uint32_t hash = crc32(namespace_prefix<_Name_>(), std::string_view{#_Getter_}); \
2330 static_assert(!((*(mLabel + 1) == 'I' && *(mLabel + 2) == 'n' && *(mLabel + 3) == 'd' && *(mLabel + 4) == 'e' && *(mLabel + 5) == 'x')), "Index is not a valid column name"); \
2331 using base = o2::soa::Column<_Type_, _Name_>; \
2332 using type = _Type_; \
2333 using column_t = _Name_; \
2334 _Name_(arrow::ChunkedArray const* column) \
2335 : o2::soa::Column<_Type_, _Name_>(o2::soa::ColumnIterator<type>(column)) \
2339 _Name_() = default; \
2340 _Name_(_Name_ const& other) = default; \
2341 _Name_& operator=(_Name_ const& other) = default; \
2343 decltype(auto) _Getter_() const \
2345 return *mColumnIterator; \
2348 decltype(auto) get() const \
2350 return _Getter_(); \
2353 [[maybe_unused]] static constexpr o2::framework::expressions::BindingNode _Getter_ { _Label_, _Name_::hash, o2::framework::expressions::selectArrowType<_Type_>() }
2355#define DECLARE_SOA_COLUMN(_Name_, _Getter_, _Type_) \
2356 DECLARE_SOA_COLUMN_FULL(_Name_, _Getter_, _Type_, "f" #_Name_)
2360#define MAKEINT(_Size_) uint##_Size_##_t
2362#define DECLARE_SOA_BITMAP_COLUMN_FULL(_Name_, _Getter_, _Size_, _Label_) \
2363 struct _Name_ : o2::soa::Column<MAKEINT(_Size_), _Name_> { \
2364 static constexpr const char* mLabel = _Label_; \
2365 static constexpr const uint32_t hash = crc32(namespace_prefix<_Name_>(), std::string_view{#_Getter_}); \
2366 static_assert(!((*(mLabel + 1) == 'I' && *(mLabel + 2) == 'n' && *(mLabel + 3) == 'd' && *(mLabel + 4) == 'e' && *(mLabel + 5) == 'x')), "Index is not a valid column name"); \
2367 using base = o2::soa::Column<MAKEINT(_Size_), _Name_>; \
2368 using type = MAKEINT(_Size_); \
2369 _Name_(arrow::ChunkedArray const* column) \
2370 : o2::soa::Column<type, _Name_>(o2::soa::ColumnIterator<type>(column)) \
2374 _Name_() = default; \
2375 _Name_(_Name_ const& other) = default; \
2376 _Name_& operator=(_Name_ const& other) = default; \
2378 decltype(auto) _Getter_##_raw() const \
2380 return *mColumnIterator; \
2383 bool _Getter_##_bit(int bit) const \
2385 return (*mColumnIterator & (static_cast<type>(1) << bit)) >> bit; \
2388 [[maybe_unused]] static constexpr o2::framework::expressions::BindingNode _Getter_ { _Label_, _Name_::hash, o2::framework::expressions::selectArrowType<MAKEINT(_Size_)>() }
2390#define DECLARE_SOA_BITMAP_COLUMN(_Name_, _Getter_, _Size_) \
2391 DECLARE_SOA_BITMAP_COLUMN_FULL(_Name_, _Getter_, _Size_, "f" #_Name_)
2395#define DECLARE_SOA_EXPRESSION_COLUMN_FULL(_Name_, _Getter_, _Type_, _Label_, _Expression_) \
2396 struct _Name_ : o2::soa::Column<_Type_, _Name_> { \
2397 static constexpr const char* mLabel = _Label_; \
2398 static constexpr const uint32_t hash = crc32(namespace_prefix<_Name_>(), std::string_view{#_Getter_}); \
2399 using base = o2::soa::Column<_Type_, _Name_>; \
2400 using type = _Type_; \
2401 using column_t = _Name_; \
2402 using spawnable_t = std::true_type; \
2403 _Name_(arrow::ChunkedArray const* column) \
2404 : o2::soa::Column<_Type_, _Name_>(o2::soa::ColumnIterator<type>(column)) \
2408 _Name_() = default; \
2409 _Name_(_Name_ const& other) = default; \
2410 _Name_& operator=(_Name_ const& other) = default; \
2412 decltype(auto) _Getter_() const \
2414 return *mColumnIterator; \
2417 decltype(auto) get() const \
2419 return _Getter_(); \
2422 static o2::framework::expressions::Projector Projector() \
2424 return _Expression_; \
2427 [[maybe_unused]] static constexpr o2::framework::expressions::BindingNode _Getter_ { _Label_, _Name_::hash, o2::framework::expressions::selectArrowType<_Type_>() }
2429#define DECLARE_SOA_EXPRESSION_COLUMN(_Name_, _Getter_, _Type_, _Expression_) \
2430 DECLARE_SOA_EXPRESSION_COLUMN_FULL(_Name_, _Getter_, _Type_, "f" #_Name_, _Expression_);
2434#define DECLARE_SOA_CONFIGURABLE_EXPRESSION_COLUMN(_Name_, _Getter_, _Type_, _Label_) \
2435 struct _Name_ : o2::soa::Column<_Type_, _Name_> { \
2436 static constexpr const char* mLabel = _Label_; \
2437 static constexpr const uint32_t hash = crc32(namespace_prefix<_Name_>(), std::string_view{#_Getter_}); \
2438 static constexpr const int32_t mHash = _Label_ ""_h; \
2439 using base = o2::soa::Column<_Type_, _Name_>; \
2440 using type = _Type_; \
2441 using column_t = _Name_; \
2442 using spawnable_t = std::true_type; \
2443 _Name_(arrow::ChunkedArray const* column) \
2444 : o2::soa::Column<_Type_, _Name_>(o2::soa::ColumnIterator<type>(column)) \
2448 _Name_() = default; \
2449 _Name_(_Name_ const& other) = default; \
2450 _Name_& operator=(_Name_ const& other) = default; \
2452 decltype(auto) _Getter_() const \
2454 return *mColumnIterator; \
2457 decltype(auto) get() const \
2459 return _Getter_(); \
2462 [[maybe_unused]] static constexpr o2::framework::expressions::BindingNode _Getter_ { _Label_, _Name_::hash, o2::framework::expressions::selectArrowType<_Type_>() }
2485template <o2::soa::is_table T>
2488 return T::originals;
2491#define DECLARE_SOA_SLICE_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, _Type_, _Table_, _Label_, _Suffix_) \
2492 struct _Name_##IdSlice : o2::soa::Column<_Type_[2], _Name_##IdSlice> { \
2493 static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
2494 static_assert((*_Suffix_ == '\0') || (*_Suffix_ == '_'), "Suffix has to begin with _"); \
2495 static constexpr const char* mLabel = "fIndexSlice" _Label_ _Suffix_; \
2496 static constexpr const uint32_t hash = 0; \
2497 using base = o2::soa::Column<_Type_[2], _Name_##IdSlice>; \
2498 using type = _Type_[2]; \
2499 using column_t = _Name_##IdSlice; \
2500 using binding_t = _Table_; \
2501 static constexpr auto index_targets = getIndexTargets<_Table_>(); \
2502 _Name_##IdSlice(arrow::ChunkedArray const* column) \
2503 : o2::soa::Column<_Type_[2], _Name_##IdSlice>(o2::soa::ColumnIterator<type>(column)) \
2507 _Name_##IdSlice() = default; \
2508 _Name_##IdSlice(_Name_##IdSlice const& other) = default; \
2509 _Name_##IdSlice& operator=(_Name_##IdSlice const& other) = default; \
2510 std::array<_Type_, 2> inline getIds() const \
2512 return _Getter_##Ids(); \
2515 bool has_##_Getter_() const \
2517 auto a = *mColumnIterator; \
2518 return a[0] >= 0 && a[1] >= 0; \
2521 std::array<_Type_, 2> _Getter_##Ids() const \
2523 auto a = *mColumnIterator; \
2524 return std::array{a[0], a[1]}; \
2527 template <typename T> \
2528 auto _Getter_##_as() const \
2530 if (O2_BUILTIN_UNLIKELY(mBinding.ptr == nullptr)) { \
2531 o2::soa::notBoundTable(#_Table_); \
2533 auto t = mBinding.get<T>(); \
2534 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2535 o2::soa::dereferenceWithWrongType(#_Getter_, #_Table_); \
2537 if (O2_BUILTIN_UNLIKELY(!has_##_Getter_())) { \
2538 return t->emptySlice(); \
2540 auto a = *mColumnIterator; \
2541 auto r = t->rawSlice(a[0], a[1]); \
2542 t->copyIndexBindings(r); \
2543 r.bindInternalIndicesTo(t); \
2547 auto _Getter_() const \
2549 return _Getter_##_as<binding_t>(); \
2552 template <typename T> \
2553 bool setCurrent(T const* current) \
2555 if constexpr (o2::soa::is_binding_compatible_v<T, binding_t>()) { \
2556 assert(current != nullptr); \
2557 this->mBinding.bind(current); \
2563 bool setCurrentRaw(o2::soa::Binding current) \
2565 this->mBinding = current; \
2568 binding_t const* getCurrent() const { return mBinding.get<binding_t>(); } \
2569 o2::soa::Binding getCurrentRaw() const { return mBinding; } \
2570 o2::soa::Binding mBinding; \
2573#define DECLARE_SOA_SLICE_INDEX_COLUMN_FULL(_Name_, _Getter_, _Type_, _Table_, _Suffix_) DECLARE_SOA_SLICE_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, _Type_, _Table_, #_Table_, _Suffix_)
2574#define DECLARE_SOA_SLICE_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_SLICE_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, _Name_##s, "")
2575#define DECLARE_SOA_SLICE_INDEX_COLUMN_CUSTOM(_Name_, _Getter_, _Label_) DECLARE_SOA_SLICE_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, int32_t, _Name_##s, _Label_, "")
2578#define DECLARE_SOA_ARRAY_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, _Type_, _Table_, _Label_, _Suffix_) \
2579 struct _Name_##Ids : o2::soa::Column<std::vector<_Type_>, _Name_##Ids> { \
2580 static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
2581 static_assert((*_Suffix_ == '\0') || (*_Suffix_ == '_'), "Suffix has to begin with _"); \
2582 static constexpr const char* mLabel = "fIndexArray" _Label_ _Suffix_; \
2583 static constexpr const uint32_t hash = 0; \
2584 using base = o2::soa::Column<std::vector<_Type_>, _Name_##Ids>; \
2585 using type = std::vector<_Type_>; \
2586 using column_t = _Name_##Ids; \
2587 using binding_t = _Table_; \
2588 static constexpr auto index_targets = getIndexTargets<_Table_>(); \
2589 _Name_##Ids(arrow::ChunkedArray const* column) \
2590 : o2::soa::Column<std::vector<_Type_>, _Name_##Ids>(o2::soa::ColumnIterator<type>(column)) \
2594 _Name_##Ids() = default; \
2595 _Name_##Ids(_Name_##Ids const& other) = default; \
2596 _Name_##Ids& operator=(_Name_##Ids const& other) = default; \
2598 gsl::span<const _Type_> inline getIds() const \
2600 return _Getter_##Ids(); \
2603 gsl::span<const _Type_> _Getter_##Ids() const \
2605 return *mColumnIterator; \
2608 bool has_##_Getter_() const \
2610 return !(*mColumnIterator).empty(); \
2613 template <typename T> \
2614 auto _Getter_##_as() const \
2616 if (O2_BUILTIN_UNLIKELY(mBinding.ptr == nullptr)) { \
2617 o2::soa::notBoundTable(#_Table_); \
2619 auto t = mBinding.get<T>(); \
2620 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2621 o2::soa::dereferenceWithWrongType(#_Getter_, #_Table_); \
2623 return getIterators<T>(); \
2626 template <typename T> \
2627 auto filtered_##_Getter_##_as() const \
2629 if (O2_BUILTIN_UNLIKELY(mBinding.ptr == nullptr)) { \
2630 o2::soa::notBoundTable(#_Table_); \
2632 auto t = mBinding.get<T>(); \
2633 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2634 o2::soa::dereferenceWithWrongType(#_Getter_, #_Table_); \
2636 return getFilteredIterators<T>(); \
2639 template <typename T> \
2640 auto getIterators() const \
2642 auto result = std::vector<typename T::unfiltered_iterator>(); \
2643 for (auto& i : *mColumnIterator) { \
2644 result.push_back(mBinding.get<T>()->rawIteratorAt(i)); \
2649 template <typename T> \
2650 std::vector<typename T::iterator> getFilteredIterators() const \
2652 if constexpr (o2::soa::is_filtered_table<T>) { \
2653 auto result = std::vector<typename T::iterator>(); \
2654 for (auto const& i : *mColumnIterator) { \
2655 auto pos = mBinding.get<T>()->isInSelectedRows(i); \
2657 result.emplace_back(mBinding.get<T>()->iteratorAt(pos)); \
2662 static_assert(o2::framework::always_static_assert_v<T>, "T is not a Filtered type"); \
2667 auto _Getter_() const \
2669 return _Getter_##_as<binding_t>(); \
2672 template <typename T> \
2673 auto _Getter_##_first_as() const \
2675 if (O2_BUILTIN_UNLIKELY(mBinding.ptr == nullptr)) { \
2676 o2::soa::notBoundTable(#_Table_); \
2678 auto t = mBinding.get<T>(); \
2679 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2680 o2::soa::dereferenceWithWrongType(#_Getter_, #_Table_); \
2682 return t->rawIteratorAt((*mColumnIterator)[0]); \
2685 template <typename T> \
2686 auto _Getter_##_last_as() const \
2688 if (O2_BUILTIN_UNLIKELY(mBinding.ptr == nullptr)) { \
2689 o2::soa::notBoundTable(#_Table_); \
2691 auto t = mBinding.get<T>(); \
2692 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2693 o2::soa::dereferenceWithWrongType(#_Getter_, #_Table_); \
2695 return t->rawIteratorAt((*mColumnIterator).back()); \
2698 auto _Getter_first() const \
2700 return _Getter_##_first_as<binding_t>(); \
2703 auto _Getter_last() const \
2705 return _Getter_##_last_as<binding_t>(); \
2708 template <typename T> \
2709 bool setCurrent(T const* current) \
2711 if constexpr (o2::soa::is_binding_compatible_v<T, binding_t>()) { \
2712 assert(current != nullptr); \
2713 this->mBinding.bind(current); \
2719 bool setCurrentRaw(o2::soa::Binding current) \
2721 this->mBinding = current; \
2724 binding_t const* getCurrent() const { return mBinding.get<binding_t>(); } \
2725 o2::soa::Binding getCurrentRaw() const { return mBinding; } \
2726 o2::soa::Binding mBinding; \
2729#define DECLARE_SOA_ARRAY_INDEX_COLUMN_FULL(_Name_, _Getter_, _Type_, _Table_, _Suffix_) DECLARE_SOA_ARRAY_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, _Type_, _Table_, #_Table_, _Suffix_)
2730#define DECLARE_SOA_ARRAY_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_ARRAY_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, _Name_##s, "")
2731#define DECLARE_SOA_ARRAY_INDEX_COLUMN_CUSTOM(_Name_, _Getter_, _Label_) DECLARE_SOA_ARRAY_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, int32_t, _Name_##s, _Label_, "")
2734#define DECLARE_SOA_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, _Type_, _Table_, _Label_, _Suffix_) \
2735 struct _Name_##Id : o2::soa::Column<_Type_, _Name_##Id> { \
2736 static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
2737 static_assert((*_Suffix_ == '\0') || (*_Suffix_ == '_'), "Suffix has to begin with _"); \
2738 static constexpr const char* mLabel = "fIndex" _Label_ _Suffix_; \
2739 static constexpr const uint32_t hash = crc32(namespace_prefix<_Name_##Id>(), std::string_view{#_Getter_ "Id"}); \
2740 using base = o2::soa::Column<_Type_, _Name_##Id>; \
2741 using type = _Type_; \
2742 using column_t = _Name_##Id; \
2743 using binding_t = _Table_; \
2744 static constexpr auto index_targets = getIndexTargets<_Table_>(); \
2745 _Name_##Id(arrow::ChunkedArray const* column) \
2746 : o2::soa::Column<_Type_, _Name_##Id>(o2::soa::ColumnIterator<type>(column)) \
2750 _Name_##Id() = default; \
2751 _Name_##Id(_Name_##Id const& other) = default; \
2752 _Name_##Id& operator=(_Name_##Id const& other) = default; \
2753 type inline getId() const \
2755 return _Getter_##Id(); \
2758 type _Getter_##Id() const \
2760 return *mColumnIterator; \
2763 bool has_##_Getter_() const \
2765 return *mColumnIterator >= 0; \
2768 template <typename T> \
2769 auto _Getter_##_as() const \
2771 if (O2_BUILTIN_UNLIKELY(mBinding.ptr == nullptr)) { \
2772 o2::soa::notBoundTable(#_Table_); \
2774 if (O2_BUILTIN_UNLIKELY(!has_##_Getter_())) { \
2775 o2::soa::accessingInvalidIndexFor(#_Getter_); \
2777 auto t = mBinding.get<T>(); \
2778 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2779 o2::soa::dereferenceWithWrongType(#_Getter_, #_Table_); \
2781 return t->rawIteratorAt(*mColumnIterator); \
2784 auto _Getter_() const \
2786 return _Getter_##_as<binding_t>(); \
2789 template <typename T> \
2790 bool setCurrent(T* current) \
2792 if constexpr (o2::soa::is_binding_compatible_v<T, binding_t>()) { \
2793 assert(current != nullptr); \
2794 this->mBinding.bind(current); \
2800 bool setCurrentRaw(o2::soa::Binding current) \
2802 this->mBinding = current; \
2805 binding_t const* getCurrent() const { return mBinding.get<binding_t>(); } \
2806 o2::soa::Binding getCurrentRaw() const { return mBinding; } \
2807 o2::soa::Binding mBinding; \
2809 [[maybe_unused]] static constexpr o2::framework::expressions::BindingNode _Getter_##Id { "fIndex" #_Table_ _Suffix_, _Name_##Id::hash, o2::framework::expressions::selectArrowType<_Type_>() }
2811#define DECLARE_SOA_INDEX_COLUMN_FULL(_Name_, _Getter_, _Type_, _Table_, _Suffix_) DECLARE_SOA_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, _Type_, _Table_, #_Table_, _Suffix_)
2812#define DECLARE_SOA_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, _Name_##s, "")
2813#define DECLARE_SOA_INDEX_COLUMN_CUSTOM(_Name_, _Getter_, _Label_) DECLARE_SOA_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, int32_t, _Name_##s, _Label_, "")
2816#define DECLARE_SOA_SELF_INDEX_COLUMN_COMPLETE(_Name_, _Getter_, _Type_, _Label_, _IndexTarget_) \
2817 struct _Name_##Id : o2::soa::Column<_Type_, _Name_##Id> { \
2818 static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
2819 static constexpr const char* mLabel = "fIndex" _Label_; \
2820 static constexpr const uint32_t hash = crc32(namespace_prefix<_Name_##Id>(), std::string_view{#_Getter_ "Id"}); \
2821 using base = o2::soa::Column<_Type_, _Name_##Id>; \
2822 using type = _Type_; \
2823 using column_t = _Name_##Id; \
2824 using self_index_t = std::true_type; \
2825 using compatible_signature = std::conditional<aod::is_aod_hash<_IndexTarget_>, _IndexTarget_, void>; \
2826 _Name_##Id(arrow::ChunkedArray const* column) \
2827 : o2::soa::Column<_Type_, _Name_##Id>(o2::soa::ColumnIterator<type>(column)) \
2831 _Name_##Id() = default; \
2832 _Name_##Id(_Name_##Id const& other) = default; \
2833 _Name_##Id& operator=(_Name_##Id const& other) = default; \
2834 type inline getId() const \
2836 return _Getter_##Id(); \
2839 type _Getter_##Id() const \
2841 return *mColumnIterator; \
2844 bool has_##_Getter_() const \
2846 return *mColumnIterator >= 0; \
2849 template <typename T> \
2850 auto _Getter_##_as() const \
2852 if (O2_BUILTIN_UNLIKELY(!has_##_Getter_())) { \
2853 o2::soa::accessingInvalidIndexFor(#_Getter_); \
2855 auto t = mBinding.get<T>(); \
2856 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2857 o2::soa::dereferenceWithWrongType(#_Getter_, "self"); \
2859 return t->rawIteratorAt(*mColumnIterator); \
2862 bool setCurrentRaw(o2::soa::Binding current) \
2864 this->mBinding = current; \
2867 o2::soa::Binding getCurrentRaw() const { return mBinding; } \
2868 o2::soa::Binding mBinding; \
2870 [[maybe_unused]] static constexpr o2::framework::expressions::BindingNode _Getter_##Id { "fIndex" _Label_, _Name_##Id::hash, o2::framework::expressions::selectArrowType<_Type_>() }
2872#define DECLARE_SOA_SELF_INDEX_COLUMN_FULL(_Name_, _Getter_, _Type_, _Label_) DECLARE_SOA_SELF_INDEX_COLUMN_COMPLETE(_Name_, _Getter_, _Type_, _Label_, void)
2873#define DECLARE_SOA_SELF_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_SELF_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, #_Name_)
2875#define DECLARE_SOA_SELF_SLICE_INDEX_COLUMN_COMPLETE(_Name_, _Getter_, _Type_, _Label_, _IndexTarget_) \
2876 struct _Name_##IdSlice : o2::soa::Column<_Type_[2], _Name_##IdSlice> { \
2877 static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
2878 static constexpr const char* mLabel = "fIndexSlice" _Label_; \
2879 static constexpr const uint32_t hash = 0; \
2880 using base = o2::soa::Column<_Type_[2], _Name_##IdSlice>; \
2881 using type = _Type_[2]; \
2882 using column_t = _Name_##IdSlice; \
2883 using self_index_t = std::true_type; \
2884 using compatible_signature = std::conditional<aod::is_aod_hash<_IndexTarget_>, _IndexTarget_, void>; \
2885 _Name_##IdSlice(arrow::ChunkedArray const* column) \
2886 : o2::soa::Column<_Type_[2], _Name_##IdSlice>(o2::soa::ColumnIterator<type>(column)) \
2890 _Name_##IdSlice() = default; \
2891 _Name_##IdSlice(_Name_##IdSlice const& other) = default; \
2892 _Name_##IdSlice& operator=(_Name_##IdSlice const& other) = default; \
2893 std::array<_Type_, 2> inline getIds() const \
2895 return _Getter_##Ids(); \
2898 bool has_##_Getter_() const \
2900 auto a = *mColumnIterator; \
2901 return a[0] >= 0 && a[1] >= 0; \
2904 std::array<_Type_, 2> _Getter_##Ids() const \
2906 auto a = *mColumnIterator; \
2907 return std::array{a[0], a[1]}; \
2910 template <typename T> \
2911 auto _Getter_##_as() const \
2913 auto t = mBinding.get<T>(); \
2914 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2915 o2::soa::dereferenceWithWrongType(#_Getter_, "self"); \
2917 if (O2_BUILTIN_UNLIKELY(!has_##_Getter_())) { \
2918 return t->emptySlice(); \
2920 auto a = *mColumnIterator; \
2921 auto r = t->rawSlice(a[0], a[1]); \
2922 t->copyIndexBindings(r); \
2923 r.bindInternalIndicesTo(t); \
2927 bool setCurrentRaw(o2::soa::Binding current) \
2929 this->mBinding = current; \
2932 o2::soa::Binding getCurrentRaw() const { return mBinding; } \
2933 o2::soa::Binding mBinding; \
2936#define DECLARE_SOA_SELF_SLICE_INDEX_COLUMN_FULL(_Name_, _Getter_, _Type_, _Label_) DECLARE_SOA_SELF_SLICE_INDEX_COLUMN_COMPLETE(_Name_, _Getter_, _Type_, _Label_, void)
2937#define DECLARE_SOA_SELF_SLICE_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_SELF_SLICE_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, "_" #_Name_)
2939#define DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN_COMPLETE(_Name_, _Getter_, _Type_, _Label_, _IndexTarget_) \
2940 struct _Name_##Ids : o2::soa::Column<std::vector<_Type_>, _Name_##Ids> { \
2941 static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
2942 static constexpr const char* mLabel = "fIndexArray" _Label_; \
2943 static constexpr const uint32_t hash = 0; \
2944 using base = o2::soa::Column<std::vector<_Type_>, _Name_##Ids>; \
2945 using type = std::vector<_Type_>; \
2946 using column_t = _Name_##Ids; \
2947 using self_index_t = std::true_type; \
2948 using compatible_signature = std::conditional<aod::is_aod_hash<_IndexTarget_>, _IndexTarget_, void>; \
2949 _Name_##Ids(arrow::ChunkedArray const* column) \
2950 : o2::soa::Column<std::vector<_Type_>, _Name_##Ids>(o2::soa::ColumnIterator<type>(column)) \
2954 _Name_##Ids() = default; \
2955 _Name_##Ids(_Name_##Ids const& other) = default; \
2956 _Name_##Ids& operator=(_Name_##Ids const& other) = default; \
2957 gsl::span<const _Type_> inline getIds() const \
2959 return _Getter_##Ids(); \
2962 gsl::span<const _Type_> _Getter_##Ids() const \
2964 return *mColumnIterator; \
2967 bool has_##_Getter_() const \
2969 return !(*mColumnIterator).empty(); \
2972 template <typename T> \
2973 auto _Getter_##_as() const \
2975 auto t = mBinding.get<T>(); \
2976 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2977 o2::soa::dereferenceWithWrongType(#_Getter_, "self"); \
2979 return getIterators<T>(); \
2982 template <typename T> \
2983 auto getIterators() const \
2985 auto result = std::vector<typename T::unfiltered_iterator>(); \
2986 for (auto& i : *mColumnIterator) { \
2987 result.push_back(mBinding.get<T>()->rawIteratorAt(i)); \
2992 template <typename T> \
2993 auto _Getter_##_first_as() const \
2995 return mBinding.get<T>()->rawIteratorAt((*mColumnIterator)[0]); \
2998 template <typename T> \
2999 auto _Getter_##_last_as() const \
3001 return mBinding.get<T>()->rawIteratorAt((*mColumnIterator).back()); \
3004 bool setCurrentRaw(o2::soa::Binding current) \
3006 this->mBinding = current; \
3009 o2::soa::Binding getCurrentRaw() const { return mBinding; } \
3010 o2::soa::Binding mBinding; \
3013#define DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN_FULL(_Name_, _Getter_, _Type_, _Label_) DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN_COMPLETE(_Name_, _Getter_, _Type_, _Label_, void)
3014#define DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, "_" #_Name_)
3044#define DECLARE_SOA_DYNAMIC_COLUMN(_Name_, _Getter_, ...) \
3045 struct _Name_##Callback { \
3046 static inline constexpr auto getLambda() { return __VA_ARGS__; } \
3049 struct _Name_##Helper { \
3050 using callable_t = decltype(o2::framework::FunctionMetadata(std::declval<decltype(_Name_##Callback::getLambda())>())); \
3051 using return_type = typename callable_t::return_type; \
3053 template <typename... Bindings> \
3054 struct _Name_ : o2::soa::DynamicColumn<typename _Name_##Helper::callable_t::type, _Name_<Bindings...>> { \
3055 using base = o2::soa::DynamicColumn<typename _Name_##Helper::callable_t::type, _Name_<Bindings...>>; \
3056 using helper = _Name_##Helper; \
3057 using callback_holder_t = _Name_##Callback; \
3058 using callable_t = helper::callable_t; \
3059 using callback_t = callable_t::type; \
3060 static constexpr const uint32_t hash = 0; \
3062 _Name_(arrow::ChunkedArray const*) \
3065 _Name_() = default; \
3066 _Name_(_Name_ const& other) = default; \
3067 _Name_& operator=(_Name_ const& other) = default; \
3068 static constexpr const char* mLabel = #_Name_; \
3069 using type = typename callable_t::return_type; \
3071 template <typename... FreeArgs> \
3072 type _Getter_(FreeArgs... freeArgs) const \
3074 return boundGetter(std::make_index_sequence<std::tuple_size_v<decltype(boundIterators)>>{}, freeArgs...); \
3076 template <typename... FreeArgs> \
3077 type getDynamicValue(FreeArgs... freeArgs) const \
3079 return boundGetter(std::make_index_sequence<std::tuple_size_v<decltype(boundIterators)>>{}, freeArgs...); \
3084 return _Getter_(); \
3087 template <size_t... Is, typename... FreeArgs> \
3088 type boundGetter(std::integer_sequence<size_t, Is...>&&, FreeArgs... freeArgs) const \
3090 return __VA_ARGS__((**std::get<Is>(boundIterators))..., freeArgs...); \
3093 using bindings_t = typename o2::framework::pack<Bindings...>; \
3094 std::tuple<o2::soa::ColumnIterator<typename Bindings::type> const*...> boundIterators; \
3097#define DECLARE_SOA_TABLE_METADATA(_Name_, _Desc_, _Version_, ...) \
3098 using _Name_##Metadata = TableMetadata<Hash<_Desc_ "/" #_Version_ ""_h>, __VA_ARGS__>;
3100#define DECLARE_SOA_TABLE_METADATA_TRAIT(_Name_, _Desc_, _Version_) \
3102 struct MetadataTrait<Hash<_Desc_ "/" #_Version_ ""_h>> { \
3103 using metadata = _Name_##Metadata; \
3106#define DECLARE_SOA_TABLE_FULL_VERSIONED_(_Name_, _Label_, _Origin_, _Desc_, _Version_) \
3107 O2HASH(_Desc_ "/" #_Version_); \
3108 template <typename O> \
3109 using _Name_##From = o2::soa::Table<Hash<_Label_ ""_h>, Hash<_Desc_ "/" #_Version_ ""_h>, O>; \
3110 using _Name_ = _Name_##From<Hash<_Origin_ ""_h>>; \
3112 struct MetadataTrait<Hash<_Desc_ "/" #_Version_ ""_h>> { \
3113 using metadata = _Name_##Metadata; \
3116#define DECLARE_SOA_STAGE(_Name_, _Origin_, _Desc_, _Version_) \
3117 template <typename O> \
3118 using _Name_##From = o2::soa::Table<Hash<#_Name_ ""_h>, Hash<_Desc_ "/" #_Version_ ""_h>, O>; \
3119 using _Name_ = _Name_##From<Hash<_Origin_ ""_h>>;
3121#define DECLARE_SOA_TABLE_FULL_VERSIONED(_Name_, _Label_, _Origin_, _Desc_, _Version_, ...) \
3122 DECLARE_SOA_TABLE_METADATA(_Name_, _Desc_, _Version_, __VA_ARGS__); \
3123 DECLARE_SOA_TABLE_FULL_VERSIONED_(_Name_, _Label_, _Origin_, _Desc_, _Version_);
3125#define DECLARE_SOA_TABLE_FULL(_Name_, _Label_, _Origin_, _Desc_, ...) \
3127 DECLARE_SOA_TABLE_METADATA(_Name_, _Desc_, 0, __VA_ARGS__); \
3128 DECLARE_SOA_TABLE_FULL_VERSIONED_(_Name_, _Label_, _Origin_, _Desc_, 0)
3130#define DECLARE_SOA_TABLE(_Name_, _Origin_, _Desc_, ...) \
3131 DECLARE_SOA_TABLE_FULL(_Name_, #_Name_, _Origin_, _Desc_, __VA_ARGS__)
3133#define DECLARE_SOA_TABLE_VERSIONED(_Name_, _Origin_, _Desc_, _Version_, ...) \
3135 DECLARE_SOA_TABLE_METADATA(_Name_, _Desc_, _Version_, __VA_ARGS__); \
3136 DECLARE_SOA_TABLE_FULL_VERSIONED_(_Name_, #_Name_, _Origin_, _Desc_, _Version_)
3138#define DECLARE_SOA_TABLE_STAGED_VERSIONED(_BaseName_, _Desc_, _Version_, ...) \
3139 O2HASH(_Desc_ "/" #_Version_); \
3140 O2HASH(#_BaseName_); \
3141 O2HASH("Stored" #_BaseName_); \
3142 DECLARE_SOA_TABLE_METADATA(_BaseName_, _Desc_, _Version_, __VA_ARGS__); \
3143 using Stored##_BaseName_##Metadata = _BaseName_##Metadata; \
3144 DECLARE_SOA_TABLE_METADATA_TRAIT(_BaseName_, _Desc_, _Version_); \
3145 DECLARE_SOA_STAGE(_BaseName_, "AOD", _Desc_, _Version_); \
3146 DECLARE_SOA_STAGE(Stored##_BaseName_, "AOD1", _Desc_, _Version_);
3148#define DECLARE_SOA_TABLE_STAGED(_BaseName_, _Desc_, ...) \
3149 DECLARE_SOA_TABLE_STAGED_VERSIONED(_BaseName_, _Desc_, 0, __VA_ARGS__);
3151#define DECLARE_SOA_EXTENDED_TABLE_FULL(_Name_, _Label_, _OriginalTable_, _Origin_, _Desc_, _Version_, ...) \
3152 O2HASH(_Desc_ "/" #_Version_); \
3153 template <typename O> \
3154 using _Name_##ExtensionFrom = soa::Table<o2::aod::Hash<_Label_ ""_h>, o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, O>; \
3155 using _Name_##Extension = _Name_##ExtensionFrom<o2::aod::Hash<_Origin_ ""_h>>; \
3156 template <typename O = o2::aod::Hash<_Origin_ ""_h>> \
3157 struct _Name_##ExtensionMetadataFrom : TableMetadata<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, __VA_ARGS__> { \
3158 using base_table_t = _OriginalTable_; \
3159 using extension_table_t = _Name_##ExtensionFrom<O>; \
3160 using expression_pack_t = framework::pack<__VA_ARGS__>; \
3161 static constexpr auto sources = _OriginalTable_::originals; \
3163 using _Name_##ExtensionMetadata = _Name_##ExtensionMetadataFrom<o2::aod::Hash<_Origin_ ""_h>>; \
3165 struct MetadataTrait<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>> { \
3166 using metadata = _Name_##ExtensionMetadata; \
3168 template <typename O> \
3169 using _Name_##From = o2::soa::JoinFull<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, _OriginalTable_, _Name_##ExtensionFrom<O>>; \
3170 using _Name_ = _Name_##From<o2::aod::Hash<_Origin_ ""_h>>;
3172#define DECLARE_SOA_EXTENDED_TABLE(_Name_, _Table_, _Description_, _Version_, ...) \
3173 O2HASH(#_Name_ "Extension"); \
3174 DECLARE_SOA_EXTENDED_TABLE_FULL(_Name_, #_Name_ "Extension", _Table_, "DYN", _Description_, _Version_, __VA_ARGS__)
3176#define DECLARE_SOA_EXTENDED_TABLE_USER(_Name_, _Table_, _Description_, ...) \
3177 O2HASH(#_Name_ "Extension"); \
3178 DECLARE_SOA_EXTENDED_TABLE_FULL(_Name_, #_Name_ "Extension", _Table_, "AOD", "EX" _Description_, 0, __VA_ARGS__)
3180#define DECLARE_SOA_CONFIGURABLE_EXTENDED_TABLE_FULL(_Name_, _Label_, _OriginalTable_, _Origin_, _Desc_, _Version_, ...) \
3181 O2HASH(_Desc_ "/" #_Version_); \
3182 template <typename O> \
3183 using _Name_##CfgExtensionFrom = soa::Table<o2::aod::Hash<_Label_ ""_h>, o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, O>; \
3184 using _Name_##CfgExtension = _Name_##CfgExtensionFrom<o2::aod::Hash<_Origin_ ""_h>>; \
3185 template <typename O = o2::aod::Hash<_Origin_ ""_h>> \
3186 struct _Name_##CfgExtensionMetadataFrom : TableMetadata<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, __VA_ARGS__> { \
3187 using base_table_t = _OriginalTable_; \
3188 using extension_table_t = _Name_##CfgExtensionFrom<O>; \
3189 using placeholders_pack_t = framework::pack<__VA_ARGS__>; \
3190 using configurable_t = std::true_type; \
3191 static constexpr auto sources = _OriginalTable_::originals; \
3193 using _Name_##CfgExtensionMetadata = _Name_##CfgExtensionMetadataFrom<o2::aod::Hash<_Origin_ ""_h>>; \
3195 struct MetadataTrait<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>> { \
3196 using metadata = _Name_##CfgExtensionMetadata; \
3198 template <typename O> \
3199 using _Name_##From = o2::soa::JoinFull<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, _OriginalTable_, _Name_##CfgExtensionFrom<O>>; \
3200 using _Name_ = _Name_##From<o2::aod::Hash<_Origin_ ""_h>>;
3202#define DECLARE_SOA_CONFIGURABLE_EXTENDED_TABLE(_Name_, _Table_, _Description_, ...) \
3203 O2HASH(#_Name_ "CfgExtension"); \
3204 DECLARE_SOA_CONFIGURABLE_EXTENDED_TABLE_FULL(_Name_, #_Name_ "CfgExtension", _Table_, "AOD", "EX" _Description_, 0, __VA_ARGS__)
3206#define DECLARE_SOA_INDEX_TABLE_FULL(_Name_, _Key_, _Origin_, _Version_, _Desc_, _Exclusive_, ...) \
3208 O2HASH(_Desc_ "/" #_Version_); \
3209 template <typename O = o2::aod::Hash<_Origin_ ""_h>> \
3210 struct _Name_##MetadataFrom : o2::aod::TableMetadata<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, soa::Index<>, __VA_ARGS__> { \
3211 static constexpr bool exclusive = _Exclusive_; \
3212 using Key = _Key_; \
3213 using index_pack_t = framework::pack<__VA_ARGS__>; \
3214 static constexpr const auto sources = []<typename... Cs>(framework::pack<Cs...>) { \
3215 constexpr auto a = o2::soa::mergeOriginals<typename Cs::binding_t...>(); \
3216 return o2::aod::filterForKey<a.size(), a, Key>(); \
3217 }(framework::pack<__VA_ARGS__>{}); \
3219 using _Name_##Metadata = _Name_##MetadataFrom<o2::aod::Hash<_Origin_ ""_h>>; \
3221 template <typename O = o2::aod::Hash<_Origin_ ""_h>> \
3222 using _Name_##From = o2::soa::IndexTable<o2::aod::Hash<#_Name_ ""_h>, o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, O, _Key_, __VA_ARGS__>; \
3223 using _Name_ = _Name_##From<o2::aod::Hash<_Origin_ ""_h>>; \
3226 struct MetadataTrait<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>> { \
3227 using metadata = _Name_##Metadata; \
3230#define DECLARE_SOA_INDEX_TABLE(_Name_, _Key_, _Description_, ...) \
3231 DECLARE_SOA_INDEX_TABLE_FULL(_Name_, _Key_, "IDX", 0, _Description_, false, __VA_ARGS__)
3233#define DECLARE_SOA_INDEX_TABLE_EXCLUSIVE(_Name_, _Key_, _Description_, ...) \
3234 DECLARE_SOA_INDEX_TABLE_FULL(_Name_, _Key_, "IDX", 0, _Description_, true, __VA_ARGS__)
3236#define DECLARE_SOA_INDEX_TABLE_USER(_Name_, _Key_, _Description_, ...) \
3237 DECLARE_SOA_INDEX_TABLE_FULL(_Name_, _Key_, "AOD", 0, _Description_, false, __VA_ARGS__)
3239#define DECLARE_SOA_INDEX_TABLE_EXCLUSIVE_USER(_Name_, _Key_, _Description_, ...) \
3240 DECLARE_SOA_INDEX_TABLE_FULL(_Name_, _Key_, "AOD", 0, _Description_, true, __VA_ARGS__)
3244template <
typename D,
typename...
Ts>
3245struct JoinFull :
Table<o2::aod::Hash<"JOIN"_h>, D, o2::aod::Hash<"JOIN"_h>, Ts...> {
3294 template <
typename T1,
typename Policy,
bool OPT>
3322 template <
typename T>
3329template <
typename...
Ts>
3332template <
typename...
Ts>
3338template <
typename T>
3341template <
typename T>
3344template <
typename...
Ts>
3345struct Concat :
Table<o2::aod::Hash<"CONC"_h>, o2::aod::Hash<"CONC/0"_h>, o2::aod::Hash<"CONC"_h>, Ts...> {
3348 Concat(std::vector<std::shared_ptr<arrow::Table>>&& tables, uint64_t
offset = 0)
3356 bindInternalIndicesTo(
this);
3359 using base::originals;
3361 using base::bindExternalIndices;
3362 using base::bindInternalIndicesTo;
3376template <
typename...
Ts>
3382template <soa::is_table T>
3393 using iterator = T::template iterator_template_o<FilteredIndexPolicy, self_t>;
3399 mSelectedRows{getSpan(selection)}
3401 if (this->tableSize() != 0) {
3402 mFilteredBegin = table_t::filtered_begin(mSelectedRows);
3405 mFilteredBegin.bindInternalIndices(
this);
3410 mSelectedRowsCache{
std::move(selection)},
3413 mSelectedRows = gsl::span{mSelectedRowsCache};
3414 if (this->tableSize() != 0) {
3415 mFilteredBegin = table_t::filtered_begin(mSelectedRows);
3418 mFilteredBegin.bindInternalIndices(
this);
3421 FilteredBase(std::vector<std::shared_ptr<arrow::Table>>&& tables, gsl::span<int64_t const>
const& selection, uint64_t
offset = 0)
3423 mSelectedRows{selection}
3425 if (this->tableSize() != 0) {
3426 mFilteredBegin = table_t::filtered_begin(mSelectedRows);
3429 mFilteredBegin.bindInternalIndices(
this);
3456 return mFilteredBegin;
3461 return mFilteredBegin;
3466 return mFilteredBegin +
i;
3471 return mSelectedRows.size();
3476 return table_t::asArrowTable()->num_rows();
3481 return mSelectedRows;
3487 newSelection.resize(
static_cast<int64_t
>(
end -
start + 1));
3488 std::iota(newSelection.begin(), newSelection.end(),
start);
3489 return self_t{{this->asArrowTable()}, std::move(newSelection), 0};
3499 if (sel ==
nullptr) {
3500 return gsl::span<int64_t const>{};
3502 auto array = std::static_pointer_cast<arrow::Int64Array>(sel->ToArray());
3505 return gsl::span{
start, stop};
3510 template <
typename... TA>
3513 table_t::bindExternalIndices(current...);
3514 mFilteredBegin.bindExternalIndices(current...);
3519 mFilteredBegin.bindExternalIndicesRaw(std::forward<std::vector<o2::soa::Binding>>(ptrs));
3522 template <
typename I>
3525 mFilteredBegin.bindInternalIndices(
ptr);
3528 template <
typename T1,
typename... Cs>
3531 dest.bindExternalIndicesRaw(mFilteredBegin.getIndexBindings());
3534 template <
typename T1>
3540 template <
typename T1>
3556 template <
typename T1,
bool OPT>
3562 template <
typename T1,
bool OPT>
3571 copyIndexBindings(t);
3577 auto locate = std::find(mSelectedRows.begin(), mSelectedRows.end(),
i);
3578 if (locate == mSelectedRows.end()) {
3581 return static_cast<int>(std::distance(mSelectedRows.begin(), locate));
3588 std::set_union(mSelectedRows.begin(), mSelectedRows.end(), selection.begin(), selection.end(), std::back_inserter(rowsUnion));
3589 mSelectedRowsCache.clear();
3590 mSelectedRowsCache = rowsUnion;
3598 std::set_intersection(mSelectedRows.begin(), mSelectedRows.end(), selection.begin(), selection.end(), std::back_inserter(intersection));
3599 mSelectedRowsCache.clear();
3600 mSelectedRowsCache = intersection;
3608 std::set_union(mSelectedRows.begin(), mSelectedRows.end(), selection.begin(), selection.end(), std::back_inserter(rowsUnion));
3609 mSelectedRowsCache.clear();
3610 mSelectedRowsCache = rowsUnion;
3618 std::set_intersection(mSelectedRows.begin(), mSelectedRows.end(), selection.begin(), selection.end(), std::back_inserter(intersection));
3619 mSelectedRowsCache.clear();
3620 mSelectedRowsCache = intersection;
3633 mSelectedRows = gsl::span{mSelectedRowsCache};
3635 mFilteredEnd.reset(
new RowViewSentinel{
static_cast<int64_t
>(mSelectedRows.size())});
3636 if (tableSize() == 0) {
3637 mFilteredBegin = *mFilteredEnd;
3639 mFilteredBegin.resetSelection(mSelectedRows);
3643 gsl::span<int64_t const> mSelectedRows;
3645 bool mCached =
false;
3646 iterator mFilteredBegin;
3647 std::shared_ptr<RowViewSentinel> mFilteredEnd;
3650template <
typename T>
3659 using iterator = T::template iterator_template_o<FilteredIndexPolicy, self_t>;
3665 return iterator(this->cached_begin());
3679 Filtered(std::vector<std::shared_ptr<arrow::Table>>&& tables, gsl::span<int64_t const>
const& selection, uint64_t
offset = 0)
3703 this->sumWithSelection(selection);
3709 this->sumWithSelection(selection);
3715 return operator+=(
other.getSelectedRows());
3734 return operator*(
other.getSelectedRows());
3739 this->intersectWithSelection(selection);
3745 this->intersectWithSelection(selection);
3751 return operator*=(
other.getSelectedRows());
3766 newSelection.resize(
static_cast<int64_t
>(
end -
start + 1));
3767 std::iota(newSelection.begin(), newSelection.end(),
start);
3768 return self_t{{this->asArrowTable()}, std::move(newSelection), 0};
3776 template <
typename T1>
3792 template <
typename T1,
bool OPT>
3798 template <
typename T1,
bool OPT>
3807 copyIndexBindings(t);
3812template <
typename T>
3821 using iterator =
typename T::template iterator_template_o<FilteredIndexPolicy, self_t>;
3827 return iterator(this->cached_begin());
3838 for (
auto& table : tables) {
3846 for (
auto& table : tables) {
3854 for (
auto& table : tables) {
3880 this->sumWithSelection(selection);
3886 this->sumWithSelection(selection);
3892 return operator+=(
other.getSelectedRows());
3898 copy.intersectionWithSelection(selection);
3905 copy.intersectionWithSelection(selection);
3911 return operator*(
other.getSelectedRows());
3916 this->intersectWithSelection(selection);
3922 this->intersectWithSelection(selection);
3928 return operator*=(
other.getSelectedRows());
3941 newSelection.resize(
static_cast<int64_t
>(
end -
start + 1));
3942 std::iota(newSelection.begin(), newSelection.end(),
start);
3943 return self_t{{this->asArrowTable()}, std::move(newSelection), 0};
3961 template <
typename T1,
bool OPT>
3967 template <
typename T1,
bool OPT>
3974 std::vector<std::shared_ptr<arrow::Table>> extractTablesFromFiltered(std::vector<
Filtered<T>>& tables)
3976 std::vector<std::shared_ptr<arrow::Table>> outTables;
3977 for (
auto& table : tables) {
3978 outTables.push_back(table.asArrowTable());
3989template <
typename L,
typename D,
typename O,
typename Key,
typename H,
typename...
Ts>
4020template <
typename T,
bool APPLY>
4022 static constexpr bool applyFilters = APPLY;
4029 SmallGroupsBase(std::vector<std::shared_ptr<arrow::Table>>&& tables, gsl::span<int64_t const>
const& selection, uint64_t
offset = 0)
4033template <
typename T>
4036template <
typename T>
4039template <
typename T>
#define O2HASH(_Str_)
Pre-declare Hash specialization for a generic string.
#define O2ORIGIN(_Str_)
Pre-declare Hash specialization for an origin string.
consteval auto getIndexTargets()
SLICE.
o2::monitoring::tags::Key Key
#define O2_BUILTIN_UNREACHABLE
#define O2_BUILTIN_LIKELY(x)
#define O2_BUILTIN_UNLIKELY(x)
Class for time synchronization of RawReader instances.
int64_t const * mCurrentPos
ColumnIterator(arrow::ChunkedArray const *column)
ColumnIterator(ColumnIterator< T, ChunkingPolicy > const &)=default
void moveToEnd()
Move the iterator to the end of the column.
ColumnIterator< T > & moveToPos()
ColumnIterator< T, ChunkingPolicy > & operator=(ColumnIterator< T, ChunkingPolicy > const &)=default
unwrap_t< T > const * mCurrent
unwrap_t< T > const * mLast
ColumnIterator(ColumnIterator< T, ChunkingPolicy > &&)=default
arrow::ChunkedArray const * mColumn
ColumnIterator< T, ChunkingPolicy > & operator=(ColumnIterator< T, ChunkingPolicy > &&)=default
void moveToChunk(int chunk)
void nextChunk() const
Move the iterator to the next chunk.
auto sliceByCachedUnsorted(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
FilteredBase(std::vector< std::shared_ptr< arrow::Table > > &&tables, gsl::span< int64_t const > const &selection, uint64_t offset=0)
int64_t tableSize() const
FilteredBase(std::vector< std::shared_ptr< arrow::Table > > &&tables, gandiva::Selection const &selection, uint64_t offset=0)
typename T::external_index_columns_t external_index_columns_t
auto select(framework::expressions::Filter const &f) const
static auto getSpan(gandiva::Selection const &sel)
T::template iterator_template_o< FilteredIndexPolicy, self_t > iterator
auto rawSliceBy(o2::framework::Preslice< T1 > const &container, int value) const
T::template iterator_template_o< DefaultIndexPolicy, self_t > unfiltered_iterator
void copyIndexBindings(T1 &dest) const
auto const & getSelectedRows() const
typename T::columns_t columns_t
void bindExternalIndices(TA *... current)
void sumWithSelection(SelectionVector const &selection)
void bindInternalIndicesTo(I const *ptr)
void intersectWithSelection(SelectionVector const &selection)
auto sliceBy(o2::framework::PresliceBase< T1, framework::PreslicePolicyGeneral, OPT > const &container, int value) const
auto rawSlice(uint64_t start, uint64_t end) const
auto sliceBy(o2::framework::PresliceBase< T1, framework::PreslicePolicySorted, OPT > const &container, int value) const
iterator iteratorAt(uint64_t i) const
typename T::table_t table_t
typename T::persistent_columns_t persistent_columns_t
RowViewSentinel end() const
void intersectWithSelection(gsl::span< int64_t const > const &selection)
FilteredBase(std::vector< std::shared_ptr< arrow::Table > > &&tables, SelectionVector &&selection, uint64_t offset=0)
void bindExternalIndicesRaw(std::vector< o2::soa::Binding > &&ptrs)
const_iterator begin() const
unfiltered_iterator rawIteratorAt(uint64_t i) const
int isInSelectedRows(int i) const
auto sliceByCached(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
void doCopyIndexBindings(framework::pack< Cs... >, T1 &dest) const
void sumWithSelection(gsl::span< int64_t const > const &selection)
auto const & cached_begin() const
auto sliceBy(o2::framework::PresliceBase< T1, framework::PreslicePolicySorted, OPT > const &container, int value) const
typename FilteredBase< typename T::table_t >::table_t table_t
Filtered< Filtered< T > > operator+=(gsl::span< int64_t const > const &selection)
typename T::template iterator_template_o< DefaultIndexPolicy, self_t > unfiltered_iterator
Filtered< Filtered< T > > operator+(SelectionVector const &selection)
auto sliceBy(o2::framework::PresliceBase< T1, framework::PreslicePolicyGeneral, OPT > const &container, int value) const
Filtered< Filtered< T > > operator*(gsl::span< int64_t const > const &selection)
typename T::template iterator_template_o< FilteredIndexPolicy, self_t > iterator
typename T::columns_t columns_t
const_iterator begin() const
Filtered(std::vector< Filtered< T > > &&tables, SelectionVector &&selection, uint64_t offset=0)
unfiltered_iterator rawIteratorAt(uint64_t i) const
Filtered< Filtered< T > > operator+=(Filtered< T > const &other)
Filtered< Filtered< T > > operator+=(SelectionVector const &selection)
Filtered< Filtered< T > > operator*=(SelectionVector const &selection)
auto rawSlice(uint64_t start, uint64_t end) const
Filtered< Filtered< T > > operator+(Filtered< T > const &other)
Filtered(std::vector< Filtered< T > > &&tables, gandiva::Selection const &selection, uint64_t offset=0)
Filtered< Filtered< T > > operator*=(Filtered< T > const &other)
auto sliceByCached(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
Filtered< Filtered< T > > operator*=(gsl::span< int64_t const > const &selection)
Filtered< Filtered< T > > operator*(Filtered< T > const &other)
Filtered< Filtered< T > > operator+(gsl::span< int64_t const > const &selection)
Filtered< Filtered< T > > operator*(SelectionVector const &selection)
auto sliceByCachedUnsorted(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
Filtered(std::vector< Filtered< T > > &&tables, gsl::span< int64_t const > const &selection, uint64_t offset=0)
Filtered< T > operator+=(Filtered< T > const &other)
auto sliceBy(o2::framework::PresliceBase< T1, framework::PreslicePolicyGeneral, OPT > const &container, int value) const
Filtered(std::vector< std::shared_ptr< arrow::Table > > &&tables, SelectionVector &&selection, uint64_t offset=0)
Filtered(std::vector< std::shared_ptr< arrow::Table > > &&tables, gsl::span< int64_t const > const &selection, uint64_t offset=0)
auto sliceByCachedUnsorted(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
Filtered< T > operator+(Filtered< T > const &other)
Filtered< T > operator*=(SelectionVector const &selection)
const_iterator begin() const
T::template iterator_template_o< FilteredIndexPolicy, self_t > iterator
auto sliceByCached(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
auto select(framework::expressions::Filter const &f) const
Filtered< T > operator+(SelectionVector const &selection)
Filtered< T > operator*(gsl::span< int64_t const > const &selection)
T::template iterator_template_o< DefaultIndexPolicy, self_t > unfiltered_iterator
unfiltered_iterator rawIteratorAt(uint64_t i) const
Filtered< T > operator*(SelectionVector const &selection)
Filtered< T > operator*=(Filtered< T > const &other)
Filtered< T > operator*(Filtered< T > const &other)
auto rawSliceBy(o2::framework::Preslice< T1 > const &container, int value) const
Filtered< T > operator+=(SelectionVector const &selection)
Filtered< T > operator*=(gsl::span< int64_t const > const &selection)
Filtered< T > operator+(gsl::span< int64_t const > const &selection)
Filtered< T > operator+=(gsl::span< int64_t const > const &selection)
auto rawSlice(uint64_t start, uint64_t end) const
Filtered(std::vector< std::shared_ptr< arrow::Table > > &&tables, gandiva::Selection const &selection, uint64_t offset=0)
auto sliceBy(o2::framework::PresliceBase< T1, framework::PreslicePolicySorted, OPT > const &container, int value) const
typename T::table_t table_t
typename T::columns_t columns_t
decltype([]< typename... C >(framework::pack< C... > &&) -> framework::selected_pack< soa::is_self_index_t, C... > {}(columns_t{})) internal_index_columns_t
void bindInternalIndicesExplicit(o2::soa::Binding binding)
iterator iteratorAt(uint64_t i) const
decltype([]< typename... C >(framework::pack< C... > &&) -> framework::selected_pack< soa::is_persistent_column_t, C... > {}(columns_t{})) persistent_columns_t
static constexpr const auto ref
auto offset() const
Return offset.
static consteval bool hasOriginal()
unfiltered_iterator begin()
int64_t tableSize() const
auto rawSlice(uint64_t start, uint64_t end) const
void bindExternalIndices(TA *... current)
auto select(framework::expressions::Filter const &f) const
unfiltered_iterator unfiltered_const_iterator
static consteval auto full_iter()
auto const & cached_begin() const
auto sliceByCachedUnsorted(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
TableIteratorBase< IP, Parent, T... > iterator_template
void bindExternalIndicesRaw(std::vector< o2::soa::Binding > &&ptrs)
auto sliceBy(o2::framework::PresliceBase< T1, Policy, OPT > const &container, int value) const
static constexpr auto hashes()
iterator unfiltered_iterator
std::shared_ptr< arrow::Table > asArrowTable() const
Return a type erased arrow table backing store for / the type safe table.
void doCopyIndexBindings(framework::pack< Cs... >, T &dest) const
int64_t size() const
Size of the table, in rows.
Table(std::vector< std::shared_ptr< arrow::Table > > &&tables, uint64_t offset=0)
decltype(getColumns< ref, Ts... >()) columns_t
arrow::ChunkedArray * getIndexToKey()
decltype([]< typename... C >(framework::pack< C... >) -> framework::pack< typename C::type... > {}(persistent_columns_t{})) column_types
static consteval auto isIndexTargetOf()
iterator_template_o< FilteredIndexPolicy, table_t > filtered_iterator
unfiltered_const_iterator begin() const
void copyIndexBindings(T &dest) const
static constexpr const auto originalLabels
Table(std::vector< std::shared_ptr< arrow::Table > > &&tables, uint64_t offset=0)
Table< L, D, O, Ts... > self_t
static consteval auto isIndexTargetOf()
decltype(full_iter< IP, Parent >()) iterator_template_o
void doBindInternalIndicesExplicit(framework::pack< Cs... >, o2::soa::Binding binding)
static constexpr const auto originals
decltype([]< typename... C >(framework::pack< C... > &&) -> framework::selected_pack< soa::is_external_index_t, C... > {}(columns_t{})) external_index_columns_t
Table(std::shared_ptr< arrow::Table > table, uint64_t offset=0)
RowViewSentinel end() const
auto sliceByCached(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
void bindInternalIndicesTo(I const *ptr)
unfiltered_iterator rawIteratorAt(uint64_t i) const
filtered_iterator filtered_begin(gsl::span< int64_t const > selection)
iterator_template_o< DefaultIndexPolicy, table_t > iterator
hash identification concepts
Helper to check if a type T is an iterator.
column identification concepts
GLuint GLsizei const GLuint const GLintptr * offsets
GLuint const GLchar * name
GLboolean GLboolean GLboolean b
GLsizei const GLfloat * value
GLint GLint GLsizei GLint GLenum GLenum type
GLuint GLsizei GLsizei * length
GLuint GLsizei const GLchar * label
GLsizei GLenum const void * indices
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GLenum GLenum GLsizei len
GLboolean GLboolean GLboolean GLboolean a
std::shared_ptr< gandiva::SelectionVector > Selection
consteval const char * origin_str()
consteval const char * signature()
consteval auto filterForKey()
Filter TableRef array for compatibility with Key table.
consteval const char * label()
consteval header::DataOrigin origin()
std::shared_ptr< arrow::DataType > concreteArrowType(atype::type type)
gandiva::Selection createSelection(std::shared_ptr< arrow::Table > const &table, Filter const &expression)
Function for creating gandiva selection from our internal filter tree.
Defining PrimaryVertex explicitly as messageable.
std::decay_t< decltype(select_pack< Condition >(pack<>{}, Pack{}, CondPack{}))> selected_pack_multicondition
std::decay_t< decltype(prune_voids_pack(pack<>{}, with_condition_pack< Condition, Types... >{}))> selected_pack
decltype(intersected_pack(Ps{}...)) full_intersected_pack_t
typename pack_element< I, T >::type pack_element_t
consteval size_t has_type_at_v(pack< Ts... >)
constexpr std::size_t pack_size(pack< Ts... > const &)
template function to determine number of types in a pack
decltype(concatenate_pack_unique(Ps{}...)) concatenated_pack_unique_t
std::string strToUpper(std::string &&str)
typename pack_element< 0, T >::type pack_head_t
std::string cutString(std::string &&str)
std::vector< std::vector< int64_t > > ListVector
std::array< std::shared_ptr< arrow::Array >, sizeof...(Cs)> getChunks(arrow::Table *table, framework::pack< Cs... >, uint64_t ci)
ColumnGetterFunction< R, typename T::iterator > getColumnGetterByLabel(const std::string_view &targetColumnLabel)
std::array< arrow::ChunkedArray *, sizeof...(Cs)> getArrowColumns(arrow::Table *table, framework::pack< Cs... >)
std::tuple< typename Cs::type... > getRowData(arrow::Table *table, T rowIterator, uint64_t ci=std::numeric_limits< uint64_t >::max(), uint64_t ai=std::numeric_limits< uint64_t >::max(), uint64_t globalIndex=std::numeric_limits< uint64_t >::max())
C::type getSingleRowData(arrow::Table *table, T &rowIterator, uint64_t ci=std::numeric_limits< uint64_t >::max(), uint64_t ai=std::numeric_limits< uint64_t >::max(), uint64_t globalIndex=std::numeric_limits< uint64_t >::max())
consteval auto computeOriginals()
auto createFieldsFromColumns(framework::pack< C... >)
SelectionVector selectionToVector(gandiva::Selection const &sel)
constexpr bool is_persistent_v
constexpr bool is_ng_index_equivalent_v
consteval auto remove_if(L l)
constexpr auto join(Ts const &... t)
auto doSliceBy(T const *table, o2::framework::PresliceBase< C, Policy, OPT > const &container, int value)
SelectionVector sliceSelection(gsl::span< int64_t const > const &mSelectedRows, int64_t nrows, uint64_t offset)
void notBoundTable(const char *tableName)
auto doFilteredSliceBy(T const *table, o2::framework::PresliceBase< C, framework::PreslicePolicySorted, OPT > const &container, int value)
constexpr auto concat(Ts const &... t)
consteval auto intersectOriginals()
consteval auto getColumns()
std::vector< int64_t > SelectionVector
std::conditional_t< is_binding_compatible_v< T, typename B::binding_t >(), std::true_type, std::false_type > is_binding_compatible
consteval auto mergeOriginals()
constexpr bool is_soa_filtered_v
typename std::conditional_t< is_index_column< C >, std::true_type, std::false_type > is_external_index_t
void missingFilterDeclaration(int hash, int ai)
auto doSliceByCachedUnsorted(T const *table, framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache)
auto doSliceByCached(T const *table, framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache)
void accessingInvalidIndexFor(const char *getter)
auto select(T const &t, framework::expressions::Filter const &f)
consteval auto base_iter(framework::pack< C... > &&) -> TableIterator< D, O, IP, C... >
constexpr bool is_index_equivalent_v
constexpr bool is_soa_join_v
void dereferenceWithWrongType(const char *getter, const char *target)
std::conditional_t< is_indexing_column< T >, std::true_type, std::false_type > is_indexing_t
auto doSliceByHelper(T const *table, gsl::span< const int64_t > const &selection)
consteval bool is_binding_compatible_v()
auto prepareFilteredSlice(T const *table, std::shared_ptr< arrow::Table > slice, uint64_t offset)
typename unwrap< T >::type unwrap_t
void getterNotFound(const char *targetColumnLabel)
auto doFilteredSliceByCached(T const *table, framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache)
void missingOptionalPreslice(const char *label, const char *key)
consteval bool is_compatible()
arrow::ChunkedArray * getIndexFromLabel(arrow::Table *table, std::string_view label)
consteval auto merge()
Helpers to manipulate TableRef arrays.
consteval auto merge_if(L l)
std::conditional_t< is_persistent_column< C >, std::true_type, std::false_type > is_persistent_column_t
typename arrow_array_for< T >::type arrow_array_for_t
void notFoundColumn(const char *label, const char *key)
std::conditional_t< is_dynamic_column< T >, std::true_type, std::false_type > is_dynamic_t
typename std::conditional_t< is_self_index_column< C >, std::true_type, std::false_type > is_self_index_t
Defining DataPointCompositeObject explicitly as copiable.
FIXME: do not use data model tables.
static constexpr uint32_t hash
static constexpr char const *const str
SliceInfoUnsortedPtr getCacheUnsortedFor(Entry const &bindingKey) const
SliceInfoPtr getCacheFor(Entry const &bindingKey) const
std::shared_ptr< arrow::Table > getSliceFor(int value, std::shared_ptr< arrow::Table > const &input, uint64_t &offset) const
static constexpr bool optional
PresliceBase(expressions::BindingNode index_)
gsl::span< const int64_t > getSliceFor(int value) const
const std::string binding
const std::string binding
Entry const & getBindingKey() const
SliceInfoUnsortedPtr sliceInfo
gsl::span< const int64_t > getSliceFor(int value) const
void updateSliceInfo(SliceInfoUnsortedPtr &&si)
void updateSliceInfo(SliceInfoPtr &&si)
std::shared_ptr< arrow::Table > getSliceFor(int value, std::shared_ptr< arrow::Table > const &input, uint64_t &offset) const
ArrowTableSlicingCache * ptr
std::pair< int64_t, int64_t > getSliceFor(int value) const
An expression tree node corresponding to a column binding.
A struct, containing the root of the expression tree.
From https://en.cppreference.com/w/cpp/utility/variant/visit.
static std::shared_ptr< arrow::Table > joinTables(std::vector< std::shared_ptr< arrow::Table > > &&tables, std::span< const char *const > labels)
static std::shared_ptr< arrow::Table > concatTables(std::vector< std::shared_ptr< arrow::Table > > &&tables)
Type-checking index column binding.
std::span< TableRef const > refs
void bind(T const *table)
static constexpr bool chunked
arrow::ChunkedArray * second
Column(ColumnIterator< T > const &it)
static constexpr const char *const & columnLabel()
ColumnIterator< T > const & getIterator() const
Column & operator=(Column const &)=default
Column(Column &&)=default
static auto asArrowField()
Column & operator=(Column &&)=default
Column(Column const &)=default
ColumnIterator< T > mColumnIterator
table_t::template iterator_template< DefaultIndexPolicy, self_t, Ts... > iterator
Concat(Ts const &... t, uint64_t offset=0)
typename table_t::persistent_columns_t persistent_columns_t
typename table_t::columns_t columns_t
const_iterator unfiltered_const_iterator
iterator unfiltered_iterator
table_t::template iterator_template< FilteredIndexPolicy, self_t, Ts... > filtered_iterator
Concat(std::vector< std::shared_ptr< arrow::Table > > &&tables, uint64_t offset=0)
filtered_iterator filtered_const_iterator
DefaultIndexPolicy(int64_t nRows, uint64_t offset)
friend bool operator==(DefaultIndexPolicy const &lh, DefaultIndexPolicy const &rh)
bool operator==(RowViewSentinel const &sentinel) const
DefaultIndexPolicy(FilteredIndexPolicy const &other)
std::tuple< uint64_t const * > getOffsets() const
DefaultIndexPolicy & operator=(DefaultIndexPolicy &&)=default
void setCursor(int64_t i)
void limitRange(int64_t start, int64_t end)
DefaultIndexPolicy(DefaultIndexPolicy &&)=default
DefaultIndexPolicy(DefaultIndexPolicy const &)=default
DefaultIndexPolicy & operator=(DefaultIndexPolicy const &)=default
std::tuple< int64_t const *, int64_t const * > getIndices() const
DefaultIndexPolicy()=default
Needed to be able to copy the policy.
void moveByIndex(int64_t i)
static constexpr const char *const & columnLabel()
void resetSelection(gsl::span< int64_t const > selection)
FilteredIndexPolicy & operator=(FilteredIndexPolicy &&)=default
std::tuple< int64_t const *, int64_t const * > getIndices() const
FilteredIndexPolicy & operator=(FilteredIndexPolicy const &)=default
auto getSelectionRow() const
FilteredIndexPolicy()=default
friend bool operator==(FilteredIndexPolicy const &lh, FilteredIndexPolicy const &rh)
void setCursor(int64_t i)
FilteredIndexPolicy(FilteredIndexPolicy const &)=default
bool operator==(RowViewSentinel const &sentinel) const
std::tuple< uint64_t const * > getOffsets() const
void limitRange(int64_t start, int64_t end)
FilteredIndexPolicy(gsl::span< int64_t const > selection, int64_t rows, uint64_t offset=0)
FilteredIndexPolicy(FilteredIndexPolicy &&)=default
void moveByIndex(int64_t i)
static constexpr bool chunked
static constexpr const char *const & columnLabel()
static constexpr const uint32_t hash
uint64_t mOffset
Offset within a larger table.
int64_t mRowIndex
Position inside the current table.
IndexTable(std::vector< std::shared_ptr< arrow::Table > > tables, uint64_t offset=0)
IndexTable(std::shared_ptr< arrow::Table > table, uint64_t offset=0)
typename base_t::template iterator_template_o< DefaultIndexPolicy, self_t > iterator
filtered_iterator const_filtered_iterator
IndexTable(IndexTable &&)=default
IndexTable & operator=(IndexTable const &)=default
IndexTable & operator=(IndexTable &&)=default
typename H::binding_t first_t
typename base_t::template iterator_template_o< FilteredIndexPolicy, self_t > filtered_iterator
IndexTable(IndexTable const &)=default
Index(Index const &)=default
void setIndices(std::tuple< int64_t const *, int64_t const * > indices)
Index & operator=(Index &&)=default
Index(arrow::ChunkedArray const *)
int64_t filteredIndex() const
constexpr int64_t rangeEnd()
constexpr int64_t rangeStart()
Index & operator=(Index const &)=default
int64_t globalIndex() const
std::tuple< int64_t const *, int64_t const * > rowIndices
void setOffsets(std::tuple< uint64_t const * > offsets)
static constexpr const char * mLabel
std::tuple< uint64_t const * > rowOffsets
iterator unfiltered_iterator
auto sliceBy(o2::framework::PresliceBase< T1, Policy, OPT > const &container, int value) const
auto rawSlice(uint64_t start, uint64_t end) const
auto sliceByCachedUnsorted(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
JoinFull(std::vector< std::shared_ptr< arrow::Table > > &&tables, uint64_t offset=0)
static constexpr const auto originalLabels
const_iterator unfiltered_const_iterator
filtered_iterator filtered_const_iterator
static consteval bool contains()
iterator iteratorAt(uint64_t i) const
typename table_t::columns_t columns_t
table_t::template iterator_template< DefaultIndexPolicy, self_t, Ts... > iterator
table_t::template iterator_template< FilteredIndexPolicy, self_t, Ts... > filtered_iterator
static constexpr const auto originals
JoinFull< D, Ts... > self_t
const_iterator begin() const
typename table_t::persistent_columns_t persistent_columns_t
iterator rawIteratorAt(uint64_t i) const
Table< o2::aod::Hash<"JOIN"_h >, D, o2::aod::Hash<"JOIN"_h >, Ts... > base
JoinFull(std::shared_ptr< arrow::Table > &&table, uint64_t offset=0)
auto sliceByCached(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
static constexpr const uint32_t hash
static constexpr const char *const & columnLabel()
Marker & operator=(Marker const &)=default
static constexpr auto value
static constexpr const char * mLabel
Marker(arrow::ChunkedArray const *)
Marker(Marker const &)=default
Marker & operator=(Marker &&)=default
Marker(Marker &&)=default
SmallGroupsBase(std::vector< std::shared_ptr< arrow::Table > > &&tables, SelectionVector &&selection, uint64_t offset=0)
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, gandiva::Selection const &selection, uint64_t offset=0)
framework::selected_pack< soa::is_persistent_column_t, C... > persistent_columns_t
void doSetCurrentIndexRaw(framework::pack< Cs... > p, std::vector< o2::soa::Binding > &&ptrs)
void bindInternalIndices(I const *table)
TableIterator(TableIterator< D, O, FilteredIndexPolicy, C... > const &other)
TableIterator(self_t const &other)
TableIterator operator-(int64_t dec) const
TableIterator(arrow::ChunkedArray *columnData[sizeof...(C)], IP &&policy)
TableIterator & operator=(TableIterator other)
TableIterator & operator++()
void doSetCurrentInternal(framework::pack< Cs... >, I const *ptr)
auto getIndexBindingsImpl(framework::pack< Cs... >) const
TableIterator operator--(int)
void bindExternalIndicesRaw(std::vector< o2::soa::Binding > &&ptrs)
TableIterator(arrow::ChunkedArray *columnData[sizeof...(C)], IP &&policy)
decltype([]< typename... Cs >(framework::pack< Cs... >) -> framework::pack< typename Cs::binding_t... > {}(external_index_columns_t{})) bindings_pack_t
void bindExternalIndices(TA *... current)
TableIterator & operator--()
framework::selected_pack< soa::is_external_index_t, C... > external_index_columns_t
TableIterator const & operator*() const
TableIterator operator++(int)
framework::selected_pack< soa::is_self_index_t, C... > internal_index_columns_t
auto getIndexBindings() const
void doSetCurrentIndex(framework::pack< CL... >, TA *current)
TableIterator operator+(int64_t inc) const
Allow incrementing by more than one the iterator.
Generic identifier for a table type.
constexpr TableRef & operator=(TableRef const &)=default
constexpr bool descriptionCompatible(uint32_t _desc_hash) const noexcept
constexpr bool operator==(TableRef const &other) const noexcept
constexpr TableRef(TableRef &&)=default
constexpr TableRef(TableRef const &)=default
consteval TableRef(uint32_t _label, uint32_t _desc, uint32_t _origin, uint32_t _version)
constexpr bool descriptionCompatible(TableRef const &other) const noexcept
constexpr TableRef & operator=(TableRef &&)=default
TableIteratorBase const & operator*() const
TableIteratorBase(TableIteratorBase< IP, P, T... > const &other)
typename Parent::columns_t columns_t
TableIteratorBase(TableIteratorBase< IP, P, O1, Os... > const &other)
typename Parent::external_index_columns_t external_index_columns_t
TableIteratorBase operator-(int64_t dec) const
void matchTo(TableIteratorBase< IP, P, T... > const &other)
auto getDynamicColumn() const
TableIteratorBase()=default
void matchTo(TableIteratorBase< IP, P, Os... > const &other)
TableIteratorBase(TableIteratorBase< FilteredIndexPolicy, P, T... > other)
std::array< B, sizeof...(CCs)> getValues() const
static constexpr auto originals
TableIteratorBase(TableIteratorBase< IP, P, T... > &&other) noexcept
decltype([]< typename... C >(framework::pack< C... >) -> framework::pack< typename C::binding_t... > {}(external_index_columns_t{})) bindings_pack_t
TableIteratorBase & operator=(TableIteratorBase< IP, P, Os... > other)
TableIteratorBase(TableIteratorBase< IP, P, O1, Os... > &&other) noexcept
TableIteratorBase & operator=(RowViewSentinel const &other)
TableIteratorBase(arrow::ChunkedArray *columnData[framework::pack_size(columns_t{})], IP &&policy)
TableIteratorBase & operator=(TableIteratorBase< IP, P, T... > other)
TableIteratorBase operator+(int64_t inc) const
Allow incrementing by more than one the iterator.
TableIteratorBase & operator=(TableIteratorBase< FilteredIndexPolicy, P, T... > other)
VectorOfTObjectPtrs other
std::vector< ReadoutWindowData > rows