12#ifndef O2_FRAMEWORK_ASOA_H_
13#define O2_FRAMEWORK_ASOA_H_
27#include <arrow/array/array_binary.h>
28#include <arrow/table.h>
29#include <arrow/array.h>
30#include <arrow/util/config.h>
31#include <gandiva/selection_vector.h>
34#include <fmt/format.h>
41using ListVector = std::vector<std::vector<int64_t>>;
57template <
typename...
C>
60 return std::vector<std::shared_ptr<arrow::Field>>{C::asArrowField()...};
75 consteval TableRef(uint32_t _label, uint32_t _desc, uint32_t _origin, uint32_t _version)
89 return (this->label_hash ==
other.label_hash) &&
90 (this->desc_hash ==
other.desc_hash) &&
91 (this->origin_hash ==
other.origin_hash) &&
92 (this->version ==
other.version);
97 return this->desc_hash ==
other.desc_hash;
102 return this->desc_hash == _desc_hash;
112template <
size_t N1,
size_t N2, std::array<TableRef, N1> ar1, std::array<TableRef, N2> ar2>
115 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; }); });
116 std::array<TableRef, N1 + N2 - duplicates> out;
118 auto pos = std::copy(ar1.begin(), ar1.end(), out.begin());
119 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; }); });
123template <
size_t N1,
size_t N2, std::array<TableRef, N1> ar1, std::array<TableRef, N2> ar2,
typename L>
126 constexpr const int to_remove = std::ranges::count_if(ar1.begin(), ar1.end(), [&](
TableRef const&
a) { return !l(a); });
127 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); });
128 std::array<TableRef, N1 + N2 - duplicates - to_remove> out;
130 auto pos = std::copy_if(ar1.begin(), ar1.end(), out.begin(), [&](TableRef
const&
a) { return l(a); });
131 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); });
135template <
size_t N, std::array<TableRef, N> ar,
typename L>
138 constexpr const int to_remove = std::ranges::count_if(ar.begin(), ar.end(), [&l](
TableRef const& e) { return l(e); });
139 std::array<
TableRef, N - to_remove> out;
140 std::copy_if(ar.begin(), ar.end(), out.begin(), [&l](
TableRef const& e) { return !l(e); });
144template <
size_t N1,
size_t N2, std::array<TableRef, N1> ar1, std::array<TableRef, N2> ar2>
145consteval auto intersect()
147 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; }); });
148 std::array<TableRef, duplicates> out;
149 std::copy_if(ar1.begin(), ar1.end(), out.begin(), [](TableRef
const&
a) { return std::find(ar2.begin(), ar2.end(), a) != ar2.end(); });
153template <
typename T,
typename... Ts>
155 requires(
sizeof...(Ts) == 1)
158 return merge<T::originals.size(), T1::originals.size(), T::originals, T1::originals>();
161template <
typename T,
typename...
Ts>
163 requires(
sizeof...(Ts) > 1)
166 return merge<T::originals.size(), tail.size(), T::originals, tail>();
169template <
typename T,
typename...
Ts>
170 requires(
sizeof...(Ts) == 1)
171consteval auto intersectOriginals()
174 return intersect<T::originals.size(), T1::originals.size(), T::originals, T1::originals>();
177template <
typename T,
typename...
Ts>
178 requires(
sizeof...(Ts) > 1)
179consteval auto intersectOriginals()
182 return intersect<T::originals.size(), tail.size(), T::originals, tail>();
191concept not_void =
requires { !std::same_as<T, void>; };
208 {
c.setCurrentRaw(
b) } -> std::same_as<bool>;
213using is_external_index_t =
typename std::conditional_t<is_index_column<C>, std::true_type, std::false_type>;
216using is_self_index_t =
typename std::conditional_t<is_self_index_column<C>, std::true_type, std::false_type>;
223template <
typename Key,
size_t N, std::array<
bool, N> map>
224static consteval int getIndexPosToKey_impl()
226 constexpr const auto pos = std::find(map.begin(), map.end(),
true);
227 if constexpr (
pos != map.end()) {
228 return std::distance(map.begin(),
pos);
236template <
typename D,
typename... Cs>
243 template <
typename Key,
typename... PCs>
246 return std::array<bool,
sizeof...(PCs)>{[]() {
247 if constexpr (
requires { PCs::index_targets.size(); }) {
248 return Key::template isIndexTargetOf<PCs::index_targets.size(), PCs::index_targets>();
255 template <
typename Key>
276 static constexpr uint32_t
hash = H;
277 static constexpr char const*
const str{
""};
281template <
size_t N, std::array<soa::TableRef, N> ar,
typename Key>
284 constexpr std::array<bool, N>
test = []<
size_t... Is>(std::index_sequence<Is...>) {
285 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))...};
286 }(std::make_index_sequence<N>());
287 constexpr int correct = std::ranges::count(
test.begin(),
test.end(),
true);
288 std::array<soa::TableRef, correct> out;
289 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))]; });
294#define O2HASH(_Str_) \
296 struct Hash<_Str_ ""_h> { \
297 static constexpr uint32_t hash = _Str_ ""_h; \
298 static constexpr char const* const str{_Str_}; \
302#define O2ORIGIN(_Str_) \
304 struct Hash<_Str_ ""_h> { \
305 static constexpr header::DataOrigin origin{_Str_}; \
306 static constexpr uint32_t hash = _Str_ ""_h; \
307 static constexpr char const* const str{_Str_}; \
311static inline constexpr uint32_t
version(
const char*
const str)
313 if (
str[0] ==
'\0') {
321 if (
str[
len - 1] ==
'\0') {
324 for (
auto i =
len + 1;
str[
i] !=
'\0'; ++
i) {
331static inline constexpr std::string_view description_str(
const char*
const str)
337 return std::string_view{
str,
len};
347 for (
auto i = 0;
i < 16; ++
i) {
350 std::memcpy(out,
str,
len);
355template <soa::TableRef R>
361template <soa::TableRef R>
367template <soa::TableRef R>
373template <soa::TableRef R>
379template <soa::TableRef R>
382 return {origin<R>(),
description(signature<R>()),
R.version};
393template <soa::TableRef R>
394static constexpr auto sourceSpec()
396 return fmt::format(
"{}/{}/{}/{}",
label<R>(), origin_str<R>(), description_str(signature<R>()),
R.version);
400template <
size_t N, std::array<soa::TableRef, N> ar, o2::aod::is_origin_hash O>
403 std::array<soa::TableRef, N>
res;
404 for (
auto i = 0U;
i < N; ++
i) {
405 res[
i].label_hash = ar[
i].label_hash;
406 res[
i].desc_hash = ar[
i].desc_hash;
407 res[
i].origin_hash = O::hash;
408 res[
i].version = ar[
i].version;
416template <aod::is_aod_hash L, aod::is_aod_hash D, aod::is_origin_hash O,
typename... Ts>
421 void const*
ptr =
nullptr;
425 template <
typename T>
429 hash = o2::framework::TypeIdHelpers::uniqueId<T>();
433 template <
typename T>
436 if (
hash == o2::framework::TypeIdHelpers::uniqueId<T>()) {
437 return static_cast<T const*
>(
ptr);
466template <
typename B,
typename E>
468 constexpr static bool value =
false;
471template <aod::is_aod_hash A, aod::is_aod_hash B>
473 constexpr static bool value =
false;
476template <
typename B,
typename E>
479template <aod::is_aod_hash A, aod::is_aod_hash B>
518template <
typename T,
typename ChunkingPolicy = Chunked>
521 static constexpr char SCALE_FACTOR = std::same_as<std::decay_t<T>,
bool> ? 3 : 0;
537 auto array = getCurrentArray();
552 auto previousArray = getCurrentArray();
556 auto array = getCurrentArray();
563 auto previousArray = getCurrentArray();
567 auto array = getCurrentArray();
589 auto array = getCurrentArray();
596 requires
std::same_as<
bool,
std::decay_t<T>>
612 decltype(
auto)
operator*()
const
613 requires((!std::same_as<bool, std::decay_t<T>>) && std::same_as<
arrow_array_for_t<T>, arrow::BinaryViewArray>)
620 decltype(
auto)
operator*()
const
643 void checkSkipChunk() const
652 void checkSkipChunk() const
660 void checkSkipChunk() const
661 requires(ChunkingPolicy::
chunked == false)
665 auto getCurrentArray() const
669 mOffset = chunkToUse->offset();
670 chunkToUse = std::dynamic_pointer_cast<arrow::FixedSizeListArray>(chunkToUse)->values();
671 return std::static_pointer_cast<arrow_array_for_t<value_for_t<T>>>(chunkToUse);
674 auto getCurrentArray() const
678 mOffset = chunkToUse->offset();
679 chunkToUse = std::dynamic_pointer_cast<arrow::ListArray>(chunkToUse)->values();
680 mOffset = chunkToUse->offset();
681 return std::static_pointer_cast<arrow_array_for_t<value_for_t<T>>>(chunkToUse);
684 auto getCurrentArray() const
688 mOffset = chunkToUse->offset();
689 return std::static_pointer_cast<arrow_array_for_t<T>>(chunkToUse);
693template <
typename T,
typename INHERIT>
709 static constexpr const char*
const&
columnLabel() {
return INHERIT::mLabel; }
717 return std::make_shared<arrow::Field>(inherited_t::mLabel, soa::asArrowDataType<type>());
727template <
typename F,
typename INHERIT>
731 static constexpr const char*
const&
columnLabel() {
return INHERIT::mLabel; }
734template <
typename INHERIT>
737 static constexpr const uint32_t
hash = 0;
739 static constexpr const char*
const&
columnLabel() {
return INHERIT::mLabel; }
742template <
typename INHERIT>
745 static constexpr const uint32_t
hash = 0;
747 static constexpr const char*
const&
columnLabel() {
return INHERIT::mLabel; }
750template <
size_t M = 0>
754 constexpr inline static auto value = M;
769 static constexpr const char*
mLabel =
"Marker";
836 static constexpr const char*
mLabel =
"Index";
860using is_dynamic_t = std::conditional_t<is_dynamic_column<T>, std::true_type, std::false_type>;
866using is_indexing_t = std::conditional_t<is_indexing_column<T>, std::true_type, std::false_type>;
887 mSelectedRows(selection),
888 mMaxSelection(selection.
size()),
896 mSelectedRows = selection;
897 mMaxSelection = selection.size();
907 [[nodiscard]] std::tuple<int64_t const*, int64_t const*>
910 return std::make_tuple(&
mRowIndex, &mSelectionRow);
913 [[nodiscard]] std::tuple<uint64_t const*>
916 return std::make_tuple(&
mOffset);
923 mMaxSelection = std::min(
end, mMaxSelection);
941 return lh.mSelectionRow == rh.mSelectionRow;
954 this->mSelectionRow = this->mMaxSelection;
960 return mSelectionRow;
963 [[nodiscard]]
auto size()
const
965 return mMaxSelection;
974 inline void updateRow()
978 std::span<int64_t const> mSelectedRows;
1015 [[nodiscard]] std::tuple<int64_t const*, int64_t const*>
1021 [[nodiscard]] std::tuple<uint64_t const*>
1024 return std::make_tuple(&
mOffset);
1065template <
typename T>
1070template <
typename C>
1076template <
typename T,
typename B>
1078 { t.B::mColumnIterator };
1081template <
typename...
C>
1084template <
typename D,
typename O,
typename IP,
typename... C>
1099 if (this->
size() != 0) {
1109 if (this->
size() != 0) {
1116 this->limitRange(this->rangeStart(), this->rangeEnd());
1122 C(static_cast<
C const&>(
other))...
1124 if (this->
size() != 0) {
1131 IP::operator=(
static_cast<IP const&
>(
other));
1132 (
void(
static_cast<C&
>(*
this) =
static_cast<C>(
other)), ...);
1133 if (this->
size() != 0) {
1140 requires std::same_as<IP, DefaultIndexPolicy>
1142 C(
static_cast<C const&
>(
other))...
1144 if (this->
size() != 0) {
1151 this->moveByIndex(1);
1164 this->moveByIndex(-1);
1179 copy.moveByIndex(inc);
1193 template <
typename CL>
1196 return CL::getCurrentRaw();
1199 template <
typename... Cs>
1202 return std::vector<o2::soa::Binding>{
static_cast<Cs const&
>(*this).getCurrentRaw()...};
1210 template <
typename... TA>
1214 (CCs::setCurrent(cur), ...);
1219 template <
typename TA>
1223 (CCs::setCurrent(cur), ...);
1227 template <
typename... Cs>
1230 (Cs::setCurrentRaw(ptrs[framework::has_type_at_v<Cs>(p)]), ...);
1233 template <
typename... Cs,
typename I>
1238 (Cs::setCurrentRaw(
b), ...);
1246 template <
typename I>
1254 template <
typename... PC>
1257 (PC::mColumnIterator.moveToEnd(), ...);
1267 [
this]<soa::is_dynamic_column T>(T*) ->
void { bindDynamicColumn<T>(
typename T::bindings_t{}); },
1268 [
this]<
typename T>(
T*) ->
void {},
1270 (
f(
static_cast<C*
>(
nullptr)), ...);
1271 if constexpr (has_index<
C...>) {
1272 this->setIndices(this->getIndices());
1273 this->setOffsets(this->getOffsets());
1277 template <
typename DC,
typename...
B>
1280 DC::boundIterators = std::make_tuple(getDynamicBinding<B>()...);
1288 template <
typename B>
1289 requires(can_bind<self_t, B>)
1290 decltype(
auto) getDynamicBinding()
1292 static_assert(std::same_as<decltype(&(static_cast<B*>(
this)->mColumnIterator)), std::decay_t<
decltype(B::mColumnIterator)>*>,
"foo");
1293 return &(
static_cast<B*
>(
this)->mColumnIterator);
1297 template <
typename B>
1298 decltype(
auto) getDynamicBinding()
1300 return static_cast<std::decay_t<decltype(B::mColumnIterator)
>*>(
nullptr);
1305 static std::shared_ptr<arrow::Table>
joinTables(std::vector<std::shared_ptr<arrow::Table>>&& tables);
1306 static std::shared_ptr<arrow::Table>
joinTables(std::vector<std::shared_ptr<arrow::Table>>&& tables, std::span<const char* const>
labels);
1307 static std::shared_ptr<arrow::Table>
joinTables(std::vector<std::shared_ptr<arrow::Table>>&& tables, std::span<const std::string>
labels);
1308 static std::shared_ptr<arrow::Table>
concatTables(std::vector<std::shared_ptr<arrow::Table>>&& tables);
1312template <
typename T>
1315template <
typename T>
1318template <
typename T>
1320 T::originals.size();
1323template <
typename T>
1328template <
typename T>
1333template <
typename T>
1335 T::ccdb_urls.size();
1338template <
typename T>
1343template <
typename T>
1345 typename T::expression_pack_t{};
1348template <
typename T>
1350 typename T::index_pack_t{};
1353template <
size_t N1, std::array<TableRef, N1> os1,
size_t N2, std::array<TableRef, N2> os2>
1356 return []<
size_t... Is>(std::index_sequence<Is...>) {
1357 return ([]<
size_t... Ks>(std::index_sequence<Ks...>) {
1358 constexpr auto h = os1[Is].desc_hash;
1361 }(std::make_index_sequence<N2>()) ||
1363 }(std::make_index_sequence<N1>());
1366template <with_originals T, with_originals B>
1369 return is_compatible<T::originals.size(), T::originals, B::originals.size(), B::originals>();
1372template <
typename T,
typename B>
1373using is_binding_compatible = std::conditional_t<is_binding_compatible_v<T, typename B::binding_t>(), std::true_type, std::false_type>;
1375template <
typename L,
typename D,
typename O,
typename Key,
typename H,
typename...
Ts>
1378template <
typename T>
1381template <soa::is_table T>
1382static constexpr std::string getLabelForTable()
1384 return std::string{aod::label<std::decay_t<T>::originals[0]>()};
1387template <soa::is_table T>
1389static constexpr std::string getLabelFromType()
1391 return getLabelForTable<T>();
1394template <soa::is_iterator T>
1395static constexpr std::string getLabelFromType()
1397 return getLabelForTable<typename std::decay_t<T>::parent_t>();
1400template <soa::is_index_table T>
1401static constexpr std::string getLabelFromType()
1403 return getLabelForTable<typename std::decay_t<T>::first_t>();
1405template <soa::with_base_table T>
1406 requires(!soa::is_iterator<T>)
1407static constexpr std::string getLabelFromType()
1412template <
typename...
C>
1415 auto caseInsensitiveCompare = [](
const std::string_view& str1,
const std::string_view& str2) {
1416 return std::ranges::equal(
1418 [](
char c1,
char c2) {
1419 return std::tolower(
static_cast<unsigned char>(c1)) ==
1420 std::tolower(
static_cast<unsigned char>(c2));
1423 return (caseInsensitiveCompare(C::inherited_t::mLabel,
key) || ...);
1426template <TableRef ref>
1427static constexpr std::pair<bool, std::string> hasKey(std::string_view
key)
1432template <TableRef ref>
1433static constexpr std::pair<bool, framework::ConcreteDataMatcher> hasKeyM(std::string_view
key)
1441template <with_originals T,
bool OPT = false>
1442static constexpr std::string getLabelFromTypeForKey(std::string_view
key)
1444 auto locate = []<
size_t... Is>(std::index_sequence<Is...>, std::string_view
key) {
1445 return std::array{hasKey<T::originals[Is]>(
key)...} |
1446 std::views::filter([](
auto const&
x) {
return x.first; });
1447 }(std::make_index_sequence<T::originals.size()>{},
key);
1448 if (!locate.empty()) {
1449 return locate.front().second;
1452 if constexpr (!OPT) {
1460template <with_originals T,
bool OPT = false>
1463 auto locate = []<
size_t... Is>(std::index_sequence<Is...>, std::string_view
key) {
1464 return std::array{hasKeyM<T::originals[Is]>(
key)...} |
1465 std::views::filter([](
auto const&
x) {
return x.first; });
1466 }(std::make_index_sequence<T::originals.size()>{},
key);
1467 if (!locate.empty()) {
1468 return locate.front().second;
1471 if constexpr (!OPT) {
1479template <
typename B,
typename...
C>
1482 return (o2::soa::is_binding_compatible_v<B, typename C::binding_t>() || ...);
1485template <
typename B,
typename...
C>
1488 return ((C::sorted && o2::soa::is_binding_compatible_v<B, typename C::binding_t>()) || ...);
1491template <
typename B,
typename Z>
1492consteval static bool relatedByIndex()
1494 return hasIndexTo<B>(
typename Z::table_t::external_index_columns_t{});
1497template <
typename B,
typename Z>
1498consteval static bool relatedBySortedIndex()
1500 return hasSortedIndexTo<B>(
typename Z::table_t::external_index_columns_t{});
1519 std::shared_ptr<arrow::Table>
getSliceFor(
int value, std::shared_ptr<arrow::Table>
const& input, uint64_t&
offset)
const;
1524 mutable std::pair<arrow::Table const*, std::shared_ptr<arrow::Table>>
emptySlice{
nullptr,
nullptr};
1534template <
typename T>
1537template <soa::is_table T, is_preslice_policy Policy,
bool OPT = false>
1545 : 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})}, {}}
1551 if constexpr (OPT) {
1552 if (Policy::isMissing()) {
1561 if constexpr (OPT) {
1562 if (Policy::isMissing()) {
1566 return Policy::getSliceFor(
value);
1570template <soa::is_table T>
1572template <soa::is_table T>
1574template <soa::is_table T>
1576template <soa::is_table T>
1579template <
typename T>
1601template <
typename T>
1608template <soa::is_table T>
1610template <
typename T>
1613template <
typename T>
1616template <
typename T>
1619template <
typename T>
1623template <
typename T>
1626template <
typename T>
1629template <
typename T>
1633template <
typename... Is>
1641template <
typename T,
typename C,
typename Policy,
bool OPT>
1642 requires std::same_as<Policy, framework::PreslicePolicySorted> && (o2::soa::is_binding_compatible_v<C, T>())
1645 if constexpr (OPT) {
1646 if (container.isMissing()) {
1652 auto t =
typename T::self_t({out},
offset);
1653 if (t.tableSize() != 0) {
1654 table->copyIndexBindings(t);
1655 t.bindInternalIndicesTo(table);
1660template <soa::is_filtered_table T>
1664 if (t.tableSize() != 0) {
1666 t.bindInternalIndicesTo(table);
1667 t.intersectWithSelection(table->getSelectedRows());
1672template <soa::is_table T>
1677 if (t.tableSize() != 0) {
1679 t.bindInternalIndicesTo(table);
1684template <
typename T,
typename C,
typename Policy,
bool OPT>
1685 requires std::same_as<Policy, framework::PreslicePolicyGeneral> && (o2::soa::is_binding_compatible_v<C, T>())
1688 if constexpr (OPT) {
1689 if (container.isMissing()) {
1699template <soa::is_filtered_table T>
1702 if (
offset >=
static_cast<uint64_t
>(table->tableSize())) {
1704 if (fresult.tableSize() != 0) {
1711 if (fresult.tableSize() != 0) {
1717template <soa::is_filtered_table T,
typename C,
bool OPT>
1718 requires(o2::soa::is_binding_compatible_v<C, T>())
1721 if constexpr (OPT) {
1722 if (container.isMissing()) {
1733template <soa::is_table T>
1741 : table->asArrowTable()->Slice(
static_cast<uint64_t
>(
offset),
count);
1742 auto t =
typename T::self_t({slice},
static_cast<uint64_t
>(
offset));
1743 if (t.tableSize() != 0) {
1744 table->copyIndexBindings(t);
1749template <soa::is_filtered_table T>
1757 : table->asArrowTable()->Slice(
static_cast<uint64_t
>(
offset),
count);
1761template <soa::is_table T>
1767 auto t =
typename T::self_t({table->asArrowTable()}, localCache.getSliceFor(
value));
1768 if (t.tableSize() != 0) {
1769 t.intersectWithSelection(table->getSelectedRows());
1770 table->copyIndexBindings(t);
1774 auto t =
Filtered<T>({table->asArrowTable()}, localCache.getSliceFor(
value));
1775 if (t.tableSize() != 0) {
1776 table->copyIndexBindings(t);
1782template <with_originals T>
1790template <
typename D,
typename O,
typename IP,
typename...
C>
1827 return std::array<TableRef, 1>{
ref};
1843 static constexpr const auto ref =
TableRef{L::hash, D::hash, O::hash, o2::aod::version(D::str)};
1848 static constexpr const auto originalLabels = []<
size_t N, std::array<TableRef, N> refs,
size_t... Is>(std::index_sequence<Is...>) {
1849 return std::array<const char*, N>{o2::aod::label<refs[Is]>()...};
1854 template <
size_t N, std::array<TableRef, N> bindings>
1855 requires(
ref.origin_hash ==
"CONC"_h)
1861 template <
size_t N, std::array<TableRef, N> bindings>
1862 requires(
ref.origin_hash ==
"JOIN"_h)
1867 return std::ranges::any_of(bindings, [&
r](
TableRef const&
b) {
return b ==
r; });
1871 template <
size_t N, std::array<TableRef, N> bindings>
1872 requires(!(
ref.origin_hash ==
"CONC"_h ||
ref.origin_hash ==
"JOIN"_h))
1875 return std::find(bindings.begin(), bindings.end(),
self_t::ref) != bindings.end();
1878 template <TableRef r>
1891 template <
typename IP>
1894 template <
typename IP,
typename Parent,
typename... T>
1911 template <
typename P,
typename... Os>
1913 requires(P::ref.desc_hash == Parent::ref.desc_hash)
1919 template <
typename P>
1926 template <
typename P>
1928 requires std::same_as<IP, DefaultIndexPolicy>
1934 template <
typename P,
typename O1,
typename... Os>
1936 requires(P::ref.desc_hash == Parent::ref.desc_hash)
1941 template <
typename P,
typename O1,
typename... Os>
1943 requires(P::ref.desc_hash == Parent::ref.desc_hash)
1948 template <
typename P>
1954 template <
typename P>
1960 template <
typename P>
1962 requires std::same_as<IP, DefaultIndexPolicy>
1969 this->mRowIndex =
other.index;
1972 template <
typename P>
1975 this->mRowIndex =
other.mRowIndex;
1978 template <
typename P,
typename... Os>
1980 requires std::same_as<typename P::table_t, typename Parent::table_t>
1982 this->mRowIndex =
other.mRowIndex;
1985 template <
typename TI>
1988 using decayed = std::decay_t<TI>;
1990 constexpr auto idx = framework::has_type_at_v<decayed>(
bindings_pack_t{});
1992 }
else if constexpr (std::same_as<decayed, Parent>) {
1993 return this->globalIndex();
1995 return this->globalIndex();
1997 return static_cast<int32_t
>(-1);
2001 template <
typename CD,
typename... CDArgs>
2004 using decayed = std::decay_t<CD>;
2006 return static_cast<decayed
>(*this).template getDynamicValue<CDArgs...>();
2009 template <
typename B,
typename CC>
2012 using COL = std::decay_t<CC>;
2014 return static_cast<B>(
static_cast<COL
>(*this).get());
2017 template <
typename B,
typename... CCs>
2020 static_assert(std::same_as<B, float> || std::same_as<B, double>,
"The common return type should be float or double");
2021 return {getValue<B, CCs>()...};
2032 copy.moveByIndex(inc);
2047 template <
typename IP,
typename Parent,
typename... T>
2050 template <
typename IP,
typename Parent>
2053 if constexpr (
sizeof...(Ts) == 0) {
2064 template <
typename IP,
typename Parent>
2082 mEnd{table->num_rows()}
2084 if (mTable->num_rows() == 0) {
2086 mColumnChunks[ci] =
nullptr;
2092 mColumnChunks[ci] = lookups[ci];
2095 mBegin.bindInternalIndices(
this);
2099 Table(std::vector<std::shared_ptr<arrow::Table>>&& tables, uint64_t
offset = 0)
2100 requires(
ref.origin_hash !=
"CONC"_h)
2105 Table(std::vector<std::shared_ptr<arrow::Table>>&& tables, uint64_t
offset = 0)
2106 requires(
ref.origin_hash ==
"CONC"_h)
2111 template <
typename Key>
2115 return std::array<bool,
sizeof...(Cs)>{[]() {
2116 if constexpr (
requires { Cs::index_targets.size(); }) {
2117 return Key::template
isIndexTargetOf<Cs::index_targets.size(), Cs::index_targets>();
2123 constexpr auto pos = std::find(map.begin(), map.end(),
true);
2124 if constexpr (
pos != map.end()) {
2125 return mColumnChunks[std::distance(map.begin(),
pos)];
2127 static_assert(framework::always_static_assert_v<Key>,
"This table does not have an index to given Key");
2157 return filtered_iterator(mColumnChunks, {selection, mTable->num_rows(), mOffset});
2195 return mTable->num_rows();
2205 template <
typename... TA>
2210 mBegin.bindExternalIndex(cur);
2216 template <
typename TA>
2219 mBegin.bindExternalIndex(current);
2222 template <
typename I>
2225 mBegin.bindInternalIndices(
ptr);
2233 template <
typename... Cs>
2236 (
static_cast<Cs
>(mBegin).setCurrentRaw(
binding), ...);
2241 mBegin.bindExternalIndicesRaw(std::forward<std::vector<o2::soa::Binding>>(ptrs));
2244 template <
typename T,
typename... Cs>
2247 dest.bindExternalIndicesRaw(mBegin.getIndexBindings());
2250 template <
typename T>
2273 template <
typename T1,
typename Policy,
bool OPT>
2286 return self_t{mTable->Slice(0, 0), 0};
2290 template <
typename T>
2291 arrow::ChunkedArray* lookupColumn()
2294 auto label = T::columnLabel();
2300 std::shared_ptr<arrow::Table> mTable =
nullptr;
2301 uint64_t mOffset = 0;
2308template <uint32_t
D, soa::is_column...
C>
2314namespace row_helpers
2316template <
typename R,
typename T,
typename C>
2319 return static_cast<R>(
static_cast<C>(rowIterator).get());
2324template <
typename R,
typename T>
2325using ColumnGetterFunction =
R (*)(
const T&);
2327template <
typename T,
typename R>
2332 { t.get() } -> std::convertible_to<R>;
2335template <
typename T,
typename R>
2337 { t.get() } -> std::convertible_to<R>;
2340template <
typename R,
typename T, persistent_with_common_getter<R> C>
2341ColumnGetterFunction<R, T> createGetterPtr(
const std::string_view& targetColumnLabel)
2343 return targetColumnLabel == C::columnLabel() ? &getColumnValue<R, T, C> :
nullptr;
2346template <
typename R,
typename T, dynamic_with_common_getter<R> C>
2347ColumnGetterFunction<R, T> createGetterPtr(
const std::string_view& targetColumnLabel)
2353 if (targetColumnLabel.starts_with(
"f") && targetColumnLabel.substr(1) ==
columnLabel) {
2354 return &getColumnValue<R, T, C>;
2359 return &getColumnValue<R, T, C>;
2365template <
typename R,
typename T,
typename... Cs>
2368 ColumnGetterFunction<R, T>
func;
2370 (
void)((
func = createGetterPtr<R, T, Cs>(targetColumnLabel),
func) || ...);
2379template <
typename T,
typename R>
2380using 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;
2383template <
typename R,
typename T>
2388 if (targetColumnLabel.size() == 0) {
2392 return getColumnGetterByLabel<R, typename T::iterator>(TypesWithCommonGetter{}, targetColumnLabel);
2417template <
typename T>
2418consteval static std::string_view namespace_prefix()
2420 constexpr auto name = o2::framework::type_name<T>();
2421 const auto pos =
name.rfind(std::string_view{
":"});
2422 return name.substr(0,
pos + 1);
2426#define DECLARE_EQUIVALENT_FOR_INDEX(_Base_, _Equiv_) \
2428 struct EquivalentIndexNG<o2::aod::Hash<_Base_::ref.desc_hash>, o2::aod::Hash<_Equiv_::ref.desc_hash>> { \
2429 constexpr static bool value = true; \
2432#define DECLARE_EQUIVALENT_FOR_INDEX_NG(_Base_, _Equiv_) \
2434 struct EquivalentIndexNG<o2::aod::Hash<_Base_ ""_h>, o2::aod::Hash<_Equiv_ ""_h>> { \
2435 constexpr static bool value = true; \
2438#define DECLARE_SOA_COLUMN_FULL(_Name_, _Getter_, _Type_, _Label_) \
2439 struct _Name_ : o2::soa::Column<_Type_, _Name_> { \
2440 static constexpr const char* mLabel = _Label_; \
2441 static constexpr const uint32_t hash = compile_time_hash(namespace_prefix<_Name_>(), std::string_view{#_Getter_}); \
2442 static_assert(!((*(mLabel + 1) == 'I' && *(mLabel + 2) == 'n' && *(mLabel + 3) == 'd' && *(mLabel + 4) == 'e' && *(mLabel + 5) == 'x')), "Index is not a valid column name"); \
2443 using base = o2::soa::Column<_Type_, _Name_>; \
2444 using type = _Type_; \
2445 using column_t = _Name_; \
2446 _Name_(arrow::ChunkedArray const* column) \
2447 : o2::soa::Column<_Type_, _Name_>(o2::soa::ColumnIterator<type>(column)) \
2451 _Name_() = default; \
2452 _Name_(_Name_ const& other) = default; \
2453 _Name_& operator=(_Name_ const& other) = default; \
2455 decltype(auto) _Getter_() const \
2457 return *mColumnIterator; \
2460 decltype(auto) get() const \
2462 return _Getter_(); \
2465 [[maybe_unused]] static constexpr o2::framework::expressions::BindingNode _Getter_ { _Label_, _Name_::hash, o2::framework::expressions::selectArrowType<_Type_>() }
2467#define DECLARE_SOA_CCDB_COLUMN_FULL(_Name_, _Label_, _Getter_, _ConcreteType_, _CCDBQuery_) \
2468 struct _Name_ : o2::soa::Column<std::span<std::byte>, _Name_> { \
2469 static constexpr const char* mLabel = _Label_; \
2470 static constexpr const char* query = _CCDBQuery_; \
2471 static constexpr const uint32_t hash = crc32(namespace_prefix<_Name_>(), std::string_view{#_Getter_}); \
2472 using base = o2::soa::Column<std::span<std::byte>, _Name_>; \
2473 using type = std::span<std::byte>; \
2474 using column_t = _Name_; \
2475 _Name_(arrow::ChunkedArray const* column) \
2476 : o2::soa::Column<std::span<std::byte>, _Name_>(o2::soa::ColumnIterator<std::span<std::byte>>(column)) \
2480 _Name_() = default; \
2481 _Name_(_Name_ const& other) = default; \
2482 _Name_& operator=(_Name_ const& other) = default; \
2484 decltype(auto) _Getter_() const \
2486 if constexpr (std::same_as<_ConcreteType_, std::span<std::byte>>) { \
2487 return *mColumnIterator; \
2489 static std::byte* payload = nullptr; \
2490 static _ConcreteType_* deserialised = nullptr; \
2491 static TClass* c = TClass::GetClass(#_ConcreteType_); \
2492 auto span = *mColumnIterator; \
2493 if (payload != (std::byte*)span.data()) { \
2494 payload = (std::byte*)span.data(); \
2495 delete deserialised; \
2496 TBufferFile f(TBufferFile::EMode::kRead, span.size(), (char*)span.data(), kFALSE); \
2497 deserialised = (_ConcreteType_*)soa::extractCCDBPayload((char*)payload, span.size(), c, "ccdb_object"); \
2499 return *deserialised; \
2506 return _Getter_(); \
2510#define DECLARE_SOA_CCDB_COLUMN(_Name_, _Getter_, _ConcreteType_, _CCDBQuery_) \
2511 DECLARE_SOA_CCDB_COLUMN_FULL(_Name_, "f" #_Name_, _Getter_, _ConcreteType_, _CCDBQuery_)
2513#define DECLARE_SOA_COLUMN(_Name_, _Getter_, _Type_) \
2514 DECLARE_SOA_COLUMN_FULL(_Name_, _Getter_, _Type_, "f" #_Name_)
2518#define MAKEINT(_Size_) uint##_Size_##_t
2520#define DECLARE_SOA_BITMAP_COLUMN_FULL(_Name_, _Getter_, _Size_, _Label_) \
2521 struct _Name_ : o2::soa::Column<MAKEINT(_Size_), _Name_> { \
2522 static constexpr const char* mLabel = _Label_; \
2523 static constexpr const uint32_t hash = compile_time_hash(namespace_prefix<_Name_>(), std::string_view{#_Getter_}); \
2524 static_assert(!((*(mLabel + 1) == 'I' && *(mLabel + 2) == 'n' && *(mLabel + 3) == 'd' && *(mLabel + 4) == 'e' && *(mLabel + 5) == 'x')), "Index is not a valid column name"); \
2525 using base = o2::soa::Column<MAKEINT(_Size_), _Name_>; \
2526 using type = MAKEINT(_Size_); \
2527 _Name_(arrow::ChunkedArray const* column) \
2528 : o2::soa::Column<type, _Name_>(o2::soa::ColumnIterator<type>(column)) \
2532 _Name_() = default; \
2533 _Name_(_Name_ const& other) = default; \
2534 _Name_& operator=(_Name_ const& other) = default; \
2536 decltype(auto) _Getter_##_raw() const \
2538 return *mColumnIterator; \
2541 bool _Getter_##_bit(int bit) const \
2543 return (*mColumnIterator & (static_cast<type>(1) << bit)) >> bit; \
2546 [[maybe_unused]] static constexpr o2::framework::expressions::BindingNode _Getter_ { _Label_, _Name_::hash, o2::framework::expressions::selectArrowType<MAKEINT(_Size_)>() }
2548#define DECLARE_SOA_BITMAP_COLUMN(_Name_, _Getter_, _Size_) \
2549 DECLARE_SOA_BITMAP_COLUMN_FULL(_Name_, _Getter_, _Size_, "f" #_Name_)
2553#define DECLARE_SOA_EXPRESSION_COLUMN_FULL(_Name_, _Getter_, _Type_, _Label_, _Expression_) \
2554 struct _Name_ : o2::soa::Column<_Type_, _Name_> { \
2555 static constexpr const char* mLabel = _Label_; \
2556 static constexpr const uint32_t hash = compile_time_hash(namespace_prefix<_Name_>(), std::string_view{#_Getter_}); \
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 static o2::framework::expressions::Projector Projector() \
2582 return _Expression_; \
2585 [[maybe_unused]] static constexpr o2::framework::expressions::BindingNode _Getter_ { _Label_, _Name_::hash, o2::framework::expressions::selectArrowType<_Type_>() }
2587#define DECLARE_SOA_EXPRESSION_COLUMN(_Name_, _Getter_, _Type_, _Expression_) \
2588 DECLARE_SOA_EXPRESSION_COLUMN_FULL(_Name_, _Getter_, _Type_, "f" #_Name_, _Expression_);
2592#define DECLARE_SOA_CONFIGURABLE_EXPRESSION_COLUMN(_Name_, _Getter_, _Type_, _Label_) \
2593 struct _Name_ : o2::soa::Column<_Type_, _Name_> { \
2594 static constexpr const char* mLabel = _Label_; \
2595 static constexpr const uint32_t hash = compile_time_hash(namespace_prefix<_Name_>(), std::string_view{#_Getter_}); \
2596 static constexpr const int32_t mHash = _Label_ ""_h; \
2597 using base = o2::soa::Column<_Type_, _Name_>; \
2598 using type = _Type_; \
2599 using column_t = _Name_; \
2600 using spawnable_t = std::true_type; \
2601 _Name_(arrow::ChunkedArray const* column) \
2602 : o2::soa::Column<_Type_, _Name_>(o2::soa::ColumnIterator<type>(column)) \
2606 _Name_() = default; \
2607 _Name_(_Name_ const& other) = default; \
2608 _Name_& operator=(_Name_ const& other) = default; \
2610 decltype(auto) _Getter_() const \
2612 return *mColumnIterator; \
2615 decltype(auto) get() const \
2617 return _Getter_(); \
2620 [[maybe_unused]] static constexpr o2::framework::expressions::BindingNode _Getter_ { _Label_, _Name_::hash, o2::framework::expressions::selectArrowType<_Type_>() }
2643template <o2::soa::is_table T>
2646 return T::originals;
2649#define DECLARE_SOA_SLICE_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, _Type_, _Table_, _Label_, _Suffix_) \
2650 struct _Name_##IdSlice : o2::soa::Column<_Type_[2], _Name_##IdSlice> { \
2651 static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
2652 static_assert((*_Suffix_ == '\0') || (*_Suffix_ == '_'), "Suffix has to begin with _"); \
2653 static constexpr const char* mLabel = "fIndexSlice" _Label_ _Suffix_; \
2654 static constexpr const uint32_t hash = 0; \
2655 using base = o2::soa::Column<_Type_[2], _Name_##IdSlice>; \
2656 using type = _Type_[2]; \
2657 using column_t = _Name_##IdSlice; \
2658 using binding_t = _Table_; \
2659 static constexpr auto index_targets = getIndexTargets<_Table_>(); \
2660 _Name_##IdSlice(arrow::ChunkedArray const* column) \
2661 : o2::soa::Column<_Type_[2], _Name_##IdSlice>(o2::soa::ColumnIterator<type>(column)) \
2665 _Name_##IdSlice() = default; \
2666 _Name_##IdSlice(_Name_##IdSlice const& other) = default; \
2667 _Name_##IdSlice& operator=(_Name_##IdSlice const& other) = default; \
2668 std::array<_Type_, 2> inline getIds() const \
2670 return _Getter_##Ids(); \
2673 bool has_##_Getter_() const \
2675 auto a = *mColumnIterator; \
2676 return a[0] >= 0 && a[1] >= 0; \
2679 std::array<_Type_, 2> _Getter_##Ids() const \
2681 auto a = *mColumnIterator; \
2682 return std::array{a[0], a[1]}; \
2685 template <typename T> \
2686 auto _Getter_##_as() const \
2688 if (O2_BUILTIN_UNLIKELY(mBinding.ptr == nullptr)) { \
2689 o2::soa::notBoundTable(#_Table_); \
2691 auto t = mBinding.get<T>(); \
2692 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2693 o2::soa::dereferenceWithWrongType(#_Getter_, #_Table_); \
2695 if (O2_BUILTIN_UNLIKELY(!has_##_Getter_())) { \
2696 return t->emptySlice(); \
2698 auto a = *mColumnIterator; \
2699 auto r = t->rawSlice(a[0], a[1]); \
2700 t->copyIndexBindings(r); \
2701 r.bindInternalIndicesTo(t); \
2705 auto _Getter_() const \
2707 return _Getter_##_as<binding_t>(); \
2710 template <typename T> \
2711 bool setCurrent(T const* current) \
2713 if constexpr (o2::soa::is_binding_compatible_v<T, binding_t>()) { \
2714 assert(current != nullptr); \
2715 this->mBinding.bind(current); \
2721 bool setCurrentRaw(o2::soa::Binding current) \
2723 this->mBinding = current; \
2726 binding_t const* getCurrent() const { return mBinding.get<binding_t>(); } \
2727 o2::soa::Binding getCurrentRaw() const { return mBinding; } \
2728 o2::soa::Binding mBinding; \
2731#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_)
2732#define DECLARE_SOA_SLICE_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_SLICE_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, _Name_##s, "")
2733#define DECLARE_SOA_SLICE_INDEX_COLUMN_CUSTOM(_Name_, _Getter_, _Label_) DECLARE_SOA_SLICE_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, int32_t, _Name_##s, _Label_, "")
2736#define DECLARE_SOA_ARRAY_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, _Type_, _Table_, _Label_, _Suffix_) \
2737 struct _Name_##Ids : o2::soa::Column<std::vector<_Type_>, _Name_##Ids> { \
2738 static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
2739 static_assert((*_Suffix_ == '\0') || (*_Suffix_ == '_'), "Suffix has to begin with _"); \
2740 static constexpr const char* mLabel = "fIndexArray" _Label_ _Suffix_; \
2741 static constexpr const uint32_t hash = 0; \
2742 using base = o2::soa::Column<std::vector<_Type_>, _Name_##Ids>; \
2743 using type = std::vector<_Type_>; \
2744 using column_t = _Name_##Ids; \
2745 using binding_t = _Table_; \
2746 static constexpr auto index_targets = getIndexTargets<_Table_>(); \
2747 _Name_##Ids(arrow::ChunkedArray const* column) \
2748 : o2::soa::Column<std::vector<_Type_>, _Name_##Ids>(o2::soa::ColumnIterator<type>(column)) \
2752 _Name_##Ids() = default; \
2753 _Name_##Ids(_Name_##Ids const& other) = default; \
2754 _Name_##Ids& operator=(_Name_##Ids const& other) = default; \
2756 gsl::span<const _Type_> inline getIds() const \
2758 return _Getter_##Ids(); \
2761 gsl::span<const _Type_> _Getter_##Ids() const \
2763 return *mColumnIterator; \
2766 bool has_##_Getter_() const \
2768 return !(*mColumnIterator).empty(); \
2771 template <soa::is_table T> \
2772 auto _Getter_##_as() const \
2774 if (O2_BUILTIN_UNLIKELY(mBinding.ptr == nullptr)) { \
2775 o2::soa::notBoundTable(#_Table_); \
2777 auto t = mBinding.get<T>(); \
2778 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2779 o2::soa::dereferenceWithWrongType(#_Getter_, #_Table_); \
2781 auto result = std::vector<typename T::unfiltered_iterator>(); \
2782 result.reserve((*mColumnIterator).size()); \
2783 for (auto& i : *mColumnIterator) { \
2784 result.emplace_back(t->rawIteratorAt(i)); \
2789 template <soa::is_filtered_table T> \
2790 auto filtered_##_Getter_##_as() const \
2792 if (O2_BUILTIN_UNLIKELY(mBinding.ptr == nullptr)) { \
2793 o2::soa::notBoundTable(#_Table_); \
2795 auto t = mBinding.get<T>(); \
2796 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2797 o2::soa::dereferenceWithWrongType(#_Getter_, #_Table_); \
2799 auto result = std::vector<typename T::iterator>(); \
2800 result.reserve((*mColumnIterator).size()); \
2801 for (auto const& i : *mColumnIterator) { \
2802 auto pos = t->isInSelectedRows(i); \
2804 result.emplace_back(t->iteratorAt(pos)); \
2810 auto _Getter_() const \
2812 return _Getter_##_as<binding_t>(); \
2815 template <typename T> \
2816 auto _Getter_##_first_as() const \
2818 if (O2_BUILTIN_UNLIKELY(mBinding.ptr == nullptr)) { \
2819 o2::soa::notBoundTable(#_Table_); \
2821 auto t = mBinding.get<T>(); \
2822 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2823 o2::soa::dereferenceWithWrongType(#_Getter_, #_Table_); \
2825 return t->rawIteratorAt((*mColumnIterator)[0]); \
2828 template <typename T> \
2829 auto _Getter_##_last_as() const \
2831 if (O2_BUILTIN_UNLIKELY(mBinding.ptr == nullptr)) { \
2832 o2::soa::notBoundTable(#_Table_); \
2834 auto t = mBinding.get<T>(); \
2835 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2836 o2::soa::dereferenceWithWrongType(#_Getter_, #_Table_); \
2838 return t->rawIteratorAt((*mColumnIterator).back()); \
2841 auto _Getter_first() const \
2843 return _Getter_##_first_as<binding_t>(); \
2846 auto _Getter_last() const \
2848 return _Getter_##_last_as<binding_t>(); \
2851 template <typename T> \
2852 bool setCurrent(T const* current) \
2854 if constexpr (o2::soa::is_binding_compatible_v<T, binding_t>()) { \
2855 assert(current != nullptr); \
2856 this->mBinding.bind(current); \
2862 bool setCurrentRaw(o2::soa::Binding current) \
2864 this->mBinding = current; \
2867 binding_t const* getCurrent() const { return mBinding.get<binding_t>(); } \
2868 o2::soa::Binding getCurrentRaw() const { return mBinding; } \
2869 o2::soa::Binding mBinding; \
2872#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_)
2873#define DECLARE_SOA_ARRAY_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_ARRAY_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, _Name_##s, "")
2874#define DECLARE_SOA_ARRAY_INDEX_COLUMN_CUSTOM(_Name_, _Getter_, _Label_) DECLARE_SOA_ARRAY_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, int32_t, _Name_##s, _Label_, "")
2877#define DECLARE_SOA_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, _Type_, _Table_, _Label_, _Suffix_) \
2878 struct _Name_##Id : o2::soa::Column<_Type_, _Name_##Id> { \
2879 static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
2880 static_assert((*_Suffix_ == '\0') || (*_Suffix_ == '_'), "Suffix has to begin with _"); \
2881 static constexpr const char* mLabel = "fIndex" _Label_ _Suffix_; \
2882 static constexpr const uint32_t hash = compile_time_hash(namespace_prefix<_Name_##Id>(), std::string_view{#_Getter_ "Id"}); \
2883 using base = o2::soa::Column<_Type_, _Name_##Id>; \
2884 using type = _Type_; \
2885 using column_t = _Name_##Id; \
2886 using binding_t = _Table_; \
2887 static constexpr auto index_targets = getIndexTargets<_Table_>(); \
2888 _Name_##Id(arrow::ChunkedArray const* column) \
2889 : o2::soa::Column<_Type_, _Name_##Id>(o2::soa::ColumnIterator<type>(column)) \
2893 _Name_##Id() = default; \
2894 _Name_##Id(_Name_##Id const& other) = default; \
2895 _Name_##Id& operator=(_Name_##Id const& other) = default; \
2896 type inline getId() const \
2898 return _Getter_##Id(); \
2901 type _Getter_##Id() const \
2903 return *mColumnIterator; \
2906 bool has_##_Getter_() const \
2908 return *mColumnIterator >= 0; \
2911 template <typename T> \
2912 auto _Getter_##_as() const \
2914 if (O2_BUILTIN_UNLIKELY(mBinding.ptr == nullptr)) { \
2915 o2::soa::notBoundTable(#_Table_); \
2917 if (O2_BUILTIN_UNLIKELY(!has_##_Getter_())) { \
2918 o2::soa::accessingInvalidIndexFor(#_Getter_); \
2920 auto t = mBinding.get<T>(); \
2921 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2922 o2::soa::dereferenceWithWrongType(#_Getter_, #_Table_); \
2924 return t->rawIteratorAt(*mColumnIterator); \
2927 auto _Getter_() const \
2929 return _Getter_##_as<binding_t>(); \
2932 template <typename T> \
2933 bool setCurrent(T* current) \
2935 if constexpr (o2::soa::is_binding_compatible_v<T, binding_t>()) { \
2936 assert(current != nullptr); \
2937 this->mBinding.bind(current); \
2943 bool setCurrentRaw(o2::soa::Binding current) \
2945 this->mBinding = current; \
2948 binding_t const* getCurrent() const { return mBinding.get<binding_t>(); } \
2949 o2::soa::Binding getCurrentRaw() const { return mBinding; } \
2950 o2::soa::Binding mBinding; \
2952 [[maybe_unused]] static constexpr o2::framework::expressions::BindingNode _Getter_##Id { "fIndex" _Label_ _Suffix_, _Name_##Id::hash, o2::framework::expressions::selectArrowType<_Type_>() }
2954#define DECLARE_SOA_INDEX_COLUMN_FULL(_Name_, _Getter_, _Type_, _Table_, _Suffix_) DECLARE_SOA_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, _Type_, _Table_, #_Table_, _Suffix_)
2955#define DECLARE_SOA_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, _Name_##s, "")
2956#define DECLARE_SOA_INDEX_COLUMN_CUSTOM(_Name_, _Getter_, _Label_) DECLARE_SOA_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, int32_t, _Name_##s, _Label_, "")
2959#define DECLARE_SOA_SELF_INDEX_COLUMN_COMPLETE(_Name_, _Getter_, _Type_, _Label_, _IndexTarget_) \
2960 struct _Name_##Id : o2::soa::Column<_Type_, _Name_##Id> { \
2961 static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
2962 static constexpr const char* mLabel = "fIndex" _Label_; \
2963 static constexpr const uint32_t hash = compile_time_hash(namespace_prefix<_Name_##Id>(), std::string_view{#_Getter_ "Id"}); \
2964 using base = o2::soa::Column<_Type_, _Name_##Id>; \
2965 using type = _Type_; \
2966 using column_t = _Name_##Id; \
2967 using self_index_t = std::true_type; \
2968 using compatible_signature = std::conditional<aod::is_aod_hash<_IndexTarget_>, _IndexTarget_, void>; \
2969 _Name_##Id(arrow::ChunkedArray const* column) \
2970 : o2::soa::Column<_Type_, _Name_##Id>(o2::soa::ColumnIterator<type>(column)) \
2974 _Name_##Id() = default; \
2975 _Name_##Id(_Name_##Id const& other) = default; \
2976 _Name_##Id& operator=(_Name_##Id const& other) = default; \
2977 type inline getId() const \
2979 return _Getter_##Id(); \
2982 type _Getter_##Id() const \
2984 return *mColumnIterator; \
2987 bool has_##_Getter_() const \
2989 return *mColumnIterator >= 0; \
2992 template <typename T> \
2993 auto _Getter_##_as() const \
2995 if (O2_BUILTIN_UNLIKELY(!has_##_Getter_())) { \
2996 o2::soa::accessingInvalidIndexFor(#_Getter_); \
2998 auto t = mBinding.get<T>(); \
2999 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
3000 o2::soa::dereferenceWithWrongType(#_Getter_, "self"); \
3002 return t->rawIteratorAt(*mColumnIterator); \
3005 bool setCurrentRaw(o2::soa::Binding current) \
3007 this->mBinding = current; \
3010 o2::soa::Binding getCurrentRaw() const { return mBinding; } \
3011 o2::soa::Binding mBinding; \
3013 [[maybe_unused]] static constexpr o2::framework::expressions::BindingNode _Getter_##Id { "fIndex" _Label_, _Name_##Id::hash, o2::framework::expressions::selectArrowType<_Type_>() }
3015#define DECLARE_SOA_SELF_INDEX_COLUMN_FULL(_Name_, _Getter_, _Type_, _Label_) DECLARE_SOA_SELF_INDEX_COLUMN_COMPLETE(_Name_, _Getter_, _Type_, _Label_, void)
3016#define DECLARE_SOA_SELF_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_SELF_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, #_Name_)
3018#define DECLARE_SOA_SELF_SLICE_INDEX_COLUMN_COMPLETE(_Name_, _Getter_, _Type_, _Label_, _IndexTarget_) \
3019 struct _Name_##IdSlice : o2::soa::Column<_Type_[2], _Name_##IdSlice> { \
3020 static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
3021 static constexpr const char* mLabel = "fIndexSlice" _Label_; \
3022 static constexpr const uint32_t hash = 0; \
3023 using base = o2::soa::Column<_Type_[2], _Name_##IdSlice>; \
3024 using type = _Type_[2]; \
3025 using column_t = _Name_##IdSlice; \
3026 using self_index_t = std::true_type; \
3027 using compatible_signature = std::conditional<aod::is_aod_hash<_IndexTarget_>, _IndexTarget_, void>; \
3028 _Name_##IdSlice(arrow::ChunkedArray const* column) \
3029 : o2::soa::Column<_Type_[2], _Name_##IdSlice>(o2::soa::ColumnIterator<type>(column)) \
3033 _Name_##IdSlice() = default; \
3034 _Name_##IdSlice(_Name_##IdSlice const& other) = default; \
3035 _Name_##IdSlice& operator=(_Name_##IdSlice const& other) = default; \
3036 std::array<_Type_, 2> inline getIds() const \
3038 return _Getter_##Ids(); \
3041 bool has_##_Getter_() const \
3043 auto a = *mColumnIterator; \
3044 return a[0] >= 0 && a[1] >= 0; \
3047 std::array<_Type_, 2> _Getter_##Ids() const \
3049 auto a = *mColumnIterator; \
3050 return std::array{a[0], a[1]}; \
3053 template <typename T> \
3054 auto _Getter_##_as() const \
3056 auto t = mBinding.get<T>(); \
3057 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
3058 o2::soa::dereferenceWithWrongType(#_Getter_, "self"); \
3060 if (O2_BUILTIN_UNLIKELY(!has_##_Getter_())) { \
3061 return t->emptySlice(); \
3063 auto a = *mColumnIterator; \
3064 auto r = t->rawSlice(a[0], a[1]); \
3065 t->copyIndexBindings(r); \
3066 r.bindInternalIndicesTo(t); \
3070 bool setCurrentRaw(o2::soa::Binding current) \
3072 this->mBinding = current; \
3075 o2::soa::Binding getCurrentRaw() const { return mBinding; } \
3076 o2::soa::Binding mBinding; \
3079#define DECLARE_SOA_SELF_SLICE_INDEX_COLUMN_FULL(_Name_, _Getter_, _Type_, _Label_) DECLARE_SOA_SELF_SLICE_INDEX_COLUMN_COMPLETE(_Name_, _Getter_, _Type_, _Label_, void)
3080#define DECLARE_SOA_SELF_SLICE_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_SELF_SLICE_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, "_" #_Name_)
3082#define DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN_COMPLETE(_Name_, _Getter_, _Type_, _Label_, _IndexTarget_) \
3083 struct _Name_##Ids : o2::soa::Column<std::vector<_Type_>, _Name_##Ids> { \
3084 static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
3085 static constexpr const char* mLabel = "fIndexArray" _Label_; \
3086 static constexpr const uint32_t hash = 0; \
3087 using base = o2::soa::Column<std::vector<_Type_>, _Name_##Ids>; \
3088 using type = std::vector<_Type_>; \
3089 using column_t = _Name_##Ids; \
3090 using self_index_t = std::true_type; \
3091 using compatible_signature = std::conditional<aod::is_aod_hash<_IndexTarget_>, _IndexTarget_, void>; \
3092 _Name_##Ids(arrow::ChunkedArray const* column) \
3093 : o2::soa::Column<std::vector<_Type_>, _Name_##Ids>(o2::soa::ColumnIterator<type>(column)) \
3097 _Name_##Ids() = default; \
3098 _Name_##Ids(_Name_##Ids const& other) = default; \
3099 _Name_##Ids& operator=(_Name_##Ids const& other) = default; \
3100 gsl::span<const _Type_> inline getIds() const \
3102 return _Getter_##Ids(); \
3105 gsl::span<const _Type_> _Getter_##Ids() const \
3107 return *mColumnIterator; \
3110 bool has_##_Getter_() const \
3112 return !(*mColumnIterator).empty(); \
3115 template <typename T> \
3116 auto _Getter_##_as() const \
3118 auto t = mBinding.get<T>(); \
3119 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
3120 o2::soa::dereferenceWithWrongType(#_Getter_, "self"); \
3122 auto result = std::vector<typename T::unfiltered_iterator>(); \
3123 for (auto& i : *mColumnIterator) { \
3124 result.push_back(t->rawIteratorAt(i)); \
3129 template <typename T> \
3130 auto _Getter_##_first_as() const \
3132 return mBinding.get<T>()->rawIteratorAt((*mColumnIterator)[0]); \
3135 template <typename T> \
3136 auto _Getter_##_last_as() const \
3138 return mBinding.get<T>()->rawIteratorAt((*mColumnIterator).back()); \
3141 bool setCurrentRaw(o2::soa::Binding current) \
3143 this->mBinding = current; \
3146 o2::soa::Binding getCurrentRaw() const { return mBinding; } \
3147 o2::soa::Binding mBinding; \
3150#define DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN_FULL(_Name_, _Getter_, _Type_, _Label_) DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN_COMPLETE(_Name_, _Getter_, _Type_, _Label_, void)
3151#define DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, "_" #_Name_)
3181#define DECLARE_SOA_DYNAMIC_COLUMN(_Name_, _Getter_, ...) \
3182 struct _Name_##Callback { \
3183 static inline constexpr auto getLambda() { return __VA_ARGS__; } \
3186 struct _Name_##Helper { \
3187 using callable_t = decltype(o2::framework::FunctionMetadata(std::declval<decltype(_Name_##Callback::getLambda())>())); \
3188 using return_type = typename callable_t::return_type; \
3190 template <typename... Bindings> \
3191 struct _Name_ : o2::soa::DynamicColumn<typename _Name_##Helper::callable_t::type, _Name_<Bindings...>> { \
3192 using base = o2::soa::DynamicColumn<typename _Name_##Helper::callable_t::type, _Name_<Bindings...>>; \
3193 using helper = _Name_##Helper; \
3194 using callback_holder_t = _Name_##Callback; \
3195 using callable_t = helper::callable_t; \
3196 using callback_t = callable_t::type; \
3197 static constexpr const uint32_t hash = 0; \
3199 _Name_(arrow::ChunkedArray const*) \
3202 _Name_() = default; \
3203 _Name_(_Name_ const& other) = default; \
3204 _Name_& operator=(_Name_ const& other) = default; \
3205 static constexpr const char* mLabel = #_Name_; \
3206 using type = typename callable_t::return_type; \
3208 template <typename... FreeArgs> \
3209 type _Getter_(FreeArgs... freeArgs) const \
3211 return boundGetter(std::make_index_sequence<std::tuple_size_v<decltype(boundIterators)>>{}, freeArgs...); \
3213 template <typename... FreeArgs> \
3214 type getDynamicValue(FreeArgs... freeArgs) const \
3216 return boundGetter(std::make_index_sequence<std::tuple_size_v<decltype(boundIterators)>>{}, freeArgs...); \
3221 return _Getter_(); \
3224 template <size_t... Is, typename... FreeArgs> \
3225 type boundGetter(std::integer_sequence<size_t, Is...>&&, FreeArgs... freeArgs) const \
3227 return __VA_ARGS__((**std::get<Is>(boundIterators))..., freeArgs...); \
3230 using bindings_t = typename o2::framework::pack<Bindings...>; \
3231 std::tuple<o2::soa::ColumnIterator<typename Bindings::type> const*...> boundIterators; \
3234#define DECLARE_SOA_TABLE_METADATA(_Name_, _Desc_, _Version_, ...) \
3235 using _Name_##Metadata = TableMetadata<Hash<_Desc_ "/" #_Version_ ""_h>, __VA_ARGS__>;
3237#define DECLARE_SOA_TABLE_METADATA_TRAIT(_Name_, _Desc_, _Version_) \
3239 struct MetadataTrait<Hash<_Desc_ "/" #_Version_ ""_h>> { \
3240 using metadata = _Name_##Metadata; \
3243#define DECLARE_SOA_TABLE_FULL_VERSIONED_(_Name_, _Label_, _Origin_, _Desc_, _Version_) \
3244 O2HASH(_Desc_ "/" #_Version_); \
3245 template <typename O> \
3246 using _Name_##From = o2::soa::Table<Hash<_Label_ ""_h>, Hash<_Desc_ "/" #_Version_ ""_h>, O>; \
3247 using _Name_ = _Name_##From<Hash<_Origin_ ""_h>>; \
3249 struct MetadataTrait<Hash<_Desc_ "/" #_Version_ ""_h>> { \
3250 using metadata = _Name_##Metadata; \
3253#define DECLARE_SOA_STAGE(_Name_, _Origin_, _Desc_, _Version_) \
3254 template <typename O> \
3255 using _Name_##From = o2::soa::Table<Hash<#_Name_ ""_h>, Hash<_Desc_ "/" #_Version_ ""_h>, O>; \
3256 using _Name_ = _Name_##From<Hash<_Origin_ ""_h>>;
3258#define DECLARE_SOA_TABLE_FULL_VERSIONED(_Name_, _Label_, _Origin_, _Desc_, _Version_, ...) \
3259 DECLARE_SOA_TABLE_METADATA(_Name_, _Desc_, _Version_, __VA_ARGS__); \
3260 DECLARE_SOA_TABLE_FULL_VERSIONED_(_Name_, _Label_, _Origin_, _Desc_, _Version_);
3262#define DECLARE_SOA_TABLE_FULL(_Name_, _Label_, _Origin_, _Desc_, ...) \
3264 DECLARE_SOA_TABLE_METADATA(_Name_, _Desc_, 0, __VA_ARGS__); \
3265 DECLARE_SOA_TABLE_FULL_VERSIONED_(_Name_, _Label_, _Origin_, _Desc_, 0)
3267#define DECLARE_SOA_TABLE(_Name_, _Origin_, _Desc_, ...) \
3268 DECLARE_SOA_TABLE_FULL(_Name_, #_Name_, _Origin_, _Desc_, __VA_ARGS__)
3270#define DECLARE_SOA_TABLE_VERSIONED(_Name_, _Origin_, _Desc_, _Version_, ...) \
3272 DECLARE_SOA_TABLE_METADATA(_Name_, _Desc_, _Version_, __VA_ARGS__); \
3273 DECLARE_SOA_TABLE_FULL_VERSIONED_(_Name_, #_Name_, _Origin_, _Desc_, _Version_)
3275#define DECLARE_SOA_TABLE_STAGED_VERSIONED(_BaseName_, _Desc_, _Version_, ...) \
3276 O2HASH(_Desc_ "/" #_Version_); \
3277 O2HASH(#_BaseName_); \
3278 O2HASH("Stored" #_BaseName_); \
3279 DECLARE_SOA_TABLE_METADATA(_BaseName_, _Desc_, _Version_, __VA_ARGS__); \
3280 using Stored##_BaseName_##Metadata = _BaseName_##Metadata; \
3281 DECLARE_SOA_TABLE_METADATA_TRAIT(_BaseName_, _Desc_, _Version_); \
3282 DECLARE_SOA_STAGE(_BaseName_, "AOD", _Desc_, _Version_); \
3283 DECLARE_SOA_STAGE(Stored##_BaseName_, "AOD1", _Desc_, _Version_);
3285#define DECLARE_SOA_TABLE_STAGED(_BaseName_, _Desc_, ...) \
3286 DECLARE_SOA_TABLE_STAGED_VERSIONED(_BaseName_, _Desc_, 0, __VA_ARGS__);
3288#define DECLARE_SOA_EXTENDED_TABLE_NG(_Name_, _OriginalTable_, _Desc_, _Version_, ...) \
3289 O2HASH(_Desc_ "/" #_Version_); \
3290 O2HASH(#_Name_ "Extension"); \
3291 template <typename O> \
3292 using _Name_##ExtensionFrom = soa::Table<o2::aod::Hash<#_Name_ "Extension"_h>, o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, O>; \
3293 using _Name_##Extension = _Name_##ExtensionFrom<o2::aod::Hash<"AOD"_h>>; \
3294 struct _Name_##ExtensionMetadata : TableMetadata<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, __VA_ARGS__> { \
3295 using base_table_t = _OriginalTable_; \
3296 template <o2::aod::is_origin_hash O> \
3297 using extension_table_t_from = _Name_##ExtensionFrom<O>; \
3298 using extension_table_t = _Name_##Extension; \
3299 using expression_pack_t = framework::pack<__VA_ARGS__>; \
3300 static constexpr auto N = _OriginalTable_::originals.size(); \
3301 template <o2::aod::is_origin_hash O = o2::aod::Hash<"AOD"_h>> \
3302 static consteval auto generateSources() \
3304 return _OriginalTable_##From<O>::originals; \
3308 struct MetadataTrait<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>> { \
3309 using metadata = _Name_##ExtensionMetadata; \
3311 template <typename O> \
3312 using _Name_##From = o2::soa::Join<_OriginalTable_##From<O>, _Name_##ExtensionFrom<O>>; \
3313 using _Name_ = _Name_##From<o2::aod::Hash<"AOD"_h>>;
3315#define DECLARE_SOA_EXTENDED_TABLE(_Name_, _Table_, _Description_, _Version_, ...) \
3316 DECLARE_SOA_EXTENDED_TABLE_NG(_Name_, _Table_, _Description_, _Version_, __VA_ARGS__)
3318#define DECLARE_SOA_EXTENDED_TABLE_USER(_Name_, _Table_, _Description_, ...) \
3319 DECLARE_SOA_EXTENDED_TABLE_NG(_Name_, _Table_, "EX" _Description_, 0, __VA_ARGS__)
3321#define DECLARE_SOA_CONFIGURABLE_EXTENDED_TABLE_NG(_Name_, _OriginalTable_, _Desc_, _Version_, ...) \
3322 O2HASH(_Desc_ "/" #_Version_); \
3323 O2HASH(#_Name_ "CfgExtension"); \
3324 template <typename O> \
3325 using _Name_##CfgExtensionFrom = soa::Table<o2::aod::Hash<#_Name_ "CfgExtension"_h>, o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, O>; \
3326 using _Name_##CfgExtension = _Name_##CfgExtensionFrom<o2::aod::Hash<"AOD"_h>>; \
3327 struct _Name_##CfgExtensionMetadata : TableMetadata<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, __VA_ARGS__> { \
3328 using base_table_t = _OriginalTable_; \
3329 template <o2::aod::is_origin_hash O> \
3330 using extension_table_t_from = _Name_##CfgExtensionFrom<O>; \
3331 using extension_table_t = _Name_##CfgExtension; \
3332 using placeholders_pack_t = framework::pack<__VA_ARGS__>; \
3333 using configurable_t = std::true_type; \
3334 static constexpr auto N = _OriginalTable_::originals.size(); \
3335 template <o2::aod::is_origin_hash O = o2::aod::Hash<"AOD"_h>> \
3336 static consteval auto generateSources() \
3338 return _OriginalTable_##From<O>::originals; \
3342 struct MetadataTrait<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>> { \
3343 using metadata = _Name_##CfgExtensionMetadata; \
3345 template <typename O> \
3346 using _Name_##From = o2::soa::Join<_OriginalTable_##From<O>, _Name_##CfgExtensionFrom<O>>; \
3347 using _Name_ = _Name_##From<o2::aod::Hash<"AOD"_h>>;
3349#define DECLARE_SOA_CONFIGURABLE_EXTENDED_TABLE(_Name_, _OriginalTable_, _Description_, ...) \
3350 DECLARE_SOA_CONFIGURABLE_EXTENDED_TABLE_NG(_Name_, _OriginalTable_, "EX" _Description_, 0, __VA_ARGS__)
3352#define DECLARE_SOA_INDEX_TABLE_NG(_Name_, _Key_, _Version_, _Desc_, _Exclusive_, ...) \
3354 O2HASH(_Desc_ "/" #_Version_); \
3355 struct _Name_##Metadata : o2::aod::TableMetadata<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, soa::Index<>, __VA_ARGS__> { \
3356 static constexpr bool exclusive = _Exclusive_; \
3357 template <o2::aod::is_origin_hash O> \
3358 using KeyFrom = _Key_##From<O>; \
3359 using Key = _Key_; \
3360 using index_pack_t = framework::pack<__VA_ARGS__>; \
3361 template <o2::aod::is_origin_hash O = o2::aod::Hash<"AOD"_h>> \
3362 static consteval auto generateSources() \
3364 return []<soa::is_index_column... Cs>(framework::pack<Cs...>) { \
3365 constexpr auto first = o2::soa::mergeOriginals<typename Cs::binding_t...>(); \
3366 constexpr auto second = o2::aod::filterForKey<first.size(), first, Key>(); \
3367 return o2::aod::replaceOrigin<second.size(), second, O>(); \
3368 }(framework::pack<__VA_ARGS__>{}); \
3370 static constexpr auto N = []<typename... Cs>(framework::pack<Cs...>) { \
3371 constexpr auto a = o2::soa::mergeOriginals<typename Cs::binding_t...>(); \
3372 return o2::aod::filterForKey<a.size(), a, Key>(); \
3373 }(framework::pack<__VA_ARGS__>{}) \
3377 struct MetadataTrait<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>> { \
3378 using metadata = _Name_##Metadata; \
3380 template <o2::aod::is_origin_hash O> \
3381 using _Name_##From = o2::soa::IndexTable<o2::aod::Hash<#_Name_ ""_h>, o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, O, _Key_##From<O>, __VA_ARGS__>; \
3382 using _Name_ = _Name_##From<o2::aod::Hash<"AOD"_h>>;
3384#define DECLARE_SOA_INDEX_TABLE(_Name_, _Key_, _Description_, ...) \
3385 DECLARE_SOA_INDEX_TABLE_NG(_Name_, _Key_, 0, _Description_, false, __VA_ARGS__)
3387#define DECLARE_SOA_INDEX_TABLE_EXCLUSIVE(_Name_, _Key_, _Description_, ...) \
3388 DECLARE_SOA_INDEX_TABLE_NG(_Name_, _Key_, 0, _Description_, true, __VA_ARGS__)
3390#define DECLARE_SOA_INDEX_TABLE_USER(_Name_, _Key_, _Description_, ...) \
3391 DECLARE_SOA_INDEX_TABLE_NG(_Name_, _Key_, 0, _Description_, false, __VA_ARGS__)
3393#define DECLARE_SOA_INDEX_TABLE_EXCLUSIVE_USER(_Name_, _Key_, _Description_, ...) \
3394 DECLARE_SOA_INDEX_TABLE_NG(_Name_, _Key_, 0, _Description_, true, __VA_ARGS__)
3401#define DECLARE_SOA_TIMESTAMPED_TABLE_FULL(_Name_, _Label_, _TimestampSource_, _TimestampColumn_, _Version_, _Desc_, ...) \
3402 O2HASH(_Desc_ "/" #_Version_); \
3403 template <typename O> \
3404 using _Name_##TimestampFrom = soa::Table<o2::aod::Hash<_Label_ ""_h>, o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, O>; \
3405 using _Name_##Timestamp = _Name_##TimestampFrom<o2::aod::Hash< \
3408 struct _Name_##TimestampMetadata : TableMetadata<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, __VA_ARGS__> { \
3409 template <typename O = o2::aod::Hash<"AOD" \
3411 using base_table_t = _TimestampSource_##From<O>; \
3412 template <typename O = o2::aod::Hash<"AOD" \
3414 using extension_table_t = _Name_##TimestampFrom<O>; \
3415 static constexpr const auto ccdb_urls = []<typename... Cs>(framework::pack<Cs...>) { \
3416 return std::array<std::string_view, sizeof...(Cs)>{Cs::query...}; \
3417 }(framework::pack<__VA_ARGS__>{}); \
3418 static constexpr const auto ccdb_bindings = []<typename... Cs>(framework::pack<Cs...>) { \
3419 return std::array<std::string_view, sizeof...(Cs)>{Cs::mLabel...}; \
3420 }(framework::pack<__VA_ARGS__>{}); \
3421 static constexpr auto N = _TimestampSource_::originals.size(); \
3422 template <o2::aod::is_origin_hash O = o2::aod::Hash<"AOD"_h>> \
3423 static consteval auto generateSources() \
3425 return _TimestampSource_##From<O>::originals; \
3427 static constexpr auto timestamp_column_label = _TimestampColumn_::mLabel; \
3431 struct MetadataTrait<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>> { \
3432 using metadata = _Name_##TimestampMetadata; \
3434 template <typename O> \
3435 using _Name_##From = o2::soa::Join<_TimestampSource_, _Name_##TimestampFrom<O>>; \
3436 using _Name_ = _Name_##From<o2::aod::Hash< \
3440#define DECLARE_SOA_TIMESTAMPED_TABLE(_Name_, _TimestampSource_, _TimestampColumn_, _Version_, _Desc_, ...) \
3441 O2HASH(#_Name_ "Timestamped"); \
3442 DECLARE_SOA_TIMESTAMPED_TABLE_FULL(_Name_, #_Name_ "Timestamped", _TimestampSource_, _TimestampColumn_, _Version_, _Desc_, __VA_ARGS__)
3446template <
typename...
Ts>
3447struct Join :
Table<o2::aod::Hash<"JOIN"_h>, o2::aod::Hash<"JOIN/0"_h>, o2::aod::Hash<"JOIN"_h>, Ts...> {
3457 Join(std::vector<std::shared_ptr<arrow::Table>>&& tables, uint64_t
offset = 0)
3469 template <
typename... TA>
3513 template <
typename T1,
typename Policy,
bool OPT>
3541 template <
typename T>
3544 return []<
size_t... Is>(std::index_sequence<Is...>) {
3545 return (std::ranges::any_of(
originals, [](
TableRef const&
ref) {
return ref.desc_hash == T::originals[Is].desc_hash; }) && ...);
3546 }(std::make_index_sequence<T::originals.size()>());
3550template <
typename...
Ts>
3556template <
typename T>
3559template <
typename T>
3562template <
typename...
Ts>
3563struct Concat :
Table<o2::aod::Hash<"CONC"_h>, o2::aod::Hash<"CONC/0"_h>, o2::aod::Hash<"CONC"_h>, Ts...> {
3566 Concat(std::vector<std::shared_ptr<arrow::Table>>&& tables, uint64_t
offset = 0)
3574 bindInternalIndicesTo(
this);
3577 using base::originals;
3579 using base::bindExternalIndices;
3580 using base::bindInternalIndicesTo;
3594template <
typename...
Ts>
3600template <soa::is_table T>
3607 static constexpr const uint32_t binding_origin = T::binding_origin;
3609 template <
typename... TA>
3613 if constexpr (binding_origin == TA::binding_origin) {
3614 this->bindExternalIndex(cur);
3615 mFilteredBegin.bindExternalIndex(cur);
3624 using iterator = T::template iterator_template_o<FilteredIndexPolicy, self_t>;
3630 mSelectedRows{getSpan(selection)}
3632 if (this->tableSize() != 0) {
3633 mFilteredBegin = table_t::filtered_begin(mSelectedRows);
3636 mFilteredBegin.bindInternalIndices(
this);
3641 mSelectedRowsCache{
std::move(selection)},
3644 mSelectedRows = std::span{mSelectedRowsCache};
3645 if (this->tableSize() != 0) {
3646 mFilteredBegin = table_t::filtered_begin(mSelectedRows);
3649 mFilteredBegin.bindInternalIndices(
this);
3652 FilteredBase(std::vector<std::shared_ptr<arrow::Table>>&& tables, std::span<int64_t const>
const& selection, uint64_t
offset = 0)
3654 mSelectedRows{selection}
3656 if (this->tableSize() != 0) {
3657 mFilteredBegin = table_t::filtered_begin(mSelectedRows);
3660 mFilteredBegin.bindInternalIndices(
this);
3687 return mFilteredBegin;
3692 return mFilteredBegin;
3697 return mFilteredBegin +
i;
3702 return mSelectedRows.size();
3707 return table_t::asArrowTable()->num_rows();
3712 return mSelectedRows;
3719 std::iota(newSelection.begin(), newSelection.end(),
start);
3720 return self_t{{this->asArrowTable()}, std::move(newSelection), 0};
3730 if (sel ==
nullptr) {
3731 return std::span<int64_t const>{};
3733 auto array = std::static_pointer_cast<arrow::Int64Array>(sel->ToArray());
3736 return std::span{
start, stop};
3743 mFilteredBegin.bindExternalIndicesRaw(std::forward<std::vector<o2::soa::Binding>>(ptrs));
3746 template <
typename I>
3749 mFilteredBegin.bindInternalIndices(
ptr);
3752 template <
typename T1,
typename... Cs>
3755 dest.bindExternalIndicesRaw(mFilteredBegin.getIndexBindings());
3758 template <
typename T1>
3764 template <
typename T1>
3780 template <
typename T1,
bool OPT>
3786 template <
typename T1,
bool OPT>
3795 copyIndexBindings(t);
3801 auto locate = std::find(mSelectedRows.begin(), mSelectedRows.end(),
i);
3802 if (locate == mSelectedRows.end()) {
3805 return static_cast<int>(std::distance(mSelectedRows.begin(), locate));
3812 std::set_union(mSelectedRows.begin(), mSelectedRows.end(), selection.begin(), selection.end(), std::back_inserter(rowsUnion));
3813 mSelectedRowsCache.clear();
3814 mSelectedRowsCache = rowsUnion;
3822 std::set_intersection(mSelectedRows.begin(), mSelectedRows.end(), selection.begin(), selection.end(), std::back_inserter(intersection));
3823 mSelectedRowsCache.clear();
3824 mSelectedRowsCache = intersection;
3832 std::set_union(mSelectedRows.begin(), mSelectedRows.end(), selection.begin(), selection.end(), std::back_inserter(rowsUnion));
3833 mSelectedRowsCache.clear();
3834 mSelectedRowsCache = rowsUnion;
3842 std::set_intersection(mSelectedRows.begin(), mSelectedRows.end(), selection.begin(), selection.end(), std::back_inserter(intersection));
3843 mSelectedRowsCache.clear();
3844 mSelectedRowsCache = intersection;
3857 mSelectedRows = std::span{mSelectedRowsCache};
3861 mFilteredBegin = *mFilteredEnd;
3863 mFilteredBegin.resetSelection(mSelectedRows);
3867 std::span<int64_t const> mSelectedRows;
3869 bool mCached =
false;
3870 iterator mFilteredBegin;
3871 std::shared_ptr<RowViewSentinel> mFilteredEnd;
3874template <
typename T>
3883 using iterator = T::template iterator_template_o<FilteredIndexPolicy, self_t>;
3889 return iterator(this->cached_begin());
3903 Filtered(std::vector<std::shared_ptr<arrow::Table>>&& tables, std::span<int64_t const>
const& selection, uint64_t
offset = 0)
3927 this->sumWithSelection(selection);
3933 this->sumWithSelection(selection);
3939 return operator+=(
other.getSelectedRows());
3958 return operator*(
other.getSelectedRows());
3963 this->intersectWithSelection(selection);
3969 this->intersectWithSelection(selection);
3975 return operator*=(
other.getSelectedRows());
3991 std::iota(newSelection.begin(), newSelection.end(),
start);
3992 return self_t{{this->asArrowTable()}, std::move(newSelection), 0};
4000 template <
typename T1>
4016 template <
typename T1,
bool OPT>
4022 template <
typename T1,
bool OPT>
4031 copyIndexBindings(t);
4036template <
typename T>
4045 using iterator =
typename T::template iterator_template_o<FilteredIndexPolicy, self_t>;
4051 return iterator(this->cached_begin());
4062 for (
auto& table : tables) {
4070 for (
auto& table : tables) {
4078 for (
auto& table : tables) {
4104 this->sumWithSelection(selection);
4110 this->sumWithSelection(selection);
4116 return operator+=(
other.getSelectedRows());
4122 copy.intersectionWithSelection(selection);
4129 copy.intersectionWithSelection(selection);
4135 return operator*(
other.getSelectedRows());
4140 this->intersectWithSelection(selection);
4146 this->intersectWithSelection(selection);
4152 return operator*=(
other.getSelectedRows());
4166 std::iota(newSelection.begin(), newSelection.end(),
start);
4167 return self_t{{this->asArrowTable()}, std::move(newSelection), 0};
4185 template <
typename T1,
bool OPT>
4191 template <
typename T1,
bool OPT>
4198 std::vector<std::shared_ptr<arrow::Table>> extractTablesFromFiltered(std::vector<
Filtered<T>>& tables)
4200 std::vector<std::shared_ptr<arrow::Table>> outTables;
4201 for (
auto& table : tables) {
4202 outTables.push_back(table.asArrowTable());
4213template <
typename L,
typename D,
typename O,
typename Key,
typename H,
typename...
Ts>
4223 static constexpr const uint32_t binding_origin = Key::binding_origin;
4226 template <
typename... TA>
4230 if constexpr (binding_origin == TA::binding_origin) {
4231 this->bindExternalIndex(cur);
4258template <
typename T,
bool APPLY>
4260 static constexpr bool applyFilters = APPLY;
4267 SmallGroupsBase(std::vector<std::shared_ptr<arrow::Table>>&& tables, std::span<int64_t const>
const& selection, uint64_t
offset = 0)
4271template <
typename T>
4274template <
typename T>
4277template <
typename T>
header::DataDescription description
std::vector< std::string > labels
#define O2HASH(_Str_)
Pre-declare Hash specialization for a generic string.
#define O2ORIGIN(_Str_)
Pre-declare Hash specialization for an origin string.
consteval auto getIndexTargets()
SLICE.
o2::monitoring::tags::Key Key
#define O2_BUILTIN_UNREACHABLE
#define O2_BUILTIN_LIKELY(x)
#define O2_BUILTIN_UNLIKELY(x)
std::unique_ptr< expressions::Node > node
Class for time synchronization of RawReader instances.
int64_t const * mCurrentPos
ColumnIterator(arrow::ChunkedArray const *column)
ColumnIterator(ColumnIterator< T, ChunkingPolicy > const &)=default
void moveToEnd()
Move the iterator to the end of the column.
ColumnIterator< T > & moveToPos()
ColumnIterator< T, ChunkingPolicy > & operator=(ColumnIterator< T, ChunkingPolicy > const &)=default
unwrap_t< T > const * mCurrent
unwrap_t< T > const * mLast
ColumnIterator(ColumnIterator< T, ChunkingPolicy > &&)=default
arrow::ChunkedArray const * mColumn
ColumnIterator< T, ChunkingPolicy > & operator=(ColumnIterator< T, ChunkingPolicy > &&)=default
void moveToChunk(int chunk)
void nextChunk() const
Move the iterator to the next chunk.
auto sliceByCachedUnsorted(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
int64_t tableSize() const
FilteredBase(std::vector< std::shared_ptr< arrow::Table > > &&tables, gandiva::Selection const &selection, uint64_t offset=0)
typename T::external_index_columns_t external_index_columns_t
auto select(framework::expressions::Filter const &f) const
static auto getSpan(gandiva::Selection const &sel)
T::template iterator_template_o< FilteredIndexPolicy, self_t > iterator
auto rawSliceBy(o2::framework::Preslice< T1 > const &container, int value) const
T::template iterator_template_o< DefaultIndexPolicy, self_t > unfiltered_iterator
void copyIndexBindings(T1 &dest) const
auto const & getSelectedRows() const
void sumWithSelection(std::span< int64_t const > const &selection)
void intersectWithSelection(std::span< int64_t const > const &selection)
typename T::columns_t columns_t
void bindExternalIndices(TA *... current)
void sumWithSelection(SelectionVector const &selection)
void bindInternalIndicesTo(I const *ptr)
void intersectWithSelection(SelectionVector const &selection)
auto sliceBy(o2::framework::PresliceBase< T1, framework::PreslicePolicyGeneral, OPT > const &container, int value) const
FilteredBase(std::vector< std::shared_ptr< arrow::Table > > &&tables, std::span< int64_t const > const &selection, uint64_t offset=0)
auto rawSlice(uint64_t start, uint64_t end) const
auto sliceBy(o2::framework::PresliceBase< T1, framework::PreslicePolicySorted, OPT > const &container, int value) const
iterator iteratorAt(uint64_t i) const
typename T::table_t table_t
typename T::persistent_columns_t persistent_columns_t
RowViewSentinel end() const
FilteredBase(std::vector< std::shared_ptr< arrow::Table > > &&tables, SelectionVector &&selection, uint64_t offset=0)
void bindExternalIndicesRaw(std::vector< o2::soa::Binding > &&ptrs)
const_iterator begin() const
unfiltered_iterator rawIteratorAt(uint64_t i) const
int isInSelectedRows(int i) const
auto sliceByCached(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
void doCopyIndexBindings(framework::pack< Cs... >, T1 &dest) const
auto const & cached_begin() const
auto sliceBy(o2::framework::PresliceBase< T1, framework::PreslicePolicySorted, OPT > const &container, int value) const
Filtered< Filtered< T > > operator*(std::span< int64_t const > const &selection)
typename FilteredBase< typename T::table_t >::table_t table_t
typename T::template iterator_template_o< DefaultIndexPolicy, self_t > unfiltered_iterator
Filtered< Filtered< T > > operator+(SelectionVector const &selection)
auto sliceBy(o2::framework::PresliceBase< T1, framework::PreslicePolicyGeneral, OPT > const &container, int value) const
Filtered< Filtered< T > > operator+=(std::span< int64_t const > const &selection)
typename T::template iterator_template_o< FilteredIndexPolicy, self_t > iterator
typename T::columns_t columns_t
const_iterator begin() const
Filtered(std::vector< Filtered< T > > &&tables, std::span< int64_t const > const &selection, uint64_t offset=0)
Filtered< Filtered< T > > operator+(std::span< int64_t const > const &selection)
Filtered(std::vector< Filtered< T > > &&tables, SelectionVector &&selection, uint64_t offset=0)
unfiltered_iterator rawIteratorAt(uint64_t i) const
Filtered< Filtered< T > > operator*=(std::span< int64_t const > const &selection)
Filtered< Filtered< T > > operator+=(Filtered< T > const &other)
Filtered< Filtered< T > > operator+=(SelectionVector const &selection)
Filtered< Filtered< T > > operator*=(SelectionVector const &selection)
auto rawSlice(uint64_t start, uint64_t end) const
Filtered< Filtered< T > > operator+(Filtered< T > const &other)
Filtered(std::vector< Filtered< T > > &&tables, gandiva::Selection const &selection, uint64_t offset=0)
Filtered< Filtered< T > > operator*=(Filtered< T > const &other)
auto sliceByCached(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
Filtered< Filtered< T > > operator*(Filtered< T > const &other)
Filtered< Filtered< T > > operator*(SelectionVector const &selection)
auto sliceByCachedUnsorted(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
Filtered< T > operator*(std::span< int64_t const > const &selection)
Filtered< T > operator+=(Filtered< T > const &other)
auto sliceBy(o2::framework::PresliceBase< T1, framework::PreslicePolicyGeneral, OPT > const &container, int value) const
Filtered(std::vector< std::shared_ptr< arrow::Table > > &&tables, SelectionVector &&selection, uint64_t offset=0)
Filtered< T > operator+(std::span< int64_t const > const &selection)
auto sliceByCachedUnsorted(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
Filtered< T > operator+(Filtered< T > const &other)
Filtered< T > operator*=(SelectionVector const &selection)
Filtered(std::vector< std::shared_ptr< arrow::Table > > &&tables, std::span< int64_t const > const &selection, uint64_t offset=0)
const_iterator begin() const
T::template iterator_template_o< FilteredIndexPolicy, self_t > iterator
auto sliceByCached(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
auto select(framework::expressions::Filter const &f) const
Filtered< T > operator+(SelectionVector const &selection)
T::template iterator_template_o< DefaultIndexPolicy, self_t > unfiltered_iterator
unfiltered_iterator rawIteratorAt(uint64_t i) const
Filtered< T > operator*(SelectionVector const &selection)
Filtered< T > operator*=(Filtered< T > const &other)
Filtered< T > operator*(Filtered< T > const &other)
auto rawSliceBy(o2::framework::Preslice< T1 > const &container, int value) const
Filtered< T > operator+=(SelectionVector const &selection)
auto rawSlice(uint64_t start, uint64_t end) const
Filtered(std::vector< std::shared_ptr< arrow::Table > > &&tables, gandiva::Selection const &selection, uint64_t offset=0)
auto sliceBy(o2::framework::PresliceBase< T1, framework::PreslicePolicySorted, OPT > const &container, int value) const
Filtered< T > operator*=(std::span< int64_t const > const &selection)
Filtered< T > operator+=(std::span< int64_t const > const &selection)
typename T::table_t table_t
typename T::columns_t columns_t
decltype([]< typename... C >(framework::pack< C... > &&) -> framework::selected_pack< soa::is_self_index_t, C... > {}(columns_t{})) internal_index_columns_t
void bindInternalIndicesExplicit(o2::soa::Binding binding)
iterator iteratorAt(uint64_t i) const
decltype([]< typename... C >(framework::pack< C... > &&) -> framework::selected_pack< soa::is_persistent_column_t, C... > {}(columns_t{})) persistent_columns_t
static constexpr const auto ref
auto offset() const
Return offset.
static consteval bool hasOriginal()
unfiltered_iterator begin()
int64_t tableSize() const
auto rawSlice(uint64_t start, uint64_t end) const
void bindExternalIndices(TA *... current)
auto select(framework::expressions::Filter const &f) const
unfiltered_iterator unfiltered_const_iterator
static consteval auto full_iter()
auto const & cached_begin() const
auto sliceByCachedUnsorted(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
TableIteratorBase< IP, Parent, T... > iterator_template
static constexpr header::DataOrigin binding_origin_
void bindExternalIndicesRaw(std::vector< o2::soa::Binding > &&ptrs)
auto sliceBy(o2::framework::PresliceBase< T1, Policy, OPT > const &container, int value) const
static constexpr auto hashes()
iterator unfiltered_iterator
void bindExternalIndex(TA *current)
std::shared_ptr< arrow::Table > asArrowTable() const
Return a type erased arrow table backing store for / the type safe table.
filtered_iterator filtered_begin(std::span< int64_t const > selection)
void doCopyIndexBindings(framework::pack< Cs... >, T &dest) const
int64_t size() const
Size of the table, in rows.
Table(std::vector< std::shared_ptr< arrow::Table > > &&tables, uint64_t offset=0)
decltype(getColumns< ref, Ts... >()) columns_t
arrow::ChunkedArray * getIndexToKey()
decltype([]< typename... C >(framework::pack< C... >) -> framework::pack< typename C::type... > {}(persistent_columns_t{})) column_types
static constexpr const uint32_t binding_origin
static consteval auto isIndexTargetOf()
iterator_template_o< FilteredIndexPolicy, table_t > filtered_iterator
unfiltered_const_iterator begin() const
void copyIndexBindings(T &dest) const
static constexpr const auto originalLabels
Table(std::vector< std::shared_ptr< arrow::Table > > &&tables, uint64_t offset=0)
Table< L, D, O, Ts... > self_t
static consteval auto isIndexTargetOf()
decltype(full_iter< IP, Parent >()) iterator_template_o
void doBindInternalIndicesExplicit(framework::pack< Cs... >, o2::soa::Binding binding)
static constexpr const auto originals
decltype([]< typename... C >(framework::pack< C... > &&) -> framework::selected_pack< soa::is_external_index_t, C... > {}(columns_t{})) external_index_columns_t
Table(std::shared_ptr< arrow::Table > table, uint64_t offset=0)
RowViewSentinel end() const
auto sliceByCached(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
void bindInternalIndicesTo(I const *ptr)
unfiltered_iterator rawIteratorAt(uint64_t i) const
iterator_template_o< DefaultIndexPolicy, table_t > iterator
hash identification concepts
Helper to check if a type T is an iterator.
column identification concepts
GLuint GLsizei const GLuint const GLintptr * offsets
GLuint const GLchar * name
GLboolean GLboolean GLboolean b
GLsizei const GLfloat * value
GLint GLint GLsizei GLint GLenum GLenum type
GLuint GLsizei GLsizei * length
GLuint GLsizei const GLchar * label
GLsizei GLenum const void * indices
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GLenum GLenum GLsizei len
GLboolean GLboolean GLboolean GLboolean a
std::shared_ptr< gandiva::SelectionVector > Selection
consteval const char * origin_str()
consteval const char * signature()
consteval auto replaceOrigin()
Replace origins in the TableRef array.
constexpr framework::ConcreteDataMatcher matcher()
consteval auto filterForKey()
Filter TableRef array for compatibility with Key table.
consteval const char * label()
consteval header::DataOrigin origin()
gandiva::Selection createSelection(std::shared_ptr< arrow::Table > const &table, Filter const &expression)
Function for creating gandiva selection from our internal filter tree.
Defining ITS Vertex explicitly as messageable.
std::decay_t< decltype(select_pack< Condition >(pack<>{}, Pack{}, CondPack{}))> selected_pack_multicondition
std::decay_t< decltype(prune_voids_pack(pack<>{}, with_condition_pack< Condition, Types... >{}))> selected_pack
decltype(intersected_pack(Ps{}...)) full_intersected_pack_t
typename pack_element< I, T >::type pack_element_t
consteval size_t has_type_at_v(pack< Ts... >)
constexpr std::size_t pack_size(pack< Ts... > const &)
template function to determine number of types in a pack
decltype(concatenate_pack_unique(Ps{}...)) concatenated_pack_unique_t
std::string strToUpper(std::string &&str)
typename pack_element< 0, T >::type pack_head_t
std::string cutString(std::string &&str)
std::vector< std::vector< int64_t > > ListVector
R getColumnValue(const T &rowIterator)
ColumnGetterFunction< R, typename T::iterator > getColumnGetterByLabel(const std::string_view &targetColumnLabel)
void * extractCCDBPayload(char *payload, size_t size, TClass const *cl, const char *what)
consteval auto computeOriginals()
auto createFieldsFromColumns(framework::pack< C... >)
SelectionVector selectionToVector(gandiva::Selection const &sel)
constexpr bool is_persistent_v
constexpr bool is_ng_index_equivalent_v
consteval auto remove_if(L l)
constexpr auto join(Ts const &... t)
auto doSliceBy(T const *table, o2::framework::PresliceBase< C, Policy, OPT > const &container, int value)
void notBoundTable(const char *tableName)
SelectionVector sliceSelection(std::span< int64_t const > const &mSelectedRows, int64_t nrows, uint64_t offset)
auto doFilteredSliceBy(T const *table, o2::framework::PresliceBase< C, framework::PreslicePolicySorted, OPT > const &container, int value)
constexpr auto concat(Ts const &... t)
consteval auto intersectOriginals()
consteval auto getColumns()
std::vector< int64_t > SelectionVector
std::conditional_t< is_binding_compatible_v< T, typename B::binding_t >(), std::true_type, std::false_type > is_binding_compatible
consteval auto mergeOriginals()
constexpr bool is_soa_filtered_v
typename std::conditional_t< is_index_column< C >, std::true_type, std::false_type > is_external_index_t
void missingFilterDeclaration(int hash, int ai)
auto doSliceByCachedUnsorted(T const *table, framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache)
auto doSliceByCached(T const *table, framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache)
void accessingInvalidIndexFor(const char *getter)
auto select(T const &t, framework::expressions::Filter const &f)
consteval auto base_iter(framework::pack< C... > &&) -> TableIterator< D, O, IP, C... >
constexpr bool is_index_equivalent_v
constexpr bool is_soa_join_v
void dereferenceWithWrongType(const char *getter, const char *target)
std::conditional_t< is_indexing_column< T >, std::true_type, std::false_type > is_indexing_t
consteval bool is_binding_compatible_v()
auto prepareFilteredSlice(T const *table, std::shared_ptr< arrow::Table > slice, uint64_t offset)
typename unwrap< T >::type unwrap_t
void getterNotFound(const char *targetColumnLabel)
auto doFilteredSliceByCached(T const *table, framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache)
void missingOptionalPreslice(const char *label, const char *key)
auto doSliceByHelper(T const *table, std::span< const int64_t > const &selection)
std::function< framework::ConcreteDataMatcher(framework::ConcreteDataMatcher &&)> originReplacement(header::DataOrigin newOrigin)
consteval bool is_compatible()
arrow::ChunkedArray * getIndexFromLabel(arrow::Table *table, std::string_view label)
consteval auto merge()
Helpers to manipulate TableRef arrays.
consteval auto merge_if(L l)
std::conditional_t< is_persistent_column< C >, std::true_type, std::false_type > is_persistent_column_t
typename arrow_array_for< T >::type arrow_array_for_t
void notFoundColumn(const char *label, const char *key)
std::conditional_t< is_dynamic_column< T >, std::true_type, std::false_type > is_dynamic_t
typename std::conditional_t< is_self_index_column< C >, std::true_type, std::false_type > is_self_index_t
FIXME: do not use data model tables.
static constexpr uint32_t hash
static constexpr char const *const str
SliceInfoUnsortedPtr getCacheUnsortedFor(Entry const &bindingKey) const
header::DataOrigin newOrigin
SliceInfoPtr getCacheFor(Entry const &bindingKey) const
std::shared_ptr< arrow::Table > getEmptySliceFor(std::shared_ptr< arrow::Table > const &table)
std::shared_ptr< arrow::Table > getSliceFor(int value, std::shared_ptr< arrow::Table > const &input, uint64_t &offset) const
static constexpr bool optional
PresliceBase(expressions::BindingNode index_)
std::span< const int64_t > getSliceFor(int value) const
const std::string binding
tracks origin in bindingKey matcher to handle the correct arguments
const std::string binding
Entry const & getBindingKey() const
SliceInfoUnsortedPtr sliceInfo
std::span< const int64_t > getSliceFor(int value) const
void updateSliceInfo(SliceInfoUnsortedPtr &&si)
void updateSliceInfo(SliceInfoPtr &&si)
std::pair< arrow::Table const *, std::shared_ptr< arrow::Table > > emptySlice
std::shared_ptr< arrow::Table > getSliceFor(int value, std::shared_ptr< arrow::Table > const &input, uint64_t &offset) const
ArrowTableSlicingCache * ptr
std::pair< int64_t, int64_t > getSliceFor(int value) const
An expression tree node corresponding to a column binding.
A struct, containing the root of the expression tree.
From https://en.cppreference.com/w/cpp/utility/variant/visit.
static std::shared_ptr< arrow::Table > joinTables(std::vector< std::shared_ptr< arrow::Table > > &&tables)
static std::shared_ptr< arrow::Table > concatTables(std::vector< std::shared_ptr< arrow::Table > > &&tables)
Type-checking index column binding.
void bind(T const *table)
static constexpr bool chunked
arrow::ChunkedArray * second
Column(ColumnIterator< T > const &it)
static constexpr const char *const & columnLabel()
ColumnIterator< T > const & getIterator() const
Column & operator=(Column const &)=default
Column(Column &&)=default
static auto asArrowField()
Column & operator=(Column &&)=default
Column(Column const &)=default
ColumnIterator< T > mColumnIterator
table_t::template iterator_template< DefaultIndexPolicy, self_t, Ts... > iterator
Concat(Ts const &... t, uint64_t offset=0)
typename table_t::persistent_columns_t persistent_columns_t
typename table_t::columns_t columns_t
const_iterator unfiltered_const_iterator
iterator unfiltered_iterator
table_t::template iterator_template< FilteredIndexPolicy, self_t, Ts... > filtered_iterator
Concat(std::vector< std::shared_ptr< arrow::Table > > &&tables, uint64_t offset=0)
filtered_iterator filtered_const_iterator
DefaultIndexPolicy(int64_t nRows, uint64_t offset)
friend bool operator==(DefaultIndexPolicy const &lh, DefaultIndexPolicy const &rh)
bool operator==(RowViewSentinel const &sentinel) const
DefaultIndexPolicy(FilteredIndexPolicy const &other)
std::tuple< uint64_t const * > getOffsets() const
DefaultIndexPolicy & operator=(DefaultIndexPolicy &&)=default
void setCursor(int64_t i)
void limitRange(int64_t start, int64_t end)
DefaultIndexPolicy(DefaultIndexPolicy &&)=default
DefaultIndexPolicy(DefaultIndexPolicy const &)=default
DefaultIndexPolicy & operator=(DefaultIndexPolicy const &)=default
std::tuple< int64_t const *, int64_t const * > getIndices() const
DefaultIndexPolicy()=default
Needed to be able to copy the policy.
void moveByIndex(int64_t i)
static constexpr const char *const & columnLabel()
FilteredIndexPolicy & operator=(FilteredIndexPolicy &&)=default
std::tuple< int64_t const *, int64_t const * > getIndices() const
FilteredIndexPolicy & operator=(FilteredIndexPolicy const &)=default
auto getSelectionRow() const
FilteredIndexPolicy()=default
FilteredIndexPolicy(std::span< int64_t const > selection, int64_t rows, uint64_t offset=0)
friend bool operator==(FilteredIndexPolicy const &lh, FilteredIndexPolicy const &rh)
void resetSelection(std::span< int64_t const > selection)
void setCursor(int64_t i)
FilteredIndexPolicy(FilteredIndexPolicy const &)=default
bool operator==(RowViewSentinel const &sentinel) const
std::tuple< uint64_t const * > getOffsets() const
void limitRange(int64_t start, int64_t end)
FilteredIndexPolicy(FilteredIndexPolicy &&)=default
void moveByIndex(int64_t i)
static constexpr bool chunked
static constexpr const char *const & columnLabel()
static constexpr const uint32_t hash
uint64_t mOffset
Offset within a larger table.
int64_t mRowIndex
Position inside the current table.
IndexTable(std::vector< std::shared_ptr< arrow::Table > > tables, uint64_t offset=0)
void bindExternalIndices(TA *... current)
IndexTable(std::shared_ptr< arrow::Table > table, uint64_t offset=0)
typename base_t::template iterator_template_o< DefaultIndexPolicy, self_t > iterator
filtered_iterator const_filtered_iterator
IndexTable(IndexTable &&)=default
IndexTable & operator=(IndexTable const &)=default
IndexTable & operator=(IndexTable &&)=default
typename H::binding_t first_t
typename base_t::template iterator_template_o< FilteredIndexPolicy, self_t > filtered_iterator
IndexTable(IndexTable const &)=default
Index(Index const &)=default
void setIndices(std::tuple< int64_t const *, int64_t const * > indices)
Index & operator=(Index &&)=default
Index(arrow::ChunkedArray const *)
int64_t filteredIndex() const
constexpr int64_t rangeEnd()
constexpr int64_t rangeStart()
Index & operator=(Index const &)=default
int64_t globalIndex() const
std::tuple< int64_t const *, int64_t const * > rowIndices
void setOffsets(std::tuple< uint64_t const * > offsets)
static constexpr const char * mLabel
std::tuple< uint64_t const * > rowOffsets
auto sliceBy(o2::framework::PresliceBase< T1, Policy, OPT > const &container, int value) const
static constexpr const auto originalLabels
Join(std::vector< std::shared_ptr< arrow::Table > > &&tables, uint64_t offset=0)
static constexpr const auto originals
iterator rawIteratorAt(uint64_t i) const
static constexpr const uint32_t binding_origin
auto sliceByCached(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
const_iterator unfiltered_const_iterator
typename table_t::columns_t columns_t
Table< o2::aod::Hash<"JOIN"_h >, o2::aod::Hash<"JOIN/0"_h >, o2::aod::Hash<"JOIN"_h >, Ts... > base
iterator iteratorAt(uint64_t i) const
typename table_t::persistent_columns_t persistent_columns_t
const_iterator begin() const
void bindExternalIndices(TA *... current)
table_t::template iterator_template< DefaultIndexPolicy, self_t, Ts... > iterator
static consteval bool contains()
Join(std::shared_ptr< arrow::Table > &&table, uint64_t offset=0)
table_t::template iterator_template< FilteredIndexPolicy, self_t, Ts... > filtered_iterator
auto sliceByCachedUnsorted(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
auto rawSlice(uint64_t start, uint64_t end) const
static constexpr const header::DataOrigin binding_origin_
iterator unfiltered_iterator
filtered_iterator filtered_const_iterator
static constexpr const uint32_t hash
static constexpr const char *const & columnLabel()
Marker & operator=(Marker const &)=default
static constexpr auto value
static constexpr const char * mLabel
Marker(arrow::ChunkedArray const *)
Marker(Marker const &)=default
Marker & operator=(Marker &&)=default
Marker(Marker &&)=default
SmallGroupsBase(std::vector< std::shared_ptr< arrow::Table > > &&tables, SelectionVector &&selection, uint64_t offset=0)
SmallGroupsBase(std::vector< std::shared_ptr< arrow::Table > > &&tables, std::span< int64_t const > const &selection, uint64_t offset=0)
SmallGroupsBase(std::vector< std::shared_ptr< arrow::Table > > &&tables, gandiva::Selection const &selection, uint64_t offset=0)
framework::selected_pack< soa::is_persistent_column_t, C... > persistent_columns_t
void doSetCurrentIndexRaw(framework::pack< Cs... > p, std::vector< o2::soa::Binding > &&ptrs)
void bindInternalIndices(I const *table)
TableIterator(TableIterator< D, O, FilteredIndexPolicy, C... > const &other)
TableIterator(self_t const &other)
TableIterator operator-(int64_t dec) const
TableIterator(arrow::ChunkedArray *columnData[sizeof...(C)], IP &&policy)
TableIterator & operator=(TableIterator other)
TableIterator & operator++()
void bindExternalIndex(TA *current)
void doSetCurrentInternal(framework::pack< Cs... >, I const *ptr)
auto getIndexBindingsImpl(framework::pack< Cs... >) const
TableIterator operator--(int)
void bindExternalIndicesRaw(std::vector< o2::soa::Binding > &&ptrs)
TableIterator(arrow::ChunkedArray *columnData[sizeof...(C)], IP &&policy)
decltype([]< typename... Cs >(framework::pack< Cs... >) -> framework::pack< typename Cs::binding_t... > {}(external_index_columns_t{})) bindings_pack_t
void bindExternalIndices(TA *... current)
TableIterator & operator--()
framework::selected_pack< soa::is_external_index_t, C... > external_index_columns_t
TableIterator const & operator*() const
TableIterator operator++(int)
framework::selected_pack< soa::is_self_index_t, C... > internal_index_columns_t
auto getIndexBindings() const
TableIterator operator+(int64_t inc) const
Allow incrementing by more than one the iterator.
Generic identifier for a table type.
constexpr TableRef & operator=(TableRef const &)=default
constexpr bool descriptionCompatible(uint32_t _desc_hash) const noexcept
constexpr bool operator==(TableRef const &other) const noexcept
constexpr TableRef(TableRef &&)=default
constexpr TableRef(TableRef const &)=default
consteval TableRef(uint32_t _label, uint32_t _desc, uint32_t _origin, uint32_t _version)
constexpr bool descriptionCompatible(TableRef const &other) const noexcept
constexpr TableRef & operator=(TableRef &&)=default
TableIteratorBase const & operator*() const
TableIteratorBase(TableIteratorBase< IP, P, T... > const &other)
typename Parent::columns_t columns_t
TableIteratorBase(TableIteratorBase< IP, P, O1, Os... > const &other)
typename Parent::external_index_columns_t external_index_columns_t
TableIteratorBase operator-(int64_t dec) const
void matchTo(TableIteratorBase< IP, P, T... > const &other)
auto getDynamicColumn() const
TableIteratorBase()=default
void matchTo(TableIteratorBase< IP, P, Os... > const &other)
TableIteratorBase(TableIteratorBase< FilteredIndexPolicy, P, T... > other)
std::array< B, sizeof...(CCs)> getValues() const
static constexpr auto originals
TableIteratorBase(TableIteratorBase< IP, P, T... > &&other) noexcept
decltype([]< typename... C >(framework::pack< C... >) -> framework::pack< typename C::binding_t... > {}(external_index_columns_t{})) bindings_pack_t
TableIteratorBase & operator=(TableIteratorBase< IP, P, Os... > other)
TableIteratorBase(TableIteratorBase< IP, P, O1, Os... > &&other) noexcept
TableIteratorBase & operator=(RowViewSentinel const &other)
TableIteratorBase(arrow::ChunkedArray *columnData[framework::pack_size(columns_t{})], IP &&policy)
TableIteratorBase & operator=(TableIteratorBase< IP, P, T... > other)
TableIteratorBase operator+(int64_t inc) const
Allow incrementing by more than one the iterator.
TableIteratorBase & operator=(TableIteratorBase< FilteredIndexPolicy, P, T... > other)
VectorOfTObjectPtrs other
std::vector< ReadoutWindowData > rows