12#ifndef O2_FRAMEWORK_ASOA_H_
13#define O2_FRAMEWORK_ASOA_H_
16#error "Please do not include this file in ROOT dictionary generation"
31#include <fairmq/Version.h>
32#include <arrow/array/array_binary.h>
33#include <arrow/table.h>
34#include <arrow/array.h>
35#include <arrow/util/config.h>
36#include <gandiva/selection_vector.h>
39#include <fmt/format.h>
51using ListVector = std::vector<std::vector<int64_t>>;
52#if (FAIRMQ_VERSION_DEC >= 111000)
53using PointerReconstructor = std::function<std::byte*(fair::mq::shmem::MetaHeader&&)>;
75 return (
c >=
'A' &&
c <=
'Z') ?
static_cast<char>(
c + 32) :
c;
78template <
typename... C>
81 return std::vector<std::shared_ptr<arrow::Field>>{C::asArrowField()...};
96 consteval TableRef(uint32_t _label, uint32_t _desc, uint32_t _origin, uint32_t _version)
110 return (this->label_hash ==
other.label_hash) &&
111 (this->desc_hash ==
other.desc_hash) &&
112 (this->origin_hash ==
other.origin_hash) &&
113 (this->version ==
other.version);
118 return this->desc_hash ==
other.desc_hash;
123 return this->desc_hash == _desc_hash;
133template <
size_t N1,
size_t N2, std::array<TableRef, N1> ar1, std::array<TableRef, N2> ar2>
136 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; }); });
137 std::array<TableRef, N1 + N2 - duplicates> out;
139 auto pos = std::copy(ar1.begin(), ar1.end(), out.begin());
140 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; }); });
144template <
size_t N1,
size_t N2, std::array<TableRef, N1> ar1, std::array<TableRef, N2> ar2,
typename L>
147 constexpr const int to_remove = std::ranges::count_if(ar1.begin(), ar1.end(), [&](
TableRef const&
a) { return !l(a); });
148 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); });
149 std::array<TableRef, N1 + N2 - duplicates - to_remove> out;
151 auto pos = std::copy_if(ar1.begin(), ar1.end(), out.begin(), [&](TableRef
const&
a) { return l(a); });
152 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); });
156template <
size_t N, std::array<TableRef, N> ar,
typename L>
159 constexpr const int to_remove = std::ranges::count_if(ar.begin(), ar.end(), [&l](
TableRef const& e) { return l(e); });
160 std::array<
TableRef, N - to_remove> out;
161 std::copy_if(ar.begin(), ar.end(), out.begin(), [&l](
TableRef const& e) { return !l(e); });
165template <
size_t N1,
size_t N2, std::array<TableRef, N1> ar1, std::array<TableRef, N2> ar2>
166consteval auto intersect()
168 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; }); });
169 std::array<TableRef, duplicates> out;
170 std::copy_if(ar1.begin(), ar1.end(), out.begin(), [](TableRef
const&
a) { return std::find(ar2.begin(), ar2.end(), a) != ar2.end(); });
174template <
typename T,
typename... Ts>
176 requires(
sizeof...(Ts) == 1)
179 return merge<T::originals.size(), T1::originals.size(), T::originals, T1::originals>();
182template <
typename T,
typename...
Ts>
184 requires(
sizeof...(Ts) > 1)
187 return merge<T::originals.size(), tail.size(), T::originals, tail>();
190template <
typename T,
typename...
Ts>
191 requires(
sizeof...(Ts) == 1)
192consteval auto intersectOriginals()
195 return intersect<T::originals.size(), T1::originals.size(), T::originals, T1::originals>();
198template <
typename T,
typename...
Ts>
199 requires(
sizeof...(Ts) > 1)
200consteval auto intersectOriginals()
203 return intersect<T::originals.size(), tail.size(), T::originals, tail>();
217using is_external_index_t =
typename std::conditional_t<is_index_column<C>, std::true_type, std::false_type>;
220using is_self_index_t =
typename std::conditional_t<is_self_index_column<C>, std::true_type, std::false_type>;
227template <
typename Key,
size_t N, std::array<
bool, N> map>
228static consteval int getIndexPosToKey_impl()
230 constexpr const auto pos = std::find(map.begin(), map.end(),
true);
231 if constexpr (
pos != map.end()) {
232 return std::distance(map.begin(),
pos);
240template <
typename D,
typename... Cs>
248 template <
typename Key,
typename... PCs>
251 return std::array<bool,
sizeof...(PCs)>{[]() {
252 if constexpr (
requires { PCs::index_targets.size(); }) {
253 return Key::template isIndexTargetOf<PCs::index_targets.size(), PCs::index_targets>();
260 template <
typename Key>
283 static constexpr uint32_t
hash = H;
284 static constexpr char const*
const str{
""};
288template <
size_t N, std::array<soa::TableRef, N> ar,
typename Key>
291 constexpr std::array<bool, N>
test = []<
size_t... Is>(std::index_sequence<Is...>) {
292 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))...};
293 }(std::make_index_sequence<N>());
294 constexpr int correct = std::ranges::count(
test.begin(),
test.end(),
true);
295 std::array<soa::TableRef, correct> out;
296 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))]; });
301#define O2HASH(_Str_) \
303 struct Hash<_Str_ ""_h> { \
304 static constexpr void isHash() {}; \
305 static constexpr uint32_t hash = _Str_ ""_h; \
306 static constexpr char const* const str{_Str_}; \
310#define O2ORIGIN(_Str_) \
312 struct Hash<_Str_ ""_h> { \
313 static constexpr void isHash() {}; \
314 static constexpr void isOriginHash() {}; \
315 static constexpr header::DataOrigin origin{_Str_}; \
316 static constexpr uint32_t hash = _Str_ ""_h; \
317 static constexpr char const* const str{_Str_}; \
321static inline constexpr uint32_t
version(
const char*
const str)
323 if (
str[0] ==
'\0') {
331 if (
str[
len - 1] ==
'\0') {
334 for (
auto i =
len + 1;
str[
i] !=
'\0'; ++
i) {
341static inline constexpr std::string_view description_str(
const char*
const str)
347 return std::string_view{
str,
len};
357 for (
auto i = 0;
i < 16; ++
i) {
360 std::memcpy(out,
str,
len);
365template <soa::TableRef R>
371template <soa::TableRef R>
377template <soa::TableRef R>
383template <soa::TableRef R>
389template <soa::TableRef R>
392 return {origin<R>(),
description(signature<R>()),
R.version};
396template <soa::TableRef R>
397static constexpr auto sourceSpec()
399 return fmt::format(
"{}/{}/{}/{}",
label<R>(), origin_str<R>(), description_str(signature<R>()),
R.version);
403template <
size_t N, std::array<soa::TableRef, N> ar, o2::aod::is_origin_hash O>
406 std::array<soa::TableRef, N>
res;
407 for (
auto i = 0U;
i < N; ++
i) {
408 res[
i].label_hash = ar[
i].label_hash;
409 res[
i].desc_hash = ar[
i].desc_hash;
410 res[
i].origin_hash = O::hash;
411 res[
i].version = ar[
i].version;
419template <aod::is_aod_hash L, aod::is_aod_hash D, aod::is_origin_hash O,
typename... Ts>
424 void const*
ptr =
nullptr;
428 template <
typename T>
432 hash = o2::framework::TypeIdHelpers::uniqueId<T>();
436 template <
typename T>
439 if (
hash == o2::framework::TypeIdHelpers::uniqueId<T>()) {
440 return static_cast<T const*
>(
ptr);
448template <
typename B,
typename E>
450 constexpr static bool value =
false;
453template <aod::is_aod_hash A, aod::is_aod_hash B>
455 constexpr static bool value =
false;
458template <
typename B,
typename E>
461template <aod::is_aod_hash A, aod::is_aod_hash B>
500template <
typename T,
typename ChunkingPolicy = Chunked>
503 static constexpr char SCALE_FACTOR = std::same_as<std::decay_t<T>,
bool> ? 3 : 0;
519 auto array = getCurrentArray();
534 auto previousArray = getCurrentArray();
537 auto array = getCurrentArray();
544 auto previousArray = getCurrentArray();
547 auto array = getCurrentArray();
569 auto array = getCurrentArray();
576 requires
std::same_as<
bool,
std::decay_t<T>>
592 decltype(
auto)
operator*()
const
593 requires((!std::same_as<bool, std::decay_t<T>>) && std::same_as<
arrow_array_for_t<T>, arrow::BinaryViewArray>)
600 decltype(
auto)
operator*()
const
623 void checkSkipChunk() const
632 void checkSkipChunk() const
640 void checkSkipChunk() const
641 requires(ChunkingPolicy::
chunked == false)
645 auto getCurrentArray() const
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 chunkToUse = std::dynamic_pointer_cast<arrow::ListArray>(chunkToUse)->values();
658 return std::static_pointer_cast<arrow_array_for_t<value_for_t<T>>>(chunkToUse);
661 auto getCurrentArray() const
665 return std::static_pointer_cast<arrow_array_for_t<T>>(chunkToUse);
669template <
typename T,
typename INHERIT>
687 static constexpr const char*
const&
columnLabel() {
return INHERIT::mLabel; }
695 return std::make_shared<arrow::Field>(inherited_t::mLabel, soa::asArrowDataType<type>());
705template <
typename F,
typename INHERIT>
710 static constexpr const char*
const&
columnLabel() {
return INHERIT::mLabel; }
713template <
typename INHERIT>
717 static constexpr const uint32_t
hash = 0;
719 static constexpr const char*
const&
columnLabel() {
return INHERIT::mLabel; }
722template <
typename INHERIT>
726 static constexpr const uint32_t
hash = 0;
728 static constexpr const char*
const&
columnLabel() {
return INHERIT::mLabel; }
731template <
size_t M = 0>
735 constexpr inline static auto value = M;
750 static constexpr const char*
mLabel =
"Marker";
817 static constexpr const char*
mLabel =
"Index";
847 mSelectedRows(selection),
848 mMaxSelection(selection.
size()),
856 mSelectedRows = selection;
857 mMaxSelection = selection.size();
867 [[nodiscard]] std::tuple<int64_t const*, int64_t const*>
870 return std::make_tuple(&
mRowIndex, &mSelectionRow);
873 [[nodiscard]] std::tuple<uint64_t const*>
876 return std::make_tuple(&
mOffset);
883 mMaxSelection = std::min(
end, mMaxSelection);
901 return lh.mSelectionRow == rh.mSelectionRow;
914 this->mSelectionRow = this->mMaxSelection;
920 return mSelectionRow;
923 [[nodiscard]]
auto size()
const
925 return mMaxSelection;
934 inline void updateRow()
938 std::span<int64_t const> mSelectedRows;
976 [[nodiscard]] std::tuple<int64_t const*, int64_t const*>
982 [[nodiscard]] std::tuple<uint64_t const*>
985 return std::make_tuple(&
mOffset);
1022template <
typename C>
1028template <
typename C>
1031template <
typename D,
typename O,
typename IP,
typename... C>
1047 if (this->
size() != 0) {
1057 if (this->
size() != 0) {
1064 this->limitRange(this->rangeStart(), this->rangeEnd());
1070 C(static_cast<
C const&>(
other))...
1072 if (this->
size() != 0) {
1079 IP::operator=(
static_cast<IP const&
>(
other));
1080 (
void(
static_cast<C&
>(*
this) =
static_cast<C>(
other)), ...);
1081 if (this->
size() != 0) {
1088 requires std::same_as<IP, DefaultIndexPolicy>
1090 C(
static_cast<C const&
>(
other))...
1092 if (this->
size() != 0) {
1099 this->moveByIndex(1);
1112 this->moveByIndex(-1);
1127 copy.moveByIndex(inc);
1141 template <
typename CL>
1144 return CL::getCurrentRaw();
1147 template <
typename... Cs>
1150 return std::vector<o2::soa::Binding>{
static_cast<Cs const&
>(*this).getCurrentRaw()...};
1158 template <
typename... TA>
1162 (CCs::setCurrent(cur), ...);
1167 template <
typename TA>
1171 (CCs::setCurrent(cur), ...);
1175 template <
typename... Cs>
1178 (Cs::setCurrentRaw(ptrs[framework::has_type_at_v<Cs>(p)]), ...);
1181 template <
typename... Cs,
typename I>
1186 (Cs::setCurrentRaw(
b), ...);
1194 template <
typename I>
1199#if (FAIRMQ_VERSION_DEC >= 111000)
1200 void setPointerReconstructor(framework::PointerReconstructor
const& pointerReconstructor)
1202 [&pointerReconstructor,
this]<
typename... Cs>(
framework::pack<Cs...>) {
1203 ([&pointerReconstructor,
this]<
typename CC>() {
1205 if (pointerReconstructor) {
1206 CC::ptrRec = &pointerReconstructor;
1209 }.template operator()<Cs>(),
1217 template <
typename... PC>
1218 void doMoveToEnd(framework::pack<PC...>)
1220 (PC::mColumnIterator.moveToEnd(), ...);
1229 [
this]<soa::is_persistent_column
T>(
T*) ->
void { T::mColumnIterator.mCurrentPos = &this->mRowIndex; T::mColumnIterator.mGlobalOffset = &this->mOffset; },
1230 [
this]<soa::is_dynamic_column
T>(
T*) ->
void { bindDynamicColumn<T>(
typename T::bindings_t{}); },
1231 [
this]<
typename T>(
T*) ->
void {},
1233 (
f(
static_cast<C*
>(
nullptr)), ...);
1234 if constexpr (has_index<
C...>) {
1235 this->setIndices(this->getIndices());
1236 this->setOffsets(this->getOffsets());
1240 template <
typename DC,
typename...
B>
1243 DC::boundIterators = std::make_tuple(getDynamicBinding<B>()...);
1251 template <
typename B>
1252 requires(can_bind<self_t, B>)
1253 decltype(
auto) getDynamicBinding()
1255 static_assert(std::same_as<decltype(&(static_cast<B*>(
this)->mColumnIterator)), std::decay_t<
decltype(B::mColumnIterator)>*>,
"foo");
1256 return &(
static_cast<B*
>(
this)->mColumnIterator);
1259 template <
typename B>
1260 decltype(
auto) getDynamicBinding()
1262 return static_cast<std::decay_t<decltype(B::mColumnIterator)
>*>(
nullptr);
1277template <
size_t N1, std::array<TableRef, N1> os1,
size_t N2, std::array<TableRef, N2> os2>
1280 return []<
size_t... Is>(std::index_sequence<Is...>) {
1281 return ([]<
size_t... Ks>(std::index_sequence<Ks...>) {
1282 constexpr auto h = os1[Is].desc_hash;
1285 }(std::make_index_sequence<N2>()) ||
1287 }(std::make_index_sequence<N1>());
1290template <with_originals T, with_originals B>
1293 return is_compatible<T::originals.size(), T::originals, B::originals.size(), B::originals>();
1296template <
typename T,
typename B>
1297using is_binding_compatible = std::conditional_t<is_binding_compatible_v<T, typename B::binding_t>(), std::true_type, std::false_type>;
1299template <soa::is_table T>
1300static constexpr std::string getLabelForTable()
1302 return std::string{aod::label<std::decay_t<T>::originals[0]>()};
1305template <soa::is_table T>
1307static constexpr std::string getLabelFromType()
1309 return getLabelForTable<T>();
1312template <soa::is_iterator T>
1313static constexpr std::string getLabelFromType()
1315 return getLabelForTable<typename std::decay_t<T>::parent_t>();
1318template <soa::is_index_table T>
1319static constexpr std::string getLabelFromType()
1321 return getLabelForTable<typename std::decay_t<T>::first_t>();
1323template <soa::with_base_table T>
1324 requires(!soa::is_iterator<T>)
1325static constexpr std::string getLabelFromType()
1330template <
typename...
C>
1333 auto caseInsensitiveCompare = [](
const std::string_view& str1,
const std::string_view& str2) {
1334 return std::ranges::equal(
1336 [](
char c1,
char c2) {
1341 return (caseInsensitiveCompare(C::inherited_t::mLabel,
key) || ...);
1344template <TableRef ref>
1345static constexpr std::pair<bool, std::string> hasKey(std::string_view
key)
1350template <TableRef ref>
1351static constexpr std::pair<bool, framework::ConcreteDataMatcher> hasKeyM(std::string_view
key)
1359template <with_originals T,
bool OPT = false>
1360static constexpr std::string getLabelFromTypeForKey(std::string_view
key)
1362 auto locate = []<
size_t... Is>(std::index_sequence<Is...>, std::string_view
key) {
1363 return std::array{hasKey<T::originals[Is]>(
key)...} |
1364 std::views::filter([](
auto const&
x) {
return x.first; });
1365 }(std::make_index_sequence<T::originals.size()>{},
key);
1366 if (!locate.empty()) {
1367 return locate.front().second;
1370 if constexpr (!OPT) {
1378template <with_originals T,
bool OPT = false>
1381 auto locate = []<
size_t... Is>(std::index_sequence<Is...>, std::string_view
key) {
1382 return std::array{hasKeyM<T::originals[Is]>(
key)...} |
1383 std::views::filter([](
auto const&
x) {
return x.first; });
1384 }(std::make_index_sequence<T::originals.size()>{},
key);
1385 if (!locate.empty()) {
1386 return locate.front().second;
1389 if constexpr (!OPT) {
1397template <
typename B,
typename...
C>
1400 return (o2::soa::is_binding_compatible_v<B, typename C::binding_t>() || ...);
1403template <
typename B,
typename...
C>
1406 return ((C::sorted && o2::soa::is_binding_compatible_v<B, typename C::binding_t>()) || ...);
1409template <
typename B,
typename Z>
1410consteval static bool relatedByIndex()
1412 return hasIndexTo<B>(
typename Z::table_t::external_index_columns_t{});
1415template <
typename B,
typename Z>
1416consteval static bool relatedBySortedIndex()
1418 return hasSortedIndexTo<B>(
typename Z::table_t::external_index_columns_t{});
1448template <soa::is_table T, is_preslice_policy Policy,
bool OPT = false>
1457 : Policy{
PreslicePolicyBase{{o2::soa::getLabelFromTypeForKey<T, OPT>(std::string{index_.
name})},
Entry(o2::soa::getLabelFromTypeForKey<T, OPT>(std::string{index_.name}), o2::soa::getMatcherFromTypeForKey<T, OPT>(std::string{index_.name}), std::string{index_.name})}, {}}
1463 if constexpr (OPT) {
1464 if (Policy::isMissing()) {
1465 return {
nullptr, {0, 0}};
1468 return Policy::getSliceFor(
value, input);
1473 if constexpr (OPT) {
1474 if (Policy::isMissing()) {
1478 return Policy::getSliceFor(
value);
1482template <soa::is_table T>
1484template <soa::is_table T>
1486template <soa::is_table T>
1488template <soa::is_table T>
1510template <soa::is_table T>
1512template <
typename T>
1516template <
typename T>
1520template <
typename... Is>
1528template <
typename T,
typename C,
typename Policy,
bool OPT>
1529 requires std::same_as<Policy, framework::PreslicePolicySorted> && (o2::soa::is_binding_compatible_v<C, T>())
1532 if constexpr (OPT) {
1533 if (container.isMissing()) {
1538 auto t =
typename T::self_t({out});
1539 if (t.tableSize() != 0) {
1540 table->copyIndexBindings(t);
1541 t.bindInternalIndicesTo(table);
1546template <soa::is_filtered_table T>
1550 if (t.tableSize() != 0) {
1552 t.bindInternalIndicesTo(table);
1553 t.intersectWithSelection(table->getSelectedRows());
1558template <soa::is_table T>
1563 if (t.tableSize() != 0) {
1565 t.bindInternalIndicesTo(table);
1570template <
typename T,
typename C,
typename Policy,
bool OPT>
1571 requires std::same_as<Policy, framework::PreslicePolicyGeneral> && (o2::soa::is_binding_compatible_v<C, T>())
1574 if constexpr (OPT) {
1575 if (container.isMissing()) {
1585template <soa::is_filtered_table T>
1588 if (slice.
range.
offset >=
static_cast<uint64_t
>(table->tableSize())) {
1590 if (fresult.tableSize() != 0) {
1591 table->copyIndexBindings(fresult);
1597 if (fresult.tableSize() != 0) {
1598 table->copyIndexBindings(fresult);
1603template <soa::is_filtered_table T,
typename C,
bool OPT>
1604 requires(o2::soa::is_binding_compatible_v<C, T>())
1607 if constexpr (OPT) {
1608 if (container.isMissing()) {
1618template <soa::is_table T>
1624 auto t =
typename T::self_t({table->asArrowTableRef().slice({
static_cast<uint64_t
>(
offset),
count})});
1625 if (t.tableSize() != 0) {
1626 table->copyIndexBindings(t);
1631template <soa::is_filtered_table T>
1637 return prepareFilteredSlice(table, table->asArrowTableRef().slice({static_cast<uint64_t>(offset), count}));
1640template <soa::is_table T>
1646 auto t =
typename T::self_t({table->asArrowTableRef()}, localCache.getSliceFor(
value));
1647 if (t.tableSize() != 0) {
1648 t.intersectWithSelection(table->getSelectedRows());
1649 table->copyIndexBindings(t);
1653 auto t =
Filtered<T>({table->asArrowTableRef()}, localCache.getSliceFor(
value));
1654 if (t.tableSize() != 0) {
1655 table->copyIndexBindings(t);
1661template <with_originals T>
1669template <
typename D,
typename O,
typename IP,
typename...
C>
1705 return std::array<TableRef, 1>{
ref};
1722 static constexpr const auto ref =
TableRef{L::hash, D::hash, O::hash, o2::aod::version(D::str)};
1727 static constexpr const auto originalLabels = []<
size_t N, std::array<TableRef, N> refs,
size_t... Is>(std::index_sequence<Is...>) {
1728 return std::array<const char*, N>{o2::aod::label<refs[Is]>()...};
1733 template <
size_t N, std::array<TableRef, N> bindings>
1734 requires(
ref.origin_hash ==
"CONC"_h)
1740 template <
size_t N, std::array<TableRef, N> bindings>
1741 requires(
ref.origin_hash ==
"JOIN"_h)
1746 return std::ranges::any_of(bindings, [&
r](
TableRef const&
b) {
return b ==
r; });
1750 template <
size_t N, std::array<TableRef, N> bindings>
1751 requires(!(
ref.origin_hash ==
"CONC"_h ||
ref.origin_hash ==
"JOIN"_h))
1754 return std::find(bindings.begin(), bindings.end(),
self_t::ref) != bindings.end();
1757 template <TableRef r>
1770 template <
typename IP>
1773 template <
typename IP,
typename Parent,
typename... T>
1789 template <
typename P,
typename... Os>
1791 requires(P::ref.desc_hash == Parent::ref.desc_hash)
1797 template <
typename P>
1804 template <
typename P>
1806 requires std::same_as<IP, DefaultIndexPolicy>
1812 template <
typename P,
typename O1,
typename... Os>
1814 requires(P::ref.desc_hash == Parent::ref.desc_hash)
1819 template <
typename P,
typename O1,
typename... Os>
1821 requires(P::ref.desc_hash == Parent::ref.desc_hash)
1826 template <
typename P>
1832 template <
typename P>
1838 template <
typename P>
1840 requires std::same_as<IP, DefaultIndexPolicy>
1847 this->mRowIndex =
other.index;
1850 template <
typename P>
1853 this->mRowIndex =
other.mRowIndex;
1856 template <
typename P,
typename... Os>
1858 requires std::same_as<typename P::table_t, typename Parent::table_t>
1860 this->mRowIndex =
other.mRowIndex;
1863 template <
typename TI>
1866 using decayed = std::decay_t<TI>;
1868 constexpr auto idx = framework::has_type_at_v<decayed>(
bindings_pack_t{});
1870 }
else if constexpr (std::same_as<decayed, Parent>) {
1871 return this->globalIndex();
1873 return this->globalIndex();
1875 return static_cast<int32_t
>(-1);
1879 template <
typename CD,
typename... CDArgs>
1882 using decayed = std::decay_t<CD>;
1884 return static_cast<decayed
>(*this).template getDynamicValue<CDArgs...>();
1887 template <
typename B,
typename CC>
1890 using COL = std::decay_t<CC>;
1892 return static_cast<B>(
static_cast<COL
>(*this).get());
1895 template <
typename B,
typename... CCs>
1898 static_assert(std::same_as<B, float> || std::same_as<B, double>,
"The common return type should be float or double");
1899 return {getValue<B, CCs>()...};
1910 copy.moveByIndex(inc);
1925 template <
typename IP,
typename Parent,
typename... T>
1928 template <
typename IP,
typename Parent>
1930 if constexpr (
sizeof...(Ts) == 0) {
1934 return iterator_template<IP, Parent>{};
1954 : mArrowTableRef(tableRef),
1957 if (mArrowTableRef.
tablePtr->num_rows() == 0) {
1959 mColumnChunks[ci] =
nullptr;
1965 mColumnChunks[ci] = lookups[ci];
1968 mBegin.bindInternalIndices(
this);
1972 Table(std::shared_ptr<arrow::Table> table)
1977 Table(std::vector<o2::soa::ArrowTableRef>&& tables)
1978 requires(
ref.origin_hash !=
"CONC"_h)
1983 Table(std::vector<o2::soa::ArrowTableRef>&& tables)
1984 requires(
ref.origin_hash ==
"CONC"_h)
1989 Table(std::vector<std::shared_ptr<arrow::Table>>&& tables)
1990 requires(
ref.origin_hash !=
"CONC"_h)
1995 Table(std::vector<std::shared_ptr<arrow::Table>>&& tables)
1996 requires(
ref.origin_hash ==
"CONC"_h)
2001 template <
typename Key>
2005 return std::array<bool,
sizeof...(Cs)>{[]() {
2006 if constexpr (
requires { Cs::index_targets.size(); }) {
2007 return Key::template
isIndexTargetOf<Cs::index_targets.size(), Cs::index_targets>();
2013 constexpr auto pos = std::find(map.begin(), map.end(),
true);
2014 if constexpr (
pos != map.end()) {
2015 return mColumnChunks[std::distance(map.begin(),
pos)];
2017 static_assert(framework::always_static_assert_v<Key>,
"This table does not have an index to given Key");
2085 return mArrowTableRef;
2105 template <
typename... TA>
2110 mBegin.bindExternalIndex(cur);
2116 template <
typename TA>
2119 mBegin.bindExternalIndex(current);
2122 template <
typename I>
2125 mBegin.bindInternalIndices(
ptr);
2133 template <
typename... Cs>
2136 (
static_cast<Cs
>(mBegin).setCurrentRaw(
binding), ...);
2141 mBegin.bindExternalIndicesRaw(std::forward<std::vector<o2::soa::Binding>>(ptrs));
2144 template <
typename T,
typename... Cs>
2147 dest.bindExternalIndicesRaw(mBegin.getIndexBindings());
2150 template <
typename T>
2173 template <
typename T1,
typename Policy,
bool OPT>
2188#if (FAIRMQ_VERSION_DEC >= 111000)
2189 void setPointerReconstructor(framework::PointerReconstructor
const& pointerReconstructor)
2191 mBegin.setPointerReconstructor(pointerReconstructor);
2195 template <
typename T>
2196 arrow::ChunkedArray* lookupColumn()
2201 template <soa::is_persistent_column T>
2202 arrow::ChunkedArray* lookupColumn()
2216template <uint32_t
D, soa::is_column...
C>
2222namespace row_helpers
2224template <
typename R,
typename T,
typename C>
2227 return static_cast<R>(
static_cast<C>(rowIterator).get());
2232template <
typename R,
typename T>
2233using ColumnGetterFunction =
R (*)(
const T&);
2235template <
typename T,
typename R>
2240 { t.get() } -> std::convertible_to<R>;
2243template <
typename T,
typename R>
2245 { t.get() } -> std::convertible_to<R>;
2248template <
typename R,
typename T, persistent_with_common_getter<R> C>
2249ColumnGetterFunction<R, T> createGetterPtr(
const std::string_view& targetColumnLabel)
2251 return targetColumnLabel == C::columnLabel() ? &getColumnValue<R, T, C> :
nullptr;
2254template <
typename R,
typename T, dynamic_with_common_getter<R> C>
2255ColumnGetterFunction<R, T> createGetterPtr(
const std::string_view& targetColumnLabel)
2261 if (targetColumnLabel.starts_with(
"f") && targetColumnLabel.substr(1) ==
columnLabel) {
2262 return &getColumnValue<R, T, C>;
2267 return &getColumnValue<R, T, C>;
2273template <
typename R,
typename T,
typename... Cs>
2276 ColumnGetterFunction<R, T>
func;
2278 (
void)((
func = createGetterPtr<R, T, Cs>(targetColumnLabel),
func) || ...);
2287template <
typename T,
typename R>
2288using 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;
2291template <
typename R,
typename T>
2296 if (targetColumnLabel.size() == 0) {
2300 return getColumnGetterByLabel<R, typename T::iterator>(TypesWithCommonGetter{}, targetColumnLabel);
2325template <
typename T>
2326consteval static std::string_view namespace_prefix()
2328 constexpr auto name = o2::framework::type_name<T>();
2329 const auto pos =
name.rfind(std::string_view{
":"});
2330 return name.substr(0,
pos + 1);
2334#define DECLARE_EQUIVALENT_FOR_INDEX(_Base_, _Equiv_) \
2336 struct EquivalentIndexNG<o2::aod::Hash<_Base_::ref.desc_hash>, o2::aod::Hash<_Equiv_::ref.desc_hash>> { \
2337 constexpr static bool value = true; \
2340#define DECLARE_EQUIVALENT_FOR_INDEX_NG(_Base_, _Equiv_) \
2342 struct EquivalentIndexNG<o2::aod::Hash<_Base_ ""_h>, o2::aod::Hash<_Equiv_ ""_h>> { \
2343 constexpr static bool value = true; \
2346#define DECLARE_SOA_COLUMN_FULL(_Name_, _Getter_, _Type_, _Label_) \
2347 struct _Name_ : o2::soa::Column<_Type_, _Name_> { \
2348 static constexpr const char* mLabel = _Label_; \
2349 static constexpr const uint32_t hash = compile_time_hash(namespace_prefix<_Name_>(), std::string_view{#_Getter_}); \
2350 static_assert(!((*(mLabel + 1) == 'I' && *(mLabel + 2) == 'n' && *(mLabel + 3) == 'd' && *(mLabel + 4) == 'e' && *(mLabel + 5) == 'x')), "Index is not a valid column name"); \
2351 using base = o2::soa::Column<_Type_, _Name_>; \
2352 using type = _Type_; \
2353 using column_t = _Name_; \
2354 _Name_(arrow::ChunkedArray const* column) \
2355 : o2::soa::Column<_Type_, _Name_>(o2::soa::ColumnIterator<type>(column)) \
2359 _Name_() = default; \
2360 _Name_(_Name_ const& other) = default; \
2361 _Name_& operator=(_Name_ const& other) = default; \
2363 decltype(auto) _Getter_() const \
2365 return *mColumnIterator; \
2368 decltype(auto) get() const \
2370 return _Getter_(); \
2373 [[maybe_unused]] static constexpr o2::framework::expressions::BindingNode _Getter_ { _Label_, _Name_::hash, o2::framework::expressions::selectArrowType<_Type_>() }
2375#if (FAIRMQ_VERSION_DEC >= 111000)
2376#define DECLARE_SOA_CCDB_COLUMN_FULL(_Name_, _Label_, _Getter_, _ConcreteType_, _CCDBQuery_) \
2377 struct _Name_ : o2::soa::Column<int64_t[3], _Name_> { \
2378 static constexpr const char* mLabel = _Label_; \
2379 static constexpr const char* query = _CCDBQuery_; \
2380 static constexpr const uint32_t hash = crc32(namespace_prefix<_Name_>(), std::string_view{#_Getter_}); \
2381 static constexpr bool needs_ptr_rec = true; \
2382 std::function<std::byte*(fair::mq::shmem::MetaHeader&&)> const* ptrRec = nullptr; \
2383 using base = o2::soa::Column<int64_t[3], _Name_>; \
2384 using type = int64_t[3]; \
2385 using column_t = _Name_; \
2386 _Name_(arrow::ChunkedArray const* column) \
2387 : o2::soa::Column<int64_t[3], _Name_>(o2::soa::ColumnIterator<int64_t[3]>(column)) \
2391 _Name_() = default; \
2392 _Name_(_Name_ const& other) = default; \
2393 _Name_& operator=(_Name_ const& other) = default; \
2395 decltype(auto) _Getter_() const \
2397 auto& [handle, segment, size] = *mColumnIterator; \
2398 auto span = std::span<std::byte>{(*ptrRec)(fair::mq::shmem::MetaHeader{ \
2399 static_cast<size_t>(size), \
2401 static_cast<uint16_t>(segment), true}), \
2402 static_cast<size_t>(size)}; \
2403 if constexpr (std::same_as<_ConcreteType_, std::span<std::byte>>) { \
2406 static std::byte* payload = nullptr; \
2407 static _ConcreteType_* deserialised = nullptr; \
2408 static TClass* c = TClass::GetClass(#_ConcreteType_); \
2409 if (payload != (std::byte*)span.data()) { \
2410 payload = (std::byte*)span.data(); \
2411 delete deserialised; \
2412 TBufferFile f(TBufferFile::EMode::kRead, span.size(), (char*)span.data(), kFALSE); \
2413 deserialised = (_ConcreteType_*)soa::extractCCDBPayload((char*)payload, span.size(), c, "ccdb_object"); \
2415 return *deserialised; \
2422 return _Getter_(); \
2426#define DECLARE_SOA_CCDB_COLUMN_FULL(_Name_, _Label_, _Getter_, _ConcreteType_, _CCDBQuery_) \
2427 struct _Name_ : o2::soa::Column<std::span<std::byte>, _Name_> { \
2428 static constexpr const char* mLabel = _Label_; \
2429 static constexpr const char* query = _CCDBQuery_; \
2430 static constexpr const uint32_t hash = crc32(namespace_prefix<_Name_>(), std::string_view{#_Getter_}); \
2431 using base = o2::soa::Column<std::span<std::byte>, _Name_>; \
2432 using type = std::span<std::byte>; \
2433 using column_t = _Name_; \
2434 _Name_(arrow::ChunkedArray const* column) \
2435 : o2::soa::Column<std::span<std::byte>, _Name_>(o2::soa::ColumnIterator<std::span<std::byte>>(column)) \
2439 _Name_() = default; \
2440 _Name_(_Name_ const& other) = default; \
2441 _Name_& operator=(_Name_ const& other) = default; \
2443 decltype(auto) _Getter_() const \
2445 if constexpr (std::same_as<_ConcreteType_, std::span<std::byte>>) { \
2446 return *mColumnIterator; \
2448 static std::byte* payload = nullptr; \
2449 static _ConcreteType_* deserialised = nullptr; \
2450 static TClass* c = TClass::GetClass(#_ConcreteType_); \
2451 auto span = *mColumnIterator; \
2452 if (payload != (std::byte*)span.data()) { \
2453 payload = (std::byte*)span.data(); \
2454 delete deserialised; \
2455 TBufferFile f(TBufferFile::EMode::kRead, span.size(), (char*)span.data(), kFALSE); \
2456 deserialised = (_ConcreteType_*)soa::extractCCDBPayload((char*)payload, span.size(), c, "ccdb_object"); \
2458 return *deserialised; \
2465 return _Getter_(); \
2470#define DECLARE_SOA_CCDB_COLUMN(_Name_, _Getter_, _ConcreteType_, _CCDBQuery_) \
2471 DECLARE_SOA_CCDB_COLUMN_FULL(_Name_, "f" #_Name_, _Getter_, _ConcreteType_, _CCDBQuery_)
2473#define DECLARE_SOA_COLUMN(_Name_, _Getter_, _Type_) \
2474 DECLARE_SOA_COLUMN_FULL(_Name_, _Getter_, _Type_, "f" #_Name_)
2478#define MAKEINT(_Size_) uint##_Size_##_t
2480#define DECLARE_SOA_BITMAP_COLUMN_FULL(_Name_, _Getter_, _Size_, _Label_) \
2481 struct _Name_ : o2::soa::Column<MAKEINT(_Size_), _Name_> { \
2482 static constexpr const char* mLabel = _Label_; \
2483 static constexpr const uint32_t hash = compile_time_hash(namespace_prefix<_Name_>(), std::string_view{#_Getter_}); \
2484 static_assert(!((*(mLabel + 1) == 'I' && *(mLabel + 2) == 'n' && *(mLabel + 3) == 'd' && *(mLabel + 4) == 'e' && *(mLabel + 5) == 'x')), "Index is not a valid column name"); \
2485 using base = o2::soa::Column<MAKEINT(_Size_), _Name_>; \
2486 using type = MAKEINT(_Size_); \
2487 _Name_(arrow::ChunkedArray const* column) \
2488 : o2::soa::Column<type, _Name_>(o2::soa::ColumnIterator<type>(column)) \
2492 _Name_() = default; \
2493 _Name_(_Name_ const& other) = default; \
2494 _Name_& operator=(_Name_ const& other) = default; \
2496 decltype(auto) _Getter_##_raw() const \
2498 return *mColumnIterator; \
2501 bool _Getter_##_bit(int bit) const \
2503 return (*mColumnIterator & (static_cast<type>(1) << bit)) >> bit; \
2506 [[maybe_unused]] static constexpr o2::framework::expressions::BindingNode _Getter_ { _Label_, _Name_::hash, o2::framework::expressions::selectArrowType<MAKEINT(_Size_)>() }
2508#define DECLARE_SOA_BITMAP_COLUMN(_Name_, _Getter_, _Size_) \
2509 DECLARE_SOA_BITMAP_COLUMN_FULL(_Name_, _Getter_, _Size_, "f" #_Name_)
2513#define DECLARE_SOA_EXPRESSION_COLUMN_FULL(_Name_, _Getter_, _Type_, _Label_, _Expression_) \
2514 struct _Name_ : o2::soa::Column<_Type_, _Name_> { \
2515 static constexpr const char* mLabel = _Label_; \
2516 static constexpr const uint32_t hash = compile_time_hash(namespace_prefix<_Name_>(), std::string_view{#_Getter_}); \
2517 using base = o2::soa::Column<_Type_, _Name_>; \
2518 using type = _Type_; \
2519 using column_t = _Name_; \
2520 using spawnable_t = std::true_type; \
2521 _Name_(arrow::ChunkedArray const* column) \
2522 : o2::soa::Column<_Type_, _Name_>(o2::soa::ColumnIterator<type>(column)) \
2526 _Name_() = default; \
2527 _Name_(_Name_ const& other) = default; \
2528 _Name_& operator=(_Name_ const& other) = default; \
2530 decltype(auto) _Getter_() const \
2532 return *mColumnIterator; \
2535 decltype(auto) get() const \
2537 return _Getter_(); \
2540 static o2::framework::expressions::Projector Projector() \
2542 return _Expression_; \
2545 [[maybe_unused]] static constexpr o2::framework::expressions::BindingNode _Getter_ { _Label_, _Name_::hash, o2::framework::expressions::selectArrowType<_Type_>() }
2547#define DECLARE_SOA_EXPRESSION_COLUMN(_Name_, _Getter_, _Type_, _Expression_) \
2548 DECLARE_SOA_EXPRESSION_COLUMN_FULL(_Name_, _Getter_, _Type_, "f" #_Name_, _Expression_);
2552#define DECLARE_SOA_CONFIGURABLE_EXPRESSION_COLUMN(_Name_, _Getter_, _Type_, _Label_) \
2553 struct _Name_ : o2::soa::Column<_Type_, _Name_> { \
2554 static constexpr const char* mLabel = _Label_; \
2555 static constexpr const uint32_t hash = compile_time_hash(namespace_prefix<_Name_>(), std::string_view{#_Getter_}); \
2556 static constexpr const int32_t mHash = _Label_ ""_h; \
2557 using base = o2::soa::Column<_Type_, _Name_>; \
2558 using type = _Type_; \
2559 using column_t = _Name_; \
2560 using spawnable_t = std::true_type; \
2561 _Name_(arrow::ChunkedArray const* column) \
2562 : o2::soa::Column<_Type_, _Name_>(o2::soa::ColumnIterator<type>(column)) \
2566 _Name_() = default; \
2567 _Name_(_Name_ const& other) = default; \
2568 _Name_& operator=(_Name_ const& other) = default; \
2570 decltype(auto) _Getter_() const \
2572 return *mColumnIterator; \
2575 decltype(auto) get() const \
2577 return _Getter_(); \
2580 [[maybe_unused]] static constexpr o2::framework::expressions::BindingNode _Getter_ { _Label_, _Name_::hash, o2::framework::expressions::selectArrowType<_Type_>() }
2603template <o2::soa::is_table T>
2606 return T::originals;
2609#define DECLARE_SOA_SLICE_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, _Type_, _Table_, _Label_, _Suffix_) \
2610 struct _Name_##IdSlice : o2::soa::Column<_Type_[2], _Name_##IdSlice> { \
2611 static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
2612 static_assert((*_Suffix_ == '\0') || (*_Suffix_ == '_'), "Suffix has to begin with _"); \
2613 static constexpr const char* mLabel = "fIndexSlice" _Label_ _Suffix_; \
2614 static constexpr const uint32_t hash = 0; \
2615 using base = o2::soa::Column<_Type_[2], _Name_##IdSlice>; \
2616 using type = _Type_[2]; \
2617 using column_t = _Name_##IdSlice; \
2618 using binding_t = _Table_; \
2619 static constexpr auto index_targets = getIndexTargets<_Table_>(); \
2620 _Name_##IdSlice(arrow::ChunkedArray const* column) \
2621 : o2::soa::Column<_Type_[2], _Name_##IdSlice>(o2::soa::ColumnIterator<type>(column)) \
2625 _Name_##IdSlice() = default; \
2626 _Name_##IdSlice(_Name_##IdSlice const& other) = default; \
2627 _Name_##IdSlice& operator=(_Name_##IdSlice const& other) = default; \
2628 std::array<_Type_, 2> inline getIds() const \
2630 return _Getter_##Ids(); \
2633 bool has_##_Getter_() const \
2635 auto a = *mColumnIterator; \
2636 return a[0] >= 0 && a[1] >= 0; \
2639 std::array<_Type_, 2> _Getter_##Ids() const \
2641 auto a = *mColumnIterator; \
2642 return std::array{a[0], a[1]}; \
2645 template <typename T> \
2646 auto _Getter_##_as() const \
2648 if (O2_BUILTIN_UNLIKELY(mBinding.ptr == nullptr)) { \
2649 o2::soa::notBoundTable(#_Table_); \
2651 auto t = mBinding.get<T>(); \
2652 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2653 o2::soa::dereferenceWithWrongType(#_Getter_, #_Table_); \
2655 if (O2_BUILTIN_UNLIKELY(!has_##_Getter_())) { \
2656 return t->emptySlice(); \
2658 auto a = *mColumnIterator; \
2659 auto r = t->rawSlice(a[0], a[1]); \
2660 t->copyIndexBindings(r); \
2661 r.bindInternalIndicesTo(t); \
2665 auto _Getter_() const \
2667 return _Getter_##_as<binding_t>(); \
2670 template <typename T> \
2671 bool setCurrent(T const* current) \
2673 if constexpr (o2::soa::is_binding_compatible_v<T, binding_t>()) { \
2674 assert(current != nullptr); \
2675 this->mBinding.bind(current); \
2681 bool setCurrentRaw(o2::soa::Binding current) \
2683 this->mBinding = current; \
2686 binding_t const* getCurrent() const { return mBinding.get<binding_t>(); } \
2687 o2::soa::Binding getCurrentRaw() const { return mBinding; } \
2688 o2::soa::Binding mBinding; \
2691#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_)
2692#define DECLARE_SOA_SLICE_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_SLICE_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, _Name_##s, "")
2693#define DECLARE_SOA_SLICE_INDEX_COLUMN_CUSTOM(_Name_, _Getter_, _Label_) DECLARE_SOA_SLICE_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, int32_t, _Name_##s, _Label_, "")
2696#define DECLARE_SOA_ARRAY_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, _Type_, _Table_, _Label_, _Suffix_) \
2697 struct _Name_##Ids : o2::soa::Column<std::vector<_Type_>, _Name_##Ids> { \
2698 static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
2699 static_assert((*_Suffix_ == '\0') || (*_Suffix_ == '_'), "Suffix has to begin with _"); \
2700 static constexpr const char* mLabel = "fIndexArray" _Label_ _Suffix_; \
2701 static constexpr const uint32_t hash = 0; \
2702 using base = o2::soa::Column<std::vector<_Type_>, _Name_##Ids>; \
2703 using type = std::vector<_Type_>; \
2704 using column_t = _Name_##Ids; \
2705 using binding_t = _Table_; \
2706 static constexpr auto index_targets = getIndexTargets<_Table_>(); \
2707 _Name_##Ids(arrow::ChunkedArray const* column) \
2708 : o2::soa::Column<std::vector<_Type_>, _Name_##Ids>(o2::soa::ColumnIterator<type>(column)) \
2712 _Name_##Ids() = default; \
2713 _Name_##Ids(_Name_##Ids const& other) = default; \
2714 _Name_##Ids& operator=(_Name_##Ids const& other) = default; \
2716 gsl::span<const _Type_> inline getIds() const \
2718 return _Getter_##Ids(); \
2721 gsl::span<const _Type_> _Getter_##Ids() const \
2723 return *mColumnIterator; \
2726 bool has_##_Getter_() const \
2728 return !(*mColumnIterator).empty(); \
2731 template <soa::is_table T> \
2732 auto _Getter_##_as() const \
2734 if (O2_BUILTIN_UNLIKELY(mBinding.ptr == nullptr)) { \
2735 o2::soa::notBoundTable(#_Table_); \
2737 auto t = mBinding.get<T>(); \
2738 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2739 o2::soa::dereferenceWithWrongType(#_Getter_, #_Table_); \
2741 auto result = std::vector<typename T::unfiltered_iterator>(); \
2742 result.reserve((*mColumnIterator).size()); \
2743 for (auto& i : *mColumnIterator) { \
2744 result.emplace_back(t->rawIteratorAt(i)); \
2749 template <soa::is_filtered_table T> \
2750 auto filtered_##_Getter_##_as() const \
2752 if (O2_BUILTIN_UNLIKELY(mBinding.ptr == nullptr)) { \
2753 o2::soa::notBoundTable(#_Table_); \
2755 auto t = mBinding.get<T>(); \
2756 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2757 o2::soa::dereferenceWithWrongType(#_Getter_, #_Table_); \
2759 auto result = std::vector<typename T::iterator>(); \
2760 result.reserve((*mColumnIterator).size()); \
2761 for (auto const& i : *mColumnIterator) { \
2762 auto pos = t->isInSelectedRows(i); \
2764 result.emplace_back(t->iteratorAt(pos)); \
2770 auto _Getter_() const \
2772 return _Getter_##_as<binding_t>(); \
2775 template <typename T> \
2776 auto _Getter_##_first_as() const \
2778 if (O2_BUILTIN_UNLIKELY(mBinding.ptr == nullptr)) { \
2779 o2::soa::notBoundTable(#_Table_); \
2781 auto t = mBinding.get<T>(); \
2782 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2783 o2::soa::dereferenceWithWrongType(#_Getter_, #_Table_); \
2785 return t->rawIteratorAt((*mColumnIterator)[0]); \
2788 template <typename T> \
2789 auto _Getter_##_last_as() const \
2791 if (O2_BUILTIN_UNLIKELY(mBinding.ptr == nullptr)) { \
2792 o2::soa::notBoundTable(#_Table_); \
2794 auto t = mBinding.get<T>(); \
2795 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2796 o2::soa::dereferenceWithWrongType(#_Getter_, #_Table_); \
2798 return t->rawIteratorAt((*mColumnIterator).back()); \
2801 auto _Getter_first() const \
2803 return _Getter_##_first_as<binding_t>(); \
2806 auto _Getter_last() const \
2808 return _Getter_##_last_as<binding_t>(); \
2811 template <typename T> \
2812 bool setCurrent(T const* current) \
2814 if constexpr (o2::soa::is_binding_compatible_v<T, binding_t>()) { \
2815 assert(current != nullptr); \
2816 this->mBinding.bind(current); \
2822 bool setCurrentRaw(o2::soa::Binding current) \
2824 this->mBinding = current; \
2827 binding_t const* getCurrent() const { return mBinding.get<binding_t>(); } \
2828 o2::soa::Binding getCurrentRaw() const { return mBinding; } \
2829 o2::soa::Binding mBinding; \
2832#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_)
2833#define DECLARE_SOA_ARRAY_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_ARRAY_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, _Name_##s, "")
2834#define DECLARE_SOA_ARRAY_INDEX_COLUMN_CUSTOM(_Name_, _Getter_, _Label_) DECLARE_SOA_ARRAY_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, int32_t, _Name_##s, _Label_, "")
2837#define DECLARE_SOA_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, _Type_, _Table_, _Label_, _Suffix_) \
2838 struct _Name_##Id : o2::soa::Column<_Type_, _Name_##Id> { \
2839 static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
2840 static_assert((*_Suffix_ == '\0') || (*_Suffix_ == '_'), "Suffix has to begin with _"); \
2841 static constexpr const char* mLabel = "fIndex" _Label_ _Suffix_; \
2842 static constexpr const uint32_t hash = compile_time_hash(namespace_prefix<_Name_##Id>(), std::string_view{#_Getter_ "Id"}); \
2843 using base = o2::soa::Column<_Type_, _Name_##Id>; \
2844 using type = _Type_; \
2845 using column_t = _Name_##Id; \
2846 using binding_t = _Table_; \
2847 static constexpr auto index_targets = getIndexTargets<_Table_>(); \
2848 _Name_##Id(arrow::ChunkedArray const* column) \
2849 : o2::soa::Column<_Type_, _Name_##Id>(o2::soa::ColumnIterator<type>(column)) \
2853 _Name_##Id() = default; \
2854 _Name_##Id(_Name_##Id const& other) = default; \
2855 _Name_##Id& operator=(_Name_##Id const& other) = default; \
2856 type inline getId() const \
2858 return _Getter_##Id(); \
2861 type _Getter_##Id() const \
2863 return *mColumnIterator; \
2866 bool has_##_Getter_() const \
2868 return *mColumnIterator >= 0; \
2871 template <typename T> \
2872 auto _Getter_##_as() const \
2874 if (O2_BUILTIN_UNLIKELY(mBinding.ptr == nullptr)) { \
2875 o2::soa::notBoundTable(#_Table_); \
2877 if (O2_BUILTIN_UNLIKELY(!has_##_Getter_())) { \
2878 o2::soa::accessingInvalidIndexFor(#_Getter_); \
2880 auto t = mBinding.get<T>(); \
2881 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2882 o2::soa::dereferenceWithWrongType(#_Getter_, #_Table_); \
2884 return t->rawIteratorAt(*mColumnIterator); \
2887 auto _Getter_() const \
2889 return _Getter_##_as<binding_t>(); \
2892 template <typename T> \
2893 bool setCurrent(T* current) \
2895 if constexpr (o2::soa::is_binding_compatible_v<T, binding_t>()) { \
2896 assert(current != nullptr); \
2897 this->mBinding.bind(current); \
2903 bool setCurrentRaw(o2::soa::Binding current) \
2905 this->mBinding = current; \
2908 binding_t const* getCurrent() const { return mBinding.get<binding_t>(); } \
2909 o2::soa::Binding getCurrentRaw() const { return mBinding; } \
2910 o2::soa::Binding mBinding; \
2912 [[maybe_unused]] static constexpr o2::framework::expressions::BindingNode _Getter_##Id { "fIndex" _Label_ _Suffix_, _Name_##Id::hash, o2::framework::expressions::selectArrowType<_Type_>() }
2914#define DECLARE_SOA_INDEX_COLUMN_FULL(_Name_, _Getter_, _Type_, _Table_, _Suffix_) DECLARE_SOA_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, _Type_, _Table_, #_Table_, _Suffix_)
2915#define DECLARE_SOA_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, _Name_##s, "")
2916#define DECLARE_SOA_INDEX_COLUMN_CUSTOM(_Name_, _Getter_, _Label_) DECLARE_SOA_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, int32_t, _Name_##s, _Label_, "")
2919#define DECLARE_SOA_SELF_INDEX_COLUMN_COMPLETE(_Name_, _Getter_, _Type_, _Label_, _IndexTarget_) \
2920 struct _Name_##Id : o2::soa::Column<_Type_, _Name_##Id> { \
2921 static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
2922 static constexpr const char* mLabel = "fIndex" _Label_; \
2923 static constexpr const uint32_t hash = compile_time_hash(namespace_prefix<_Name_##Id>(), std::string_view{#_Getter_ "Id"}); \
2924 using base = o2::soa::Column<_Type_, _Name_##Id>; \
2925 using type = _Type_; \
2926 using column_t = _Name_##Id; \
2927 using self_index_t = std::true_type; \
2928 using compatible_signature = std::conditional<aod::is_aod_hash<_IndexTarget_>, _IndexTarget_, void>; \
2929 _Name_##Id(arrow::ChunkedArray const* column) \
2930 : o2::soa::Column<_Type_, _Name_##Id>(o2::soa::ColumnIterator<type>(column)) \
2934 _Name_##Id() = default; \
2935 _Name_##Id(_Name_##Id const& other) = default; \
2936 _Name_##Id& operator=(_Name_##Id const& other) = default; \
2937 type inline getId() const \
2939 return _Getter_##Id(); \
2942 type _Getter_##Id() const \
2944 return *mColumnIterator; \
2947 bool has_##_Getter_() const \
2949 return *mColumnIterator >= 0; \
2952 template <typename T> \
2953 auto _Getter_##_as() const \
2955 if (O2_BUILTIN_UNLIKELY(!has_##_Getter_())) { \
2956 o2::soa::accessingInvalidIndexFor(#_Getter_); \
2958 auto t = mBinding.get<T>(); \
2959 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2960 o2::soa::dereferenceWithWrongType(#_Getter_, "self"); \
2962 return t->rawIteratorAt(*mColumnIterator); \
2965 bool setCurrentRaw(o2::soa::Binding current) \
2967 this->mBinding = current; \
2970 o2::soa::Binding getCurrentRaw() const { return mBinding; } \
2971 o2::soa::Binding mBinding; \
2973 [[maybe_unused]] static constexpr o2::framework::expressions::BindingNode _Getter_##Id { "fIndex" _Label_, _Name_##Id::hash, o2::framework::expressions::selectArrowType<_Type_>() }
2975#define DECLARE_SOA_SELF_INDEX_COLUMN_FULL(_Name_, _Getter_, _Type_, _Label_) DECLARE_SOA_SELF_INDEX_COLUMN_COMPLETE(_Name_, _Getter_, _Type_, _Label_, void)
2976#define DECLARE_SOA_SELF_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_SELF_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, #_Name_)
2978#define DECLARE_SOA_SELF_SLICE_INDEX_COLUMN_COMPLETE(_Name_, _Getter_, _Type_, _Label_, _IndexTarget_) \
2979 struct _Name_##IdSlice : o2::soa::Column<_Type_[2], _Name_##IdSlice> { \
2980 static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
2981 static constexpr const char* mLabel = "fIndexSlice" _Label_; \
2982 static constexpr const uint32_t hash = 0; \
2983 using base = o2::soa::Column<_Type_[2], _Name_##IdSlice>; \
2984 using type = _Type_[2]; \
2985 using column_t = _Name_##IdSlice; \
2986 using self_index_t = std::true_type; \
2987 using compatible_signature = std::conditional<aod::is_aod_hash<_IndexTarget_>, _IndexTarget_, void>; \
2988 _Name_##IdSlice(arrow::ChunkedArray const* column) \
2989 : o2::soa::Column<_Type_[2], _Name_##IdSlice>(o2::soa::ColumnIterator<type>(column)) \
2993 _Name_##IdSlice() = default; \
2994 _Name_##IdSlice(_Name_##IdSlice const& other) = default; \
2995 _Name_##IdSlice& operator=(_Name_##IdSlice const& other) = default; \
2996 std::array<_Type_, 2> inline getIds() const \
2998 return _Getter_##Ids(); \
3001 bool has_##_Getter_() const \
3003 auto a = *mColumnIterator; \
3004 return a[0] >= 0 && a[1] >= 0; \
3007 std::array<_Type_, 2> _Getter_##Ids() const \
3009 auto a = *mColumnIterator; \
3010 return std::array{a[0], a[1]}; \
3013 template <typename T> \
3014 auto _Getter_##_as() const \
3016 auto t = mBinding.get<T>(); \
3017 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
3018 o2::soa::dereferenceWithWrongType(#_Getter_, "self"); \
3020 if (O2_BUILTIN_UNLIKELY(!has_##_Getter_())) { \
3021 return t->emptySlice(); \
3023 auto a = *mColumnIterator; \
3024 auto r = t->rawSlice(a[0], a[1]); \
3025 t->copyIndexBindings(r); \
3026 r.bindInternalIndicesTo(t); \
3030 bool setCurrentRaw(o2::soa::Binding current) \
3032 this->mBinding = current; \
3035 o2::soa::Binding getCurrentRaw() const { return mBinding; } \
3036 o2::soa::Binding mBinding; \
3039#define DECLARE_SOA_SELF_SLICE_INDEX_COLUMN_FULL(_Name_, _Getter_, _Type_, _Label_) DECLARE_SOA_SELF_SLICE_INDEX_COLUMN_COMPLETE(_Name_, _Getter_, _Type_, _Label_, void)
3040#define DECLARE_SOA_SELF_SLICE_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_SELF_SLICE_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, "_" #_Name_)
3042#define DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN_COMPLETE(_Name_, _Getter_, _Type_, _Label_, _IndexTarget_) \
3043 struct _Name_##Ids : o2::soa::Column<std::vector<_Type_>, _Name_##Ids> { \
3044 static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
3045 static constexpr const char* mLabel = "fIndexArray" _Label_; \
3046 static constexpr const uint32_t hash = 0; \
3047 using base = o2::soa::Column<std::vector<_Type_>, _Name_##Ids>; \
3048 using type = std::vector<_Type_>; \
3049 using column_t = _Name_##Ids; \
3050 using self_index_t = std::true_type; \
3051 using compatible_signature = std::conditional<aod::is_aod_hash<_IndexTarget_>, _IndexTarget_, void>; \
3052 _Name_##Ids(arrow::ChunkedArray const* column) \
3053 : o2::soa::Column<std::vector<_Type_>, _Name_##Ids>(o2::soa::ColumnIterator<type>(column)) \
3057 _Name_##Ids() = default; \
3058 _Name_##Ids(_Name_##Ids const& other) = default; \
3059 _Name_##Ids& operator=(_Name_##Ids const& other) = default; \
3060 gsl::span<const _Type_> inline getIds() const \
3062 return _Getter_##Ids(); \
3065 gsl::span<const _Type_> _Getter_##Ids() const \
3067 return *mColumnIterator; \
3070 bool has_##_Getter_() const \
3072 return !(*mColumnIterator).empty(); \
3075 template <typename T> \
3076 auto _Getter_##_as() const \
3078 auto t = mBinding.get<T>(); \
3079 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
3080 o2::soa::dereferenceWithWrongType(#_Getter_, "self"); \
3082 auto result = std::vector<typename T::unfiltered_iterator>(); \
3083 for (auto& i : *mColumnIterator) { \
3084 result.push_back(t->rawIteratorAt(i)); \
3089 template <typename T> \
3090 auto _Getter_##_first_as() const \
3092 return mBinding.get<T>()->rawIteratorAt((*mColumnIterator)[0]); \
3095 template <typename T> \
3096 auto _Getter_##_last_as() const \
3098 return mBinding.get<T>()->rawIteratorAt((*mColumnIterator).back()); \
3101 bool setCurrentRaw(o2::soa::Binding current) \
3103 this->mBinding = current; \
3106 o2::soa::Binding getCurrentRaw() const { return mBinding; } \
3107 o2::soa::Binding mBinding; \
3110#define DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN_FULL(_Name_, _Getter_, _Type_, _Label_) DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN_COMPLETE(_Name_, _Getter_, _Type_, _Label_, void)
3111#define DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, "_" #_Name_)
3141#define DECLARE_SOA_DYNAMIC_COLUMN(_Name_, _Getter_, ...) \
3142 struct _Name_##Callback { \
3143 static inline constexpr auto getLambda() { return __VA_ARGS__; } \
3146 struct _Name_##Helper { \
3147 using callable_t = decltype(o2::framework::FunctionMetadata(std::declval<decltype(_Name_##Callback::getLambda())>())); \
3148 using return_type = typename callable_t::return_type; \
3150 template <typename... Bindings> \
3151 struct _Name_ : o2::soa::DynamicColumn<typename _Name_##Helper::callable_t::type, _Name_<Bindings...>> { \
3152 using base = o2::soa::DynamicColumn<typename _Name_##Helper::callable_t::type, _Name_<Bindings...>>; \
3153 using helper = _Name_##Helper; \
3154 using callback_holder_t = _Name_##Callback; \
3155 using callable_t = helper::callable_t; \
3156 using callback_t = callable_t::type; \
3157 static constexpr const uint32_t hash = 0; \
3159 _Name_(arrow::ChunkedArray const*) \
3162 _Name_() = default; \
3163 _Name_(_Name_ const& other) = default; \
3164 _Name_& operator=(_Name_ const& other) = default; \
3165 static constexpr const char* mLabel = #_Name_; \
3166 using type = typename callable_t::return_type; \
3168 template <typename... FreeArgs> \
3169 type _Getter_(FreeArgs... freeArgs) const \
3171 return boundGetter(std::make_index_sequence<std::tuple_size_v<decltype(boundIterators)>>{}, freeArgs...); \
3173 template <typename... FreeArgs> \
3174 type getDynamicValue(FreeArgs... freeArgs) const \
3176 return boundGetter(std::make_index_sequence<std::tuple_size_v<decltype(boundIterators)>>{}, freeArgs...); \
3181 return _Getter_(); \
3184 template <size_t... Is, typename... FreeArgs> \
3185 type boundGetter(std::integer_sequence<size_t, Is...>&&, FreeArgs... freeArgs) const \
3187 return __VA_ARGS__((**std::get<Is>(boundIterators))..., freeArgs...); \
3190 using bindings_t = typename o2::framework::pack<Bindings...>; \
3191 std::tuple<o2::soa::ColumnIterator<typename Bindings::type> const*...> boundIterators; \
3194#define DECLARE_SOA_TABLE_METADATA(_Name_, _Desc_, _Version_, ...) \
3195 using _Name_##Metadata = TableMetadata<Hash<_Desc_ "/" #_Version_ ""_h>, __VA_ARGS__>;
3197#define DECLARE_SOA_TABLE_METADATA_TRAIT(_Name_, _Desc_, _Version_) \
3199 struct MetadataTrait<Hash<_Desc_ "/" #_Version_ ""_h>> { \
3200 static constexpr void isMetadataTrait() {}; \
3201 using metadata = _Name_##Metadata; \
3204#define DECLARE_SOA_TABLE_FULL_VERSIONED_(_Name_, _Label_, _Origin_, _Desc_, _Version_) \
3205 O2HASH(_Desc_ "/" #_Version_); \
3206 template <typename O> \
3207 using _Name_##From = o2::soa::Table<Hash<_Label_ ""_h>, Hash<_Desc_ "/" #_Version_ ""_h>, O>; \
3208 using _Name_ = _Name_##From<Hash<_Origin_ ""_h>>; \
3210 struct MetadataTrait<Hash<_Desc_ "/" #_Version_ ""_h>> { \
3211 static constexpr void isMetadataTrait() {}; \
3212 using metadata = _Name_##Metadata; \
3215#define DECLARE_SOA_STAGE(_Name_, _Origin_, _Desc_, _Version_) \
3216 template <typename O> \
3217 using _Name_##From = o2::soa::Table<Hash<#_Name_ ""_h>, Hash<_Desc_ "/" #_Version_ ""_h>, O>; \
3218 using _Name_ = _Name_##From<Hash<_Origin_ ""_h>>;
3220#define DECLARE_SOA_TABLE_FULL_VERSIONED(_Name_, _Label_, _Origin_, _Desc_, _Version_, ...) \
3221 DECLARE_SOA_TABLE_METADATA(_Name_, _Desc_, _Version_, __VA_ARGS__); \
3222 DECLARE_SOA_TABLE_FULL_VERSIONED_(_Name_, _Label_, _Origin_, _Desc_, _Version_);
3224#define DECLARE_SOA_TABLE_FULL(_Name_, _Label_, _Origin_, _Desc_, ...) \
3226 DECLARE_SOA_TABLE_METADATA(_Name_, _Desc_, 0, __VA_ARGS__); \
3227 DECLARE_SOA_TABLE_FULL_VERSIONED_(_Name_, _Label_, _Origin_, _Desc_, 0)
3229#define DECLARE_SOA_TABLE(_Name_, _Origin_, _Desc_, ...) \
3230 DECLARE_SOA_TABLE_FULL(_Name_, #_Name_, _Origin_, _Desc_, __VA_ARGS__)
3232#define DECLARE_SOA_TABLE_VERSIONED(_Name_, _Origin_, _Desc_, _Version_, ...) \
3234 DECLARE_SOA_TABLE_METADATA(_Name_, _Desc_, _Version_, __VA_ARGS__); \
3235 DECLARE_SOA_TABLE_FULL_VERSIONED_(_Name_, #_Name_, _Origin_, _Desc_, _Version_)
3237#define DECLARE_SOA_TABLE_STAGED_VERSIONED(_BaseName_, _Desc_, _Version_, ...) \
3238 O2HASH(_Desc_ "/" #_Version_); \
3239 O2HASH(#_BaseName_); \
3240 O2HASH("Stored" #_BaseName_); \
3241 DECLARE_SOA_TABLE_METADATA(_BaseName_, _Desc_, _Version_, __VA_ARGS__); \
3242 using Stored##_BaseName_##Metadata = _BaseName_##Metadata; \
3243 DECLARE_SOA_TABLE_METADATA_TRAIT(_BaseName_, _Desc_, _Version_); \
3244 DECLARE_SOA_STAGE(_BaseName_, "AOD", _Desc_, _Version_); \
3245 DECLARE_SOA_STAGE(Stored##_BaseName_, "AOD1", _Desc_, _Version_);
3247#define DECLARE_SOA_TABLE_STAGED(_BaseName_, _Desc_, ...) \
3248 DECLARE_SOA_TABLE_STAGED_VERSIONED(_BaseName_, _Desc_, 0, __VA_ARGS__);
3250#define DECLARE_SOA_EXTENDED_TABLE_NG(_Name_, _OriginalTable_, _Desc_, _Version_, ...) \
3251 O2HASH(_Desc_ "/" #_Version_); \
3252 O2HASH(#_Name_ "Extension"); \
3253 template <typename O> \
3254 using _Name_##ExtensionFrom = soa::Table<o2::aod::Hash<#_Name_ "Extension"_h>, o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, O>; \
3255 using _Name_##Extension = _Name_##ExtensionFrom<o2::aod::Hash<"AOD"_h>>; \
3256 struct _Name_##ExtensionMetadata : TableMetadata<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, __VA_ARGS__> { \
3257 using base_table_t = _OriginalTable_; \
3258 template <o2::aod::is_origin_hash O> \
3259 using extension_table_t_from = _Name_##ExtensionFrom<O>; \
3260 using extension_table_t = _Name_##Extension; \
3261 using expression_pack_t = framework::pack<__VA_ARGS__>; \
3262 static constexpr auto N = _OriginalTable_::originals.size(); \
3263 template <o2::aod::is_origin_hash O = o2::aod::Hash<"AOD"_h>> \
3264 static consteval auto generateSources() \
3266 return _OriginalTable_##From<O>::originals; \
3270 struct MetadataTrait<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>> { \
3271 static constexpr void isMetadataTrait() {}; \
3272 using metadata = _Name_##ExtensionMetadata; \
3274 template <typename O> \
3275 using _Name_##From = o2::soa::Join<_OriginalTable_##From<O>, _Name_##ExtensionFrom<O>>; \
3276 using _Name_ = _Name_##From<o2::aod::Hash<"AOD"_h>>;
3278#define DECLARE_SOA_EXTENDED_TABLE(_Name_, _Table_, _Description_, _Version_, ...) \
3279 DECLARE_SOA_EXTENDED_TABLE_NG(_Name_, _Table_, _Description_, _Version_, __VA_ARGS__)
3281#define DECLARE_SOA_EXTENDED_TABLE_USER(_Name_, _Table_, _Description_, ...) \
3282 DECLARE_SOA_EXTENDED_TABLE_NG(_Name_, _Table_, "EX" _Description_, 0, __VA_ARGS__)
3284#define DECLARE_SOA_CONFIGURABLE_EXTENDED_TABLE_NG(_Name_, _OriginalTable_, _Desc_, _Version_, ...) \
3285 O2HASH(_Desc_ "/" #_Version_); \
3286 O2HASH(#_Name_ "CfgExtension"); \
3287 template <typename O> \
3288 using _Name_##CfgExtensionFrom = soa::Table<o2::aod::Hash<#_Name_ "CfgExtension"_h>, o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, O>; \
3289 using _Name_##CfgExtension = _Name_##CfgExtensionFrom<o2::aod::Hash<"AOD"_h>>; \
3290 struct _Name_##CfgExtensionMetadata : TableMetadata<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, __VA_ARGS__> { \
3291 using base_table_t = _OriginalTable_; \
3292 template <o2::aod::is_origin_hash O> \
3293 using extension_table_t_from = _Name_##CfgExtensionFrom<O>; \
3294 using extension_table_t = _Name_##CfgExtension; \
3295 using placeholders_pack_t = framework::pack<__VA_ARGS__>; \
3296 using configurable_t = std::true_type; \
3297 static constexpr auto N = _OriginalTable_::originals.size(); \
3298 template <o2::aod::is_origin_hash O = o2::aod::Hash<"AOD"_h>> \
3299 static consteval auto generateSources() \
3301 return _OriginalTable_##From<O>::originals; \
3305 struct MetadataTrait<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>> { \
3306 static constexpr void isMetadataTrait() {}; \
3307 using metadata = _Name_##CfgExtensionMetadata; \
3309 template <typename O> \
3310 using _Name_##From = o2::soa::Join<_OriginalTable_##From<O>, _Name_##CfgExtensionFrom<O>>; \
3311 using _Name_ = _Name_##From<o2::aod::Hash<"AOD"_h>>;
3313#define DECLARE_SOA_CONFIGURABLE_EXTENDED_TABLE(_Name_, _OriginalTable_, _Description_, ...) \
3314 DECLARE_SOA_CONFIGURABLE_EXTENDED_TABLE_NG(_Name_, _OriginalTable_, "EX" _Description_, 0, __VA_ARGS__)
3316#define DECLARE_SOA_INDEX_TABLE_NG(_Name_, _Key_, _Version_, _Desc_, _Exclusive_, ...) \
3318 O2HASH(_Desc_ "/" #_Version_); \
3319 struct _Name_##Metadata : o2::aod::TableMetadata<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, soa::Index<>, __VA_ARGS__> { \
3320 static constexpr bool exclusive = _Exclusive_; \
3321 template <o2::aod::is_origin_hash O> \
3322 using KeyFrom = _Key_##From<O>; \
3323 using Key = _Key_; \
3324 using index_pack_t = framework::pack<__VA_ARGS__>; \
3325 template <o2::aod::is_origin_hash O = o2::aod::Hash<"AOD"_h>> \
3326 static consteval auto generateSources() \
3328 return []<soa::is_index_column... Cs>(framework::pack<Cs...>) { \
3329 constexpr auto first = o2::soa::mergeOriginals<typename Cs::binding_t...>(); \
3330 constexpr auto second = o2::aod::filterForKey<first.size(), first, Key>(); \
3331 return o2::aod::replaceOrigin<second.size(), second, O>(); \
3332 }(framework::pack<__VA_ARGS__>{}); \
3334 static constexpr auto N = []<typename... Cs>(framework::pack<Cs...>) { \
3335 constexpr auto a = o2::soa::mergeOriginals<typename Cs::binding_t...>(); \
3336 return o2::aod::filterForKey<a.size(), a, Key>(); \
3337 }(framework::pack<__VA_ARGS__>{}) \
3341 struct MetadataTrait<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>> { \
3342 static constexpr void isMetadataTrait() {}; \
3343 using metadata = _Name_##Metadata; \
3345 template <o2::aod::is_origin_hash O> \
3346 using _Name_##From = o2::soa::IndexTable<o2::aod::Hash<#_Name_ ""_h>, o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, O, _Key_##From<O>, __VA_ARGS__>; \
3347 using _Name_ = _Name_##From<o2::aod::Hash<"AOD"_h>>;
3349#define DECLARE_SOA_INDEX_TABLE(_Name_, _Key_, _Description_, ...) \
3350 DECLARE_SOA_INDEX_TABLE_NG(_Name_, _Key_, 0, _Description_, false, __VA_ARGS__)
3352#define DECLARE_SOA_INDEX_TABLE_EXCLUSIVE(_Name_, _Key_, _Description_, ...) \
3353 DECLARE_SOA_INDEX_TABLE_NG(_Name_, _Key_, 0, _Description_, true, __VA_ARGS__)
3355#define DECLARE_SOA_INDEX_TABLE_USER(_Name_, _Key_, _Description_, ...) \
3356 DECLARE_SOA_INDEX_TABLE_NG(_Name_, _Key_, 0, _Description_, false, __VA_ARGS__)
3358#define DECLARE_SOA_INDEX_TABLE_EXCLUSIVE_USER(_Name_, _Key_, _Description_, ...) \
3359 DECLARE_SOA_INDEX_TABLE_NG(_Name_, _Key_, 0, _Description_, true, __VA_ARGS__)
3366#define DECLARE_SOA_TIMESTAMPED_TABLE_FULL(_Name_, _Label_, _TimestampSource_, _TimestampColumn_, _Version_, _Desc_, ...) \
3367 O2HASH(_Desc_ "/" #_Version_); \
3368 template <typename O> \
3369 using _Name_##TimestampFrom = soa::Table<o2::aod::Hash<_Label_ ""_h>, o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, O>; \
3370 using _Name_##Timestamp = _Name_##TimestampFrom<o2::aod::Hash< \
3373 struct _Name_##TimestampMetadata : TableMetadata<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, __VA_ARGS__> { \
3374 template <typename O = o2::aod::Hash<"AOD" \
3376 using base_table_t = _TimestampSource_##From<O>; \
3377 template <typename O = o2::aod::Hash<"AOD" \
3379 using extension_table_t = _Name_##TimestampFrom<O>; \
3380 static constexpr const auto ccdb_urls = []<typename... Cs>(framework::pack<Cs...>) { \
3381 return std::array<std::string_view, sizeof...(Cs)>{Cs::query...}; \
3382 }(framework::pack<__VA_ARGS__>{}); \
3383 static constexpr const auto ccdb_bindings = []<typename... Cs>(framework::pack<Cs...>) { \
3384 return std::array<std::string_view, sizeof...(Cs)>{Cs::mLabel...}; \
3385 }(framework::pack<__VA_ARGS__>{}); \
3386 static constexpr auto N = _TimestampSource_::originals.size(); \
3387 template <o2::aod::is_origin_hash O = o2::aod::Hash<"AOD"_h>> \
3388 static consteval auto generateSources() \
3390 return _TimestampSource_##From<O>::originals; \
3392 static constexpr auto timestamp_column_label = _TimestampColumn_::mLabel; \
3396 struct MetadataTrait<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>> { \
3397 static constexpr void isMetadataTrait() {}; \
3398 using metadata = _Name_##TimestampMetadata; \
3400 template <typename O> \
3401 using _Name_##From = o2::soa::Join<_TimestampSource_, _Name_##TimestampFrom<O>>; \
3402 using _Name_ = _Name_##From<o2::aod::Hash< \
3406#define DECLARE_SOA_TIMESTAMPED_TABLE(_Name_, _TimestampSource_, _TimestampColumn_, _Version_, _Desc_, ...) \
3407 O2HASH(#_Name_ "Timestamped"); \
3408 DECLARE_SOA_TIMESTAMPED_TABLE_FULL(_Name_, #_Name_ "Timestamped", _TimestampSource_, _TimestampColumn_, _Version_, _Desc_, __VA_ARGS__)
3412template <
typename...
Ts>
3413struct Join :
Table<o2::aod::Hash<"JOIN"_h>, o2::aod::Hash<"JOIN/0"_h>, o2::aod::Hash<"JOIN"_h>, Ts...> {
3417 Join(std::vector<ArrowTableRef>&& tables)
3430 template <
typename... TA>
3474 template <
typename T1,
typename Policy,
bool OPT>
3502 template <
typename T>
3505 return []<
size_t... Is>(std::index_sequence<Is...>) {
3506 return (std::ranges::any_of(
originals, [](
TableRef const&
ref) {
return ref.desc_hash == T::originals[Is].desc_hash; }) && ...);
3507 }(std::make_index_sequence<T::originals.size()>());
3511template <
typename...
Ts>
3517template <
typename T>
3520template <
typename...
Ts>
3521struct Concat :
Table<o2::aod::Hash<"CONC"_h>, o2::aod::Hash<"CONC/0"_h>, o2::aod::Hash<"CONC"_h>, Ts...> {
3546 using base::originals;
3548 using base::bindExternalIndices;
3549 using base::bindInternalIndicesTo;
3563template <
typename...
Ts>
3569template <
typename S>
3572template <soa::is_table T>
3580 static constexpr const uint32_t binding_origin = T::binding_origin;
3582 template <
typename... TA>
3586 if constexpr (binding_origin == TA::binding_origin) {
3587 this->bindExternalIndex(cur);
3588 mFilteredBegin.bindExternalIndex(cur);
3597 using iterator = T::template iterator_template_o<FilteredIndexPolicy, self_t>;
3602 : T{
std::move(tables)}
3604 adoptSelection(selection);
3605 if (this->tableSize() != 0) {
3606 mFilteredBegin = table_t::filtered_begin(mSelectedRows);
3609 mFilteredBegin.bindInternalIndices(
this);
3636 return mFilteredBegin;
3641 return mFilteredBegin;
3646 return mFilteredBegin +
i;
3651 return mSelectedRows.size();
3656 return this->asArrowTableRef().range.size;
3661 return mSelectedRows;
3668 std::iota(newSelection.begin(), newSelection.end(),
start);
3669 return self_t{{this->asArrowTableRef()}, std::move(newSelection)};
3679 if (sel ==
nullptr) {
3680 return std::span<int64_t const>{};
3682 auto array = std::static_pointer_cast<arrow::Int64Array>(sel->ToArray());
3685 return std::span{
start, stop};
3692 mFilteredBegin.bindExternalIndicesRaw(std::forward<std::vector<o2::soa::Binding>>(ptrs));
3695 template <
typename I>
3698 mFilteredBegin.bindInternalIndices(
ptr);
3701 template <
typename T1,
typename... Cs>
3704 dest.bindExternalIndicesRaw(mFilteredBegin.getIndexBindings());
3707 template <
typename T1>
3713 template <
typename T1>
3729 template <
typename T1,
bool OPT>
3735 template <
typename T1,
bool OPT>
3744 copyIndexBindings(t);
3750 auto locate = std::find(mSelectedRows.begin(), mSelectedRows.end(),
i);
3751 if (locate == mSelectedRows.end()) {
3754 return static_cast<int>(std::distance(mSelectedRows.begin(), locate));
3761 std::ranges::set_union(mSelectedRows, selection, std::back_inserter(rowsUnion));
3762 mSelectedRowsCache.clear();
3763 mSelectedRowsCache = rowsUnion;
3771 std::ranges::set_intersection(mSelectedRows, selection, std::back_inserter(intersection));
3772 mSelectedRowsCache.clear();
3773 mSelectedRowsCache = intersection;
3781#if (FAIRMQ_VERSION_DEC >= 111000)
3782 void setPointerReconstructor(framework::PointerReconstructor
const& pointerReconstructor)
3784 mFilteredBegin.setPointerReconstructor(pointerReconstructor);
3791 mSelectedRows = std::span{mSelectedRowsCache};
3795 mFilteredBegin = *mFilteredEnd;
3797 mFilteredBegin.resetSelection(mSelectedRows);
3801 template <
typename S>
3802 inline void adoptSelection(
S)
3806 template <
typename S>
3808 inline void adoptSelection(
S selection)
3810 mSelectedRows = getSpan(selection);
3814 template <
typename S>
3816 inline void adoptSelection(
S selection)
3818 mSelectedRowsCache = std::move(selection);
3819 mSelectedRows = std::span{mSelectedRowsCache};
3823 template <
typename S>
3824 requires(std::same_as<std::decay_t<S>, std::span<int64_t const>>)
3825 inline void adoptSelection(
S selection)
3827 mSelectedRows = selection;
3831 std::span<int64_t const> mSelectedRows;
3833 bool mCached =
false;
3834 iterator mFilteredBegin;
3835 std::shared_ptr<RowViewSentinel> mFilteredEnd;
3838template <
typename T>
3847 using iterator = T::template iterator_template_o<FilteredIndexPolicy, self_t>;
3853 return iterator(this->cached_begin());
3862 :
FilteredBase<T>{std::move(tables), std::forward<decltype(selection)>(selection)} {}
3878 this->sumWithSelection(selection);
3884 return operator+=(
other.getSelectedRows());
3896 return operator*(
other.getSelectedRows());
3901 this->intersectWithSelection(selection);
3907 return operator*=(
other.getSelectedRows());
3923 std::iota(newSelection.begin(), newSelection.end(),
start);
3924 return self_t{{this->asArrowTableRef()}, std::move(newSelection)};
3932 template <
typename T1>
3948 template <
typename T1,
bool OPT>
3954 template <
typename T1,
bool OPT>
3963 copyIndexBindings(t);
3968template <
typename T>
3977 using iterator =
typename T::template iterator_template_o<FilteredIndexPolicy, self_t>;
3983 return iterator(this->cached_begin());
3992 :
FilteredBase<typename T::
table_t>(
std::move(extractTablesFromFiltered(tables)),
std::forward<decltype(selection)>(selection))
3994 for (
auto& table : tables) {
4013 this->sumWithSelection(selection);
4019 return operator+=(
other.getSelectedRows());
4025 copy.intersectionWithSelection(selection);
4031 return operator*(
other.getSelectedRows());
4036 this->intersectWithSelection(selection);
4042 return operator*=(
other.getSelectedRows());
4056 std::iota(newSelection.begin(), newSelection.end(),
start);
4057 return self_t{{this->asArrowTableRef()}, std::move(newSelection)};
4075 template <
typename T1,
bool OPT>
4081 template <
typename T1,
bool OPT>
4088 std::vector<ArrowTableRef> extractTablesFromFiltered(std::vector<
Filtered<T>>& tables)
4090 std::vector<ArrowTableRef> outTables;
4091 for (
auto& table : tables) {
4092 outTables.push_back(table.asArrowTableRef());
4103template <
typename L,
typename D,
typename O,
typename Key,
typename H,
typename...
Ts>
4114 static constexpr const uint32_t binding_origin = Key::binding_origin;
4117 template <
typename... TA>
4121 if constexpr (binding_origin == TA::binding_origin) {
4122 this->bindExternalIndex(cur);
4147template <
typename T,
bool APPLY>
4150 static constexpr bool applyFilters = APPLY;
4156template <
typename T>
4159template <
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
uint64_t const * mGlobalOffset
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
typename T::external_index_columns_t external_index_columns_t
auto select(framework::expressions::Filter const &f) const
static auto getSpan(gandiva::Selection const &sel)
T::template iterator_template_o< FilteredIndexPolicy, self_t > iterator
auto rawSliceBy(o2::framework::Preslice< T1 > const &container, int value) const
T::template iterator_template_o< DefaultIndexPolicy, self_t > unfiltered_iterator
void copyIndexBindings(T1 &dest) const
auto const & getSelectedRows() const
typename T::columns_t columns_t
void bindExternalIndices(TA *... current)
void sumWithSelection(is_a_selection auto selection)
void bindInternalIndicesTo(I const *ptr)
FilteredBase(std::vector< ArrowTableRef > &&tables, is_a_selection auto selection)
auto sliceBy(o2::framework::PresliceBase< T1, framework::PreslicePolicyGeneral, OPT > const &container, int value) const
auto rawSlice(uint64_t start, uint64_t end) const
auto sliceBy(o2::framework::PresliceBase< T1, framework::PreslicePolicySorted, OPT > const &container, int value) const
iterator iteratorAt(uint64_t i) const
typename T::table_t table_t
typename T::persistent_columns_t persistent_columns_t
static constexpr void isFilteredBase()
RowViewSentinel end() const
void intersectWithSelection(is_a_selection auto selection)
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(std::vector< Filtered< T > > &&tables, is_a_selection auto selection)
typename FilteredBase< typename T::table_t >::table_t table_t
typename T::template iterator_template_o< DefaultIndexPolicy, self_t > unfiltered_iterator
auto sliceBy(o2::framework::PresliceBase< T1, framework::PreslicePolicyGeneral, OPT > const &container, int value) const
typename T::template iterator_template_o< FilteredIndexPolicy, self_t > iterator
typename T::columns_t columns_t
const_iterator begin() const
Filtered< Filtered< T > > operator+=(is_a_selection auto selection)
Filtered< Filtered< T > > operator*(is_a_selection auto selection)
Filtered< Filtered< T > > operator+(is_a_selection auto selection)
unfiltered_iterator rawIteratorAt(uint64_t i) const
Filtered< Filtered< T > > operator*=(is_a_selection auto selection)
Filtered< Filtered< T > > operator+=(Filtered< T > const &other)
auto rawSlice(uint64_t start, uint64_t end) const
Filtered< Filtered< T > > operator+(Filtered< T > const &other)
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)
auto sliceByCachedUnsorted(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
Filtered< T > operator+=(Filtered< T > const &other)
Filtered(std::vector< ArrowTableRef > &&tables, is_a_selection auto selection)
auto sliceBy(o2::framework::PresliceBase< T1, framework::PreslicePolicyGeneral, OPT > const &container, int value) const
auto sliceByCachedUnsorted(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
Filtered< T > operator+(Filtered< T > const &other)
const_iterator begin() const
Filtered< T > operator+(is_a_selection auto selection)
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*(is_a_selection auto selection)
T::template iterator_template_o< DefaultIndexPolicy, self_t > unfiltered_iterator
unfiltered_iterator rawIteratorAt(uint64_t i) const
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
auto rawSlice(uint64_t start, uint64_t end) const
auto sliceBy(o2::framework::PresliceBase< T1, framework::PreslicePolicySorted, OPT > const &container, int value) const
typename T::table_t table_t
typename T::columns_t columns_t
Filtered< T > operator+=(is_a_selection auto selection)
Filtered< T > operator*=(is_a_selection auto selection)
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
Table(std::vector< o2::soa::ArrowTableRef > &&tables)
void bindExternalIndices(TA *... current)
auto select(framework::expressions::Filter const &f) const
unfiltered_iterator unfiltered_const_iterator
decltype([]() { if constexpr(sizeof...(Ts)==0) { return iterator_template< IP, Parent >{} iterator_template_o
auto const & cached_begin() const
auto sliceByCachedUnsorted(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
TableIteratorBase< IP, Parent, T... > iterator_template
static constexpr header::DataOrigin binding_origin_
void bindExternalIndicesRaw(std::vector< o2::soa::Binding > &&ptrs)
auto sliceBy(o2::framework::PresliceBase< T1, Policy, OPT > const &container, int value) const
static constexpr auto hashes()
iterator unfiltered_iterator
void bindExternalIndex(TA *current)
std::shared_ptr< arrow::Table > asArrowTable() const
Return a type erased arrow table backing store for / the type safe table.
filtered_iterator filtered_begin(std::span< int64_t const > selection)
void doCopyIndexBindings(framework::pack< Cs... >, T &dest) const
int64_t size() const
Size of the table, in rows.
decltype(getColumns< ref, Ts... >()) columns_t
arrow::ChunkedArray * getIndexToKey()
ArrowTableRef asArrowTableRef() const
decltype([]< typename... C >(framework::pack< C... >) -> framework::pack< typename C::type... > {}(persistent_columns_t{})) column_types
static constexpr const uint32_t binding_origin
static consteval auto isIndexTargetOf()
std::shared_ptr< arrow::Table > asArrowTableConstrained() const
iterator_template_o< FilteredIndexPolicy, table_t > filtered_iterator
unfiltered_const_iterator begin() const
void copyIndexBindings(T &dest) const
static constexpr const auto originalLabels
Table< L, D, O, Ts... > self_t
static consteval auto isIndexTargetOf()
void doBindInternalIndicesExplicit(framework::pack< Cs... >, o2::soa::Binding binding)
static constexpr const auto originals
Table(std::vector< std::shared_ptr< arrow::Table > > &&tables)
Table(std::shared_ptr< arrow::Table > table)
Table(o2::soa::ArrowTableRef tableRef)
Table(std::vector< std::shared_ptr< arrow::Table > > &&tables)
decltype([]< typename... C >(framework::pack< C... > &&) -> framework::selected_pack< soa::is_external_index_t, C... > {}(columns_t{})) external_index_columns_t
RowViewSentinel end() const
static constexpr void isSOATable()
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
Table(std::vector< o2::soa::ArrowTableRef > &&tables)
iterator_template_o< DefaultIndexPolicy, table_t > iterator
GLuint GLsizei const GLuint const GLintptr * offsets
GLuint const GLchar * name
GLboolean GLboolean GLboolean b
GLsizei const GLfloat * value
GLint GLint GLsizei GLint GLenum GLenum type
GLuint GLsizei GLsizei * length
GLuint GLsizei const GLchar * label
GLsizei GLenum const void * indices
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GLenum GLenum GLsizei len
GLboolean GLboolean GLboolean GLboolean a
std::shared_ptr< gandiva::SelectionVector > Selection
consteval const char * origin_str()
consteval const char * signature()
consteval auto replaceOrigin()
Replace origins in the TableRef array.
constexpr framework::ConcreteDataMatcher matcher()
consteval auto filterForKey()
Filter TableRef array for compatibility with Key table.
consteval const char * label()
consteval header::DataOrigin origin()
gandiva::Selection createSelection(std::shared_ptr< arrow::Table > const &table, Filter const &expression)
Function for creating gandiva selection from our internal filter tree.
Defining ITS Vertex explicitly as messageable.
std::decay_t< decltype(select_pack< Condition >(pack<>{}, Pack{}, CondPack{}))> selected_pack_multicondition
std::decay_t< decltype(prune_voids_pack(pack<>{}, with_condition_pack< Condition, Types... >{}))> selected_pack
decltype(intersected_pack(Ps{}...)) full_intersected_pack_t
typename pack_element< I, T >::type pack_element_t
consteval size_t has_type_at_v(pack< Ts... >)
constexpr std::size_t pack_size(pack< Ts... > const &)
template function to determine number of types in a pack
decltype(concatenate_pack_unique(Ps{}...)) concatenated_pack_unique_t
std::string strToUpper(std::string &&str)
typename pack_element< 0, T >::type pack_head_t
std::string cutString(std::string &&str)
std::vector< std::vector< int64_t > > ListVector
R getColumnValue(const T &rowIterator)
ColumnGetterFunction< R, typename T::iterator > getColumnGetterByLabel(const std::string_view &targetColumnLabel)
void * extractCCDBPayload(char *payload, size_t size, TClass const *cl, const char *what)
consteval auto computeOriginals()
auto createFieldsFromColumns(framework::pack< C... >)
SelectionVector selectionToVector(gandiva::Selection const &sel)
constexpr bool is_persistent_v
column identification
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)
consteval bool is_binding_compatible_v()
typename unwrap< T >::type unwrap_t
auto prepareFilteredSlice(T const *table, o2::soa::ArrowTableRef slice)
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)
constexpr char asciiToLower(char c)
auto doSliceByHelper(T const *table, std::span< const int64_t > const &selection)
std::function< framework::ConcreteDataMatcher(framework::ConcreteDataMatcher &&)> originReplacement(header::DataOrigin newOrigin)
consteval bool is_compatible()
arrow::ChunkedArray * getIndexFromLabel(arrow::Table *table, std::string_view label)
consteval auto merge()
Helpers to manipulate TableRef arrays.
consteval auto merge_if(L l)
std::conditional_t< is_persistent_column< C >, std::true_type, std::false_type > is_persistent_column_t
typename arrow_array_for< T >::type arrow_array_for_t
void notFoundColumn(const char *label, const char *key)
std::conditional_t< is_dynamic_column< T >, std::true_type, std::false_type > is_dynamic_t
pack filtering helpers
typename std::conditional_t< is_self_index_column< C >, std::true_type, std::false_type > is_self_index_t
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
FIXME: do not use data model tables.
static constexpr uint32_t hash
static constexpr char const *const str
static constexpr void isHash()
SliceInfoUnsortedPtr getCacheUnsortedFor(Entry const &bindingKey) const
header::DataOrigin newOrigin
SliceInfoPtr getCacheFor(Entry const &bindingKey) const
static constexpr bool optional
PresliceBase(expressions::BindingNode index_)
std::span< const int64_t > getSliceFor(int value) const
const std::string binding
o2::soa::ArrowTableRef getSliceFor(int value, o2::soa::ArrowTableRef const &input) const
static constexpr void isPresliceContainer()
static constexpr void isPresliceGroup()
tracks origin in bindingKey matcher to handle the correct arguments
const std::string binding
Entry const & getBindingKey() const
static constexpr void isPreslicePolicy()
SliceInfoUnsortedPtr sliceInfo
std::span< const int64_t > getSliceFor(int value) const
void updateSliceInfo(SliceInfoUnsortedPtr &&si)
o2::soa::ArrowTableRef getSliceFor(int value, o2::soa::ArrowTableRef const &input) const
void updateSliceInfo(SliceInfoPtr &&si)
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 o2::soa::ArrowTableRef concatTables(std::vector< std::shared_ptr< arrow::Table > > &&tables)
static o2::soa::ArrowTableRef joinTables(std::vector< std::shared_ptr< arrow::Table > > &&tables)
static o2::soa::ArrowTableRef concatTables(std::vector< o2::soa::ArrowTableRef > &&tables)
ArrowTableRef makeEmpty() const
std::shared_ptr< arrow::Table > tablePtr
ArrowTableRef slice(ArrowRange newRange) const
Type-checking index column binding.
void bind(T const *table)
static constexpr bool chunked
arrow::ChunkedArray * second
Column(ColumnIterator< T > const &it)
static constexpr const char *const & columnLabel()
ColumnIterator< T > const & getIterator() const
Column & operator=(Column const &)=default
Column(Column &&)=default
static auto asArrowField()
Column & operator=(Column &&)=default
Column(Column const &)=default
static constexpr void isIteratableColumn()
ColumnIterator< T > mColumnIterator
Concat(std::shared_ptr< arrow::Table > table)
table_t::template iterator_template< DefaultIndexPolicy, self_t, Ts... > iterator
typename table_t::persistent_columns_t persistent_columns_t
typename table_t::columns_t columns_t
Concat(std::vector< ArrowTableRef > &&tables)
const_iterator unfiltered_const_iterator
iterator unfiltered_iterator
table_t::template iterator_template< FilteredIndexPolicy, self_t, Ts... > filtered_iterator
Concat(ArrowTableRef table)
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
static constexpr void isDefaultIndexPolicy()
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()
static constexpr void isDynamicColumn()
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)
static constexpr void isFilteredIndexPolicy()
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 void isEnumeratingColumn()
static constexpr const uint32_t hash
uint64_t mOffset
Offset within a larger table.
int64_t mRowIndex
Position inside the current table.
static constexpr void isIndexTable()
void bindExternalIndices(TA *... current)
IndexTable(ArrowTableRef table)
typename base_t::template iterator_template_o< DefaultIndexPolicy, self_t > iterator
filtered_iterator const_filtered_iterator
IndexTable(IndexTable &&)=default
IndexTable(std::vector< ArrowTableRef > &&tables)
IndexTable & operator=(IndexTable const &)=default
IndexTable & operator=(IndexTable &&)=default
typename H::binding_t first_t
typename base_t::template iterator_template_o< FilteredIndexPolicy, self_t > filtered_iterator
IndexTable(IndexTable const &)=default
Index(Index const &)=default
void setIndices(std::tuple< int64_t const *, int64_t const * > indices)
Index & operator=(Index &&)=default
Index(arrow::ChunkedArray const *)
int64_t filteredIndex() const
constexpr int64_t rangeEnd()
constexpr int64_t rangeStart()
Index & operator=(Index const &)=default
int64_t globalIndex() const
std::tuple< int64_t const *, int64_t const * > rowIndices
void setOffsets(std::tuple< uint64_t const * > offsets)
static constexpr const char * mLabel
std::tuple< uint64_t const * > rowOffsets
auto sliceBy(o2::framework::PresliceBase< T1, Policy, OPT > const &container, int value) const
static constexpr const auto originalLabels
static constexpr const auto originals
iterator rawIteratorAt(uint64_t i) const
static constexpr const uint32_t binding_origin
auto sliceByCached(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
const_iterator unfiltered_const_iterator
typename table_t::columns_t columns_t
Table< o2::aod::Hash<"JOIN"_h >, o2::aod::Hash<"JOIN/0"_h >, o2::aod::Hash<"JOIN"_h >, Ts... > base
iterator iteratorAt(uint64_t i) const
typename table_t::persistent_columns_t persistent_columns_t
const_iterator begin() const
void bindExternalIndices(TA *... current)
table_t::template iterator_template< DefaultIndexPolicy, self_t, Ts... > iterator
static consteval bool contains()
static constexpr void isJoin()
Join(std::vector< ArrowTableRef > &&tables)
table_t::template iterator_template< FilteredIndexPolicy, self_t, Ts... > filtered_iterator
auto sliceByCachedUnsorted(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
auto rawSlice(uint64_t start, uint64_t end) const
static constexpr const header::DataOrigin binding_origin_
iterator unfiltered_iterator
filtered_iterator filtered_const_iterator
static constexpr const uint32_t hash
static constexpr const char *const & columnLabel()
static constexpr void isMarkingColumn()
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
static constexpr void isRowViewSentinel()
SmallGroupsBase(std::vector< ArrowTableRef > &&tables, is_a_selection auto selection)
static constexpr void isSmallGroups()
framework::selected_pack< soa::is_persistent_column_t, C... > persistent_columns_t
void doSetCurrentIndexRaw(framework::pack< Cs... > p, std::vector< o2::soa::Binding > &&ptrs)
void bindInternalIndices(I const *table)
TableIterator(TableIterator< D, O, FilteredIndexPolicy, C... > const &other)
TableIterator(self_t const &other)
TableIterator operator-(int64_t dec) const
TableIterator(arrow::ChunkedArray *columnData[sizeof...(C)], IP &&policy)
TableIterator & operator=(TableIterator other)
TableIterator & operator++()
void bindExternalIndex(TA *current)
void doSetCurrentInternal(framework::pack< Cs... >, I const *ptr)
auto getIndexBindingsImpl(framework::pack< Cs... >) const
TableIterator operator--(int)
void bindExternalIndicesRaw(std::vector< o2::soa::Binding > &&ptrs)
TableIterator(arrow::ChunkedArray *columnData[sizeof...(C)], IP &&policy)
decltype([]< typename... Cs >(framework::pack< Cs... >) -> framework::pack< typename Cs::binding_t... > {}(external_index_columns_t{})) bindings_pack_t
void bindExternalIndices(TA *... current)
TableIterator & operator--()
framework::selected_pack< soa::is_external_index_t, C... > external_index_columns_t
TableIterator const & operator*() const
static constexpr void isTableIterator()
TableIterator operator++(int)
framework::selected_pack< soa::is_self_index_t, C... > internal_index_columns_t
auto getIndexBindings() const
TableIterator operator+(int64_t inc) const
Allow incrementing by more than one the iterator.
framework::pack< C... > all_columns
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