12#ifndef O2_FRAMEWORK_ASOA_H_
13#define O2_FRAMEWORK_ASOA_H_
16#error "Please do not include this file in ROOT dictionary generation"
31#include <arrow/array/array_binary.h>
32#include <arrow/table.h>
33#include <arrow/array.h>
34#include <arrow/util/config.h>
35#include <gandiva/selection_vector.h>
38#include <fmt/format.h>
45using ListVector = std::vector<std::vector<int64_t>>;
61template <
typename...
C>
64 return std::vector<std::shared_ptr<arrow::Field>>{C::asArrowField()...};
79 consteval TableRef(uint32_t _label, uint32_t _desc, uint32_t _origin, uint32_t _version)
93 return (this->label_hash ==
other.label_hash) &&
94 (this->desc_hash ==
other.desc_hash) &&
95 (this->origin_hash ==
other.origin_hash) &&
96 (this->version ==
other.version);
101 return this->desc_hash ==
other.desc_hash;
106 return this->desc_hash == _desc_hash;
116template <
size_t N1,
size_t N2, std::array<TableRef, N1> ar1, std::array<TableRef, N2> ar2>
119 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; }); });
120 std::array<TableRef, N1 + N2 - duplicates> out;
122 auto pos = std::copy(ar1.begin(), ar1.end(), out.begin());
123 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; }); });
127template <
size_t N1,
size_t N2, std::array<TableRef, N1> ar1, std::array<TableRef, N2> ar2,
typename L>
130 constexpr const int to_remove = std::ranges::count_if(ar1.begin(), ar1.end(), [&](
TableRef const&
a) { return !l(a); });
131 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); });
132 std::array<TableRef, N1 + N2 - duplicates - to_remove> out;
134 auto pos = std::copy_if(ar1.begin(), ar1.end(), out.begin(), [&](TableRef
const&
a) { return l(a); });
135 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); });
139template <
size_t N, std::array<TableRef, N> ar,
typename L>
142 constexpr const int to_remove = std::ranges::count_if(ar.begin(), ar.end(), [&l](
TableRef const& e) { return l(e); });
143 std::array<
TableRef, N - to_remove> out;
144 std::copy_if(ar.begin(), ar.end(), out.begin(), [&l](
TableRef const& e) { return !l(e); });
148template <
size_t N1,
size_t N2, std::array<TableRef, N1> ar1, std::array<TableRef, N2> ar2>
149consteval auto intersect()
151 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; }); });
152 std::array<TableRef, duplicates> out;
153 std::copy_if(ar1.begin(), ar1.end(), out.begin(), [](TableRef
const&
a) { return std::find(ar2.begin(), ar2.end(), a) != ar2.end(); });
157template <
typename T,
typename... Ts>
159 requires(
sizeof...(Ts) == 1)
162 return merge<T::originals.size(), T1::originals.size(), T::originals, T1::originals>();
165template <
typename T,
typename...
Ts>
167 requires(
sizeof...(Ts) > 1)
170 return merge<T::originals.size(), tail.size(), T::originals, tail>();
173template <
typename T,
typename...
Ts>
174 requires(
sizeof...(Ts) == 1)
175consteval auto intersectOriginals()
178 return intersect<T::originals.size(), T1::originals.size(), T::originals, T1::originals>();
181template <
typename T,
typename...
Ts>
182 requires(
sizeof...(Ts) > 1)
183consteval auto intersectOriginals()
186 return intersect<T::originals.size(), tail.size(), T::originals, tail>();
195concept not_void =
requires { !std::same_as<T, void>; };
212 {
c.setCurrentRaw(
b) } -> std::same_as<bool>;
217using is_external_index_t =
typename std::conditional_t<is_index_column<C>, std::true_type, std::false_type>;
220using is_self_index_t =
typename std::conditional_t<is_self_index_column<C>, std::true_type, std::false_type>;
227template <
typename Key,
size_t N, std::array<
bool, N> map>
228static consteval int getIndexPosToKey_impl()
230 constexpr const auto pos = std::find(map.begin(), map.end(),
true);
231 if constexpr (
pos != map.end()) {
232 return std::distance(map.begin(),
pos);
240template <
typename D,
typename... Cs>
247 template <
typename Key,
typename... PCs>
250 return std::array<bool,
sizeof...(PCs)>{[]() {
251 if constexpr (
requires { PCs::index_targets.size(); }) {
252 return Key::template isIndexTargetOf<PCs::index_targets.size(), PCs::index_targets>();
259 template <
typename Key>
280 static constexpr uint32_t
hash = H;
281 static constexpr char const*
const str{
""};
285template <
size_t N, std::array<soa::TableRef, N> ar,
typename Key>
288 constexpr std::array<bool, N>
test = []<
size_t... Is>(std::index_sequence<Is...>) {
289 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))...};
290 }(std::make_index_sequence<N>());
291 constexpr int correct = std::ranges::count(
test.begin(),
test.end(),
true);
292 std::array<soa::TableRef, correct> out;
293 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))]; });
298#define O2HASH(_Str_) \
300 struct Hash<_Str_ ""_h> { \
301 static constexpr uint32_t hash = _Str_ ""_h; \
302 static constexpr char const* const str{_Str_}; \
306#define O2ORIGIN(_Str_) \
308 struct Hash<_Str_ ""_h> { \
309 static constexpr header::DataOrigin origin{_Str_}; \
310 static constexpr uint32_t hash = _Str_ ""_h; \
311 static constexpr char const* const str{_Str_}; \
315static inline constexpr uint32_t
version(
const char*
const str)
317 if (
str[0] ==
'\0') {
325 if (
str[
len - 1] ==
'\0') {
328 for (
auto i =
len + 1;
str[
i] !=
'\0'; ++
i) {
335static inline constexpr std::string_view description_str(
const char*
const str)
341 return std::string_view{
str,
len};
351 for (
auto i = 0;
i < 16; ++
i) {
354 std::memcpy(out,
str,
len);
359template <soa::TableRef R>
365template <soa::TableRef R>
371template <soa::TableRef R>
377template <soa::TableRef R>
383template <soa::TableRef R>
386 return {origin<R>(),
description(signature<R>()),
R.version};
397template <soa::TableRef R>
398static constexpr auto sourceSpec()
400 return fmt::format(
"{}/{}/{}/{}",
label<R>(), origin_str<R>(), description_str(signature<R>()),
R.version);
404template <
size_t N, std::array<soa::TableRef, N> ar, o2::aod::is_origin_hash O>
407 std::array<soa::TableRef, N>
res;
408 for (
auto i = 0U;
i < N; ++
i) {
409 res[
i].label_hash = ar[
i].label_hash;
410 res[
i].desc_hash = ar[
i].desc_hash;
411 res[
i].origin_hash = O::hash;
412 res[
i].version = ar[
i].version;
420template <aod::is_aod_hash L, aod::is_aod_hash D, aod::is_origin_hash O,
typename... Ts>
425 void const*
ptr =
nullptr;
429 template <
typename T>
433 hash = o2::framework::TypeIdHelpers::uniqueId<T>();
437 template <
typename T>
440 if (
hash == o2::framework::TypeIdHelpers::uniqueId<T>()) {
441 return static_cast<T const*
>(
ptr);
470template <
typename B,
typename E>
472 constexpr static bool value =
false;
475template <aod::is_aod_hash A, aod::is_aod_hash B>
477 constexpr static bool value =
false;
480template <
typename B,
typename E>
483template <aod::is_aod_hash A, aod::is_aod_hash B>
522template <
typename T,
typename ChunkingPolicy = Chunked>
525 static constexpr char SCALE_FACTOR = std::same_as<std::decay_t<T>,
bool> ? 3 : 0;
541 auto array = getCurrentArray();
556 auto previousArray = getCurrentArray();
560 auto array = getCurrentArray();
567 auto previousArray = getCurrentArray();
571 auto array = getCurrentArray();
593 auto array = getCurrentArray();
600 requires
std::same_as<
bool,
std::decay_t<T>>
616 decltype(
auto)
operator*()
const
617 requires((!std::same_as<bool, std::decay_t<T>>) && std::same_as<
arrow_array_for_t<T>, arrow::BinaryViewArray>)
624 decltype(
auto)
operator*()
const
647 void checkSkipChunk() const
656 void checkSkipChunk() const
664 void checkSkipChunk() const
665 requires(ChunkingPolicy::
chunked == false)
669 auto getCurrentArray() const
673 mOffset = chunkToUse->offset();
674 chunkToUse = std::dynamic_pointer_cast<arrow::FixedSizeListArray>(chunkToUse)->values();
675 return std::static_pointer_cast<arrow_array_for_t<value_for_t<T>>>(chunkToUse);
678 auto getCurrentArray() const
682 mOffset = chunkToUse->offset();
683 chunkToUse = std::dynamic_pointer_cast<arrow::ListArray>(chunkToUse)->values();
684 mOffset = chunkToUse->offset();
685 return std::static_pointer_cast<arrow_array_for_t<value_for_t<T>>>(chunkToUse);
688 auto getCurrentArray() const
692 mOffset = chunkToUse->offset();
693 return std::static_pointer_cast<arrow_array_for_t<T>>(chunkToUse);
697template <
typename T,
typename INHERIT>
713 static constexpr const char*
const&
columnLabel() {
return INHERIT::mLabel; }
721 return std::make_shared<arrow::Field>(inherited_t::mLabel, soa::asArrowDataType<type>());
731template <
typename F,
typename INHERIT>
735 static constexpr const char*
const&
columnLabel() {
return INHERIT::mLabel; }
738template <
typename INHERIT>
741 static constexpr const uint32_t
hash = 0;
743 static constexpr const char*
const&
columnLabel() {
return INHERIT::mLabel; }
746template <
typename INHERIT>
749 static constexpr const uint32_t
hash = 0;
751 static constexpr const char*
const&
columnLabel() {
return INHERIT::mLabel; }
754template <
size_t M = 0>
758 constexpr inline static auto value = M;
773 static constexpr const char*
mLabel =
"Marker";
840 static constexpr const char*
mLabel =
"Index";
864using is_dynamic_t = std::conditional_t<is_dynamic_column<T>, std::true_type, std::false_type>;
870using is_indexing_t = std::conditional_t<is_indexing_column<T>, std::true_type, std::false_type>;
891 mSelectedRows(selection),
892 mMaxSelection(selection.
size()),
900 mSelectedRows = selection;
901 mMaxSelection = selection.size();
911 [[nodiscard]] std::tuple<int64_t const*, int64_t const*>
914 return std::make_tuple(&
mRowIndex, &mSelectionRow);
917 [[nodiscard]] std::tuple<uint64_t const*>
920 return std::make_tuple(&
mOffset);
927 mMaxSelection = std::min(
end, mMaxSelection);
945 return lh.mSelectionRow == rh.mSelectionRow;
958 this->mSelectionRow = this->mMaxSelection;
964 return mSelectionRow;
967 [[nodiscard]]
auto size()
const
969 return mMaxSelection;
978 inline void updateRow()
982 std::span<int64_t const> mSelectedRows;
1019 [[nodiscard]] std::tuple<int64_t const*, int64_t const*>
1025 [[nodiscard]] std::tuple<uint64_t const*>
1028 return std::make_tuple(&
mOffset);
1069template <
typename T>
1074template <
typename C>
1080template <
typename T,
typename B>
1082 { t.B::mColumnIterator };
1085template <
typename...
C>
1088template <
typename D,
typename O,
typename IP,
typename... C>
1103 if (this->
size() != 0) {
1113 if (this->
size() != 0) {
1120 this->limitRange(this->rangeStart(), this->rangeEnd());
1126 C(static_cast<
C const&>(
other))...
1128 if (this->
size() != 0) {
1135 IP::operator=(
static_cast<IP const&
>(
other));
1136 (
void(
static_cast<C&
>(*
this) =
static_cast<C>(
other)), ...);
1137 if (this->
size() != 0) {
1144 requires std::same_as<IP, DefaultIndexPolicy>
1146 C(
static_cast<C const&
>(
other))...
1148 if (this->
size() != 0) {
1155 this->moveByIndex(1);
1168 this->moveByIndex(-1);
1183 copy.moveByIndex(inc);
1197 template <
typename CL>
1200 return CL::getCurrentRaw();
1203 template <
typename... Cs>
1206 return std::vector<o2::soa::Binding>{
static_cast<Cs const&
>(*this).getCurrentRaw()...};
1214 template <
typename... TA>
1218 (CCs::setCurrent(cur), ...);
1223 template <
typename TA>
1227 (CCs::setCurrent(cur), ...);
1231 template <
typename... Cs>
1234 (Cs::setCurrentRaw(ptrs[framework::has_type_at_v<Cs>(p)]), ...);
1237 template <
typename... Cs,
typename I>
1242 (Cs::setCurrentRaw(
b), ...);
1250 template <
typename I>
1258 template <
typename... PC>
1261 (PC::mColumnIterator.moveToEnd(), ...);
1271 [
this]<soa::is_dynamic_column T>(T*) ->
void { bindDynamicColumn<T>(
typename T::bindings_t{}); },
1272 [
this]<
typename T>(
T*) ->
void {},
1274 (
f(
static_cast<C*
>(
nullptr)), ...);
1275 if constexpr (has_index<
C...>) {
1276 this->setIndices(this->getIndices());
1277 this->setOffsets(this->getOffsets());
1281 template <
typename DC,
typename...
B>
1284 DC::boundIterators = std::make_tuple(getDynamicBinding<B>()...);
1292 template <
typename B>
1293 requires(can_bind<self_t, B>)
1294 decltype(
auto) getDynamicBinding()
1296 static_assert(std::same_as<decltype(&(static_cast<B*>(
this)->mColumnIterator)), std::decay_t<
decltype(B::mColumnIterator)>*>,
"foo");
1297 return &(
static_cast<B*
>(
this)->mColumnIterator);
1301 template <
typename B>
1302 decltype(
auto) getDynamicBinding()
1304 return static_cast<std::decay_t<decltype(B::mColumnIterator)
>*>(
nullptr);
1309 static std::shared_ptr<arrow::Table>
joinTables(std::vector<std::shared_ptr<arrow::Table>>&& tables);
1310 static std::shared_ptr<arrow::Table>
joinTables(std::vector<std::shared_ptr<arrow::Table>>&& tables, std::span<const char* const>
labels);
1311 static std::shared_ptr<arrow::Table>
joinTables(std::vector<std::shared_ptr<arrow::Table>>&& tables, std::span<const std::string>
labels);
1312 static std::shared_ptr<arrow::Table>
concatTables(std::vector<std::shared_ptr<arrow::Table>>&& tables);
1316template <
typename T>
1319template <
typename T>
1322template <
typename T>
1324 T::originals.size();
1327template <
typename T>
1332template <
typename T>
1337template <
typename T>
1339 T::ccdb_urls.size();
1342template <
typename T>
1347template <
typename T>
1349 typename T::expression_pack_t{};
1352template <
typename T>
1354 typename T::index_pack_t{};
1357template <
size_t N1, std::array<TableRef, N1> os1,
size_t N2, std::array<TableRef, N2> os2>
1360 return []<
size_t... Is>(std::index_sequence<Is...>) {
1361 return ([]<
size_t... Ks>(std::index_sequence<Ks...>) {
1362 constexpr auto h = os1[Is].desc_hash;
1365 }(std::make_index_sequence<N2>()) ||
1367 }(std::make_index_sequence<N1>());
1370template <with_originals T, with_originals B>
1373 return is_compatible<T::originals.size(), T::originals, B::originals.size(), B::originals>();
1376template <
typename T,
typename B>
1377using is_binding_compatible = std::conditional_t<is_binding_compatible_v<T, typename B::binding_t>(), std::true_type, std::false_type>;
1379template <
typename L,
typename D,
typename O,
typename Key,
typename H,
typename...
Ts>
1382template <
typename T>
1385template <soa::is_table T>
1386static constexpr std::string getLabelForTable()
1388 return std::string{aod::label<std::decay_t<T>::originals[0]>()};
1391template <soa::is_table T>
1393static constexpr std::string getLabelFromType()
1395 return getLabelForTable<T>();
1398template <soa::is_iterator T>
1399static constexpr std::string getLabelFromType()
1401 return getLabelForTable<typename std::decay_t<T>::parent_t>();
1404template <soa::is_index_table T>
1405static constexpr std::string getLabelFromType()
1407 return getLabelForTable<typename std::decay_t<T>::first_t>();
1409template <soa::with_base_table T>
1410 requires(!soa::is_iterator<T>)
1411static constexpr std::string getLabelFromType()
1416template <
typename...
C>
1419 auto caseInsensitiveCompare = [](
const std::string_view& str1,
const std::string_view& str2) {
1420 return std::ranges::equal(
1422 [](
char c1,
char c2) {
1423 return std::tolower(
static_cast<unsigned char>(c1)) ==
1424 std::tolower(
static_cast<unsigned char>(c2));
1427 return (caseInsensitiveCompare(C::inherited_t::mLabel,
key) || ...);
1430template <TableRef ref>
1431static constexpr std::pair<bool, std::string> hasKey(std::string_view
key)
1436template <TableRef ref>
1437static constexpr std::pair<bool, framework::ConcreteDataMatcher> hasKeyM(std::string_view
key)
1445template <with_originals T,
bool OPT = false>
1446static constexpr std::string getLabelFromTypeForKey(std::string_view
key)
1448 auto locate = []<
size_t... Is>(std::index_sequence<Is...>, std::string_view
key) {
1449 return std::array{hasKey<T::originals[Is]>(
key)...} |
1450 std::views::filter([](
auto const&
x) {
return x.first; });
1451 }(std::make_index_sequence<T::originals.size()>{},
key);
1452 if (!locate.empty()) {
1453 return locate.front().second;
1456 if constexpr (!OPT) {
1464template <with_originals T,
bool OPT = false>
1467 auto locate = []<
size_t... Is>(std::index_sequence<Is...>, std::string_view
key) {
1468 return std::array{hasKeyM<T::originals[Is]>(
key)...} |
1469 std::views::filter([](
auto const&
x) {
return x.first; });
1470 }(std::make_index_sequence<T::originals.size()>{},
key);
1471 if (!locate.empty()) {
1472 return locate.front().second;
1475 if constexpr (!OPT) {
1483template <
typename B,
typename...
C>
1486 return (o2::soa::is_binding_compatible_v<B, typename C::binding_t>() || ...);
1489template <
typename B,
typename...
C>
1492 return ((C::sorted && o2::soa::is_binding_compatible_v<B, typename C::binding_t>()) || ...);
1495template <
typename B,
typename Z>
1496consteval static bool relatedByIndex()
1498 return hasIndexTo<B>(
typename Z::table_t::external_index_columns_t{});
1501template <
typename B,
typename Z>
1502consteval static bool relatedBySortedIndex()
1504 return hasSortedIndexTo<B>(
typename Z::table_t::external_index_columns_t{});
1523 std::shared_ptr<arrow::Table>
getSliceFor(
int value, std::shared_ptr<arrow::Table>
const& input, uint64_t&
offset)
const;
1528 mutable std::pair<arrow::Table const*, std::shared_ptr<arrow::Table>>
emptySlice{
nullptr,
nullptr};
1538template <
typename T>
1541template <soa::is_table T, is_preslice_policy Policy,
bool OPT = false>
1549 : Policy{
PreslicePolicyBase{{o2::soa::getLabelFromTypeForKey<T, OPT>(std::string{index_.
name})},
Entry(o2::soa::getLabelFromTypeForKey<T, OPT>(std::string{index_.name}), o2::soa::getMatcherFromTypeForKey<T, OPT>(std::string{index_.name}), std::string{index_.name})}, {}}
1555 if constexpr (OPT) {
1556 if (Policy::isMissing()) {
1565 if constexpr (OPT) {
1566 if (Policy::isMissing()) {
1570 return Policy::getSliceFor(
value);
1574template <soa::is_table T>
1576template <soa::is_table T>
1578template <soa::is_table T>
1580template <soa::is_table T>
1583template <
typename T>
1605template <
typename T>
1612template <soa::is_table T>
1614template <
typename T>
1617template <
typename T>
1620template <
typename T>
1623template <
typename T>
1627template <
typename T>
1630template <
typename T>
1633template <
typename T>
1637template <
typename... Is>
1645template <
typename T,
typename C,
typename Policy,
bool OPT>
1646 requires std::same_as<Policy, framework::PreslicePolicySorted> && (o2::soa::is_binding_compatible_v<C, T>())
1649 if constexpr (OPT) {
1650 if (container.isMissing()) {
1656 auto t =
typename T::self_t({out},
offset);
1657 if (t.tableSize() != 0) {
1658 table->copyIndexBindings(t);
1659 t.bindInternalIndicesTo(table);
1664template <soa::is_filtered_table T>
1668 if (t.tableSize() != 0) {
1670 t.bindInternalIndicesTo(table);
1671 t.intersectWithSelection(table->getSelectedRows());
1676template <soa::is_table T>
1681 if (t.tableSize() != 0) {
1683 t.bindInternalIndicesTo(table);
1688template <
typename T,
typename C,
typename Policy,
bool OPT>
1689 requires std::same_as<Policy, framework::PreslicePolicyGeneral> && (o2::soa::is_binding_compatible_v<C, T>())
1692 if constexpr (OPT) {
1693 if (container.isMissing()) {
1703template <soa::is_filtered_table T>
1706 if (
offset >=
static_cast<uint64_t
>(table->tableSize())) {
1708 if (fresult.tableSize() != 0) {
1715 if (fresult.tableSize() != 0) {
1721template <soa::is_filtered_table T,
typename C,
bool OPT>
1722 requires(o2::soa::is_binding_compatible_v<C, T>())
1725 if constexpr (OPT) {
1726 if (container.isMissing()) {
1737template <soa::is_table T>
1745 : table->asArrowTable()->Slice(
static_cast<uint64_t
>(
offset),
count);
1746 auto t =
typename T::self_t({slice},
static_cast<uint64_t
>(
offset));
1747 if (t.tableSize() != 0) {
1748 table->copyIndexBindings(t);
1753template <soa::is_filtered_table T>
1761 : table->asArrowTable()->Slice(
static_cast<uint64_t
>(
offset),
count);
1765template <soa::is_table T>
1771 auto t =
typename T::self_t({table->asArrowTable()}, localCache.getSliceFor(
value));
1772 if (t.tableSize() != 0) {
1773 t.intersectWithSelection(table->getSelectedRows());
1774 table->copyIndexBindings(t);
1778 auto t =
Filtered<T>({table->asArrowTable()}, localCache.getSliceFor(
value));
1779 if (t.tableSize() != 0) {
1780 table->copyIndexBindings(t);
1786template <with_originals T>
1794template <
typename D,
typename O,
typename IP,
typename...
C>
1831 return std::array<TableRef, 1>{
ref};
1847 static constexpr const auto ref =
TableRef{L::hash, D::hash, O::hash, o2::aod::version(D::str)};
1852 static constexpr const auto originalLabels = []<
size_t N, std::array<TableRef, N> refs,
size_t... Is>(std::index_sequence<Is...>) {
1853 return std::array<const char*, N>{o2::aod::label<refs[Is]>()...};
1858 template <
size_t N, std::array<TableRef, N> bindings>
1859 requires(
ref.origin_hash ==
"CONC"_h)
1865 template <
size_t N, std::array<TableRef, N> bindings>
1866 requires(
ref.origin_hash ==
"JOIN"_h)
1871 return std::ranges::any_of(bindings, [&
r](
TableRef const&
b) {
return b ==
r; });
1875 template <
size_t N, std::array<TableRef, N> bindings>
1876 requires(!(
ref.origin_hash ==
"CONC"_h ||
ref.origin_hash ==
"JOIN"_h))
1879 return std::find(bindings.begin(), bindings.end(),
self_t::ref) != bindings.end();
1882 template <TableRef r>
1895 template <
typename IP>
1898 template <
typename IP,
typename Parent,
typename... T>
1915 template <
typename P,
typename... Os>
1917 requires(P::ref.desc_hash == Parent::ref.desc_hash)
1923 template <
typename P>
1930 template <
typename P>
1932 requires std::same_as<IP, DefaultIndexPolicy>
1938 template <
typename P,
typename O1,
typename... Os>
1940 requires(P::ref.desc_hash == Parent::ref.desc_hash)
1945 template <
typename P,
typename O1,
typename... Os>
1947 requires(P::ref.desc_hash == Parent::ref.desc_hash)
1952 template <
typename P>
1958 template <
typename P>
1964 template <
typename P>
1966 requires std::same_as<IP, DefaultIndexPolicy>
1973 this->mRowIndex =
other.index;
1976 template <
typename P>
1979 this->mRowIndex =
other.mRowIndex;
1982 template <
typename P,
typename... Os>
1984 requires std::same_as<typename P::table_t, typename Parent::table_t>
1986 this->mRowIndex =
other.mRowIndex;
1989 template <
typename TI>
1992 using decayed = std::decay_t<TI>;
1994 constexpr auto idx = framework::has_type_at_v<decayed>(
bindings_pack_t{});
1996 }
else if constexpr (std::same_as<decayed, Parent>) {
1997 return this->globalIndex();
1999 return this->globalIndex();
2001 return static_cast<int32_t
>(-1);
2005 template <
typename CD,
typename... CDArgs>
2008 using decayed = std::decay_t<CD>;
2010 return static_cast<decayed
>(*this).template getDynamicValue<CDArgs...>();
2013 template <
typename B,
typename CC>
2016 using COL = std::decay_t<CC>;
2018 return static_cast<B>(
static_cast<COL
>(*this).get());
2021 template <
typename B,
typename... CCs>
2024 static_assert(std::same_as<B, float> || std::same_as<B, double>,
"The common return type should be float or double");
2025 return {getValue<B, CCs>()...};
2036 copy.moveByIndex(inc);
2051 template <
typename IP,
typename Parent,
typename... T>
2054 template <
typename IP,
typename Parent>
2057 if constexpr (
sizeof...(Ts) == 0) {
2068 template <
typename IP,
typename Parent>
2086 mEnd{table->num_rows()}
2088 if (mTable->num_rows() == 0) {
2090 mColumnChunks[ci] =
nullptr;
2096 mColumnChunks[ci] = lookups[ci];
2099 mBegin.bindInternalIndices(
this);
2103 Table(std::vector<std::shared_ptr<arrow::Table>>&& tables, uint64_t
offset = 0)
2104 requires(
ref.origin_hash !=
"CONC"_h)
2109 Table(std::vector<std::shared_ptr<arrow::Table>>&& tables, uint64_t
offset = 0)
2110 requires(
ref.origin_hash ==
"CONC"_h)
2115 template <
typename Key>
2119 return std::array<bool,
sizeof...(Cs)>{[]() {
2120 if constexpr (
requires { Cs::index_targets.size(); }) {
2121 return Key::template
isIndexTargetOf<Cs::index_targets.size(), Cs::index_targets>();
2127 constexpr auto pos = std::find(map.begin(), map.end(),
true);
2128 if constexpr (
pos != map.end()) {
2129 return mColumnChunks[std::distance(map.begin(),
pos)];
2131 static_assert(framework::always_static_assert_v<Key>,
"This table does not have an index to given Key");
2161 return filtered_iterator(mColumnChunks, {selection, mTable->num_rows(), mOffset});
2199 return mTable->num_rows();
2209 template <
typename... TA>
2214 mBegin.bindExternalIndex(cur);
2220 template <
typename TA>
2223 mBegin.bindExternalIndex(current);
2226 template <
typename I>
2229 mBegin.bindInternalIndices(
ptr);
2237 template <
typename... Cs>
2240 (
static_cast<Cs
>(mBegin).setCurrentRaw(
binding), ...);
2245 mBegin.bindExternalIndicesRaw(std::forward<std::vector<o2::soa::Binding>>(ptrs));
2248 template <
typename T,
typename... Cs>
2251 dest.bindExternalIndicesRaw(mBegin.getIndexBindings());
2254 template <
typename T>
2277 template <
typename T1,
typename Policy,
bool OPT>
2290 return self_t{mTable->Slice(0, 0), 0};
2294 template <
typename T>
2295 arrow::ChunkedArray* lookupColumn()
2298 auto label = T::columnLabel();
2304 std::shared_ptr<arrow::Table> mTable =
nullptr;
2305 uint64_t mOffset = 0;
2312template <uint32_t
D, soa::is_column...
C>
2318namespace row_helpers
2320template <
typename R,
typename T,
typename C>
2323 return static_cast<R>(
static_cast<C>(rowIterator).get());
2328template <
typename R,
typename T>
2329using ColumnGetterFunction =
R (*)(
const T&);
2331template <
typename T,
typename R>
2336 { t.get() } -> std::convertible_to<R>;
2339template <
typename T,
typename R>
2341 { t.get() } -> std::convertible_to<R>;
2344template <
typename R,
typename T, persistent_with_common_getter<R> C>
2345ColumnGetterFunction<R, T> createGetterPtr(
const std::string_view& targetColumnLabel)
2347 return targetColumnLabel == C::columnLabel() ? &getColumnValue<R, T, C> :
nullptr;
2350template <
typename R,
typename T, dynamic_with_common_getter<R> C>
2351ColumnGetterFunction<R, T> createGetterPtr(
const std::string_view& targetColumnLabel)
2357 if (targetColumnLabel.starts_with(
"f") && targetColumnLabel.substr(1) ==
columnLabel) {
2358 return &getColumnValue<R, T, C>;
2363 return &getColumnValue<R, T, C>;
2369template <
typename R,
typename T,
typename... Cs>
2372 ColumnGetterFunction<R, T>
func;
2374 (
void)((
func = createGetterPtr<R, T, Cs>(targetColumnLabel),
func) || ...);
2383template <
typename T,
typename R>
2384using 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;
2387template <
typename R,
typename T>
2392 if (targetColumnLabel.size() == 0) {
2396 return getColumnGetterByLabel<R, typename T::iterator>(TypesWithCommonGetter{}, targetColumnLabel);
2421template <
typename T>
2422consteval static std::string_view namespace_prefix()
2424 constexpr auto name = o2::framework::type_name<T>();
2425 const auto pos =
name.rfind(std::string_view{
":"});
2426 return name.substr(0,
pos + 1);
2430#define DECLARE_EQUIVALENT_FOR_INDEX(_Base_, _Equiv_) \
2432 struct EquivalentIndexNG<o2::aod::Hash<_Base_::ref.desc_hash>, o2::aod::Hash<_Equiv_::ref.desc_hash>> { \
2433 constexpr static bool value = true; \
2436#define DECLARE_EQUIVALENT_FOR_INDEX_NG(_Base_, _Equiv_) \
2438 struct EquivalentIndexNG<o2::aod::Hash<_Base_ ""_h>, o2::aod::Hash<_Equiv_ ""_h>> { \
2439 constexpr static bool value = true; \
2442#define DECLARE_SOA_COLUMN_FULL(_Name_, _Getter_, _Type_, _Label_) \
2443 struct _Name_ : o2::soa::Column<_Type_, _Name_> { \
2444 static constexpr const char* mLabel = _Label_; \
2445 static constexpr const uint32_t hash = compile_time_hash(namespace_prefix<_Name_>(), std::string_view{#_Getter_}); \
2446 static_assert(!((*(mLabel + 1) == 'I' && *(mLabel + 2) == 'n' && *(mLabel + 3) == 'd' && *(mLabel + 4) == 'e' && *(mLabel + 5) == 'x')), "Index is not a valid column name"); \
2447 using base = o2::soa::Column<_Type_, _Name_>; \
2448 using type = _Type_; \
2449 using column_t = _Name_; \
2450 _Name_(arrow::ChunkedArray const* column) \
2451 : o2::soa::Column<_Type_, _Name_>(o2::soa::ColumnIterator<type>(column)) \
2455 _Name_() = default; \
2456 _Name_(_Name_ const& other) = default; \
2457 _Name_& operator=(_Name_ const& other) = default; \
2459 decltype(auto) _Getter_() const \
2461 return *mColumnIterator; \
2464 decltype(auto) get() const \
2466 return _Getter_(); \
2469 [[maybe_unused]] static constexpr o2::framework::expressions::BindingNode _Getter_ { _Label_, _Name_::hash, o2::framework::expressions::selectArrowType<_Type_>() }
2471#define DECLARE_SOA_CCDB_COLUMN_FULL(_Name_, _Label_, _Getter_, _ConcreteType_, _CCDBQuery_) \
2472 struct _Name_ : o2::soa::Column<std::span<std::byte>, _Name_> { \
2473 static constexpr const char* mLabel = _Label_; \
2474 static constexpr const char* query = _CCDBQuery_; \
2475 static constexpr const uint32_t hash = crc32(namespace_prefix<_Name_>(), std::string_view{#_Getter_}); \
2476 using base = o2::soa::Column<std::span<std::byte>, _Name_>; \
2477 using type = std::span<std::byte>; \
2478 using column_t = _Name_; \
2479 _Name_(arrow::ChunkedArray const* column) \
2480 : o2::soa::Column<std::span<std::byte>, _Name_>(o2::soa::ColumnIterator<std::span<std::byte>>(column)) \
2484 _Name_() = default; \
2485 _Name_(_Name_ const& other) = default; \
2486 _Name_& operator=(_Name_ const& other) = default; \
2488 decltype(auto) _Getter_() const \
2490 if constexpr (std::same_as<_ConcreteType_, std::span<std::byte>>) { \
2491 return *mColumnIterator; \
2493 static std::byte* payload = nullptr; \
2494 static _ConcreteType_* deserialised = nullptr; \
2495 static TClass* c = TClass::GetClass(#_ConcreteType_); \
2496 auto span = *mColumnIterator; \
2497 if (payload != (std::byte*)span.data()) { \
2498 payload = (std::byte*)span.data(); \
2499 delete deserialised; \
2500 TBufferFile f(TBufferFile::EMode::kRead, span.size(), (char*)span.data(), kFALSE); \
2501 deserialised = (_ConcreteType_*)soa::extractCCDBPayload((char*)payload, span.size(), c, "ccdb_object"); \
2503 return *deserialised; \
2510 return _Getter_(); \
2514#define DECLARE_SOA_CCDB_COLUMN(_Name_, _Getter_, _ConcreteType_, _CCDBQuery_) \
2515 DECLARE_SOA_CCDB_COLUMN_FULL(_Name_, "f" #_Name_, _Getter_, _ConcreteType_, _CCDBQuery_)
2517#define DECLARE_SOA_COLUMN(_Name_, _Getter_, _Type_) \
2518 DECLARE_SOA_COLUMN_FULL(_Name_, _Getter_, _Type_, "f" #_Name_)
2522#define MAKEINT(_Size_) uint##_Size_##_t
2524#define DECLARE_SOA_BITMAP_COLUMN_FULL(_Name_, _Getter_, _Size_, _Label_) \
2525 struct _Name_ : o2::soa::Column<MAKEINT(_Size_), _Name_> { \
2526 static constexpr const char* mLabel = _Label_; \
2527 static constexpr const uint32_t hash = compile_time_hash(namespace_prefix<_Name_>(), std::string_view{#_Getter_}); \
2528 static_assert(!((*(mLabel + 1) == 'I' && *(mLabel + 2) == 'n' && *(mLabel + 3) == 'd' && *(mLabel + 4) == 'e' && *(mLabel + 5) == 'x')), "Index is not a valid column name"); \
2529 using base = o2::soa::Column<MAKEINT(_Size_), _Name_>; \
2530 using type = MAKEINT(_Size_); \
2531 _Name_(arrow::ChunkedArray const* column) \
2532 : o2::soa::Column<type, _Name_>(o2::soa::ColumnIterator<type>(column)) \
2536 _Name_() = default; \
2537 _Name_(_Name_ const& other) = default; \
2538 _Name_& operator=(_Name_ const& other) = default; \
2540 decltype(auto) _Getter_##_raw() const \
2542 return *mColumnIterator; \
2545 bool _Getter_##_bit(int bit) const \
2547 return (*mColumnIterator & (static_cast<type>(1) << bit)) >> bit; \
2550 [[maybe_unused]] static constexpr o2::framework::expressions::BindingNode _Getter_ { _Label_, _Name_::hash, o2::framework::expressions::selectArrowType<MAKEINT(_Size_)>() }
2552#define DECLARE_SOA_BITMAP_COLUMN(_Name_, _Getter_, _Size_) \
2553 DECLARE_SOA_BITMAP_COLUMN_FULL(_Name_, _Getter_, _Size_, "f" #_Name_)
2557#define DECLARE_SOA_EXPRESSION_COLUMN_FULL(_Name_, _Getter_, _Type_, _Label_, _Expression_) \
2558 struct _Name_ : o2::soa::Column<_Type_, _Name_> { \
2559 static constexpr const char* mLabel = _Label_; \
2560 static constexpr const uint32_t hash = compile_time_hash(namespace_prefix<_Name_>(), std::string_view{#_Getter_}); \
2561 using base = o2::soa::Column<_Type_, _Name_>; \
2562 using type = _Type_; \
2563 using column_t = _Name_; \
2564 using spawnable_t = std::true_type; \
2565 _Name_(arrow::ChunkedArray const* column) \
2566 : o2::soa::Column<_Type_, _Name_>(o2::soa::ColumnIterator<type>(column)) \
2570 _Name_() = default; \
2571 _Name_(_Name_ const& other) = default; \
2572 _Name_& operator=(_Name_ const& other) = default; \
2574 decltype(auto) _Getter_() const \
2576 return *mColumnIterator; \
2579 decltype(auto) get() const \
2581 return _Getter_(); \
2584 static o2::framework::expressions::Projector Projector() \
2586 return _Expression_; \
2589 [[maybe_unused]] static constexpr o2::framework::expressions::BindingNode _Getter_ { _Label_, _Name_::hash, o2::framework::expressions::selectArrowType<_Type_>() }
2591#define DECLARE_SOA_EXPRESSION_COLUMN(_Name_, _Getter_, _Type_, _Expression_) \
2592 DECLARE_SOA_EXPRESSION_COLUMN_FULL(_Name_, _Getter_, _Type_, "f" #_Name_, _Expression_);
2596#define DECLARE_SOA_CONFIGURABLE_EXPRESSION_COLUMN(_Name_, _Getter_, _Type_, _Label_) \
2597 struct _Name_ : o2::soa::Column<_Type_, _Name_> { \
2598 static constexpr const char* mLabel = _Label_; \
2599 static constexpr const uint32_t hash = compile_time_hash(namespace_prefix<_Name_>(), std::string_view{#_Getter_}); \
2600 static constexpr const int32_t mHash = _Label_ ""_h; \
2601 using base = o2::soa::Column<_Type_, _Name_>; \
2602 using type = _Type_; \
2603 using column_t = _Name_; \
2604 using spawnable_t = std::true_type; \
2605 _Name_(arrow::ChunkedArray const* column) \
2606 : o2::soa::Column<_Type_, _Name_>(o2::soa::ColumnIterator<type>(column)) \
2610 _Name_() = default; \
2611 _Name_(_Name_ const& other) = default; \
2612 _Name_& operator=(_Name_ const& other) = default; \
2614 decltype(auto) _Getter_() const \
2616 return *mColumnIterator; \
2619 decltype(auto) get() const \
2621 return _Getter_(); \
2624 [[maybe_unused]] static constexpr o2::framework::expressions::BindingNode _Getter_ { _Label_, _Name_::hash, o2::framework::expressions::selectArrowType<_Type_>() }
2647template <o2::soa::is_table T>
2650 return T::originals;
2653#define DECLARE_SOA_SLICE_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, _Type_, _Table_, _Label_, _Suffix_) \
2654 struct _Name_##IdSlice : o2::soa::Column<_Type_[2], _Name_##IdSlice> { \
2655 static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
2656 static_assert((*_Suffix_ == '\0') || (*_Suffix_ == '_'), "Suffix has to begin with _"); \
2657 static constexpr const char* mLabel = "fIndexSlice" _Label_ _Suffix_; \
2658 static constexpr const uint32_t hash = 0; \
2659 using base = o2::soa::Column<_Type_[2], _Name_##IdSlice>; \
2660 using type = _Type_[2]; \
2661 using column_t = _Name_##IdSlice; \
2662 using binding_t = _Table_; \
2663 static constexpr auto index_targets = getIndexTargets<_Table_>(); \
2664 _Name_##IdSlice(arrow::ChunkedArray const* column) \
2665 : o2::soa::Column<_Type_[2], _Name_##IdSlice>(o2::soa::ColumnIterator<type>(column)) \
2669 _Name_##IdSlice() = default; \
2670 _Name_##IdSlice(_Name_##IdSlice const& other) = default; \
2671 _Name_##IdSlice& operator=(_Name_##IdSlice const& other) = default; \
2672 std::array<_Type_, 2> inline getIds() const \
2674 return _Getter_##Ids(); \
2677 bool has_##_Getter_() const \
2679 auto a = *mColumnIterator; \
2680 return a[0] >= 0 && a[1] >= 0; \
2683 std::array<_Type_, 2> _Getter_##Ids() const \
2685 auto a = *mColumnIterator; \
2686 return std::array{a[0], a[1]}; \
2689 template <typename T> \
2690 auto _Getter_##_as() const \
2692 if (O2_BUILTIN_UNLIKELY(mBinding.ptr == nullptr)) { \
2693 o2::soa::notBoundTable(#_Table_); \
2695 auto t = mBinding.get<T>(); \
2696 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2697 o2::soa::dereferenceWithWrongType(#_Getter_, #_Table_); \
2699 if (O2_BUILTIN_UNLIKELY(!has_##_Getter_())) { \
2700 return t->emptySlice(); \
2702 auto a = *mColumnIterator; \
2703 auto r = t->rawSlice(a[0], a[1]); \
2704 t->copyIndexBindings(r); \
2705 r.bindInternalIndicesTo(t); \
2709 auto _Getter_() const \
2711 return _Getter_##_as<binding_t>(); \
2714 template <typename T> \
2715 bool setCurrent(T const* current) \
2717 if constexpr (o2::soa::is_binding_compatible_v<T, binding_t>()) { \
2718 assert(current != nullptr); \
2719 this->mBinding.bind(current); \
2725 bool setCurrentRaw(o2::soa::Binding current) \
2727 this->mBinding = current; \
2730 binding_t const* getCurrent() const { return mBinding.get<binding_t>(); } \
2731 o2::soa::Binding getCurrentRaw() const { return mBinding; } \
2732 o2::soa::Binding mBinding; \
2735#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_)
2736#define DECLARE_SOA_SLICE_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_SLICE_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, _Name_##s, "")
2737#define DECLARE_SOA_SLICE_INDEX_COLUMN_CUSTOM(_Name_, _Getter_, _Label_) DECLARE_SOA_SLICE_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, int32_t, _Name_##s, _Label_, "")
2740#define DECLARE_SOA_ARRAY_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, _Type_, _Table_, _Label_, _Suffix_) \
2741 struct _Name_##Ids : o2::soa::Column<std::vector<_Type_>, _Name_##Ids> { \
2742 static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
2743 static_assert((*_Suffix_ == '\0') || (*_Suffix_ == '_'), "Suffix has to begin with _"); \
2744 static constexpr const char* mLabel = "fIndexArray" _Label_ _Suffix_; \
2745 static constexpr const uint32_t hash = 0; \
2746 using base = o2::soa::Column<std::vector<_Type_>, _Name_##Ids>; \
2747 using type = std::vector<_Type_>; \
2748 using column_t = _Name_##Ids; \
2749 using binding_t = _Table_; \
2750 static constexpr auto index_targets = getIndexTargets<_Table_>(); \
2751 _Name_##Ids(arrow::ChunkedArray const* column) \
2752 : o2::soa::Column<std::vector<_Type_>, _Name_##Ids>(o2::soa::ColumnIterator<type>(column)) \
2756 _Name_##Ids() = default; \
2757 _Name_##Ids(_Name_##Ids const& other) = default; \
2758 _Name_##Ids& operator=(_Name_##Ids const& other) = default; \
2760 gsl::span<const _Type_> inline getIds() const \
2762 return _Getter_##Ids(); \
2765 gsl::span<const _Type_> _Getter_##Ids() const \
2767 return *mColumnIterator; \
2770 bool has_##_Getter_() const \
2772 return !(*mColumnIterator).empty(); \
2775 template <soa::is_table T> \
2776 auto _Getter_##_as() const \
2778 if (O2_BUILTIN_UNLIKELY(mBinding.ptr == nullptr)) { \
2779 o2::soa::notBoundTable(#_Table_); \
2781 auto t = mBinding.get<T>(); \
2782 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2783 o2::soa::dereferenceWithWrongType(#_Getter_, #_Table_); \
2785 auto result = std::vector<typename T::unfiltered_iterator>(); \
2786 result.reserve((*mColumnIterator).size()); \
2787 for (auto& i : *mColumnIterator) { \
2788 result.emplace_back(t->rawIteratorAt(i)); \
2793 template <soa::is_filtered_table T> \
2794 auto filtered_##_Getter_##_as() const \
2796 if (O2_BUILTIN_UNLIKELY(mBinding.ptr == nullptr)) { \
2797 o2::soa::notBoundTable(#_Table_); \
2799 auto t = mBinding.get<T>(); \
2800 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2801 o2::soa::dereferenceWithWrongType(#_Getter_, #_Table_); \
2803 auto result = std::vector<typename T::iterator>(); \
2804 result.reserve((*mColumnIterator).size()); \
2805 for (auto const& i : *mColumnIterator) { \
2806 auto pos = t->isInSelectedRows(i); \
2808 result.emplace_back(t->iteratorAt(pos)); \
2814 auto _Getter_() const \
2816 return _Getter_##_as<binding_t>(); \
2819 template <typename T> \
2820 auto _Getter_##_first_as() const \
2822 if (O2_BUILTIN_UNLIKELY(mBinding.ptr == nullptr)) { \
2823 o2::soa::notBoundTable(#_Table_); \
2825 auto t = mBinding.get<T>(); \
2826 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2827 o2::soa::dereferenceWithWrongType(#_Getter_, #_Table_); \
2829 return t->rawIteratorAt((*mColumnIterator)[0]); \
2832 template <typename T> \
2833 auto _Getter_##_last_as() const \
2835 if (O2_BUILTIN_UNLIKELY(mBinding.ptr == nullptr)) { \
2836 o2::soa::notBoundTable(#_Table_); \
2838 auto t = mBinding.get<T>(); \
2839 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2840 o2::soa::dereferenceWithWrongType(#_Getter_, #_Table_); \
2842 return t->rawIteratorAt((*mColumnIterator).back()); \
2845 auto _Getter_first() const \
2847 return _Getter_##_first_as<binding_t>(); \
2850 auto _Getter_last() const \
2852 return _Getter_##_last_as<binding_t>(); \
2855 template <typename T> \
2856 bool setCurrent(T const* current) \
2858 if constexpr (o2::soa::is_binding_compatible_v<T, binding_t>()) { \
2859 assert(current != nullptr); \
2860 this->mBinding.bind(current); \
2866 bool setCurrentRaw(o2::soa::Binding current) \
2868 this->mBinding = current; \
2871 binding_t const* getCurrent() const { return mBinding.get<binding_t>(); } \
2872 o2::soa::Binding getCurrentRaw() const { return mBinding; } \
2873 o2::soa::Binding mBinding; \
2876#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_)
2877#define DECLARE_SOA_ARRAY_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_ARRAY_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, _Name_##s, "")
2878#define DECLARE_SOA_ARRAY_INDEX_COLUMN_CUSTOM(_Name_, _Getter_, _Label_) DECLARE_SOA_ARRAY_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, int32_t, _Name_##s, _Label_, "")
2881#define DECLARE_SOA_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, _Type_, _Table_, _Label_, _Suffix_) \
2882 struct _Name_##Id : o2::soa::Column<_Type_, _Name_##Id> { \
2883 static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
2884 static_assert((*_Suffix_ == '\0') || (*_Suffix_ == '_'), "Suffix has to begin with _"); \
2885 static constexpr const char* mLabel = "fIndex" _Label_ _Suffix_; \
2886 static constexpr const uint32_t hash = compile_time_hash(namespace_prefix<_Name_##Id>(), std::string_view{#_Getter_ "Id"}); \
2887 using base = o2::soa::Column<_Type_, _Name_##Id>; \
2888 using type = _Type_; \
2889 using column_t = _Name_##Id; \
2890 using binding_t = _Table_; \
2891 static constexpr auto index_targets = getIndexTargets<_Table_>(); \
2892 _Name_##Id(arrow::ChunkedArray const* column) \
2893 : o2::soa::Column<_Type_, _Name_##Id>(o2::soa::ColumnIterator<type>(column)) \
2897 _Name_##Id() = default; \
2898 _Name_##Id(_Name_##Id const& other) = default; \
2899 _Name_##Id& operator=(_Name_##Id const& other) = default; \
2900 type inline getId() const \
2902 return _Getter_##Id(); \
2905 type _Getter_##Id() const \
2907 return *mColumnIterator; \
2910 bool has_##_Getter_() const \
2912 return *mColumnIterator >= 0; \
2915 template <typename T> \
2916 auto _Getter_##_as() const \
2918 if (O2_BUILTIN_UNLIKELY(mBinding.ptr == nullptr)) { \
2919 o2::soa::notBoundTable(#_Table_); \
2921 if (O2_BUILTIN_UNLIKELY(!has_##_Getter_())) { \
2922 o2::soa::accessingInvalidIndexFor(#_Getter_); \
2924 auto t = mBinding.get<T>(); \
2925 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2926 o2::soa::dereferenceWithWrongType(#_Getter_, #_Table_); \
2928 return t->rawIteratorAt(*mColumnIterator); \
2931 auto _Getter_() const \
2933 return _Getter_##_as<binding_t>(); \
2936 template <typename T> \
2937 bool setCurrent(T* current) \
2939 if constexpr (o2::soa::is_binding_compatible_v<T, binding_t>()) { \
2940 assert(current != nullptr); \
2941 this->mBinding.bind(current); \
2947 bool setCurrentRaw(o2::soa::Binding current) \
2949 this->mBinding = current; \
2952 binding_t const* getCurrent() const { return mBinding.get<binding_t>(); } \
2953 o2::soa::Binding getCurrentRaw() const { return mBinding; } \
2954 o2::soa::Binding mBinding; \
2956 [[maybe_unused]] static constexpr o2::framework::expressions::BindingNode _Getter_##Id { "fIndex" _Label_ _Suffix_, _Name_##Id::hash, o2::framework::expressions::selectArrowType<_Type_>() }
2958#define DECLARE_SOA_INDEX_COLUMN_FULL(_Name_, _Getter_, _Type_, _Table_, _Suffix_) DECLARE_SOA_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, _Type_, _Table_, #_Table_, _Suffix_)
2959#define DECLARE_SOA_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, _Name_##s, "")
2960#define DECLARE_SOA_INDEX_COLUMN_CUSTOM(_Name_, _Getter_, _Label_) DECLARE_SOA_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, int32_t, _Name_##s, _Label_, "")
2963#define DECLARE_SOA_SELF_INDEX_COLUMN_COMPLETE(_Name_, _Getter_, _Type_, _Label_, _IndexTarget_) \
2964 struct _Name_##Id : o2::soa::Column<_Type_, _Name_##Id> { \
2965 static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
2966 static constexpr const char* mLabel = "fIndex" _Label_; \
2967 static constexpr const uint32_t hash = compile_time_hash(namespace_prefix<_Name_##Id>(), std::string_view{#_Getter_ "Id"}); \
2968 using base = o2::soa::Column<_Type_, _Name_##Id>; \
2969 using type = _Type_; \
2970 using column_t = _Name_##Id; \
2971 using self_index_t = std::true_type; \
2972 using compatible_signature = std::conditional<aod::is_aod_hash<_IndexTarget_>, _IndexTarget_, void>; \
2973 _Name_##Id(arrow::ChunkedArray const* column) \
2974 : o2::soa::Column<_Type_, _Name_##Id>(o2::soa::ColumnIterator<type>(column)) \
2978 _Name_##Id() = default; \
2979 _Name_##Id(_Name_##Id const& other) = default; \
2980 _Name_##Id& operator=(_Name_##Id const& other) = default; \
2981 type inline getId() const \
2983 return _Getter_##Id(); \
2986 type _Getter_##Id() const \
2988 return *mColumnIterator; \
2991 bool has_##_Getter_() const \
2993 return *mColumnIterator >= 0; \
2996 template <typename T> \
2997 auto _Getter_##_as() const \
2999 if (O2_BUILTIN_UNLIKELY(!has_##_Getter_())) { \
3000 o2::soa::accessingInvalidIndexFor(#_Getter_); \
3002 auto t = mBinding.get<T>(); \
3003 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
3004 o2::soa::dereferenceWithWrongType(#_Getter_, "self"); \
3006 return t->rawIteratorAt(*mColumnIterator); \
3009 bool setCurrentRaw(o2::soa::Binding current) \
3011 this->mBinding = current; \
3014 o2::soa::Binding getCurrentRaw() const { return mBinding; } \
3015 o2::soa::Binding mBinding; \
3017 [[maybe_unused]] static constexpr o2::framework::expressions::BindingNode _Getter_##Id { "fIndex" _Label_, _Name_##Id::hash, o2::framework::expressions::selectArrowType<_Type_>() }
3019#define DECLARE_SOA_SELF_INDEX_COLUMN_FULL(_Name_, _Getter_, _Type_, _Label_) DECLARE_SOA_SELF_INDEX_COLUMN_COMPLETE(_Name_, _Getter_, _Type_, _Label_, void)
3020#define DECLARE_SOA_SELF_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_SELF_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, #_Name_)
3022#define DECLARE_SOA_SELF_SLICE_INDEX_COLUMN_COMPLETE(_Name_, _Getter_, _Type_, _Label_, _IndexTarget_) \
3023 struct _Name_##IdSlice : o2::soa::Column<_Type_[2], _Name_##IdSlice> { \
3024 static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
3025 static constexpr const char* mLabel = "fIndexSlice" _Label_; \
3026 static constexpr const uint32_t hash = 0; \
3027 using base = o2::soa::Column<_Type_[2], _Name_##IdSlice>; \
3028 using type = _Type_[2]; \
3029 using column_t = _Name_##IdSlice; \
3030 using self_index_t = std::true_type; \
3031 using compatible_signature = std::conditional<aod::is_aod_hash<_IndexTarget_>, _IndexTarget_, void>; \
3032 _Name_##IdSlice(arrow::ChunkedArray const* column) \
3033 : o2::soa::Column<_Type_[2], _Name_##IdSlice>(o2::soa::ColumnIterator<type>(column)) \
3037 _Name_##IdSlice() = default; \
3038 _Name_##IdSlice(_Name_##IdSlice const& other) = default; \
3039 _Name_##IdSlice& operator=(_Name_##IdSlice const& other) = default; \
3040 std::array<_Type_, 2> inline getIds() const \
3042 return _Getter_##Ids(); \
3045 bool has_##_Getter_() const \
3047 auto a = *mColumnIterator; \
3048 return a[0] >= 0 && a[1] >= 0; \
3051 std::array<_Type_, 2> _Getter_##Ids() const \
3053 auto a = *mColumnIterator; \
3054 return std::array{a[0], a[1]}; \
3057 template <typename T> \
3058 auto _Getter_##_as() const \
3060 auto t = mBinding.get<T>(); \
3061 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
3062 o2::soa::dereferenceWithWrongType(#_Getter_, "self"); \
3064 if (O2_BUILTIN_UNLIKELY(!has_##_Getter_())) { \
3065 return t->emptySlice(); \
3067 auto a = *mColumnIterator; \
3068 auto r = t->rawSlice(a[0], a[1]); \
3069 t->copyIndexBindings(r); \
3070 r.bindInternalIndicesTo(t); \
3074 bool setCurrentRaw(o2::soa::Binding current) \
3076 this->mBinding = current; \
3079 o2::soa::Binding getCurrentRaw() const { return mBinding; } \
3080 o2::soa::Binding mBinding; \
3083#define DECLARE_SOA_SELF_SLICE_INDEX_COLUMN_FULL(_Name_, _Getter_, _Type_, _Label_) DECLARE_SOA_SELF_SLICE_INDEX_COLUMN_COMPLETE(_Name_, _Getter_, _Type_, _Label_, void)
3084#define DECLARE_SOA_SELF_SLICE_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_SELF_SLICE_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, "_" #_Name_)
3086#define DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN_COMPLETE(_Name_, _Getter_, _Type_, _Label_, _IndexTarget_) \
3087 struct _Name_##Ids : o2::soa::Column<std::vector<_Type_>, _Name_##Ids> { \
3088 static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
3089 static constexpr const char* mLabel = "fIndexArray" _Label_; \
3090 static constexpr const uint32_t hash = 0; \
3091 using base = o2::soa::Column<std::vector<_Type_>, _Name_##Ids>; \
3092 using type = std::vector<_Type_>; \
3093 using column_t = _Name_##Ids; \
3094 using self_index_t = std::true_type; \
3095 using compatible_signature = std::conditional<aod::is_aod_hash<_IndexTarget_>, _IndexTarget_, void>; \
3096 _Name_##Ids(arrow::ChunkedArray const* column) \
3097 : o2::soa::Column<std::vector<_Type_>, _Name_##Ids>(o2::soa::ColumnIterator<type>(column)) \
3101 _Name_##Ids() = default; \
3102 _Name_##Ids(_Name_##Ids const& other) = default; \
3103 _Name_##Ids& operator=(_Name_##Ids const& other) = default; \
3104 gsl::span<const _Type_> inline getIds() const \
3106 return _Getter_##Ids(); \
3109 gsl::span<const _Type_> _Getter_##Ids() const \
3111 return *mColumnIterator; \
3114 bool has_##_Getter_() const \
3116 return !(*mColumnIterator).empty(); \
3119 template <typename T> \
3120 auto _Getter_##_as() const \
3122 auto t = mBinding.get<T>(); \
3123 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
3124 o2::soa::dereferenceWithWrongType(#_Getter_, "self"); \
3126 auto result = std::vector<typename T::unfiltered_iterator>(); \
3127 for (auto& i : *mColumnIterator) { \
3128 result.push_back(t->rawIteratorAt(i)); \
3133 template <typename T> \
3134 auto _Getter_##_first_as() const \
3136 return mBinding.get<T>()->rawIteratorAt((*mColumnIterator)[0]); \
3139 template <typename T> \
3140 auto _Getter_##_last_as() const \
3142 return mBinding.get<T>()->rawIteratorAt((*mColumnIterator).back()); \
3145 bool setCurrentRaw(o2::soa::Binding current) \
3147 this->mBinding = current; \
3150 o2::soa::Binding getCurrentRaw() const { return mBinding; } \
3151 o2::soa::Binding mBinding; \
3154#define DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN_FULL(_Name_, _Getter_, _Type_, _Label_) DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN_COMPLETE(_Name_, _Getter_, _Type_, _Label_, void)
3155#define DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, "_" #_Name_)
3185#define DECLARE_SOA_DYNAMIC_COLUMN(_Name_, _Getter_, ...) \
3186 struct _Name_##Callback { \
3187 static inline constexpr auto getLambda() { return __VA_ARGS__; } \
3190 struct _Name_##Helper { \
3191 using callable_t = decltype(o2::framework::FunctionMetadata(std::declval<decltype(_Name_##Callback::getLambda())>())); \
3192 using return_type = typename callable_t::return_type; \
3194 template <typename... Bindings> \
3195 struct _Name_ : o2::soa::DynamicColumn<typename _Name_##Helper::callable_t::type, _Name_<Bindings...>> { \
3196 using base = o2::soa::DynamicColumn<typename _Name_##Helper::callable_t::type, _Name_<Bindings...>>; \
3197 using helper = _Name_##Helper; \
3198 using callback_holder_t = _Name_##Callback; \
3199 using callable_t = helper::callable_t; \
3200 using callback_t = callable_t::type; \
3201 static constexpr const uint32_t hash = 0; \
3203 _Name_(arrow::ChunkedArray const*) \
3206 _Name_() = default; \
3207 _Name_(_Name_ const& other) = default; \
3208 _Name_& operator=(_Name_ const& other) = default; \
3209 static constexpr const char* mLabel = #_Name_; \
3210 using type = typename callable_t::return_type; \
3212 template <typename... FreeArgs> \
3213 type _Getter_(FreeArgs... freeArgs) const \
3215 return boundGetter(std::make_index_sequence<std::tuple_size_v<decltype(boundIterators)>>{}, freeArgs...); \
3217 template <typename... FreeArgs> \
3218 type getDynamicValue(FreeArgs... freeArgs) const \
3220 return boundGetter(std::make_index_sequence<std::tuple_size_v<decltype(boundIterators)>>{}, freeArgs...); \
3225 return _Getter_(); \
3228 template <size_t... Is, typename... FreeArgs> \
3229 type boundGetter(std::integer_sequence<size_t, Is...>&&, FreeArgs... freeArgs) const \
3231 return __VA_ARGS__((**std::get<Is>(boundIterators))..., freeArgs...); \
3234 using bindings_t = typename o2::framework::pack<Bindings...>; \
3235 std::tuple<o2::soa::ColumnIterator<typename Bindings::type> const*...> boundIterators; \
3238#define DECLARE_SOA_TABLE_METADATA(_Name_, _Desc_, _Version_, ...) \
3239 using _Name_##Metadata = TableMetadata<Hash<_Desc_ "/" #_Version_ ""_h>, __VA_ARGS__>;
3241#define DECLARE_SOA_TABLE_METADATA_TRAIT(_Name_, _Desc_, _Version_) \
3243 struct MetadataTrait<Hash<_Desc_ "/" #_Version_ ""_h>> { \
3244 using metadata = _Name_##Metadata; \
3247#define DECLARE_SOA_TABLE_FULL_VERSIONED_(_Name_, _Label_, _Origin_, _Desc_, _Version_) \
3248 O2HASH(_Desc_ "/" #_Version_); \
3249 template <typename O> \
3250 using _Name_##From = o2::soa::Table<Hash<_Label_ ""_h>, Hash<_Desc_ "/" #_Version_ ""_h>, O>; \
3251 using _Name_ = _Name_##From<Hash<_Origin_ ""_h>>; \
3253 struct MetadataTrait<Hash<_Desc_ "/" #_Version_ ""_h>> { \
3254 using metadata = _Name_##Metadata; \
3257#define DECLARE_SOA_STAGE(_Name_, _Origin_, _Desc_, _Version_) \
3258 template <typename O> \
3259 using _Name_##From = o2::soa::Table<Hash<#_Name_ ""_h>, Hash<_Desc_ "/" #_Version_ ""_h>, O>; \
3260 using _Name_ = _Name_##From<Hash<_Origin_ ""_h>>;
3262#define DECLARE_SOA_TABLE_FULL_VERSIONED(_Name_, _Label_, _Origin_, _Desc_, _Version_, ...) \
3263 DECLARE_SOA_TABLE_METADATA(_Name_, _Desc_, _Version_, __VA_ARGS__); \
3264 DECLARE_SOA_TABLE_FULL_VERSIONED_(_Name_, _Label_, _Origin_, _Desc_, _Version_);
3266#define DECLARE_SOA_TABLE_FULL(_Name_, _Label_, _Origin_, _Desc_, ...) \
3268 DECLARE_SOA_TABLE_METADATA(_Name_, _Desc_, 0, __VA_ARGS__); \
3269 DECLARE_SOA_TABLE_FULL_VERSIONED_(_Name_, _Label_, _Origin_, _Desc_, 0)
3271#define DECLARE_SOA_TABLE(_Name_, _Origin_, _Desc_, ...) \
3272 DECLARE_SOA_TABLE_FULL(_Name_, #_Name_, _Origin_, _Desc_, __VA_ARGS__)
3274#define DECLARE_SOA_TABLE_VERSIONED(_Name_, _Origin_, _Desc_, _Version_, ...) \
3276 DECLARE_SOA_TABLE_METADATA(_Name_, _Desc_, _Version_, __VA_ARGS__); \
3277 DECLARE_SOA_TABLE_FULL_VERSIONED_(_Name_, #_Name_, _Origin_, _Desc_, _Version_)
3279#define DECLARE_SOA_TABLE_STAGED_VERSIONED(_BaseName_, _Desc_, _Version_, ...) \
3280 O2HASH(_Desc_ "/" #_Version_); \
3281 O2HASH(#_BaseName_); \
3282 O2HASH("Stored" #_BaseName_); \
3283 DECLARE_SOA_TABLE_METADATA(_BaseName_, _Desc_, _Version_, __VA_ARGS__); \
3284 using Stored##_BaseName_##Metadata = _BaseName_##Metadata; \
3285 DECLARE_SOA_TABLE_METADATA_TRAIT(_BaseName_, _Desc_, _Version_); \
3286 DECLARE_SOA_STAGE(_BaseName_, "AOD", _Desc_, _Version_); \
3287 DECLARE_SOA_STAGE(Stored##_BaseName_, "AOD1", _Desc_, _Version_);
3289#define DECLARE_SOA_TABLE_STAGED(_BaseName_, _Desc_, ...) \
3290 DECLARE_SOA_TABLE_STAGED_VERSIONED(_BaseName_, _Desc_, 0, __VA_ARGS__);
3292#define DECLARE_SOA_EXTENDED_TABLE_NG(_Name_, _OriginalTable_, _Desc_, _Version_, ...) \
3293 O2HASH(_Desc_ "/" #_Version_); \
3294 O2HASH(#_Name_ "Extension"); \
3295 template <typename O> \
3296 using _Name_##ExtensionFrom = soa::Table<o2::aod::Hash<#_Name_ "Extension"_h>, o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, O>; \
3297 using _Name_##Extension = _Name_##ExtensionFrom<o2::aod::Hash<"AOD"_h>>; \
3298 struct _Name_##ExtensionMetadata : TableMetadata<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, __VA_ARGS__> { \
3299 using base_table_t = _OriginalTable_; \
3300 template <o2::aod::is_origin_hash O> \
3301 using extension_table_t_from = _Name_##ExtensionFrom<O>; \
3302 using extension_table_t = _Name_##Extension; \
3303 using expression_pack_t = framework::pack<__VA_ARGS__>; \
3304 static constexpr auto N = _OriginalTable_::originals.size(); \
3305 template <o2::aod::is_origin_hash O = o2::aod::Hash<"AOD"_h>> \
3306 static consteval auto generateSources() \
3308 return _OriginalTable_##From<O>::originals; \
3312 struct MetadataTrait<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>> { \
3313 using metadata = _Name_##ExtensionMetadata; \
3315 template <typename O> \
3316 using _Name_##From = o2::soa::Join<_OriginalTable_##From<O>, _Name_##ExtensionFrom<O>>; \
3317 using _Name_ = _Name_##From<o2::aod::Hash<"AOD"_h>>;
3319#define DECLARE_SOA_EXTENDED_TABLE(_Name_, _Table_, _Description_, _Version_, ...) \
3320 DECLARE_SOA_EXTENDED_TABLE_NG(_Name_, _Table_, _Description_, _Version_, __VA_ARGS__)
3322#define DECLARE_SOA_EXTENDED_TABLE_USER(_Name_, _Table_, _Description_, ...) \
3323 DECLARE_SOA_EXTENDED_TABLE_NG(_Name_, _Table_, "EX" _Description_, 0, __VA_ARGS__)
3325#define DECLARE_SOA_CONFIGURABLE_EXTENDED_TABLE_NG(_Name_, _OriginalTable_, _Desc_, _Version_, ...) \
3326 O2HASH(_Desc_ "/" #_Version_); \
3327 O2HASH(#_Name_ "CfgExtension"); \
3328 template <typename O> \
3329 using _Name_##CfgExtensionFrom = soa::Table<o2::aod::Hash<#_Name_ "CfgExtension"_h>, o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, O>; \
3330 using _Name_##CfgExtension = _Name_##CfgExtensionFrom<o2::aod::Hash<"AOD"_h>>; \
3331 struct _Name_##CfgExtensionMetadata : TableMetadata<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, __VA_ARGS__> { \
3332 using base_table_t = _OriginalTable_; \
3333 template <o2::aod::is_origin_hash O> \
3334 using extension_table_t_from = _Name_##CfgExtensionFrom<O>; \
3335 using extension_table_t = _Name_##CfgExtension; \
3336 using placeholders_pack_t = framework::pack<__VA_ARGS__>; \
3337 using configurable_t = std::true_type; \
3338 static constexpr auto N = _OriginalTable_::originals.size(); \
3339 template <o2::aod::is_origin_hash O = o2::aod::Hash<"AOD"_h>> \
3340 static consteval auto generateSources() \
3342 return _OriginalTable_##From<O>::originals; \
3346 struct MetadataTrait<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>> { \
3347 using metadata = _Name_##CfgExtensionMetadata; \
3349 template <typename O> \
3350 using _Name_##From = o2::soa::Join<_OriginalTable_##From<O>, _Name_##CfgExtensionFrom<O>>; \
3351 using _Name_ = _Name_##From<o2::aod::Hash<"AOD"_h>>;
3353#define DECLARE_SOA_CONFIGURABLE_EXTENDED_TABLE(_Name_, _OriginalTable_, _Description_, ...) \
3354 DECLARE_SOA_CONFIGURABLE_EXTENDED_TABLE_NG(_Name_, _OriginalTable_, "EX" _Description_, 0, __VA_ARGS__)
3356#define DECLARE_SOA_INDEX_TABLE_NG(_Name_, _Key_, _Version_, _Desc_, _Exclusive_, ...) \
3358 O2HASH(_Desc_ "/" #_Version_); \
3359 struct _Name_##Metadata : o2::aod::TableMetadata<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, soa::Index<>, __VA_ARGS__> { \
3360 static constexpr bool exclusive = _Exclusive_; \
3361 template <o2::aod::is_origin_hash O> \
3362 using KeyFrom = _Key_##From<O>; \
3363 using Key = _Key_; \
3364 using index_pack_t = framework::pack<__VA_ARGS__>; \
3365 template <o2::aod::is_origin_hash O = o2::aod::Hash<"AOD"_h>> \
3366 static consteval auto generateSources() \
3368 return []<soa::is_index_column... Cs>(framework::pack<Cs...>) { \
3369 constexpr auto first = o2::soa::mergeOriginals<typename Cs::binding_t...>(); \
3370 constexpr auto second = o2::aod::filterForKey<first.size(), first, Key>(); \
3371 return o2::aod::replaceOrigin<second.size(), second, O>(); \
3372 }(framework::pack<__VA_ARGS__>{}); \
3374 static constexpr auto N = []<typename... Cs>(framework::pack<Cs...>) { \
3375 constexpr auto a = o2::soa::mergeOriginals<typename Cs::binding_t...>(); \
3376 return o2::aod::filterForKey<a.size(), a, Key>(); \
3377 }(framework::pack<__VA_ARGS__>{}) \
3381 struct MetadataTrait<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>> { \
3382 using metadata = _Name_##Metadata; \
3384 template <o2::aod::is_origin_hash O> \
3385 using _Name_##From = o2::soa::IndexTable<o2::aod::Hash<#_Name_ ""_h>, o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, O, _Key_##From<O>, __VA_ARGS__>; \
3386 using _Name_ = _Name_##From<o2::aod::Hash<"AOD"_h>>;
3388#define DECLARE_SOA_INDEX_TABLE(_Name_, _Key_, _Description_, ...) \
3389 DECLARE_SOA_INDEX_TABLE_NG(_Name_, _Key_, 0, _Description_, false, __VA_ARGS__)
3391#define DECLARE_SOA_INDEX_TABLE_EXCLUSIVE(_Name_, _Key_, _Description_, ...) \
3392 DECLARE_SOA_INDEX_TABLE_NG(_Name_, _Key_, 0, _Description_, true, __VA_ARGS__)
3394#define DECLARE_SOA_INDEX_TABLE_USER(_Name_, _Key_, _Description_, ...) \
3395 DECLARE_SOA_INDEX_TABLE_NG(_Name_, _Key_, 0, _Description_, false, __VA_ARGS__)
3397#define DECLARE_SOA_INDEX_TABLE_EXCLUSIVE_USER(_Name_, _Key_, _Description_, ...) \
3398 DECLARE_SOA_INDEX_TABLE_NG(_Name_, _Key_, 0, _Description_, true, __VA_ARGS__)
3405#define DECLARE_SOA_TIMESTAMPED_TABLE_FULL(_Name_, _Label_, _TimestampSource_, _TimestampColumn_, _Version_, _Desc_, ...) \
3406 O2HASH(_Desc_ "/" #_Version_); \
3407 template <typename O> \
3408 using _Name_##TimestampFrom = soa::Table<o2::aod::Hash<_Label_ ""_h>, o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, O>; \
3409 using _Name_##Timestamp = _Name_##TimestampFrom<o2::aod::Hash< \
3412 struct _Name_##TimestampMetadata : TableMetadata<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, __VA_ARGS__> { \
3413 template <typename O = o2::aod::Hash<"AOD" \
3415 using base_table_t = _TimestampSource_##From<O>; \
3416 template <typename O = o2::aod::Hash<"AOD" \
3418 using extension_table_t = _Name_##TimestampFrom<O>; \
3419 static constexpr const auto ccdb_urls = []<typename... Cs>(framework::pack<Cs...>) { \
3420 return std::array<std::string_view, sizeof...(Cs)>{Cs::query...}; \
3421 }(framework::pack<__VA_ARGS__>{}); \
3422 static constexpr const auto ccdb_bindings = []<typename... Cs>(framework::pack<Cs...>) { \
3423 return std::array<std::string_view, sizeof...(Cs)>{Cs::mLabel...}; \
3424 }(framework::pack<__VA_ARGS__>{}); \
3425 static constexpr auto N = _TimestampSource_::originals.size(); \
3426 template <o2::aod::is_origin_hash O = o2::aod::Hash<"AOD"_h>> \
3427 static consteval auto generateSources() \
3429 return _TimestampSource_##From<O>::originals; \
3431 static constexpr auto timestamp_column_label = _TimestampColumn_::mLabel; \
3435 struct MetadataTrait<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>> { \
3436 using metadata = _Name_##TimestampMetadata; \
3438 template <typename O> \
3439 using _Name_##From = o2::soa::Join<_TimestampSource_, _Name_##TimestampFrom<O>>; \
3440 using _Name_ = _Name_##From<o2::aod::Hash< \
3444#define DECLARE_SOA_TIMESTAMPED_TABLE(_Name_, _TimestampSource_, _TimestampColumn_, _Version_, _Desc_, ...) \
3445 O2HASH(#_Name_ "Timestamped"); \
3446 DECLARE_SOA_TIMESTAMPED_TABLE_FULL(_Name_, #_Name_ "Timestamped", _TimestampSource_, _TimestampColumn_, _Version_, _Desc_, __VA_ARGS__)
3450template <
typename...
Ts>
3451struct Join :
Table<o2::aod::Hash<"JOIN"_h>, o2::aod::Hash<"JOIN/0"_h>, o2::aod::Hash<"JOIN"_h>, Ts...> {
3461 Join(std::vector<std::shared_ptr<arrow::Table>>&& tables, uint64_t
offset = 0)
3473 template <
typename... TA>
3517 template <
typename T1,
typename Policy,
bool OPT>
3545 template <
typename T>
3548 return []<
size_t... Is>(std::index_sequence<Is...>) {
3549 return (std::ranges::any_of(
originals, [](
TableRef const&
ref) {
return ref.desc_hash == T::originals[Is].desc_hash; }) && ...);
3550 }(std::make_index_sequence<T::originals.size()>());
3554template <
typename...
Ts>
3560template <
typename T>
3563template <
typename T>
3566template <
typename...
Ts>
3567struct Concat :
Table<o2::aod::Hash<"CONC"_h>, o2::aod::Hash<"CONC/0"_h>, o2::aod::Hash<"CONC"_h>, Ts...> {
3570 Concat(std::vector<std::shared_ptr<arrow::Table>>&& tables, uint64_t
offset = 0)
3578 bindInternalIndicesTo(
this);
3581 using base::originals;
3583 using base::bindExternalIndices;
3584 using base::bindInternalIndicesTo;
3598template <
typename...
Ts>
3604template <soa::is_table T>
3611 static constexpr const uint32_t binding_origin = T::binding_origin;
3613 template <
typename... TA>
3617 if constexpr (binding_origin == TA::binding_origin) {
3618 this->bindExternalIndex(cur);
3619 mFilteredBegin.bindExternalIndex(cur);
3628 using iterator = T::template iterator_template_o<FilteredIndexPolicy, self_t>;
3634 mSelectedRows{getSpan(selection)}
3636 if (this->tableSize() != 0) {
3637 mFilteredBegin = table_t::filtered_begin(mSelectedRows);
3640 mFilteredBegin.bindInternalIndices(
this);
3645 mSelectedRowsCache{
std::move(selection)},
3648 mSelectedRows = std::span{mSelectedRowsCache};
3649 if (this->tableSize() != 0) {
3650 mFilteredBegin = table_t::filtered_begin(mSelectedRows);
3653 mFilteredBegin.bindInternalIndices(
this);
3656 FilteredBase(std::vector<std::shared_ptr<arrow::Table>>&& tables, std::span<int64_t const>
const& selection, uint64_t
offset = 0)
3658 mSelectedRows{selection}
3660 if (this->tableSize() != 0) {
3661 mFilteredBegin = table_t::filtered_begin(mSelectedRows);
3664 mFilteredBegin.bindInternalIndices(
this);
3691 return mFilteredBegin;
3696 return mFilteredBegin;
3701 return mFilteredBegin +
i;
3706 return mSelectedRows.size();
3711 return table_t::asArrowTable()->num_rows();
3716 return mSelectedRows;
3723 std::iota(newSelection.begin(), newSelection.end(),
start);
3724 return self_t{{this->asArrowTable()}, std::move(newSelection), 0};
3734 if (sel ==
nullptr) {
3735 return std::span<int64_t const>{};
3737 auto array = std::static_pointer_cast<arrow::Int64Array>(sel->ToArray());
3740 return std::span{
start, stop};
3747 mFilteredBegin.bindExternalIndicesRaw(std::forward<std::vector<o2::soa::Binding>>(ptrs));
3750 template <
typename I>
3753 mFilteredBegin.bindInternalIndices(
ptr);
3756 template <
typename T1,
typename... Cs>
3759 dest.bindExternalIndicesRaw(mFilteredBegin.getIndexBindings());
3762 template <
typename T1>
3768 template <
typename T1>
3784 template <
typename T1,
bool OPT>
3790 template <
typename T1,
bool OPT>
3799 copyIndexBindings(t);
3805 auto locate = std::find(mSelectedRows.begin(), mSelectedRows.end(),
i);
3806 if (locate == mSelectedRows.end()) {
3809 return static_cast<int>(std::distance(mSelectedRows.begin(), locate));
3816 std::set_union(mSelectedRows.begin(), mSelectedRows.end(), selection.begin(), selection.end(), std::back_inserter(rowsUnion));
3817 mSelectedRowsCache.clear();
3818 mSelectedRowsCache = rowsUnion;
3826 std::set_intersection(mSelectedRows.begin(), mSelectedRows.end(), selection.begin(), selection.end(), std::back_inserter(intersection));
3827 mSelectedRowsCache.clear();
3828 mSelectedRowsCache = intersection;
3836 std::set_union(mSelectedRows.begin(), mSelectedRows.end(), selection.begin(), selection.end(), std::back_inserter(rowsUnion));
3837 mSelectedRowsCache.clear();
3838 mSelectedRowsCache = rowsUnion;
3846 std::set_intersection(mSelectedRows.begin(), mSelectedRows.end(), selection.begin(), selection.end(), std::back_inserter(intersection));
3847 mSelectedRowsCache.clear();
3848 mSelectedRowsCache = intersection;
3861 mSelectedRows = std::span{mSelectedRowsCache};
3865 mFilteredBegin = *mFilteredEnd;
3867 mFilteredBegin.resetSelection(mSelectedRows);
3871 std::span<int64_t const> mSelectedRows;
3873 bool mCached =
false;
3874 iterator mFilteredBegin;
3875 std::shared_ptr<RowViewSentinel> mFilteredEnd;
3878template <
typename T>
3887 using iterator = T::template iterator_template_o<FilteredIndexPolicy, self_t>;
3893 return iterator(this->cached_begin());
3907 Filtered(std::vector<std::shared_ptr<arrow::Table>>&& tables, std::span<int64_t const>
const& selection, uint64_t
offset = 0)
3931 this->sumWithSelection(selection);
3937 this->sumWithSelection(selection);
3943 return operator+=(
other.getSelectedRows());
3962 return operator*(
other.getSelectedRows());
3967 this->intersectWithSelection(selection);
3973 this->intersectWithSelection(selection);
3979 return operator*=(
other.getSelectedRows());
3995 std::iota(newSelection.begin(), newSelection.end(),
start);
3996 return self_t{{this->asArrowTable()}, std::move(newSelection), 0};
4004 template <
typename T1>
4020 template <
typename T1,
bool OPT>
4026 template <
typename T1,
bool OPT>
4035 copyIndexBindings(t);
4040template <
typename T>
4049 using iterator =
typename T::template iterator_template_o<FilteredIndexPolicy, self_t>;
4055 return iterator(this->cached_begin());
4066 for (
auto& table : tables) {
4074 for (
auto& table : tables) {
4082 for (
auto& table : tables) {
4108 this->sumWithSelection(selection);
4114 this->sumWithSelection(selection);
4120 return operator+=(
other.getSelectedRows());
4126 copy.intersectionWithSelection(selection);
4133 copy.intersectionWithSelection(selection);
4139 return operator*(
other.getSelectedRows());
4144 this->intersectWithSelection(selection);
4150 this->intersectWithSelection(selection);
4156 return operator*=(
other.getSelectedRows());
4170 std::iota(newSelection.begin(), newSelection.end(),
start);
4171 return self_t{{this->asArrowTable()}, std::move(newSelection), 0};
4189 template <
typename T1,
bool OPT>
4195 template <
typename T1,
bool OPT>
4202 std::vector<std::shared_ptr<arrow::Table>> extractTablesFromFiltered(std::vector<
Filtered<T>>& tables)
4204 std::vector<std::shared_ptr<arrow::Table>> outTables;
4205 for (
auto& table : tables) {
4206 outTables.push_back(table.asArrowTable());
4217template <
typename L,
typename D,
typename O,
typename Key,
typename H,
typename...
Ts>
4227 static constexpr const uint32_t binding_origin = Key::binding_origin;
4230 template <
typename... TA>
4234 if constexpr (binding_origin == TA::binding_origin) {
4235 this->bindExternalIndex(cur);
4262template <
typename T,
bool APPLY>
4264 static constexpr bool applyFilters = APPLY;
4271 SmallGroupsBase(std::vector<std::shared_ptr<arrow::Table>>&& tables, std::span<int64_t const>
const& selection, uint64_t
offset = 0)
4275template <
typename T>
4278template <
typename T>
4281template <
typename T>
header::DataDescription description
std::vector< std::string > labels
#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)
std::unique_ptr< expressions::Node > node
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
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
void sumWithSelection(std::span< int64_t const > const &selection)
void intersectWithSelection(std::span< int64_t const > const &selection)
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
FilteredBase(std::vector< std::shared_ptr< arrow::Table > > &&tables, std::span< int64_t const > const &selection, uint64_t offset=0)
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
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
auto const & cached_begin() const
auto sliceBy(o2::framework::PresliceBase< T1, framework::PreslicePolicySorted, OPT > const &container, int value) const
Filtered< Filtered< T > > operator*(std::span< int64_t const > const &selection)
typename FilteredBase< typename T::table_t >::table_t table_t
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+=(std::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, std::span< int64_t const > const &selection, uint64_t offset=0)
Filtered< Filtered< T > > operator+(std::span< int64_t const > const &selection)
Filtered(std::vector< Filtered< T > > &&tables, SelectionVector &&selection, uint64_t offset=0)
unfiltered_iterator rawIteratorAt(uint64_t i) const
Filtered< Filtered< T > > operator*=(std::span< int64_t const > const &selection)
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*(Filtered< T > const &other)
Filtered< Filtered< T > > operator*(SelectionVector const &selection)
auto sliceByCachedUnsorted(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
Filtered< T > operator*(std::span< int64_t const > const &selection)
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< T > operator+(std::span< int64_t const > const &selection)
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)
Filtered(std::vector< std::shared_ptr< arrow::Table > > &&tables, std::span< int64_t const > const &selection, uint64_t offset=0)
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)
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)
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
Filtered< T > operator*=(std::span< int64_t const > const &selection)
Filtered< T > operator+=(std::span< int64_t const > const &selection)
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
static constexpr header::DataOrigin binding_origin_
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
void bindExternalIndex(TA *current)
std::shared_ptr< arrow::Table > asArrowTable() const
Return a type erased arrow table backing store for / the type safe table.
filtered_iterator filtered_begin(std::span< int64_t const > selection)
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 constexpr const uint32_t binding_origin
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
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 replaceOrigin()
Replace origins in the TableRef array.
constexpr framework::ConcreteDataMatcher matcher()
consteval auto filterForKey()
Filter TableRef array for compatibility with Key table.
consteval const char * label()
consteval header::DataOrigin origin()
gandiva::Selection createSelection(std::shared_ptr< arrow::Table > const &table, Filter const &expression)
Function for creating gandiva selection from our internal filter tree.
Defining ITS Vertex 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
R getColumnValue(const T &rowIterator)
ColumnGetterFunction< R, typename T::iterator > getColumnGetterByLabel(const std::string_view &targetColumnLabel)
void * extractCCDBPayload(char *payload, size_t size, TClass const *cl, const char *what)
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)
void notBoundTable(const char *tableName)
SelectionVector sliceSelection(std::span< int64_t const > const &mSelectedRows, int64_t nrows, uint64_t offset)
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
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)
auto doSliceByHelper(T const *table, std::span< const int64_t > const &selection)
std::function< framework::ConcreteDataMatcher(framework::ConcreteDataMatcher &&)> originReplacement(header::DataOrigin newOrigin)
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
FIXME: do not use data model tables.
static constexpr uint32_t hash
static constexpr char const *const str
SliceInfoUnsortedPtr getCacheUnsortedFor(Entry const &bindingKey) const
header::DataOrigin newOrigin
SliceInfoPtr getCacheFor(Entry const &bindingKey) const
std::shared_ptr< arrow::Table > getEmptySliceFor(std::shared_ptr< arrow::Table > const &table)
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_)
std::span< const int64_t > getSliceFor(int value) const
const std::string binding
tracks origin in bindingKey matcher to handle the correct arguments
const std::string binding
Entry const & getBindingKey() const
SliceInfoUnsortedPtr sliceInfo
std::span< const int64_t > getSliceFor(int value) const
void updateSliceInfo(SliceInfoUnsortedPtr &&si)
void updateSliceInfo(SliceInfoPtr &&si)
std::pair< arrow::Table const *, std::shared_ptr< arrow::Table > > emptySlice
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)
static std::shared_ptr< arrow::Table > concatTables(std::vector< std::shared_ptr< arrow::Table > > &&tables)
Type-checking index column binding.
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()
FilteredIndexPolicy & operator=(FilteredIndexPolicy &&)=default
std::tuple< int64_t const *, int64_t const * > getIndices() const
FilteredIndexPolicy & operator=(FilteredIndexPolicy const &)=default
auto getSelectionRow() const
FilteredIndexPolicy()=default
FilteredIndexPolicy(std::span< int64_t const > selection, int64_t rows, uint64_t offset=0)
friend bool operator==(FilteredIndexPolicy const &lh, FilteredIndexPolicy const &rh)
void resetSelection(std::span< int64_t const > selection)
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(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)
void bindExternalIndices(TA *... current)
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
auto sliceBy(o2::framework::PresliceBase< T1, Policy, OPT > const &container, int value) const
static constexpr const auto originalLabels
Join(std::vector< std::shared_ptr< arrow::Table > > &&tables, uint64_t offset=0)
static constexpr const auto originals
iterator rawIteratorAt(uint64_t i) const
static constexpr const uint32_t binding_origin
auto sliceByCached(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
const_iterator unfiltered_const_iterator
typename table_t::columns_t columns_t
Table< o2::aod::Hash<"JOIN"_h >, o2::aod::Hash<"JOIN/0"_h >, o2::aod::Hash<"JOIN"_h >, Ts... > base
iterator iteratorAt(uint64_t i) const
typename table_t::persistent_columns_t persistent_columns_t
const_iterator begin() const
void bindExternalIndices(TA *... current)
table_t::template iterator_template< DefaultIndexPolicy, self_t, Ts... > iterator
static consteval bool contains()
Join(std::shared_ptr< arrow::Table > &&table, uint64_t offset=0)
table_t::template iterator_template< FilteredIndexPolicy, self_t, Ts... > filtered_iterator
auto sliceByCachedUnsorted(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
auto rawSlice(uint64_t start, uint64_t end) const
static constexpr const header::DataOrigin binding_origin_
iterator unfiltered_iterator
filtered_iterator filtered_const_iterator
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, std::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 bindExternalIndex(TA *current)
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
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