12#ifndef O2_FRAMEWORK_ASOA_H_
13#define O2_FRAMEWORK_ASOA_H_
26#include <arrow/array/array_binary.h>
27#include <arrow/table.h>
28#include <arrow/array.h>
29#include <arrow/util/config.h>
30#include <gandiva/selection_vector.h>
33#include <fmt/format.h>
40using ListVector = std::vector<std::vector<int64_t>>;
56template <
typename...
C>
59 return std::vector<std::shared_ptr<arrow::Field>>{C::asArrowField()...};
74 consteval TableRef(uint32_t _label, uint32_t _desc, uint32_t _origin, uint32_t _version)
88 return (this->label_hash ==
other.label_hash) &&
89 (this->desc_hash ==
other.desc_hash) &&
90 (this->origin_hash ==
other.origin_hash) &&
91 (this->version ==
other.version);
96 return this->desc_hash ==
other.desc_hash;
101 return this->desc_hash == _desc_hash;
111template <
size_t N1,
size_t N2, std::array<TableRef, N1> ar1, std::array<TableRef, N2> ar2>
114 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; }); });
115 std::array<TableRef, N1 + N2 - duplicates> out;
117 auto pos = std::copy(ar1.begin(), ar1.end(), out.begin());
118 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; }); });
122template <
size_t N1,
size_t N2, std::array<TableRef, N1> ar1, std::array<TableRef, N2> ar2,
typename L>
125 constexpr const int to_remove = std::ranges::count_if(ar1.begin(), ar1.end(), [&](
TableRef const&
a) { return !l(a); });
126 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); });
127 std::array<TableRef, N1 + N2 - duplicates - to_remove> out;
129 auto pos = std::copy_if(ar1.begin(), ar1.end(), out.begin(), [&](TableRef
const&
a) { return l(a); });
130 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); });
134template <
size_t N, std::array<TableRef, N> ar,
typename L>
137 constexpr const int to_remove = std::ranges::count_if(ar.begin(), ar.end(), [&l](
TableRef const& e) { return l(e); });
138 std::array<
TableRef, N - to_remove> out;
139 std::copy_if(ar.begin(), ar.end(), out.begin(), [&l](
TableRef const& e) { return !l(e); });
143template <
size_t N1,
size_t N2, std::array<TableRef, N1> ar1, std::array<TableRef, N2> ar2>
144consteval auto intersect()
146 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; }); });
147 std::array<TableRef, duplicates> out;
148 std::copy_if(ar1.begin(), ar1.end(), out.begin(), [](TableRef
const&
a) { return std::find(ar2.begin(), ar2.end(), a) != ar2.end(); });
152template <
typename T,
typename... Ts>
154 requires(
sizeof...(Ts) == 1)
157 return merge<T::originals.size(), T1::originals.size(), T::originals, T1::originals>();
160template <
typename T,
typename...
Ts>
162 requires(
sizeof...(Ts) > 1)
165 return merge<T::originals.size(), tail.size(), T::originals, tail>();
168template <
typename T,
typename...
Ts>
169 requires(
sizeof...(Ts) == 1)
170consteval auto intersectOriginals()
173 return intersect<T::originals.size(), T1::originals.size(), T::originals, T1::originals>();
176template <
typename T,
typename...
Ts>
177 requires(
sizeof...(Ts) > 1)
178consteval auto intersectOriginals()
181 return intersect<T::originals.size(), tail.size(), T::originals, tail>();
190concept not_void =
requires { !std::same_as<T, void>; };
207 {
c.setCurrentRaw(
b) } -> std::same_as<bool>;
212using is_external_index_t =
typename std::conditional_t<is_index_column<C>, std::true_type, std::false_type>;
215using is_self_index_t =
typename std::conditional_t<is_self_index_column<C>, std::true_type, std::false_type>;
222template <
typename Key,
size_t N, std::array<
bool, N> map>
223static consteval int getIndexPosToKey_impl()
225 constexpr const auto pos = std::find(map.begin(), map.end(),
true);
226 if constexpr (
pos != map.end()) {
227 return std::distance(map.begin(),
pos);
235template <
typename D,
typename... Cs>
242 template <
typename Key,
typename... PCs>
245 return std::array<bool,
sizeof...(PCs)>{[]() {
246 if constexpr (
requires { PCs::index_targets.size(); }) {
247 return Key::template isIndexTargetOf<PCs::index_targets.size(), PCs::index_targets>();
254 template <
typename Key>
275 static constexpr uint32_t
hash = H;
276 static constexpr char const*
const str{
""};
280template <
size_t N, std::array<soa::TableRef, N> ar,
typename Key>
283 constexpr std::array<bool, N>
test = []<
size_t... Is>(std::index_sequence<Is...>) {
284 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))...};
285 }(std::make_index_sequence<N>());
286 constexpr int correct = std::ranges::count(
test.begin(),
test.end(),
true);
287 std::array<soa::TableRef, correct> out;
288 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))]; });
293#define O2HASH(_Str_) \
295 struct Hash<_Str_ ""_h> { \
296 static constexpr uint32_t hash = _Str_ ""_h; \
297 static constexpr char const* const str{_Str_}; \
301#define O2ORIGIN(_Str_) \
303 struct Hash<_Str_ ""_h> { \
304 static constexpr header::DataOrigin origin{_Str_}; \
305 static constexpr uint32_t hash = _Str_ ""_h; \
306 static constexpr char const* const str{_Str_}; \
310static inline constexpr uint32_t
version(
const char*
const str)
312 if (
str[0] ==
'\0') {
320 if (
str[
len - 1] ==
'\0') {
323 for (
auto i =
len + 1;
str[
i] !=
'\0'; ++
i) {
330static inline constexpr std::string_view description_str(
const char*
const str)
336 return std::string_view{
str,
len};
346 for (
auto i = 0;
i < 16; ++
i) {
349 std::memcpy(out,
str,
len);
354template <soa::TableRef R>
360template <soa::TableRef R>
366template <soa::TableRef R>
372template <soa::TableRef R>
386template <soa::TableRef R>
387static constexpr auto sourceSpec()
389 return fmt::format(
"{}/{}/{}/{}",
label<R>(), origin_str<R>(), description_str(signature<R>()),
R.version);
395template <aod::is_aod_hash L, aod::is_aod_hash D, aod::is_origin_hash O,
typename... Ts>
400 void const*
ptr =
nullptr;
402 std::span<TableRef const>
refs;
404 template <
typename T>
408 hash = o2::framework::TypeIdHelpers::uniqueId<T>();
409 refs = std::span{T::originals};
412 template <
typename T>
415 if (
hash == o2::framework::TypeIdHelpers::uniqueId<T>()) {
416 return static_cast<T const*
>(
ptr);
445template <
typename B,
typename E>
447 constexpr static bool value =
false;
450template <aod::is_aod_hash A, aod::is_aod_hash B>
452 constexpr static bool value =
false;
455template <
typename B,
typename E>
458template <aod::is_aod_hash A, aod::is_aod_hash B>
497template <
typename T,
typename ChunkingPolicy = Chunked>
500 static constexpr char SCALE_FACTOR = std::same_as<std::decay_t<T>,
bool> ? 3 : 0;
516 auto array = getCurrentArray();
531 auto previousArray = getCurrentArray();
535 auto array = getCurrentArray();
542 auto previousArray = getCurrentArray();
546 auto array = getCurrentArray();
568 auto array = getCurrentArray();
575 requires
std::same_as<
bool,
std::decay_t<T>>
591 decltype(
auto)
operator*()
const
592 requires((!std::same_as<bool, std::decay_t<T>>) && std::same_as<
arrow_array_for_t<T>, arrow::BinaryViewArray>)
599 decltype(
auto)
operator*()
const
622 void checkSkipChunk() const
631 void checkSkipChunk() const
639 void checkSkipChunk() const
640 requires(ChunkingPolicy::
chunked == false)
644 auto getCurrentArray() const
648 mOffset = chunkToUse->offset();
649 chunkToUse = std::dynamic_pointer_cast<arrow::FixedSizeListArray>(chunkToUse)->values();
650 return std::static_pointer_cast<arrow_array_for_t<value_for_t<T>>>(chunkToUse);
653 auto getCurrentArray() const
657 mOffset = chunkToUse->offset();
658 chunkToUse = std::dynamic_pointer_cast<arrow::ListArray>(chunkToUse)->values();
659 mOffset = chunkToUse->offset();
660 return std::static_pointer_cast<arrow_array_for_t<value_for_t<T>>>(chunkToUse);
663 auto getCurrentArray() const
667 mOffset = chunkToUse->offset();
668 return std::static_pointer_cast<arrow_array_for_t<T>>(chunkToUse);
672template <
typename T,
typename INHERIT>
688 static constexpr const char*
const&
columnLabel() {
return INHERIT::mLabel; }
696 return std::make_shared<arrow::Field>(inherited_t::mLabel, soa::asArrowDataType<type>());
706template <
typename F,
typename INHERIT>
710 static constexpr const char*
const&
columnLabel() {
return INHERIT::mLabel; }
713template <
typename INHERIT>
716 static constexpr const uint32_t
hash = 0;
718 static constexpr const char*
const&
columnLabel() {
return INHERIT::mLabel; }
721template <
typename INHERIT>
724 static constexpr const uint32_t
hash = 0;
726 static constexpr const char*
const&
columnLabel() {
return INHERIT::mLabel; }
729template <
size_t M = 0>
733 constexpr inline static auto value = M;
748 static constexpr const char*
mLabel =
"Marker";
751template <int64_t START = 0, int64_t
END = -1>
754 constexpr inline static int64_t
start = START;
755 constexpr inline static int64_t
end =
END;
815 static constexpr const char*
mLabel =
"Index";
839using is_dynamic_t = std::conditional_t<is_dynamic_column<T>, std::true_type, std::false_type>;
845using is_indexing_t = std::conditional_t<is_indexing_column<T>, std::true_type, std::false_type>;
866 mSelectedRows(selection),
867 mMaxSelection(selection.
size()),
875 mSelectedRows = selection;
876 mMaxSelection = selection.size();
886 [[nodiscard]] std::tuple<int64_t const*, int64_t const*>
889 return std::make_tuple(&
mRowIndex, &mSelectionRow);
892 [[nodiscard]] std::tuple<uint64_t const*>
895 return std::make_tuple(&
mOffset);
902 mMaxSelection = std::min(
end, mMaxSelection);
920 return lh.mSelectionRow == rh.mSelectionRow;
933 this->mSelectionRow = this->mMaxSelection;
939 return mSelectionRow;
942 [[nodiscard]]
auto size()
const
944 return mMaxSelection;
953 inline void updateRow()
957 std::span<int64_t const> mSelectedRows;
958 int64_t mSelectionRow = 0;
959 int64_t mMaxSelection = 0;
994 [[nodiscard]] std::tuple<int64_t const*, int64_t const*>
1000 [[nodiscard]] std::tuple<uint64_t const*>
1003 return std::make_tuple(&
mOffset);
1044template <
typename T>
1049template <
typename C>
1055template <
typename T,
typename B>
1057 { t.B::mColumnIterator };
1060template <
typename...
C>
1063template <
typename D,
typename O,
typename IP,
typename... C>
1078 if (this->
size() != 0) {
1088 if (this->
size() != 0) {
1095 this->limitRange(this->rangeStart(), this->rangeEnd());
1101 C(static_cast<
C const&>(
other))...
1103 if (this->
size() != 0) {
1110 IP::operator=(
static_cast<IP const&
>(
other));
1111 (
void(
static_cast<C&
>(*
this) =
static_cast<C>(
other)), ...);
1112 if (this->
size() != 0) {
1119 requires std::same_as<IP, DefaultIndexPolicy>
1121 C(
static_cast<C const&
>(
other))...
1123 if (this->
size() != 0) {
1130 this->moveByIndex(1);
1143 this->moveByIndex(-1);
1158 copy.moveByIndex(inc);
1172 template <
typename... CL,
typename TA>
1175 (CL::setCurrent(current), ...);
1178 template <
typename CL>
1181 return CL::getCurrentRaw();
1184 template <
typename... Cs>
1187 return std::vector<o2::soa::Binding>{
static_cast<Cs const&
>(*this).getCurrentRaw()...};
1195 template <
typename... TA>
1201 template <
typename... Cs>
1204 (Cs::setCurrentRaw(ptrs[framework::has_type_at_v<Cs>(p)]), ...);
1207 template <
typename... Cs,
typename I>
1212 (Cs::setCurrentRaw(
b), ...);
1220 template <
typename I>
1228 template <
typename... PC>
1231 (PC::mColumnIterator.moveToEnd(), ...);
1241 [
this]<soa::is_dynamic_column T>(T*) ->
void { bindDynamicColumn<T>(
typename T::bindings_t{}); },
1242 [
this]<
typename T>(
T*) ->
void {},
1244 (
f(
static_cast<C*
>(
nullptr)), ...);
1245 if constexpr (has_index<
C...>) {
1246 this->setIndices(this->getIndices());
1247 this->setOffsets(this->getOffsets());
1251 template <
typename DC,
typename...
B>
1254 DC::boundIterators = std::make_tuple(getDynamicBinding<B>()...);
1262 template <
typename B>
1263 requires(can_bind<self_t, B>)
1264 decltype(
auto) getDynamicBinding()
1266 static_assert(std::same_as<decltype(&(static_cast<B*>(
this)->mColumnIterator)), std::decay_t<
decltype(B::mColumnIterator)>*>,
"foo");
1267 return &(
static_cast<B*
>(
this)->mColumnIterator);
1271 template <
typename B>
1272 decltype(
auto) getDynamicBinding()
1274 return static_cast<std::decay_t<decltype(B::mColumnIterator)
>*>(
nullptr);
1279 static std::shared_ptr<arrow::Table>
joinTables(std::vector<std::shared_ptr<arrow::Table>>&& tables, std::span<const char* const>
labels);
1280 static std::shared_ptr<arrow::Table>
joinTables(std::vector<std::shared_ptr<arrow::Table>>&& tables, std::span<const std::string>
labels);
1281 static std::shared_ptr<arrow::Table>
concatTables(std::vector<std::shared_ptr<arrow::Table>>&& tables);
1285template <
typename T>
1288template <
typename T>
1290 T::originals.size();
1293template <
typename T>
1298template <
typename T>
1300 T::ccdb_urls.size();
1303template <
typename T>
1308template <
typename T>
1310 typename T::expression_pack_t{};
1313template <
typename T>
1315 typename T::index_pack_t{};
1318template <
size_t N1, std::array<TableRef, N1> os1,
size_t N2, std::array<TableRef, N2> os2>
1321 return []<
size_t... Is>(std::index_sequence<Is...>) {
1322 return ([]<
size_t... Ks>(std::index_sequence<Ks...>) {
1323 constexpr auto h = os1[Is].desc_hash;
1326 }(std::make_index_sequence<N2>()) ||
1328 }(std::make_index_sequence<N1>());
1331template <with_originals T, with_originals B>
1334 return is_compatible<T::originals.size(), T::originals, B::originals.size(), B::originals>();
1337template <
typename T,
typename B>
1338using is_binding_compatible = std::conditional_t<is_binding_compatible_v<T, typename B::binding_t>(), std::true_type, std::false_type>;
1340template <
typename L,
typename D,
typename O,
typename Key,
typename H,
typename...
Ts>
1343template <
typename T>
1346template <soa::is_table T>
1347static constexpr std::string getLabelForTable()
1349 return std::string{aod::label<std::decay_t<T>::originals[0]>()};
1352template <soa::is_table T>
1354static constexpr std::string getLabelFromType()
1356 return getLabelForTable<T>();
1359template <soa::is_iterator T>
1360static constexpr std::string getLabelFromType()
1362 return getLabelForTable<typename std::decay_t<T>::parent_t>();
1365template <soa::is_index_table T>
1366static constexpr std::string getLabelFromType()
1368 return getLabelForTable<typename std::decay_t<T>::first_t>();
1370template <soa::with_base_table T>
1371static constexpr std::string getLabelFromType()
1376template <
typename...
C>
1379 return ((C::inherited_t::mLabel ==
key) || ...);
1382template <TableRef ref>
1383static constexpr std::pair<bool, std::string> hasKey(std::string
const&
key)
1388template <
typename...
C>
1391 return std::vector{hasKey<C>(
key)...};
1397template <with_originals T,
bool OPT = false>
1398static constexpr std::string getLabelFromTypeForKey(std::string
const&
key)
1400 if constexpr (T::originals.size() == 1) {
1401 auto locate = hasKey<T::originals[0]>(
key);
1403 return locate.second;
1406 auto locate = [&]<
size_t... Is>(std::index_sequence<Is...>) {
1407 return std::vector{hasKey<T::originals[Is]>(
key)...};
1408 }(std::make_index_sequence<T::originals.size()>{});
1409 auto it = std::find_if(locate.begin(), locate.end(), [](
auto const&
x) { return x.first; });
1410 if (it != locate.end()) {
1414 if constexpr (!OPT) {
1422template <
typename B,
typename...
C>
1425 return (o2::soa::is_binding_compatible_v<B, typename C::binding_t>() || ...);
1428template <
typename B,
typename...
C>
1431 return ((C::sorted && o2::soa::is_binding_compatible_v<B, typename C::binding_t>()) || ...);
1434template <
typename B,
typename Z>
1435consteval static bool relatedByIndex()
1437 return hasIndexTo<B>(
typename Z::table_t::external_index_columns_t{});
1440template <
typename B,
typename Z>
1441consteval static bool relatedBySortedIndex()
1443 return hasSortedIndexTo<B>(
typename Z::table_t::external_index_columns_t{});
1462 std::shared_ptr<arrow::Table>
getSliceFor(
int value, std::shared_ptr<arrow::Table>
const& input, uint64_t&
offset)
const;
1472template <
typename T,
typename Policy,
bool OPT = false>
1480 : Policy{
PreslicePolicyBase{{o2::soa::getLabelFromTypeForKey<T, OPT>(std::string{index_.
name})},
Entry(o2::soa::getLabelFromTypeForKey<T, OPT>(std::string{index_.name}), std::string{index_.name})}, {}}
1486 if constexpr (OPT) {
1487 if (Policy::isMissing()) {
1496 if constexpr (OPT) {
1497 if (Policy::isMissing()) {
1501 return Policy::getSliceFor(
value);
1505template <
typename T>
1507template <
typename T>
1509template <
typename T>
1511template <
typename T>
1514template <
typename T>
1532template <
typename T>
1539template <soa::is_table T>
1541template <
typename T>
1544template <
typename T>
1547template <
typename T>
1550template <
typename T>
1554template <
typename T>
1557template <
typename T>
1560template <
typename T>
1564template <
typename... Is>
1572template <
typename T,
typename C,
typename Policy,
bool OPT>
1573 requires std::same_as<Policy, framework::PreslicePolicySorted> && (o2::soa::is_binding_compatible_v<C, T>())
1576 if constexpr (OPT) {
1577 if (container.isMissing()) {
1583 auto t =
typename T::self_t({out},
offset);
1584 if (t.tableSize() != 0) {
1585 table->copyIndexBindings(t);
1586 t.bindInternalIndicesTo(table);
1591template <soa::is_filtered_table T>
1595 if (t.tableSize() != 0) {
1597 t.bindInternalIndicesTo(table);
1598 t.intersectWithSelection(table->getSelectedRows());
1603template <soa::is_table T>
1608 if (t.tableSize() != 0) {
1610 t.bindInternalIndicesTo(table);
1615template <
typename T,
typename C,
typename Policy,
bool OPT>
1616 requires std::same_as<Policy, framework::PreslicePolicyGeneral> && (o2::soa::is_binding_compatible_v<C, T>())
1619 if constexpr (OPT) {
1620 if (container.isMissing()) {
1630template <soa::is_filtered_table T>
1633 if (
offset >=
static_cast<uint64_t
>(table->tableSize())) {
1635 if (fresult.tableSize() != 0) {
1642 if (fresult.tableSize() != 0) {
1648template <soa::is_filtered_table T,
typename C,
bool OPT>
1649 requires(o2::soa::is_binding_compatible_v<C, T>())
1652 if constexpr (OPT) {
1653 if (container.isMissing()) {
1662template <
typename T>
1667 auto t =
typename T::self_t({table->asArrowTable()->Slice(
static_cast<uint64_t
>(
offset),
count)},
static_cast<uint64_t
>(
offset));
1668 if (t.tableSize() != 0) {
1669 table->copyIndexBindings(t);
1674template <
typename T>
1679 auto slice = table->asArrowTable()->Slice(
static_cast<uint64_t
>(
offset),
count);
1683template <
typename T>
1688 auto t =
typename T::self_t({table->asArrowTable()}, localCache.getSliceFor(
value));
1689 if (t.tableSize() != 0) {
1690 t.intersectWithSelection(table->getSelectedRows());
1691 table->copyIndexBindings(t);
1695 auto t =
Filtered<T>({table->asArrowTable()}, localCache.getSliceFor(
value));
1696 if (t.tableSize() != 0) {
1697 table->copyIndexBindings(t);
1703template <with_originals T>
1711template <
typename D,
typename O,
typename IP,
typename...
C>
1748 return std::array<TableRef, 1>{
ref};
1764 static constexpr const auto ref =
TableRef{L::hash, D::hash, O::hash, o2::aod::version(D::str)};
1769 static constexpr const auto originalLabels = []<
size_t N, std::array<TableRef, N> refs,
size_t... Is>(std::index_sequence<Is...>) {
return std::array<const char*, N>{o2::aod::label<refs[Is]>()...}; }.template operator()<
originals.size(),
originals>(std::make_index_sequence<
originals.size()>());
1771 template <
size_t N, std::array<TableRef, N> bindings>
1772 requires(
ref.origin_hash ==
"CONC"_h)
1778 template <
size_t N, std::array<TableRef, N> bindings>
1779 requires(
ref.origin_hash ==
"JOIN"_h)
1784 return std::find(bindings.begin(), bindings.end(),
r) != bindings.end();
1788 template <
size_t N, std::array<TableRef, N> bindings>
1789 requires(!(
ref.origin_hash ==
"CONC"_h ||
ref.origin_hash ==
"JOIN"_h))
1792 return std::find(bindings.begin(), bindings.end(),
self_t::ref) != bindings.end();
1795 template <TableRef r>
1808 template <
typename IP>
1811 template <
typename IP,
typename Parent,
typename... T>
1828 template <
typename P,
typename... Os>
1830 requires(P::ref.desc_hash == Parent::ref.desc_hash)
1836 template <
typename P>
1843 template <
typename P>
1845 requires std::same_as<IP, DefaultIndexPolicy>
1851 template <
typename P,
typename O1,
typename... Os>
1853 requires(P::ref.desc_hash == Parent::ref.desc_hash)
1858 template <
typename P,
typename O1,
typename... Os>
1860 requires(P::ref.desc_hash == Parent::ref.desc_hash)
1865 template <
typename P>
1871 template <
typename P>
1877 template <
typename P>
1879 requires std::same_as<IP, DefaultIndexPolicy>
1886 this->mRowIndex =
other.index;
1889 template <
typename P>
1892 this->mRowIndex =
other.mRowIndex;
1895 template <
typename P,
typename... Os>
1897 requires std::same_as<typename P::table_t, typename Parent::table_t>
1899 this->mRowIndex =
other.mRowIndex;
1902 template <
typename TI>
1905 using decayed = std::decay_t<TI>;
1907 constexpr auto idx = framework::has_type_at_v<decayed>(
bindings_pack_t{});
1909 }
else if constexpr (std::same_as<decayed, Parent>) {
1910 return this->globalIndex();
1912 return this->globalIndex();
1914 return static_cast<int32_t
>(-1);
1918 template <
typename CD,
typename... CDArgs>
1921 using decayed = std::decay_t<CD>;
1923 return static_cast<decayed
>(*this).template getDynamicValue<CDArgs...>();
1926 template <
typename B,
typename CC>
1929 using COL = std::decay_t<CC>;
1931 return static_cast<B>(
static_cast<COL
>(*this).get());
1934 template <
typename B,
typename... CCs>
1937 static_assert(std::same_as<B, float> || std::same_as<B, double>,
"The common return type should be float or double");
1938 return {getValue<B, CCs>()...};
1949 copy.moveByIndex(inc);
1964 template <
typename IP,
typename Parent,
typename... T>
1967 template <
typename IP,
typename Parent>
1970 if constexpr (
sizeof...(Ts) == 0) {
1981 template <
typename IP,
typename Parent>
1998 mEnd{table->num_rows()},
2001 if (mTable->num_rows() == 0) {
2003 mColumnChunks[ci] =
nullptr;
2009 mColumnChunks[ci] = lookups[ci];
2012 mBegin.bindInternalIndices(
this);
2016 Table(std::vector<std::shared_ptr<arrow::Table>>&& tables, uint64_t
offset = 0)
2017 requires(
ref.origin_hash !=
"CONC"_h)
2022 Table(std::vector<std::shared_ptr<arrow::Table>>&& tables, uint64_t
offset = 0)
2023 requires(
ref.origin_hash ==
"CONC"_h)
2028 template <
typename Key>
2032 return std::array<bool,
sizeof...(Cs)>{[]() {
2033 if constexpr (
requires { Cs::index_targets.size(); }) {
2034 return Key::template
isIndexTargetOf<Cs::index_targets.size(), Cs::index_targets>();
2040 constexpr auto pos = std::find(map.begin(), map.end(),
true);
2041 if constexpr (
pos != map.end()) {
2042 return mColumnChunks[std::distance(map.begin(),
pos)];
2044 static_assert(framework::always_static_assert_v<Key>,
"This table does not have an index to given Key");
2074 return filtered_iterator(mColumnChunks, {selection, mTable->num_rows(), mOffset});
2112 return mTable->num_rows();
2122 template <
typename... TA>
2125 mBegin.bindExternalIndices(current...);
2128 template <
typename I>
2131 mBegin.bindInternalIndices(
ptr);
2139 template <
typename... Cs>
2142 (
static_cast<Cs
>(mBegin).setCurrentRaw(
binding), ...);
2147 mBegin.bindExternalIndicesRaw(std::forward<std::vector<o2::soa::Binding>>(ptrs));
2150 template <
typename T,
typename... Cs>
2153 dest.bindExternalIndicesRaw(mBegin.getIndexBindings());
2156 template <
typename T>
2179 template <
typename T1,
typename Policy,
bool OPT>
2192 return self_t{mTable->Slice(0, 0), 0};
2196 template <
typename T>
2197 arrow::ChunkedArray* lookupColumn()
2200 auto label = T::columnLabel();
2206 std::shared_ptr<arrow::Table> mTable =
nullptr;
2207 uint64_t mOffset = 0;
2214template <uint32_t
D, soa::is_column...
C>
2220namespace row_helpers
2222template <
typename R,
typename T,
typename C>
2225 return static_cast<R>(
static_cast<C>(rowIterator).get());
2230template <
typename R,
typename T>
2231using ColumnGetterFunction =
R (*)(
const T&);
2233template <
typename T,
typename R>
2238 { t.get() } -> std::convertible_to<R>;
2241template <
typename T,
typename R>
2243 { t.get() } -> std::convertible_to<R>;
2246template <
typename R,
typename T, persistent_with_common_getter<R> C>
2247ColumnGetterFunction<R, T> createGetterPtr(
const std::string_view& targetColumnLabel)
2249 return targetColumnLabel == C::columnLabel() ? &getColumnValue<R, T, C> :
nullptr;
2252template <
typename R,
typename T, dynamic_with_common_getter<R> C>
2253ColumnGetterFunction<R, T> createGetterPtr(
const std::string_view& targetColumnLabel)
2259 if (targetColumnLabel.starts_with(
"f") && targetColumnLabel.substr(1) ==
columnLabel) {
2260 return &getColumnValue<R, T, C>;
2265 return &getColumnValue<R, T, C>;
2271template <
typename R,
typename T,
typename... Cs>
2274 ColumnGetterFunction<R, T>
func;
2276 (
void)((
func = createGetterPtr<R, T, Cs>(targetColumnLabel),
func) || ...);
2285template <
typename T,
typename R>
2286using 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;
2289template <
typename R,
typename T>
2294 if (targetColumnLabel.size() == 0) {
2298 return getColumnGetterByLabel<R, typename T::iterator>(TypesWithCommonGetter{}, targetColumnLabel);
2323template <
typename T>
2324consteval static std::string_view namespace_prefix()
2326 constexpr auto name = o2::framework::type_name<T>();
2327 const auto pos =
name.rfind(std::string_view{
":"});
2328 return name.substr(0,
pos + 1);
2332#define DECLARE_EQUIVALENT_FOR_INDEX(_Base_, _Equiv_) \
2334 struct EquivalentIndexNG<o2::aod::Hash<_Base_::ref.desc_hash>, o2::aod::Hash<_Equiv_::ref.desc_hash>> { \
2335 constexpr static bool value = true; \
2338#define DECLARE_EQUIVALENT_FOR_INDEX_NG(_Base_, _Equiv_) \
2340 struct EquivalentIndexNG<o2::aod::Hash<_Base_ ""_h>, o2::aod::Hash<_Equiv_ ""_h>> { \
2341 constexpr static bool value = true; \
2344#define DECLARE_SOA_COLUMN_FULL(_Name_, _Getter_, _Type_, _Label_) \
2345 struct _Name_ : o2::soa::Column<_Type_, _Name_> { \
2346 static constexpr const char* mLabel = _Label_; \
2347 static constexpr const uint32_t hash = compile_time_hash(namespace_prefix<_Name_>(), std::string_view{#_Getter_}); \
2348 static_assert(!((*(mLabel + 1) == 'I' && *(mLabel + 2) == 'n' && *(mLabel + 3) == 'd' && *(mLabel + 4) == 'e' && *(mLabel + 5) == 'x')), "Index is not a valid column name"); \
2349 using base = o2::soa::Column<_Type_, _Name_>; \
2350 using type = _Type_; \
2351 using column_t = _Name_; \
2352 _Name_(arrow::ChunkedArray const* column) \
2353 : o2::soa::Column<_Type_, _Name_>(o2::soa::ColumnIterator<type>(column)) \
2357 _Name_() = default; \
2358 _Name_(_Name_ const& other) = default; \
2359 _Name_& operator=(_Name_ const& other) = default; \
2361 decltype(auto) _Getter_() const \
2363 return *mColumnIterator; \
2366 decltype(auto) get() const \
2368 return _Getter_(); \
2371 [[maybe_unused]] static constexpr o2::framework::expressions::BindingNode _Getter_ { _Label_, _Name_::hash, o2::framework::expressions::selectArrowType<_Type_>() }
2373#define DECLARE_SOA_CCDB_COLUMN_FULL(_Name_, _Label_, _Getter_, _ConcreteType_, _CCDBQuery_) \
2374 struct _Name_ : o2::soa::Column<std::span<std::byte>, _Name_> { \
2375 static constexpr const char* mLabel = _Label_; \
2376 static constexpr const char* query = _CCDBQuery_; \
2377 static constexpr const uint32_t hash = crc32(namespace_prefix<_Name_>(), std::string_view{#_Getter_}); \
2378 using base = o2::soa::Column<std::span<std::byte>, _Name_>; \
2379 using type = std::span<std::byte>; \
2380 using column_t = _Name_; \
2381 _Name_(arrow::ChunkedArray const* column) \
2382 : o2::soa::Column<std::span<std::byte>, _Name_>(o2::soa::ColumnIterator<std::span<std::byte>>(column)) \
2386 _Name_() = default; \
2387 _Name_(_Name_ const& other) = default; \
2388 _Name_& operator=(_Name_ const& other) = default; \
2390 decltype(auto) _Getter_() const \
2392 static std::byte* payload = nullptr; \
2393 static _ConcreteType_* deserialised = nullptr; \
2394 static TClass* c = TClass::GetClass(#_ConcreteType_); \
2395 auto span = *mColumnIterator; \
2396 if (payload != (std::byte*)span.data()) { \
2397 payload = (std::byte*)span.data(); \
2398 delete deserialised; \
2399 TBufferFile f(TBufferFile::EMode::kRead, span.size(), (char*)span.data(), kFALSE); \
2400 deserialised = (_ConcreteType_*)soa::extractCCDBPayload((char*)payload, span.size(), c, "ccdb_object"); \
2402 return *deserialised; \
2408 return _Getter_(); \
2412#define DECLARE_SOA_CCDB_COLUMN(_Name_, _Getter_, _ConcreteType_, _CCDBQuery_) \
2413 DECLARE_SOA_CCDB_COLUMN_FULL(_Name_, "f" #_Name_, _Getter_, _ConcreteType_, _CCDBQuery_)
2415#define DECLARE_SOA_COLUMN(_Name_, _Getter_, _Type_) \
2416 DECLARE_SOA_COLUMN_FULL(_Name_, _Getter_, _Type_, "f" #_Name_)
2420#define MAKEINT(_Size_) uint##_Size_##_t
2422#define DECLARE_SOA_BITMAP_COLUMN_FULL(_Name_, _Getter_, _Size_, _Label_) \
2423 struct _Name_ : o2::soa::Column<MAKEINT(_Size_), _Name_> { \
2424 static constexpr const char* mLabel = _Label_; \
2425 static constexpr const uint32_t hash = compile_time_hash(namespace_prefix<_Name_>(), std::string_view{#_Getter_}); \
2426 static_assert(!((*(mLabel + 1) == 'I' && *(mLabel + 2) == 'n' && *(mLabel + 3) == 'd' && *(mLabel + 4) == 'e' && *(mLabel + 5) == 'x')), "Index is not a valid column name"); \
2427 using base = o2::soa::Column<MAKEINT(_Size_), _Name_>; \
2428 using type = MAKEINT(_Size_); \
2429 _Name_(arrow::ChunkedArray const* column) \
2430 : o2::soa::Column<type, _Name_>(o2::soa::ColumnIterator<type>(column)) \
2434 _Name_() = default; \
2435 _Name_(_Name_ const& other) = default; \
2436 _Name_& operator=(_Name_ const& other) = default; \
2438 decltype(auto) _Getter_##_raw() const \
2440 return *mColumnIterator; \
2443 bool _Getter_##_bit(int bit) const \
2445 return (*mColumnIterator & (static_cast<type>(1) << bit)) >> bit; \
2448 [[maybe_unused]] static constexpr o2::framework::expressions::BindingNode _Getter_ { _Label_, _Name_::hash, o2::framework::expressions::selectArrowType<MAKEINT(_Size_)>() }
2450#define DECLARE_SOA_BITMAP_COLUMN(_Name_, _Getter_, _Size_) \
2451 DECLARE_SOA_BITMAP_COLUMN_FULL(_Name_, _Getter_, _Size_, "f" #_Name_)
2455#define DECLARE_SOA_EXPRESSION_COLUMN_FULL(_Name_, _Getter_, _Type_, _Label_, _Expression_) \
2456 struct _Name_ : o2::soa::Column<_Type_, _Name_> { \
2457 static constexpr const char* mLabel = _Label_; \
2458 static constexpr const uint32_t hash = compile_time_hash(namespace_prefix<_Name_>(), std::string_view{#_Getter_}); \
2459 using base = o2::soa::Column<_Type_, _Name_>; \
2460 using type = _Type_; \
2461 using column_t = _Name_; \
2462 using spawnable_t = std::true_type; \
2463 _Name_(arrow::ChunkedArray const* column) \
2464 : o2::soa::Column<_Type_, _Name_>(o2::soa::ColumnIterator<type>(column)) \
2468 _Name_() = default; \
2469 _Name_(_Name_ const& other) = default; \
2470 _Name_& operator=(_Name_ const& other) = default; \
2472 decltype(auto) _Getter_() const \
2474 return *mColumnIterator; \
2477 decltype(auto) get() const \
2479 return _Getter_(); \
2482 static o2::framework::expressions::Projector Projector() \
2484 return _Expression_; \
2487 [[maybe_unused]] static constexpr o2::framework::expressions::BindingNode _Getter_ { _Label_, _Name_::hash, o2::framework::expressions::selectArrowType<_Type_>() }
2489#define DECLARE_SOA_EXPRESSION_COLUMN(_Name_, _Getter_, _Type_, _Expression_) \
2490 DECLARE_SOA_EXPRESSION_COLUMN_FULL(_Name_, _Getter_, _Type_, "f" #_Name_, _Expression_);
2494#define DECLARE_SOA_CONFIGURABLE_EXPRESSION_COLUMN(_Name_, _Getter_, _Type_, _Label_) \
2495 struct _Name_ : o2::soa::Column<_Type_, _Name_> { \
2496 static constexpr const char* mLabel = _Label_; \
2497 static constexpr const uint32_t hash = compile_time_hash(namespace_prefix<_Name_>(), std::string_view{#_Getter_}); \
2498 static constexpr const int32_t mHash = _Label_ ""_h; \
2499 using base = o2::soa::Column<_Type_, _Name_>; \
2500 using type = _Type_; \
2501 using column_t = _Name_; \
2502 using spawnable_t = std::true_type; \
2503 _Name_(arrow::ChunkedArray const* column) \
2504 : o2::soa::Column<_Type_, _Name_>(o2::soa::ColumnIterator<type>(column)) \
2508 _Name_() = default; \
2509 _Name_(_Name_ const& other) = default; \
2510 _Name_& operator=(_Name_ const& other) = default; \
2512 decltype(auto) _Getter_() const \
2514 return *mColumnIterator; \
2517 decltype(auto) get() const \
2519 return _Getter_(); \
2522 [[maybe_unused]] static constexpr o2::framework::expressions::BindingNode _Getter_ { _Label_, _Name_::hash, o2::framework::expressions::selectArrowType<_Type_>() }
2545template <o2::soa::is_table T>
2548 return T::originals;
2551#define DECLARE_SOA_SLICE_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, _Type_, _Table_, _Label_, _Suffix_) \
2552 struct _Name_##IdSlice : o2::soa::Column<_Type_[2], _Name_##IdSlice> { \
2553 static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
2554 static_assert((*_Suffix_ == '\0') || (*_Suffix_ == '_'), "Suffix has to begin with _"); \
2555 static constexpr const char* mLabel = "fIndexSlice" _Label_ _Suffix_; \
2556 static constexpr const uint32_t hash = 0; \
2557 using base = o2::soa::Column<_Type_[2], _Name_##IdSlice>; \
2558 using type = _Type_[2]; \
2559 using column_t = _Name_##IdSlice; \
2560 using binding_t = _Table_; \
2561 static constexpr auto index_targets = getIndexTargets<_Table_>(); \
2562 _Name_##IdSlice(arrow::ChunkedArray const* column) \
2563 : o2::soa::Column<_Type_[2], _Name_##IdSlice>(o2::soa::ColumnIterator<type>(column)) \
2567 _Name_##IdSlice() = default; \
2568 _Name_##IdSlice(_Name_##IdSlice const& other) = default; \
2569 _Name_##IdSlice& operator=(_Name_##IdSlice const& other) = default; \
2570 std::array<_Type_, 2> inline getIds() const \
2572 return _Getter_##Ids(); \
2575 bool has_##_Getter_() const \
2577 auto a = *mColumnIterator; \
2578 return a[0] >= 0 && a[1] >= 0; \
2581 std::array<_Type_, 2> _Getter_##Ids() const \
2583 auto a = *mColumnIterator; \
2584 return std::array{a[0], a[1]}; \
2587 template <typename T> \
2588 auto _Getter_##_as() const \
2590 if (O2_BUILTIN_UNLIKELY(mBinding.ptr == nullptr)) { \
2591 o2::soa::notBoundTable(#_Table_); \
2593 auto t = mBinding.get<T>(); \
2594 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2595 o2::soa::dereferenceWithWrongType(#_Getter_, #_Table_); \
2597 if (O2_BUILTIN_UNLIKELY(!has_##_Getter_())) { \
2598 return t->emptySlice(); \
2600 auto a = *mColumnIterator; \
2601 auto r = t->rawSlice(a[0], a[1]); \
2602 t->copyIndexBindings(r); \
2603 r.bindInternalIndicesTo(t); \
2607 auto _Getter_() const \
2609 return _Getter_##_as<binding_t>(); \
2612 template <typename T> \
2613 bool setCurrent(T const* current) \
2615 if constexpr (o2::soa::is_binding_compatible_v<T, binding_t>()) { \
2616 assert(current != nullptr); \
2617 this->mBinding.bind(current); \
2623 bool setCurrentRaw(o2::soa::Binding current) \
2625 this->mBinding = current; \
2628 binding_t const* getCurrent() const { return mBinding.get<binding_t>(); } \
2629 o2::soa::Binding getCurrentRaw() const { return mBinding; } \
2630 o2::soa::Binding mBinding; \
2633#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_)
2634#define DECLARE_SOA_SLICE_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_SLICE_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, _Name_##s, "")
2635#define DECLARE_SOA_SLICE_INDEX_COLUMN_CUSTOM(_Name_, _Getter_, _Label_) DECLARE_SOA_SLICE_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, int32_t, _Name_##s, _Label_, "")
2638#define DECLARE_SOA_ARRAY_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, _Type_, _Table_, _Label_, _Suffix_) \
2639 struct _Name_##Ids : o2::soa::Column<std::vector<_Type_>, _Name_##Ids> { \
2640 static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
2641 static_assert((*_Suffix_ == '\0') || (*_Suffix_ == '_'), "Suffix has to begin with _"); \
2642 static constexpr const char* mLabel = "fIndexArray" _Label_ _Suffix_; \
2643 static constexpr const uint32_t hash = 0; \
2644 using base = o2::soa::Column<std::vector<_Type_>, _Name_##Ids>; \
2645 using type = std::vector<_Type_>; \
2646 using column_t = _Name_##Ids; \
2647 using binding_t = _Table_; \
2648 static constexpr auto index_targets = getIndexTargets<_Table_>(); \
2649 _Name_##Ids(arrow::ChunkedArray const* column) \
2650 : o2::soa::Column<std::vector<_Type_>, _Name_##Ids>(o2::soa::ColumnIterator<type>(column)) \
2654 _Name_##Ids() = default; \
2655 _Name_##Ids(_Name_##Ids const& other) = default; \
2656 _Name_##Ids& operator=(_Name_##Ids const& other) = default; \
2658 gsl::span<const _Type_> inline getIds() const \
2660 return _Getter_##Ids(); \
2663 gsl::span<const _Type_> _Getter_##Ids() const \
2665 return *mColumnIterator; \
2668 bool has_##_Getter_() const \
2670 return !(*mColumnIterator).empty(); \
2673 template <typename T> \
2674 auto _Getter_##_as() const \
2676 if (O2_BUILTIN_UNLIKELY(mBinding.ptr == nullptr)) { \
2677 o2::soa::notBoundTable(#_Table_); \
2679 auto t = mBinding.get<T>(); \
2680 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2681 o2::soa::dereferenceWithWrongType(#_Getter_, #_Table_); \
2683 return getIterators<T>(); \
2686 template <typename T> \
2687 auto filtered_##_Getter_##_as() const \
2689 if (O2_BUILTIN_UNLIKELY(mBinding.ptr == nullptr)) { \
2690 o2::soa::notBoundTable(#_Table_); \
2692 auto t = mBinding.get<T>(); \
2693 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2694 o2::soa::dereferenceWithWrongType(#_Getter_, #_Table_); \
2696 return getFilteredIterators<T>(); \
2699 template <typename T> \
2700 auto getIterators() const \
2702 auto result = std::vector<typename T::unfiltered_iterator>(); \
2703 for (auto& i : *mColumnIterator) { \
2704 result.push_back(mBinding.get<T>()->rawIteratorAt(i)); \
2709 template <typename T> \
2710 std::vector<typename T::iterator> getFilteredIterators() const \
2712 if constexpr (o2::soa::is_filtered_table<T>) { \
2713 auto result = std::vector<typename T::iterator>(); \
2714 for (auto const& i : *mColumnIterator) { \
2715 auto pos = mBinding.get<T>()->isInSelectedRows(i); \
2717 result.emplace_back(mBinding.get<T>()->iteratorAt(pos)); \
2722 static_assert(o2::framework::always_static_assert_v<T>, "T is not a Filtered type"); \
2727 auto _Getter_() const \
2729 return _Getter_##_as<binding_t>(); \
2732 template <typename T> \
2733 auto _Getter_##_first_as() const \
2735 if (O2_BUILTIN_UNLIKELY(mBinding.ptr == nullptr)) { \
2736 o2::soa::notBoundTable(#_Table_); \
2738 auto t = mBinding.get<T>(); \
2739 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2740 o2::soa::dereferenceWithWrongType(#_Getter_, #_Table_); \
2742 return t->rawIteratorAt((*mColumnIterator)[0]); \
2745 template <typename T> \
2746 auto _Getter_##_last_as() const \
2748 if (O2_BUILTIN_UNLIKELY(mBinding.ptr == nullptr)) { \
2749 o2::soa::notBoundTable(#_Table_); \
2751 auto t = mBinding.get<T>(); \
2752 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2753 o2::soa::dereferenceWithWrongType(#_Getter_, #_Table_); \
2755 return t->rawIteratorAt((*mColumnIterator).back()); \
2758 auto _Getter_first() const \
2760 return _Getter_##_first_as<binding_t>(); \
2763 auto _Getter_last() const \
2765 return _Getter_##_last_as<binding_t>(); \
2768 template <typename T> \
2769 bool setCurrent(T const* current) \
2771 if constexpr (o2::soa::is_binding_compatible_v<T, binding_t>()) { \
2772 assert(current != nullptr); \
2773 this->mBinding.bind(current); \
2779 bool setCurrentRaw(o2::soa::Binding current) \
2781 this->mBinding = current; \
2784 binding_t const* getCurrent() const { return mBinding.get<binding_t>(); } \
2785 o2::soa::Binding getCurrentRaw() const { return mBinding; } \
2786 o2::soa::Binding mBinding; \
2789#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_)
2790#define DECLARE_SOA_ARRAY_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_ARRAY_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, _Name_##s, "")
2791#define DECLARE_SOA_ARRAY_INDEX_COLUMN_CUSTOM(_Name_, _Getter_, _Label_) DECLARE_SOA_ARRAY_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, int32_t, _Name_##s, _Label_, "")
2794#define DECLARE_SOA_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, _Type_, _Table_, _Label_, _Suffix_) \
2795 struct _Name_##Id : o2::soa::Column<_Type_, _Name_##Id> { \
2796 static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
2797 static_assert((*_Suffix_ == '\0') || (*_Suffix_ == '_'), "Suffix has to begin with _"); \
2798 static constexpr const char* mLabel = "fIndex" _Label_ _Suffix_; \
2799 static constexpr const uint32_t hash = compile_time_hash(namespace_prefix<_Name_##Id>(), std::string_view{#_Getter_ "Id"}); \
2800 using base = o2::soa::Column<_Type_, _Name_##Id>; \
2801 using type = _Type_; \
2802 using column_t = _Name_##Id; \
2803 using binding_t = _Table_; \
2804 static constexpr auto index_targets = getIndexTargets<_Table_>(); \
2805 _Name_##Id(arrow::ChunkedArray const* column) \
2806 : o2::soa::Column<_Type_, _Name_##Id>(o2::soa::ColumnIterator<type>(column)) \
2810 _Name_##Id() = default; \
2811 _Name_##Id(_Name_##Id const& other) = default; \
2812 _Name_##Id& operator=(_Name_##Id const& other) = default; \
2813 type inline getId() const \
2815 return _Getter_##Id(); \
2818 type _Getter_##Id() const \
2820 return *mColumnIterator; \
2823 bool has_##_Getter_() const \
2825 return *mColumnIterator >= 0; \
2828 template <typename T> \
2829 auto _Getter_##_as() const \
2831 if (O2_BUILTIN_UNLIKELY(mBinding.ptr == nullptr)) { \
2832 o2::soa::notBoundTable(#_Table_); \
2834 if (O2_BUILTIN_UNLIKELY(!has_##_Getter_())) { \
2835 o2::soa::accessingInvalidIndexFor(#_Getter_); \
2837 auto t = mBinding.get<T>(); \
2838 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2839 o2::soa::dereferenceWithWrongType(#_Getter_, #_Table_); \
2841 return t->rawIteratorAt(*mColumnIterator); \
2844 auto _Getter_() const \
2846 return _Getter_##_as<binding_t>(); \
2849 template <typename T> \
2850 bool setCurrent(T* current) \
2852 if constexpr (o2::soa::is_binding_compatible_v<T, binding_t>()) { \
2853 assert(current != nullptr); \
2854 this->mBinding.bind(current); \
2860 bool setCurrentRaw(o2::soa::Binding current) \
2862 this->mBinding = current; \
2865 binding_t const* getCurrent() const { return mBinding.get<binding_t>(); } \
2866 o2::soa::Binding getCurrentRaw() const { return mBinding; } \
2867 o2::soa::Binding mBinding; \
2869 [[maybe_unused]] static constexpr o2::framework::expressions::BindingNode _Getter_##Id { "fIndex" #_Table_ _Suffix_, _Name_##Id::hash, o2::framework::expressions::selectArrowType<_Type_>() }
2871#define DECLARE_SOA_INDEX_COLUMN_FULL(_Name_, _Getter_, _Type_, _Table_, _Suffix_) DECLARE_SOA_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, _Type_, _Table_, #_Table_, _Suffix_)
2872#define DECLARE_SOA_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, _Name_##s, "")
2873#define DECLARE_SOA_INDEX_COLUMN_CUSTOM(_Name_, _Getter_, _Label_) DECLARE_SOA_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, int32_t, _Name_##s, _Label_, "")
2876#define DECLARE_SOA_SELF_INDEX_COLUMN_COMPLETE(_Name_, _Getter_, _Type_, _Label_, _IndexTarget_) \
2877 struct _Name_##Id : o2::soa::Column<_Type_, _Name_##Id> { \
2878 static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
2879 static constexpr const char* mLabel = "fIndex" _Label_; \
2880 static constexpr const uint32_t hash = compile_time_hash(namespace_prefix<_Name_##Id>(), std::string_view{#_Getter_ "Id"}); \
2881 using base = o2::soa::Column<_Type_, _Name_##Id>; \
2882 using type = _Type_; \
2883 using column_t = _Name_##Id; \
2884 using self_index_t = std::true_type; \
2885 using compatible_signature = std::conditional<aod::is_aod_hash<_IndexTarget_>, _IndexTarget_, void>; \
2886 _Name_##Id(arrow::ChunkedArray const* column) \
2887 : o2::soa::Column<_Type_, _Name_##Id>(o2::soa::ColumnIterator<type>(column)) \
2891 _Name_##Id() = default; \
2892 _Name_##Id(_Name_##Id const& other) = default; \
2893 _Name_##Id& operator=(_Name_##Id const& other) = default; \
2894 type inline getId() const \
2896 return _Getter_##Id(); \
2899 type _Getter_##Id() const \
2901 return *mColumnIterator; \
2904 bool has_##_Getter_() const \
2906 return *mColumnIterator >= 0; \
2909 template <typename T> \
2910 auto _Getter_##_as() const \
2912 if (O2_BUILTIN_UNLIKELY(!has_##_Getter_())) { \
2913 o2::soa::accessingInvalidIndexFor(#_Getter_); \
2915 auto t = mBinding.get<T>(); \
2916 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2917 o2::soa::dereferenceWithWrongType(#_Getter_, "self"); \
2919 return t->rawIteratorAt(*mColumnIterator); \
2922 bool setCurrentRaw(o2::soa::Binding current) \
2924 this->mBinding = current; \
2927 o2::soa::Binding getCurrentRaw() const { return mBinding; } \
2928 o2::soa::Binding mBinding; \
2930 [[maybe_unused]] static constexpr o2::framework::expressions::BindingNode _Getter_##Id { "fIndex" _Label_, _Name_##Id::hash, o2::framework::expressions::selectArrowType<_Type_>() }
2932#define DECLARE_SOA_SELF_INDEX_COLUMN_FULL(_Name_, _Getter_, _Type_, _Label_) DECLARE_SOA_SELF_INDEX_COLUMN_COMPLETE(_Name_, _Getter_, _Type_, _Label_, void)
2933#define DECLARE_SOA_SELF_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_SELF_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, #_Name_)
2935#define DECLARE_SOA_SELF_SLICE_INDEX_COLUMN_COMPLETE(_Name_, _Getter_, _Type_, _Label_, _IndexTarget_) \
2936 struct _Name_##IdSlice : o2::soa::Column<_Type_[2], _Name_##IdSlice> { \
2937 static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
2938 static constexpr const char* mLabel = "fIndexSlice" _Label_; \
2939 static constexpr const uint32_t hash = 0; \
2940 using base = o2::soa::Column<_Type_[2], _Name_##IdSlice>; \
2941 using type = _Type_[2]; \
2942 using column_t = _Name_##IdSlice; \
2943 using self_index_t = std::true_type; \
2944 using compatible_signature = std::conditional<aod::is_aod_hash<_IndexTarget_>, _IndexTarget_, void>; \
2945 _Name_##IdSlice(arrow::ChunkedArray const* column) \
2946 : o2::soa::Column<_Type_[2], _Name_##IdSlice>(o2::soa::ColumnIterator<type>(column)) \
2950 _Name_##IdSlice() = default; \
2951 _Name_##IdSlice(_Name_##IdSlice const& other) = default; \
2952 _Name_##IdSlice& operator=(_Name_##IdSlice const& other) = default; \
2953 std::array<_Type_, 2> inline getIds() const \
2955 return _Getter_##Ids(); \
2958 bool has_##_Getter_() const \
2960 auto a = *mColumnIterator; \
2961 return a[0] >= 0 && a[1] >= 0; \
2964 std::array<_Type_, 2> _Getter_##Ids() const \
2966 auto a = *mColumnIterator; \
2967 return std::array{a[0], a[1]}; \
2970 template <typename T> \
2971 auto _Getter_##_as() const \
2973 auto t = mBinding.get<T>(); \
2974 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2975 o2::soa::dereferenceWithWrongType(#_Getter_, "self"); \
2977 if (O2_BUILTIN_UNLIKELY(!has_##_Getter_())) { \
2978 return t->emptySlice(); \
2980 auto a = *mColumnIterator; \
2981 auto r = t->rawSlice(a[0], a[1]); \
2982 t->copyIndexBindings(r); \
2983 r.bindInternalIndicesTo(t); \
2987 bool setCurrentRaw(o2::soa::Binding current) \
2989 this->mBinding = current; \
2992 o2::soa::Binding getCurrentRaw() const { return mBinding; } \
2993 o2::soa::Binding mBinding; \
2996#define DECLARE_SOA_SELF_SLICE_INDEX_COLUMN_FULL(_Name_, _Getter_, _Type_, _Label_) DECLARE_SOA_SELF_SLICE_INDEX_COLUMN_COMPLETE(_Name_, _Getter_, _Type_, _Label_, void)
2997#define DECLARE_SOA_SELF_SLICE_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_SELF_SLICE_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, "_" #_Name_)
2999#define DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN_COMPLETE(_Name_, _Getter_, _Type_, _Label_, _IndexTarget_) \
3000 struct _Name_##Ids : o2::soa::Column<std::vector<_Type_>, _Name_##Ids> { \
3001 static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
3002 static constexpr const char* mLabel = "fIndexArray" _Label_; \
3003 static constexpr const uint32_t hash = 0; \
3004 using base = o2::soa::Column<std::vector<_Type_>, _Name_##Ids>; \
3005 using type = std::vector<_Type_>; \
3006 using column_t = _Name_##Ids; \
3007 using self_index_t = std::true_type; \
3008 using compatible_signature = std::conditional<aod::is_aod_hash<_IndexTarget_>, _IndexTarget_, void>; \
3009 _Name_##Ids(arrow::ChunkedArray const* column) \
3010 : o2::soa::Column<std::vector<_Type_>, _Name_##Ids>(o2::soa::ColumnIterator<type>(column)) \
3014 _Name_##Ids() = default; \
3015 _Name_##Ids(_Name_##Ids const& other) = default; \
3016 _Name_##Ids& operator=(_Name_##Ids const& other) = default; \
3017 gsl::span<const _Type_> inline getIds() const \
3019 return _Getter_##Ids(); \
3022 gsl::span<const _Type_> _Getter_##Ids() const \
3024 return *mColumnIterator; \
3027 bool has_##_Getter_() const \
3029 return !(*mColumnIterator).empty(); \
3032 template <typename T> \
3033 auto _Getter_##_as() const \
3035 auto t = mBinding.get<T>(); \
3036 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
3037 o2::soa::dereferenceWithWrongType(#_Getter_, "self"); \
3039 return getIterators<T>(); \
3042 template <typename T> \
3043 auto getIterators() const \
3045 auto result = std::vector<typename T::unfiltered_iterator>(); \
3046 for (auto& i : *mColumnIterator) { \
3047 result.push_back(mBinding.get<T>()->rawIteratorAt(i)); \
3052 template <typename T> \
3053 auto _Getter_##_first_as() const \
3055 return mBinding.get<T>()->rawIteratorAt((*mColumnIterator)[0]); \
3058 template <typename T> \
3059 auto _Getter_##_last_as() const \
3061 return mBinding.get<T>()->rawIteratorAt((*mColumnIterator).back()); \
3064 bool setCurrentRaw(o2::soa::Binding current) \
3066 this->mBinding = current; \
3069 o2::soa::Binding getCurrentRaw() const { return mBinding; } \
3070 o2::soa::Binding mBinding; \
3073#define DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN_FULL(_Name_, _Getter_, _Type_, _Label_) DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN_COMPLETE(_Name_, _Getter_, _Type_, _Label_, void)
3074#define DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, "_" #_Name_)
3104#define DECLARE_SOA_DYNAMIC_COLUMN(_Name_, _Getter_, ...) \
3105 struct _Name_##Callback { \
3106 static inline constexpr auto getLambda() { return __VA_ARGS__; } \
3109 struct _Name_##Helper { \
3110 using callable_t = decltype(o2::framework::FunctionMetadata(std::declval<decltype(_Name_##Callback::getLambda())>())); \
3111 using return_type = typename callable_t::return_type; \
3113 template <typename... Bindings> \
3114 struct _Name_ : o2::soa::DynamicColumn<typename _Name_##Helper::callable_t::type, _Name_<Bindings...>> { \
3115 using base = o2::soa::DynamicColumn<typename _Name_##Helper::callable_t::type, _Name_<Bindings...>>; \
3116 using helper = _Name_##Helper; \
3117 using callback_holder_t = _Name_##Callback; \
3118 using callable_t = helper::callable_t; \
3119 using callback_t = callable_t::type; \
3120 static constexpr const uint32_t hash = 0; \
3122 _Name_(arrow::ChunkedArray const*) \
3125 _Name_() = default; \
3126 _Name_(_Name_ const& other) = default; \
3127 _Name_& operator=(_Name_ const& other) = default; \
3128 static constexpr const char* mLabel = #_Name_; \
3129 using type = typename callable_t::return_type; \
3131 template <typename... FreeArgs> \
3132 type _Getter_(FreeArgs... freeArgs) const \
3134 return boundGetter(std::make_index_sequence<std::tuple_size_v<decltype(boundIterators)>>{}, freeArgs...); \
3136 template <typename... FreeArgs> \
3137 type getDynamicValue(FreeArgs... freeArgs) const \
3139 return boundGetter(std::make_index_sequence<std::tuple_size_v<decltype(boundIterators)>>{}, freeArgs...); \
3144 return _Getter_(); \
3147 template <size_t... Is, typename... FreeArgs> \
3148 type boundGetter(std::integer_sequence<size_t, Is...>&&, FreeArgs... freeArgs) const \
3150 return __VA_ARGS__((**std::get<Is>(boundIterators))..., freeArgs...); \
3153 using bindings_t = typename o2::framework::pack<Bindings...>; \
3154 std::tuple<o2::soa::ColumnIterator<typename Bindings::type> const*...> boundIterators; \
3157#define DECLARE_SOA_TABLE_METADATA(_Name_, _Desc_, _Version_, ...) \
3158 using _Name_##Metadata = TableMetadata<Hash<_Desc_ "/" #_Version_ ""_h>, __VA_ARGS__>;
3160#define DECLARE_SOA_TABLE_METADATA_TRAIT(_Name_, _Desc_, _Version_) \
3162 struct MetadataTrait<Hash<_Desc_ "/" #_Version_ ""_h>> { \
3163 using metadata = _Name_##Metadata; \
3166#define DECLARE_SOA_TABLE_FULL_VERSIONED_(_Name_, _Label_, _Origin_, _Desc_, _Version_) \
3167 O2HASH(_Desc_ "/" #_Version_); \
3168 template <typename O> \
3169 using _Name_##From = o2::soa::Table<Hash<_Label_ ""_h>, Hash<_Desc_ "/" #_Version_ ""_h>, O>; \
3170 using _Name_ = _Name_##From<Hash<_Origin_ ""_h>>; \
3172 struct MetadataTrait<Hash<_Desc_ "/" #_Version_ ""_h>> { \
3173 using metadata = _Name_##Metadata; \
3176#define DECLARE_SOA_STAGE(_Name_, _Origin_, _Desc_, _Version_) \
3177 template <typename O> \
3178 using _Name_##From = o2::soa::Table<Hash<#_Name_ ""_h>, Hash<_Desc_ "/" #_Version_ ""_h>, O>; \
3179 using _Name_ = _Name_##From<Hash<_Origin_ ""_h>>;
3181#define DECLARE_SOA_TABLE_FULL_VERSIONED(_Name_, _Label_, _Origin_, _Desc_, _Version_, ...) \
3182 DECLARE_SOA_TABLE_METADATA(_Name_, _Desc_, _Version_, __VA_ARGS__); \
3183 DECLARE_SOA_TABLE_FULL_VERSIONED_(_Name_, _Label_, _Origin_, _Desc_, _Version_);
3185#define DECLARE_SOA_TABLE_FULL(_Name_, _Label_, _Origin_, _Desc_, ...) \
3187 DECLARE_SOA_TABLE_METADATA(_Name_, _Desc_, 0, __VA_ARGS__); \
3188 DECLARE_SOA_TABLE_FULL_VERSIONED_(_Name_, _Label_, _Origin_, _Desc_, 0)
3190#define DECLARE_SOA_TABLE(_Name_, _Origin_, _Desc_, ...) \
3191 DECLARE_SOA_TABLE_FULL(_Name_, #_Name_, _Origin_, _Desc_, __VA_ARGS__)
3193#define DECLARE_SOA_TABLE_VERSIONED(_Name_, _Origin_, _Desc_, _Version_, ...) \
3195 DECLARE_SOA_TABLE_METADATA(_Name_, _Desc_, _Version_, __VA_ARGS__); \
3196 DECLARE_SOA_TABLE_FULL_VERSIONED_(_Name_, #_Name_, _Origin_, _Desc_, _Version_)
3198#define DECLARE_SOA_TABLE_STAGED_VERSIONED(_BaseName_, _Desc_, _Version_, ...) \
3199 O2HASH(_Desc_ "/" #_Version_); \
3200 O2HASH(#_BaseName_); \
3201 O2HASH("Stored" #_BaseName_); \
3202 DECLARE_SOA_TABLE_METADATA(_BaseName_, _Desc_, _Version_, __VA_ARGS__); \
3203 using Stored##_BaseName_##Metadata = _BaseName_##Metadata; \
3204 DECLARE_SOA_TABLE_METADATA_TRAIT(_BaseName_, _Desc_, _Version_); \
3205 DECLARE_SOA_STAGE(_BaseName_, "AOD", _Desc_, _Version_); \
3206 DECLARE_SOA_STAGE(Stored##_BaseName_, "AOD1", _Desc_, _Version_);
3208#define DECLARE_SOA_TABLE_STAGED(_BaseName_, _Desc_, ...) \
3209 DECLARE_SOA_TABLE_STAGED_VERSIONED(_BaseName_, _Desc_, 0, __VA_ARGS__);
3211#define DECLARE_SOA_EXTENDED_TABLE_FULL(_Name_, _Label_, _OriginalTable_, _Origin_, _Desc_, _Version_, ...) \
3212 O2HASH(_Desc_ "/" #_Version_); \
3213 template <typename O> \
3214 using _Name_##ExtensionFrom = soa::Table<o2::aod::Hash<_Label_ ""_h>, o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, O>; \
3215 using _Name_##Extension = _Name_##ExtensionFrom<o2::aod::Hash<_Origin_ ""_h>>; \
3216 template <typename O = o2::aod::Hash<_Origin_ ""_h>> \
3217 struct _Name_##ExtensionMetadataFrom : TableMetadata<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, __VA_ARGS__> { \
3218 using base_table_t = _OriginalTable_; \
3219 using extension_table_t = _Name_##ExtensionFrom<O>; \
3220 using expression_pack_t = framework::pack<__VA_ARGS__>; \
3221 static constexpr auto sources = _OriginalTable_::originals; \
3223 using _Name_##ExtensionMetadata = _Name_##ExtensionMetadataFrom<o2::aod::Hash<_Origin_ ""_h>>; \
3225 struct MetadataTrait<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>> { \
3226 using metadata = _Name_##ExtensionMetadata; \
3228 template <typename O> \
3229 using _Name_##From = o2::soa::JoinFull<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, _OriginalTable_, _Name_##ExtensionFrom<O>>; \
3230 using _Name_ = _Name_##From<o2::aod::Hash<_Origin_ ""_h>>;
3232#define DECLARE_SOA_EXTENDED_TABLE(_Name_, _Table_, _Description_, _Version_, ...) \
3233 O2HASH(#_Name_ "Extension"); \
3234 DECLARE_SOA_EXTENDED_TABLE_FULL(_Name_, #_Name_ "Extension", _Table_, "DYN", _Description_, _Version_, __VA_ARGS__)
3236#define DECLARE_SOA_EXTENDED_TABLE_USER(_Name_, _Table_, _Description_, ...) \
3237 O2HASH(#_Name_ "Extension"); \
3238 DECLARE_SOA_EXTENDED_TABLE_FULL(_Name_, #_Name_ "Extension", _Table_, "AOD", "EX" _Description_, 0, __VA_ARGS__)
3240#define DECLARE_SOA_CONFIGURABLE_EXTENDED_TABLE_FULL(_Name_, _Label_, _OriginalTable_, _Origin_, _Desc_, _Version_, ...) \
3241 O2HASH(_Desc_ "/" #_Version_); \
3242 template <typename O> \
3243 using _Name_##CfgExtensionFrom = soa::Table<o2::aod::Hash<_Label_ ""_h>, o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, O>; \
3244 using _Name_##CfgExtension = _Name_##CfgExtensionFrom<o2::aod::Hash<_Origin_ ""_h>>; \
3245 template <typename O = o2::aod::Hash<_Origin_ ""_h>> \
3246 struct _Name_##CfgExtensionMetadataFrom : TableMetadata<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, __VA_ARGS__> { \
3247 using base_table_t = _OriginalTable_; \
3248 using extension_table_t = _Name_##CfgExtensionFrom<O>; \
3249 using placeholders_pack_t = framework::pack<__VA_ARGS__>; \
3250 using configurable_t = std::true_type; \
3251 static constexpr auto sources = _OriginalTable_::originals; \
3253 using _Name_##CfgExtensionMetadata = _Name_##CfgExtensionMetadataFrom<o2::aod::Hash<_Origin_ ""_h>>; \
3255 struct MetadataTrait<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>> { \
3256 using metadata = _Name_##CfgExtensionMetadata; \
3258 template <typename O> \
3259 using _Name_##From = o2::soa::JoinFull<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, _OriginalTable_, _Name_##CfgExtensionFrom<O>>; \
3260 using _Name_ = _Name_##From<o2::aod::Hash<_Origin_ ""_h>>;
3262#define DECLARE_SOA_CONFIGURABLE_EXTENDED_TABLE(_Name_, _Table_, _Description_, ...) \
3263 O2HASH(#_Name_ "CfgExtension"); \
3264 DECLARE_SOA_CONFIGURABLE_EXTENDED_TABLE_FULL(_Name_, #_Name_ "CfgExtension", _Table_, "AOD", "EX" _Description_, 0, __VA_ARGS__)
3266#define DECLARE_SOA_INDEX_TABLE_FULL(_Name_, _Key_, _Origin_, _Version_, _Desc_, _Exclusive_, ...) \
3268 O2HASH(_Desc_ "/" #_Version_); \
3269 template <typename O = o2::aod::Hash<_Origin_ ""_h>> \
3270 struct _Name_##MetadataFrom : o2::aod::TableMetadata<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, soa::Index<>, __VA_ARGS__> { \
3271 static constexpr bool exclusive = _Exclusive_; \
3272 using Key = _Key_; \
3273 using index_pack_t = framework::pack<__VA_ARGS__>; \
3274 static constexpr const auto sources = []<typename... Cs>(framework::pack<Cs...>) { \
3275 constexpr auto a = o2::soa::mergeOriginals<typename Cs::binding_t...>(); \
3276 return o2::aod::filterForKey<a.size(), a, Key>(); \
3277 }(framework::pack<__VA_ARGS__>{}); \
3278 static_assert(sources.size() - Key::originals.size() + 1 == framework::pack_size(index_pack_t{}), "One of the referred tables does not have index to Key"); \
3280 using _Name_##Metadata = _Name_##MetadataFrom<o2::aod::Hash<_Origin_ ""_h>>; \
3282 template <typename O = o2::aod::Hash<_Origin_ ""_h>> \
3283 using _Name_##From = o2::soa::IndexTable<o2::aod::Hash<#_Name_ ""_h>, o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, O, _Key_, __VA_ARGS__>; \
3284 using _Name_ = _Name_##From<o2::aod::Hash<_Origin_ ""_h>>; \
3287 struct MetadataTrait<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>> { \
3288 using metadata = _Name_##Metadata; \
3296#define DECLARE_SOA_TIMESTAMPED_TABLE_FULL(_Name_, _Label_, _TimestampSource_, _TimestampColumn_, _Origin_, _Version_, _Desc_, ...) \
3297 O2HASH(_Desc_ "/" #_Version_); \
3298 template <typename O> \
3299 using _Name_##TimestampFrom = soa::Table<o2::aod::Hash<_Label_ ""_h>, o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, O>; \
3300 using _Name_##Timestamp = _Name_##TimestampFrom<o2::aod::Hash<_Origin_ ""_h>>; \
3301 template <typename O = o2::aod::Hash<_Origin_ ""_h>> \
3302 struct _Name_##TimestampMetadataFrom : TableMetadata<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, __VA_ARGS__> { \
3303 using base_table_t = _TimestampSource_; \
3304 using extension_table_t = _Name_##TimestampFrom<O>; \
3305 static constexpr const auto ccdb_urls = []<typename... Cs>(framework::pack<Cs...>) { \
3306 return std::array<std::string_view, sizeof...(Cs)>{Cs::query...}; \
3307 }(framework::pack<__VA_ARGS__>{}); \
3308 static constexpr const auto ccdb_bindings = []<typename... Cs>(framework::pack<Cs...>) { \
3309 return std::array<std::string_view, sizeof...(Cs)>{Cs::mLabel...}; \
3310 }(framework::pack<__VA_ARGS__>{}); \
3311 static constexpr auto sources = _TimestampSource_::originals; \
3312 static constexpr auto timestamp_column_label = _TimestampColumn_::mLabel; \
3315 using _Name_##TimestampMetadata = _Name_##TimestampMetadataFrom<o2::aod::Hash<_Origin_ ""_h>>; \
3317 struct MetadataTrait<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>> { \
3318 using metadata = _Name_##TimestampMetadata; \
3320 template <typename O> \
3321 using _Name_##From = o2::soa::JoinFull<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, _TimestampSource_, _Name_##TimestampFrom<O>>; \
3322 using _Name_ = _Name_##From<o2::aod::Hash<_Origin_ ""_h>>;
3324#define DECLARE_SOA_TIMESTAMPED_TABLE(_Name_, _TimestampSource_, _TimestampColumn_, _Version_, _Desc_, ...) \
3325 O2HASH(#_Name_ "Timestamped"); \
3326 DECLARE_SOA_TIMESTAMPED_TABLE_FULL(_Name_, #_Name_ "Timestamped", _TimestampSource_, _TimestampColumn_, "ATIM", _Version_, _Desc_, __VA_ARGS__)
3328#define DECLARE_SOA_INDEX_TABLE(_Name_, _Key_, _Description_, ...) \
3329 DECLARE_SOA_INDEX_TABLE_FULL(_Name_, _Key_, "IDX", 0, _Description_, false, __VA_ARGS__)
3331#define DECLARE_SOA_INDEX_TABLE_EXCLUSIVE(_Name_, _Key_, _Description_, ...) \
3332 DECLARE_SOA_INDEX_TABLE_FULL(_Name_, _Key_, "IDX", 0, _Description_, true, __VA_ARGS__)
3334#define DECLARE_SOA_INDEX_TABLE_USER(_Name_, _Key_, _Description_, ...) \
3335 DECLARE_SOA_INDEX_TABLE_FULL(_Name_, _Key_, "AOD", 0, _Description_, false, __VA_ARGS__)
3337#define DECLARE_SOA_INDEX_TABLE_EXCLUSIVE_USER(_Name_, _Key_, _Description_, ...) \
3338 DECLARE_SOA_INDEX_TABLE_FULL(_Name_, _Key_, "AOD", 0, _Description_, true, __VA_ARGS__)
3342template <
typename D,
typename...
Ts>
3343struct JoinFull :
Table<o2::aod::Hash<"JOIN"_h>, D, o2::aod::Hash<"JOIN"_h>, Ts...> {
3396 template <
typename T1,
typename Policy,
bool OPT>
3424 template <
typename T>
3431template <
typename...
Ts>
3434template <
typename...
Ts>
3440template <
typename T>
3443template <
typename T>
3446template <
typename...
Ts>
3447struct Concat :
Table<o2::aod::Hash<"CONC"_h>, o2::aod::Hash<"CONC/0"_h>, o2::aod::Hash<"CONC"_h>, Ts...> {
3450 Concat(std::vector<std::shared_ptr<arrow::Table>>&& tables, uint64_t
offset = 0)
3458 bindInternalIndicesTo(
this);
3461 using base::originals;
3463 using base::bindExternalIndices;
3464 using base::bindInternalIndicesTo;
3478template <
typename...
Ts>
3484template <soa::is_table T>
3495 using iterator = T::template iterator_template_o<FilteredIndexPolicy, self_t>;
3501 mSelectedRows{getSpan(selection)}
3503 if (this->tableSize() != 0) {
3504 mFilteredBegin = table_t::filtered_begin(mSelectedRows);
3507 mFilteredBegin.bindInternalIndices(
this);
3512 mSelectedRowsCache{
std::move(selection)},
3515 mSelectedRows = std::span{mSelectedRowsCache};
3516 if (this->tableSize() != 0) {
3517 mFilteredBegin = table_t::filtered_begin(mSelectedRows);
3520 mFilteredBegin.bindInternalIndices(
this);
3523 FilteredBase(std::vector<std::shared_ptr<arrow::Table>>&& tables, std::span<int64_t const>
const& selection, uint64_t
offset = 0)
3525 mSelectedRows{selection}
3527 if (this->tableSize() != 0) {
3528 mFilteredBegin = table_t::filtered_begin(mSelectedRows);
3531 mFilteredBegin.bindInternalIndices(
this);
3558 return mFilteredBegin;
3563 return mFilteredBegin;
3568 return mFilteredBegin +
i;
3573 return mSelectedRows.size();
3578 return table_t::asArrowTable()->num_rows();
3583 return mSelectedRows;
3589 newSelection.resize(
static_cast<int64_t
>(
end -
start + 1));
3590 std::iota(newSelection.begin(), newSelection.end(),
start);
3591 return self_t{{this->asArrowTable()}, std::move(newSelection), 0};
3601 if (sel ==
nullptr) {
3602 return std::span<int64_t const>{};
3604 auto array = std::static_pointer_cast<arrow::Int64Array>(sel->ToArray());
3607 return std::span{
start, stop};
3612 template <
typename... TA>
3615 table_t::bindExternalIndices(current...);
3616 mFilteredBegin.bindExternalIndices(current...);
3621 mFilteredBegin.bindExternalIndicesRaw(std::forward<std::vector<o2::soa::Binding>>(ptrs));
3624 template <
typename I>
3627 mFilteredBegin.bindInternalIndices(
ptr);
3630 template <
typename T1,
typename... Cs>
3633 dest.bindExternalIndicesRaw(mFilteredBegin.getIndexBindings());
3636 template <
typename T1>
3642 template <
typename T1>
3658 template <
typename T1,
bool OPT>
3664 template <
typename T1,
bool OPT>
3673 copyIndexBindings(t);
3679 auto locate = std::find(mSelectedRows.begin(), mSelectedRows.end(),
i);
3680 if (locate == mSelectedRows.end()) {
3683 return static_cast<int>(std::distance(mSelectedRows.begin(), locate));
3690 std::set_union(mSelectedRows.begin(), mSelectedRows.end(), selection.begin(), selection.end(), std::back_inserter(rowsUnion));
3691 mSelectedRowsCache.clear();
3692 mSelectedRowsCache = rowsUnion;
3700 std::set_intersection(mSelectedRows.begin(), mSelectedRows.end(), selection.begin(), selection.end(), std::back_inserter(intersection));
3701 mSelectedRowsCache.clear();
3702 mSelectedRowsCache = intersection;
3710 std::set_union(mSelectedRows.begin(), mSelectedRows.end(), selection.begin(), selection.end(), std::back_inserter(rowsUnion));
3711 mSelectedRowsCache.clear();
3712 mSelectedRowsCache = rowsUnion;
3720 std::set_intersection(mSelectedRows.begin(), mSelectedRows.end(), selection.begin(), selection.end(), std::back_inserter(intersection));
3721 mSelectedRowsCache.clear();
3722 mSelectedRowsCache = intersection;
3735 mSelectedRows = std::span{mSelectedRowsCache};
3737 mFilteredEnd.reset(
new RowViewSentinel{
static_cast<int64_t
>(mSelectedRows.size())});
3738 if (tableSize() == 0) {
3739 mFilteredBegin = *mFilteredEnd;
3741 mFilteredBegin.resetSelection(mSelectedRows);
3745 std::span<int64_t const> mSelectedRows;
3747 bool mCached =
false;
3748 iterator mFilteredBegin;
3749 std::shared_ptr<RowViewSentinel> mFilteredEnd;
3752template <
typename T>
3761 using iterator = T::template iterator_template_o<FilteredIndexPolicy, self_t>;
3767 return iterator(this->cached_begin());
3781 Filtered(std::vector<std::shared_ptr<arrow::Table>>&& tables, std::span<int64_t const>
const& selection, uint64_t
offset = 0)
3805 this->sumWithSelection(selection);
3811 this->sumWithSelection(selection);
3817 return operator+=(
other.getSelectedRows());
3836 return operator*(
other.getSelectedRows());
3841 this->intersectWithSelection(selection);
3847 this->intersectWithSelection(selection);
3853 return operator*=(
other.getSelectedRows());
3868 newSelection.resize(
static_cast<int64_t
>(
end -
start + 1));
3869 std::iota(newSelection.begin(), newSelection.end(),
start);
3870 return self_t{{this->asArrowTable()}, std::move(newSelection), 0};
3878 template <
typename T1>
3894 template <
typename T1,
bool OPT>
3900 template <
typename T1,
bool OPT>
3909 copyIndexBindings(t);
3914template <
typename T>
3923 using iterator =
typename T::template iterator_template_o<FilteredIndexPolicy, self_t>;
3929 return iterator(this->cached_begin());
3940 for (
auto& table : tables) {
3948 for (
auto& table : tables) {
3956 for (
auto& table : tables) {
3982 this->sumWithSelection(selection);
3988 this->sumWithSelection(selection);
3994 return operator+=(
other.getSelectedRows());
4000 copy.intersectionWithSelection(selection);
4007 copy.intersectionWithSelection(selection);
4013 return operator*(
other.getSelectedRows());
4018 this->intersectWithSelection(selection);
4024 this->intersectWithSelection(selection);
4030 return operator*=(
other.getSelectedRows());
4043 newSelection.resize(
static_cast<int64_t
>(
end -
start + 1));
4044 std::iota(newSelection.begin(), newSelection.end(),
start);
4045 return self_t{{this->asArrowTable()}, std::move(newSelection), 0};
4063 template <
typename T1,
bool OPT>
4069 template <
typename T1,
bool OPT>
4076 std::vector<std::shared_ptr<arrow::Table>> extractTablesFromFiltered(std::vector<
Filtered<T>>& tables)
4078 std::vector<std::shared_ptr<arrow::Table>> outTables;
4079 for (
auto& table : tables) {
4080 outTables.push_back(table.asArrowTable());
4091template <
typename L,
typename D,
typename O,
typename Key,
typename H,
typename...
Ts>
4122template <
typename T,
bool APPLY>
4124 static constexpr bool applyFilters = APPLY;
4131 SmallGroupsBase(std::vector<std::shared_ptr<arrow::Table>>&& tables, std::span<int64_t const>
const& selection, uint64_t
offset = 0)
4135template <
typename T>
4138template <
typename T>
4141template <
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
void bindExternalIndicesRaw(std::vector< o2::soa::Binding > &&ptrs)
auto sliceBy(o2::framework::PresliceBase< T1, Policy, OPT > const &container, int value) const
static constexpr auto hashes()
iterator unfiltered_iterator
std::shared_ptr< arrow::Table > asArrowTable() const
Return a type erased arrow table backing store for / the type safe table.
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 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 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 PrimaryVertex explicitly as messageable.
std::decay_t< decltype(select_pack< Condition >(pack<>{}, Pack{}, CondPack{}))> selected_pack_multicondition
std::decay_t< decltype(prune_voids_pack(pack<>{}, with_condition_pack< Condition, Types... >{}))> selected_pack
decltype(intersected_pack(Ps{}...)) full_intersected_pack_t
typename pack_element< I, T >::type pack_element_t
consteval size_t has_type_at_v(pack< Ts... >)
constexpr std::size_t pack_size(pack< Ts... > const &)
template function to determine number of types in a pack
decltype(concatenate_pack_unique(Ps{}...)) concatenated_pack_unique_t
std::string strToUpper(std::string &&str)
typename pack_element< 0, T >::type pack_head_t
std::string cutString(std::string &&str)
std::vector< std::vector< int64_t > > ListVector
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)
consteval bool is_compatible()
arrow::ChunkedArray * getIndexFromLabel(arrow::Table *table, std::string_view label)
consteval auto merge()
Helpers to manipulate TableRef arrays.
consteval auto merge_if(L l)
std::conditional_t< is_persistent_column< C >, std::true_type, std::false_type > is_persistent_column_t
typename arrow_array_for< T >::type arrow_array_for_t
void notFoundColumn(const char *label, const char *key)
std::conditional_t< is_dynamic_column< T >, std::true_type, std::false_type > is_dynamic_t
typename std::conditional_t< is_self_index_column< C >, std::true_type, std::false_type > is_self_index_t
Defining DataPointCompositeObject explicitly as copiable.
FIXME: do not use data model tables.
static constexpr uint32_t hash
static constexpr char const *const str
SliceInfoUnsortedPtr getCacheUnsortedFor(Entry const &bindingKey) const
SliceInfoPtr getCacheFor(Entry const &bindingKey) const
std::shared_ptr< arrow::Table > getSliceFor(int value, std::shared_ptr< arrow::Table > const &input, uint64_t &offset) const
static constexpr bool optional
PresliceBase(expressions::BindingNode index_)
std::span< const int64_t > getSliceFor(int value) const
const std::string binding
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::shared_ptr< arrow::Table > getSliceFor(int value, std::shared_ptr< arrow::Table > const &input, uint64_t &offset) const
ArrowTableSlicingCache * ptr
std::pair< int64_t, int64_t > getSliceFor(int value) const
An expression tree node corresponding to a column binding.
A struct, containing the root of the expression tree.
From https://en.cppreference.com/w/cpp/utility/variant/visit.
static std::shared_ptr< arrow::Table > joinTables(std::vector< std::shared_ptr< arrow::Table > > &&tables, std::span< const char *const > labels)
static std::shared_ptr< arrow::Table > concatTables(std::vector< std::shared_ptr< arrow::Table > > &&tables)
Type-checking index column binding.
std::span< TableRef const > refs
void bind(T const *table)
static constexpr bool chunked
arrow::ChunkedArray * second
Column(ColumnIterator< T > const &it)
static constexpr const char *const & columnLabel()
ColumnIterator< T > const & getIterator() const
Column & operator=(Column const &)=default
Column(Column &&)=default
static auto asArrowField()
Column & operator=(Column &&)=default
Column(Column const &)=default
ColumnIterator< T > mColumnIterator
table_t::template iterator_template< DefaultIndexPolicy, self_t, Ts... > iterator
Concat(Ts const &... t, uint64_t offset=0)
typename table_t::persistent_columns_t persistent_columns_t
typename table_t::columns_t columns_t
const_iterator unfiltered_const_iterator
iterator unfiltered_iterator
table_t::template iterator_template< FilteredIndexPolicy, self_t, Ts... > filtered_iterator
Concat(std::vector< std::shared_ptr< arrow::Table > > &&tables, uint64_t offset=0)
filtered_iterator filtered_const_iterator
DefaultIndexPolicy(int64_t nRows, uint64_t offset)
friend bool operator==(DefaultIndexPolicy const &lh, DefaultIndexPolicy const &rh)
bool operator==(RowViewSentinel const &sentinel) const
DefaultIndexPolicy(FilteredIndexPolicy const &other)
std::tuple< uint64_t const * > getOffsets() const
DefaultIndexPolicy & operator=(DefaultIndexPolicy &&)=default
void setCursor(int64_t i)
void limitRange(int64_t start, int64_t end)
DefaultIndexPolicy(DefaultIndexPolicy &&)=default
DefaultIndexPolicy(DefaultIndexPolicy const &)=default
DefaultIndexPolicy & operator=(DefaultIndexPolicy const &)=default
std::tuple< int64_t const *, int64_t const * > getIndices() const
DefaultIndexPolicy()=default
Needed to be able to copy the policy.
void moveByIndex(int64_t i)
static constexpr const char *const & columnLabel()
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)
IndexTable(std::shared_ptr< arrow::Table > table, uint64_t offset=0)
typename base_t::template iterator_template_o< DefaultIndexPolicy, self_t > iterator
filtered_iterator const_filtered_iterator
IndexTable(IndexTable &&)=default
IndexTable & operator=(IndexTable const &)=default
IndexTable & operator=(IndexTable &&)=default
typename H::binding_t first_t
typename base_t::template iterator_template_o< FilteredIndexPolicy, self_t > filtered_iterator
IndexTable(IndexTable const &)=default
Index(Index const &)=default
void setIndices(std::tuple< int64_t const *, int64_t const * > indices)
Index & operator=(Index &&)=default
Index(arrow::ChunkedArray const *)
int64_t filteredIndex() const
constexpr int64_t rangeEnd()
constexpr int64_t rangeStart()
Index & operator=(Index const &)=default
int64_t globalIndex() const
std::tuple< int64_t const *, int64_t const * > rowIndices
void setOffsets(std::tuple< uint64_t const * > offsets)
static constexpr const char * mLabel
std::tuple< uint64_t const * > rowOffsets
iterator unfiltered_iterator
auto sliceBy(o2::framework::PresliceBase< T1, Policy, OPT > const &container, int value) const
auto rawSlice(uint64_t start, uint64_t end) const
auto sliceByCachedUnsorted(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
JoinFull(std::vector< std::shared_ptr< arrow::Table > > &&tables, uint64_t offset=0)
static constexpr const auto originalLabels
const_iterator unfiltered_const_iterator
filtered_iterator filtered_const_iterator
static consteval bool contains()
iterator iteratorAt(uint64_t i) const
typename table_t::columns_t columns_t
table_t::template iterator_template< DefaultIndexPolicy, self_t, Ts... > iterator
table_t::template iterator_template< FilteredIndexPolicy, self_t, Ts... > filtered_iterator
static constexpr const auto originals
JoinFull< D, Ts... > self_t
const_iterator begin() const
typename table_t::persistent_columns_t persistent_columns_t
iterator rawIteratorAt(uint64_t i) const
Table< o2::aod::Hash<"JOIN"_h >, D, o2::aod::Hash<"JOIN"_h >, Ts... > base
JoinFull(std::shared_ptr< arrow::Table > &&table, uint64_t offset=0)
auto sliceByCached(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
static constexpr const uint32_t hash
static constexpr const char *const & columnLabel()
Marker & operator=(Marker const &)=default
static constexpr auto value
static constexpr const char * mLabel
Marker(arrow::ChunkedArray const *)
Marker(Marker const &)=default
Marker & operator=(Marker &&)=default
Marker(Marker &&)=default
SmallGroupsBase(std::vector< std::shared_ptr< arrow::Table > > &&tables, SelectionVector &&selection, uint64_t offset=0)
SmallGroupsBase(std::vector< std::shared_ptr< arrow::Table > > &&tables, 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 doSetCurrentInternal(framework::pack< Cs... >, I const *ptr)
auto getIndexBindingsImpl(framework::pack< Cs... >) const
TableIterator operator--(int)
void bindExternalIndicesRaw(std::vector< o2::soa::Binding > &&ptrs)
TableIterator(arrow::ChunkedArray *columnData[sizeof...(C)], IP &&policy)
decltype([]< typename... Cs >(framework::pack< Cs... >) -> framework::pack< typename Cs::binding_t... > {}(external_index_columns_t{})) bindings_pack_t
void bindExternalIndices(TA *... current)
TableIterator & operator--()
framework::selected_pack< soa::is_external_index_t, C... > external_index_columns_t
TableIterator const & operator*() const
TableIterator operator++(int)
framework::selected_pack< soa::is_self_index_t, C... > internal_index_columns_t
auto getIndexBindings() const
void doSetCurrentIndex(framework::pack< CL... >, TA *current)
TableIterator operator+(int64_t inc) const
Allow incrementing by more than one the iterator.
Generic identifier for a table type.
constexpr TableRef & operator=(TableRef const &)=default
constexpr bool descriptionCompatible(uint32_t _desc_hash) const noexcept
constexpr bool operator==(TableRef const &other) const noexcept
constexpr TableRef(TableRef &&)=default
constexpr TableRef(TableRef const &)=default
consteval TableRef(uint32_t _label, uint32_t _desc, uint32_t _origin, uint32_t _version)
constexpr bool descriptionCompatible(TableRef const &other) const noexcept
constexpr TableRef & operator=(TableRef &&)=default
TableIteratorBase const & operator*() const
TableIteratorBase(TableIteratorBase< IP, P, T... > const &other)
typename Parent::columns_t columns_t
TableIteratorBase(TableIteratorBase< IP, P, O1, Os... > const &other)
typename Parent::external_index_columns_t external_index_columns_t
TableIteratorBase operator-(int64_t dec) const
void matchTo(TableIteratorBase< IP, P, T... > const &other)
auto getDynamicColumn() const
TableIteratorBase()=default
void matchTo(TableIteratorBase< IP, P, Os... > const &other)
TableIteratorBase(TableIteratorBase< FilteredIndexPolicy, P, T... > other)
std::array< B, sizeof...(CCs)> getValues() const
static constexpr auto originals
TableIteratorBase(TableIteratorBase< IP, P, T... > &&other) noexcept
decltype([]< typename... C >(framework::pack< C... >) -> framework::pack< typename C::binding_t... > {}(external_index_columns_t{})) bindings_pack_t
TableIteratorBase & operator=(TableIteratorBase< IP, P, Os... > other)
TableIteratorBase(TableIteratorBase< IP, P, O1, Os... > &&other) noexcept
TableIteratorBase & operator=(RowViewSentinel const &other)
TableIteratorBase(arrow::ChunkedArray *columnData[framework::pack_size(columns_t{})], IP &&policy)
TableIteratorBase & operator=(TableIteratorBase< IP, P, T... > other)
TableIteratorBase operator+(int64_t inc) const
Allow incrementing by more than one the iterator.
TableIteratorBase & operator=(TableIteratorBase< FilteredIndexPolicy, P, T... > other)
VectorOfTObjectPtrs other
std::vector< ReadoutWindowData > rows