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& 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
const&
key)
1432template <TableRef ref>
1433static constexpr std::pair<bool, framework::ConcreteDataMatcher> hasKeyM(std::string
const&
key)
1438template <
typename...
C>
1441 return std::vector{hasKey<C>(
key)...};
1447template <with_originals T,
bool OPT = false>
1448static constexpr std::string getLabelFromTypeForKey(std::string
const&
key)
1450 if constexpr (T::originals.size() == 1) {
1451 auto locate = hasKey<T::originals[0]>(
key);
1453 return locate.second;
1456 auto locate = [&]<
size_t... Is>(std::index_sequence<Is...>) {
1457 return std::vector{hasKey<T::originals[Is]>(
key)...};
1458 }(std::make_index_sequence<T::originals.size()>{});
1459 auto it = std::find_if(locate.begin(), locate.end(), [](
auto const&
x) { return x.first; });
1460 if (it != locate.end()) {
1464 if constexpr (!OPT) {
1472template <with_originals T,
bool OPT = false>
1475 if constexpr (T::originals.size() == 1) {
1476 auto locate = hasKeyM<T::originals[0]>(
key);
1478 return locate.second;
1481 auto locate = [&]<
size_t... Is>(std::index_sequence<Is...>) {
1482 return std::vector{hasKeyM<T::originals[Is]>(
key)...};
1483 }(std::make_index_sequence<T::originals.size()>{});
1484 auto it = std::find_if(locate.begin(), locate.end(), [](
auto const&
x) { return x.first; });
1485 if (it != locate.end()) {
1489 if constexpr (!OPT) {
1497template <
typename B,
typename...
C>
1500 return (o2::soa::is_binding_compatible_v<B, typename C::binding_t>() || ...);
1503template <
typename B,
typename...
C>
1506 return ((C::sorted && o2::soa::is_binding_compatible_v<B, typename C::binding_t>()) || ...);
1509template <
typename B,
typename Z>
1510consteval static bool relatedByIndex()
1512 return hasIndexTo<B>(
typename Z::table_t::external_index_columns_t{});
1515template <
typename B,
typename Z>
1516consteval static bool relatedBySortedIndex()
1518 return hasSortedIndexTo<B>(
typename Z::table_t::external_index_columns_t{});
1537 std::shared_ptr<arrow::Table>
getSliceFor(
int value, std::shared_ptr<arrow::Table>
const& input, uint64_t&
offset)
const;
1547template <
typename T>
1550template <
typename T, is_preslice_policy Policy,
bool OPT = false>
1558 : 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})}, {}}
1564 if constexpr (OPT) {
1565 if (Policy::isMissing()) {
1574 if constexpr (OPT) {
1575 if (Policy::isMissing()) {
1579 return Policy::getSliceFor(
value);
1583template <
typename T>
1585template <
typename T>
1587template <
typename T>
1589template <
typename T>
1592template <
typename T>
1614template <
typename T>
1621template <soa::is_table T>
1623template <
typename T>
1626template <
typename T>
1629template <
typename T>
1632template <
typename T>
1636template <
typename T>
1639template <
typename T>
1642template <
typename T>
1646template <
typename... Is>
1654template <
typename T,
typename C,
typename Policy,
bool OPT>
1655 requires std::same_as<Policy, framework::PreslicePolicySorted> && (o2::soa::is_binding_compatible_v<C, T>())
1658 if constexpr (OPT) {
1659 if (container.isMissing()) {
1665 auto t =
typename T::self_t({out},
offset);
1666 if (t.tableSize() != 0) {
1667 table->copyIndexBindings(t);
1668 t.bindInternalIndicesTo(table);
1673template <soa::is_filtered_table T>
1677 if (t.tableSize() != 0) {
1679 t.bindInternalIndicesTo(table);
1680 t.intersectWithSelection(table->getSelectedRows());
1685template <soa::is_table T>
1690 if (t.tableSize() != 0) {
1692 t.bindInternalIndicesTo(table);
1697template <
typename T,
typename C,
typename Policy,
bool OPT>
1698 requires std::same_as<Policy, framework::PreslicePolicyGeneral> && (o2::soa::is_binding_compatible_v<C, T>())
1701 if constexpr (OPT) {
1702 if (container.isMissing()) {
1712template <soa::is_filtered_table T>
1715 if (
offset >=
static_cast<uint64_t
>(table->tableSize())) {
1717 if (fresult.tableSize() != 0) {
1724 if (fresult.tableSize() != 0) {
1730template <soa::is_filtered_table T,
typename C,
bool OPT>
1731 requires(o2::soa::is_binding_compatible_v<C, T>())
1734 if constexpr (OPT) {
1735 if (container.isMissing()) {
1744template <soa::is_table T>
1747 auto localCache = cache.
ptr->
getCacheFor({
"", o2::soa::getMatcherFromTypeForKey<T>(
node.name),
node.name});
1749 auto t =
typename T::self_t({table->asArrowTable()->Slice(
static_cast<uint64_t
>(
offset),
count)},
static_cast<uint64_t
>(
offset));
1750 if (t.tableSize() != 0) {
1751 table->copyIndexBindings(t);
1756template <soa::is_filtered_table T>
1759 auto localCache = cache.
ptr->
getCacheFor({
"", o2::soa::getMatcherFromTypeForKey<T>(
node.name),
node.name});
1761 auto slice = table->asArrowTable()->Slice(
static_cast<uint64_t
>(
offset),
count);
1765template <soa::is_table T>
1770 auto t =
typename T::self_t({table->asArrowTable()}, localCache.getSliceFor(
value));
1771 if (t.tableSize() != 0) {
1772 t.intersectWithSelection(table->getSelectedRows());
1773 table->copyIndexBindings(t);
1777 auto t =
Filtered<T>({table->asArrowTable()}, localCache.getSliceFor(
value));
1778 if (t.tableSize() != 0) {
1779 table->copyIndexBindings(t);
1785template <with_originals T>
1793template <
typename D,
typename O,
typename IP,
typename...
C>
1830 return std::array<TableRef, 1>{
ref};
1852 static constexpr const auto ref =
TableRef{L::hash, D::hash, O::hash, o2::aod::version(D::str)};
1857 static constexpr const auto originalLabels = []<
size_t N, std::array<TableRef, N> refs,
size_t... Is>(std::index_sequence<Is...>) {
1858 return std::array<const char*, N>{o2::aod::label<refs[Is]>()...};
1863 template <
size_t N, std::array<TableRef, N> bindings>
1864 requires(
ref.origin_hash ==
"CONC"_h)
1870 template <
size_t N, std::array<TableRef, N> bindings>
1871 requires(
ref.origin_hash ==
"JOIN"_h)
1876 return std::ranges::any_of(bindings, [&
r](
TableRef const&
b) {
return b ==
r; });
1880 template <
size_t N, std::array<TableRef, N> bindings>
1881 requires(!(
ref.origin_hash ==
"CONC"_h ||
ref.origin_hash ==
"JOIN"_h))
1884 return std::find(bindings.begin(), bindings.end(),
self_t::ref) != bindings.end();
1887 template <TableRef r>
1900 template <
typename IP>
1903 template <
typename IP,
typename Parent,
typename... T>
1920 template <
typename P,
typename... Os>
1922 requires(P::ref.desc_hash == Parent::ref.desc_hash)
1928 template <
typename P>
1935 template <
typename P>
1937 requires std::same_as<IP, DefaultIndexPolicy>
1943 template <
typename P,
typename O1,
typename... Os>
1945 requires(P::ref.desc_hash == Parent::ref.desc_hash)
1950 template <
typename P,
typename O1,
typename... Os>
1952 requires(P::ref.desc_hash == Parent::ref.desc_hash)
1957 template <
typename P>
1963 template <
typename P>
1969 template <
typename P>
1971 requires std::same_as<IP, DefaultIndexPolicy>
1978 this->mRowIndex =
other.index;
1981 template <
typename P>
1984 this->mRowIndex =
other.mRowIndex;
1987 template <
typename P,
typename... Os>
1989 requires std::same_as<typename P::table_t, typename Parent::table_t>
1991 this->mRowIndex =
other.mRowIndex;
1994 template <
typename TI>
1997 using decayed = std::decay_t<TI>;
1999 constexpr auto idx = framework::has_type_at_v<decayed>(
bindings_pack_t{});
2001 }
else if constexpr (std::same_as<decayed, Parent>) {
2002 return this->globalIndex();
2004 return this->globalIndex();
2006 return static_cast<int32_t
>(-1);
2010 template <
typename CD,
typename... CDArgs>
2013 using decayed = std::decay_t<CD>;
2015 return static_cast<decayed
>(*this).template getDynamicValue<CDArgs...>();
2018 template <
typename B,
typename CC>
2021 using COL = std::decay_t<CC>;
2023 return static_cast<B>(
static_cast<COL
>(*this).get());
2026 template <
typename B,
typename... CCs>
2029 static_assert(std::same_as<B, float> || std::same_as<B, double>,
"The common return type should be float or double");
2030 return {getValue<B, CCs>()...};
2041 copy.moveByIndex(inc);
2056 template <
typename IP,
typename Parent,
typename... T>
2059 template <
typename IP,
typename Parent>
2062 if constexpr (
sizeof...(Ts) == 0) {
2073 template <
typename IP,
typename Parent>
2091 mEnd{table->num_rows()}
2093 if (mTable->num_rows() == 0) {
2095 mColumnChunks[ci] =
nullptr;
2101 mColumnChunks[ci] = lookups[ci];
2104 mBegin.bindInternalIndices(
this);
2108 Table(std::vector<std::shared_ptr<arrow::Table>>&& tables, uint64_t
offset = 0)
2109 requires(
ref.origin_hash !=
"CONC"_h)
2114 Table(std::vector<std::shared_ptr<arrow::Table>>&& tables, uint64_t
offset = 0)
2115 requires(
ref.origin_hash ==
"CONC"_h)
2120 template <
typename Key>
2124 return std::array<bool,
sizeof...(Cs)>{[]() {
2125 if constexpr (
requires { Cs::index_targets.size(); }) {
2126 return Key::template
isIndexTargetOf<Cs::index_targets.size(), Cs::index_targets>();
2132 constexpr auto pos = std::find(map.begin(), map.end(),
true);
2133 if constexpr (
pos != map.end()) {
2134 return mColumnChunks[std::distance(map.begin(),
pos)];
2136 static_assert(framework::always_static_assert_v<Key>,
"This table does not have an index to given Key");
2166 return filtered_iterator(mColumnChunks, {selection, mTable->num_rows(), mOffset});
2204 return mTable->num_rows();
2214 template <
typename... TA>
2219 mBegin.bindExternalIndex(cur);
2225 template <
typename TA>
2228 mBegin.bindExternalIndex(current);
2231 template <
typename I>
2234 mBegin.bindInternalIndices(
ptr);
2242 template <
typename... Cs>
2245 (
static_cast<Cs
>(mBegin).setCurrentRaw(
binding), ...);
2250 mBegin.bindExternalIndicesRaw(std::forward<std::vector<o2::soa::Binding>>(ptrs));
2253 template <
typename T,
typename... Cs>
2256 dest.bindExternalIndicesRaw(mBegin.getIndexBindings());
2259 template <
typename T>
2282 template <
typename T1,
typename Policy,
bool OPT>
2295 return self_t{mTable->Slice(0, 0), 0};
2299 template <
typename T>
2300 arrow::ChunkedArray* lookupColumn()
2303 auto label = T::columnLabel();
2309 std::shared_ptr<arrow::Table> mTable =
nullptr;
2310 uint64_t mOffset = 0;
2317template <uint32_t
D, soa::is_column...
C>
2323namespace row_helpers
2325template <
typename R,
typename T,
typename C>
2328 return static_cast<R>(
static_cast<C>(rowIterator).get());
2333template <
typename R,
typename T>
2334using ColumnGetterFunction =
R (*)(
const T&);
2336template <
typename T,
typename R>
2341 { t.get() } -> std::convertible_to<R>;
2344template <
typename T,
typename R>
2346 { t.get() } -> std::convertible_to<R>;
2349template <
typename R,
typename T, persistent_with_common_getter<R> C>
2350ColumnGetterFunction<R, T> createGetterPtr(
const std::string_view& targetColumnLabel)
2352 return targetColumnLabel == C::columnLabel() ? &getColumnValue<R, T, C> :
nullptr;
2355template <
typename R,
typename T, dynamic_with_common_getter<R> C>
2356ColumnGetterFunction<R, T> createGetterPtr(
const std::string_view& targetColumnLabel)
2362 if (targetColumnLabel.starts_with(
"f") && targetColumnLabel.substr(1) ==
columnLabel) {
2363 return &getColumnValue<R, T, C>;
2368 return &getColumnValue<R, T, C>;
2374template <
typename R,
typename T,
typename... Cs>
2377 ColumnGetterFunction<R, T>
func;
2379 (
void)((
func = createGetterPtr<R, T, Cs>(targetColumnLabel),
func) || ...);
2388template <
typename T,
typename R>
2389using 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;
2392template <
typename R,
typename T>
2397 if (targetColumnLabel.size() == 0) {
2401 return getColumnGetterByLabel<R, typename T::iterator>(TypesWithCommonGetter{}, targetColumnLabel);
2426template <
typename T>
2427consteval static std::string_view namespace_prefix()
2429 constexpr auto name = o2::framework::type_name<T>();
2430 const auto pos =
name.rfind(std::string_view{
":"});
2431 return name.substr(0,
pos + 1);
2435#define DECLARE_EQUIVALENT_FOR_INDEX(_Base_, _Equiv_) \
2437 struct EquivalentIndexNG<o2::aod::Hash<_Base_::ref.desc_hash>, o2::aod::Hash<_Equiv_::ref.desc_hash>> { \
2438 constexpr static bool value = true; \
2441#define DECLARE_EQUIVALENT_FOR_INDEX_NG(_Base_, _Equiv_) \
2443 struct EquivalentIndexNG<o2::aod::Hash<_Base_ ""_h>, o2::aod::Hash<_Equiv_ ""_h>> { \
2444 constexpr static bool value = true; \
2447#define DECLARE_SOA_COLUMN_FULL(_Name_, _Getter_, _Type_, _Label_) \
2448 struct _Name_ : o2::soa::Column<_Type_, _Name_> { \
2449 static constexpr const char* mLabel = _Label_; \
2450 static constexpr const uint32_t hash = compile_time_hash(namespace_prefix<_Name_>(), std::string_view{#_Getter_}); \
2451 static_assert(!((*(mLabel + 1) == 'I' && *(mLabel + 2) == 'n' && *(mLabel + 3) == 'd' && *(mLabel + 4) == 'e' && *(mLabel + 5) == 'x')), "Index is not a valid column name"); \
2452 using base = o2::soa::Column<_Type_, _Name_>; \
2453 using type = _Type_; \
2454 using column_t = _Name_; \
2455 _Name_(arrow::ChunkedArray const* column) \
2456 : o2::soa::Column<_Type_, _Name_>(o2::soa::ColumnIterator<type>(column)) \
2460 _Name_() = default; \
2461 _Name_(_Name_ const& other) = default; \
2462 _Name_& operator=(_Name_ const& other) = default; \
2464 decltype(auto) _Getter_() const \
2466 return *mColumnIterator; \
2469 decltype(auto) get() const \
2471 return _Getter_(); \
2474 [[maybe_unused]] static constexpr o2::framework::expressions::BindingNode _Getter_ { _Label_, _Name_::hash, o2::framework::expressions::selectArrowType<_Type_>() }
2476#define DECLARE_SOA_CCDB_COLUMN_FULL(_Name_, _Label_, _Getter_, _ConcreteType_, _CCDBQuery_) \
2477 struct _Name_ : o2::soa::Column<std::span<std::byte>, _Name_> { \
2478 static constexpr const char* mLabel = _Label_; \
2479 static constexpr const char* query = _CCDBQuery_; \
2480 static constexpr const uint32_t hash = crc32(namespace_prefix<_Name_>(), std::string_view{#_Getter_}); \
2481 using base = o2::soa::Column<std::span<std::byte>, _Name_>; \
2482 using type = std::span<std::byte>; \
2483 using column_t = _Name_; \
2484 _Name_(arrow::ChunkedArray const* column) \
2485 : o2::soa::Column<std::span<std::byte>, _Name_>(o2::soa::ColumnIterator<std::span<std::byte>>(column)) \
2489 _Name_() = default; \
2490 _Name_(_Name_ const& other) = default; \
2491 _Name_& operator=(_Name_ const& other) = default; \
2493 decltype(auto) _Getter_() const \
2495 if constexpr (std::same_as<_ConcreteType_, std::span<std::byte>>) { \
2496 return *mColumnIterator; \
2498 static std::byte* payload = nullptr; \
2499 static _ConcreteType_* deserialised = nullptr; \
2500 static TClass* c = TClass::GetClass(#_ConcreteType_); \
2501 auto span = *mColumnIterator; \
2502 if (payload != (std::byte*)span.data()) { \
2503 payload = (std::byte*)span.data(); \
2504 delete deserialised; \
2505 TBufferFile f(TBufferFile::EMode::kRead, span.size(), (char*)span.data(), kFALSE); \
2506 deserialised = (_ConcreteType_*)soa::extractCCDBPayload((char*)payload, span.size(), c, "ccdb_object"); \
2508 return *deserialised; \
2515 return _Getter_(); \
2519#define DECLARE_SOA_CCDB_COLUMN(_Name_, _Getter_, _ConcreteType_, _CCDBQuery_) \
2520 DECLARE_SOA_CCDB_COLUMN_FULL(_Name_, "f" #_Name_, _Getter_, _ConcreteType_, _CCDBQuery_)
2522#define DECLARE_SOA_COLUMN(_Name_, _Getter_, _Type_) \
2523 DECLARE_SOA_COLUMN_FULL(_Name_, _Getter_, _Type_, "f" #_Name_)
2527#define MAKEINT(_Size_) uint##_Size_##_t
2529#define DECLARE_SOA_BITMAP_COLUMN_FULL(_Name_, _Getter_, _Size_, _Label_) \
2530 struct _Name_ : o2::soa::Column<MAKEINT(_Size_), _Name_> { \
2531 static constexpr const char* mLabel = _Label_; \
2532 static constexpr const uint32_t hash = compile_time_hash(namespace_prefix<_Name_>(), std::string_view{#_Getter_}); \
2533 static_assert(!((*(mLabel + 1) == 'I' && *(mLabel + 2) == 'n' && *(mLabel + 3) == 'd' && *(mLabel + 4) == 'e' && *(mLabel + 5) == 'x')), "Index is not a valid column name"); \
2534 using base = o2::soa::Column<MAKEINT(_Size_), _Name_>; \
2535 using type = MAKEINT(_Size_); \
2536 _Name_(arrow::ChunkedArray const* column) \
2537 : o2::soa::Column<type, _Name_>(o2::soa::ColumnIterator<type>(column)) \
2541 _Name_() = default; \
2542 _Name_(_Name_ const& other) = default; \
2543 _Name_& operator=(_Name_ const& other) = default; \
2545 decltype(auto) _Getter_##_raw() const \
2547 return *mColumnIterator; \
2550 bool _Getter_##_bit(int bit) const \
2552 return (*mColumnIterator & (static_cast<type>(1) << bit)) >> bit; \
2555 [[maybe_unused]] static constexpr o2::framework::expressions::BindingNode _Getter_ { _Label_, _Name_::hash, o2::framework::expressions::selectArrowType<MAKEINT(_Size_)>() }
2557#define DECLARE_SOA_BITMAP_COLUMN(_Name_, _Getter_, _Size_) \
2558 DECLARE_SOA_BITMAP_COLUMN_FULL(_Name_, _Getter_, _Size_, "f" #_Name_)
2562#define DECLARE_SOA_EXPRESSION_COLUMN_FULL(_Name_, _Getter_, _Type_, _Label_, _Expression_) \
2563 struct _Name_ : o2::soa::Column<_Type_, _Name_> { \
2564 static constexpr const char* mLabel = _Label_; \
2565 static constexpr const uint32_t hash = compile_time_hash(namespace_prefix<_Name_>(), std::string_view{#_Getter_}); \
2566 using base = o2::soa::Column<_Type_, _Name_>; \
2567 using type = _Type_; \
2568 using column_t = _Name_; \
2569 using spawnable_t = std::true_type; \
2570 _Name_(arrow::ChunkedArray const* column) \
2571 : o2::soa::Column<_Type_, _Name_>(o2::soa::ColumnIterator<type>(column)) \
2575 _Name_() = default; \
2576 _Name_(_Name_ const& other) = default; \
2577 _Name_& operator=(_Name_ const& other) = default; \
2579 decltype(auto) _Getter_() const \
2581 return *mColumnIterator; \
2584 decltype(auto) get() const \
2586 return _Getter_(); \
2589 static o2::framework::expressions::Projector Projector() \
2591 return _Expression_; \
2594 [[maybe_unused]] static constexpr o2::framework::expressions::BindingNode _Getter_ { _Label_, _Name_::hash, o2::framework::expressions::selectArrowType<_Type_>() }
2596#define DECLARE_SOA_EXPRESSION_COLUMN(_Name_, _Getter_, _Type_, _Expression_) \
2597 DECLARE_SOA_EXPRESSION_COLUMN_FULL(_Name_, _Getter_, _Type_, "f" #_Name_, _Expression_);
2601#define DECLARE_SOA_CONFIGURABLE_EXPRESSION_COLUMN(_Name_, _Getter_, _Type_, _Label_) \
2602 struct _Name_ : o2::soa::Column<_Type_, _Name_> { \
2603 static constexpr const char* mLabel = _Label_; \
2604 static constexpr const uint32_t hash = compile_time_hash(namespace_prefix<_Name_>(), std::string_view{#_Getter_}); \
2605 static constexpr const int32_t mHash = _Label_ ""_h; \
2606 using base = o2::soa::Column<_Type_, _Name_>; \
2607 using type = _Type_; \
2608 using column_t = _Name_; \
2609 using spawnable_t = std::true_type; \
2610 _Name_(arrow::ChunkedArray const* column) \
2611 : o2::soa::Column<_Type_, _Name_>(o2::soa::ColumnIterator<type>(column)) \
2615 _Name_() = default; \
2616 _Name_(_Name_ const& other) = default; \
2617 _Name_& operator=(_Name_ const& other) = default; \
2619 decltype(auto) _Getter_() const \
2621 return *mColumnIterator; \
2624 decltype(auto) get() const \
2626 return _Getter_(); \
2629 [[maybe_unused]] static constexpr o2::framework::expressions::BindingNode _Getter_ { _Label_, _Name_::hash, o2::framework::expressions::selectArrowType<_Type_>() }
2652template <o2::soa::is_table T>
2655 return T::originals;
2658#define DECLARE_SOA_SLICE_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, _Type_, _Table_, _Label_, _Suffix_) \
2659 struct _Name_##IdSlice : o2::soa::Column<_Type_[2], _Name_##IdSlice> { \
2660 static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
2661 static_assert((*_Suffix_ == '\0') || (*_Suffix_ == '_'), "Suffix has to begin with _"); \
2662 static constexpr const char* mLabel = "fIndexSlice" _Label_ _Suffix_; \
2663 static constexpr const uint32_t hash = 0; \
2664 using base = o2::soa::Column<_Type_[2], _Name_##IdSlice>; \
2665 using type = _Type_[2]; \
2666 using column_t = _Name_##IdSlice; \
2667 using binding_t = _Table_; \
2668 static constexpr auto index_targets = getIndexTargets<_Table_>(); \
2669 _Name_##IdSlice(arrow::ChunkedArray const* column) \
2670 : o2::soa::Column<_Type_[2], _Name_##IdSlice>(o2::soa::ColumnIterator<type>(column)) \
2674 _Name_##IdSlice() = default; \
2675 _Name_##IdSlice(_Name_##IdSlice const& other) = default; \
2676 _Name_##IdSlice& operator=(_Name_##IdSlice const& other) = default; \
2677 std::array<_Type_, 2> inline getIds() const \
2679 return _Getter_##Ids(); \
2682 bool has_##_Getter_() const \
2684 auto a = *mColumnIterator; \
2685 return a[0] >= 0 && a[1] >= 0; \
2688 std::array<_Type_, 2> _Getter_##Ids() const \
2690 auto a = *mColumnIterator; \
2691 return std::array{a[0], a[1]}; \
2694 template <typename T> \
2695 auto _Getter_##_as() const \
2697 if (O2_BUILTIN_UNLIKELY(mBinding.ptr == nullptr)) { \
2698 o2::soa::notBoundTable(#_Table_); \
2700 auto t = mBinding.get<T>(); \
2701 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2702 o2::soa::dereferenceWithWrongType(#_Getter_, #_Table_); \
2704 if (O2_BUILTIN_UNLIKELY(!has_##_Getter_())) { \
2705 return t->emptySlice(); \
2707 auto a = *mColumnIterator; \
2708 auto r = t->rawSlice(a[0], a[1]); \
2709 t->copyIndexBindings(r); \
2710 r.bindInternalIndicesTo(t); \
2714 auto _Getter_() const \
2716 return _Getter_##_as<binding_t>(); \
2719 template <typename T> \
2720 bool setCurrent(T const* current) \
2722 if constexpr (o2::soa::is_binding_compatible_v<T, binding_t>()) { \
2723 assert(current != nullptr); \
2724 this->mBinding.bind(current); \
2730 bool setCurrentRaw(o2::soa::Binding current) \
2732 this->mBinding = current; \
2735 binding_t const* getCurrent() const { return mBinding.get<binding_t>(); } \
2736 o2::soa::Binding getCurrentRaw() const { return mBinding; } \
2737 o2::soa::Binding mBinding; \
2740#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_)
2741#define DECLARE_SOA_SLICE_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_SLICE_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, _Name_##s, "")
2742#define DECLARE_SOA_SLICE_INDEX_COLUMN_CUSTOM(_Name_, _Getter_, _Label_) DECLARE_SOA_SLICE_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, int32_t, _Name_##s, _Label_, "")
2745#define DECLARE_SOA_ARRAY_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, _Type_, _Table_, _Label_, _Suffix_) \
2746 struct _Name_##Ids : o2::soa::Column<std::vector<_Type_>, _Name_##Ids> { \
2747 static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
2748 static_assert((*_Suffix_ == '\0') || (*_Suffix_ == '_'), "Suffix has to begin with _"); \
2749 static constexpr const char* mLabel = "fIndexArray" _Label_ _Suffix_; \
2750 static constexpr const uint32_t hash = 0; \
2751 using base = o2::soa::Column<std::vector<_Type_>, _Name_##Ids>; \
2752 using type = std::vector<_Type_>; \
2753 using column_t = _Name_##Ids; \
2754 using binding_t = _Table_; \
2755 static constexpr auto index_targets = getIndexTargets<_Table_>(); \
2756 _Name_##Ids(arrow::ChunkedArray const* column) \
2757 : o2::soa::Column<std::vector<_Type_>, _Name_##Ids>(o2::soa::ColumnIterator<type>(column)) \
2761 _Name_##Ids() = default; \
2762 _Name_##Ids(_Name_##Ids const& other) = default; \
2763 _Name_##Ids& operator=(_Name_##Ids const& other) = default; \
2765 gsl::span<const _Type_> inline getIds() const \
2767 return _Getter_##Ids(); \
2770 gsl::span<const _Type_> _Getter_##Ids() const \
2772 return *mColumnIterator; \
2775 bool has_##_Getter_() const \
2777 return !(*mColumnIterator).empty(); \
2780 template <soa::is_table T> \
2781 auto _Getter_##_as() const \
2783 if (O2_BUILTIN_UNLIKELY(mBinding.ptr == nullptr)) { \
2784 o2::soa::notBoundTable(#_Table_); \
2786 auto t = mBinding.get<T>(); \
2787 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2788 o2::soa::dereferenceWithWrongType(#_Getter_, #_Table_); \
2790 auto result = std::vector<typename T::unfiltered_iterator>(); \
2791 result.reserve((*mColumnIterator).size()); \
2792 for (auto& i : *mColumnIterator) { \
2793 result.emplace_back(t->rawIteratorAt(i)); \
2798 template <soa::is_filtered_table T> \
2799 auto filtered_##_Getter_##_as() const \
2801 if (O2_BUILTIN_UNLIKELY(mBinding.ptr == nullptr)) { \
2802 o2::soa::notBoundTable(#_Table_); \
2804 auto t = mBinding.get<T>(); \
2805 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2806 o2::soa::dereferenceWithWrongType(#_Getter_, #_Table_); \
2808 auto result = std::vector<typename T::iterator>(); \
2809 result.reserve((*mColumnIterator).size()); \
2810 for (auto const& i : *mColumnIterator) { \
2811 auto pos = t->isInSelectedRows(i); \
2813 result.emplace_back(t->iteratorAt(pos)); \
2819 auto _Getter_() const \
2821 return _Getter_##_as<binding_t>(); \
2824 template <typename T> \
2825 auto _Getter_##_first_as() const \
2827 if (O2_BUILTIN_UNLIKELY(mBinding.ptr == nullptr)) { \
2828 o2::soa::notBoundTable(#_Table_); \
2830 auto t = mBinding.get<T>(); \
2831 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2832 o2::soa::dereferenceWithWrongType(#_Getter_, #_Table_); \
2834 return t->rawIteratorAt((*mColumnIterator)[0]); \
2837 template <typename T> \
2838 auto _Getter_##_last_as() const \
2840 if (O2_BUILTIN_UNLIKELY(mBinding.ptr == nullptr)) { \
2841 o2::soa::notBoundTable(#_Table_); \
2843 auto t = mBinding.get<T>(); \
2844 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2845 o2::soa::dereferenceWithWrongType(#_Getter_, #_Table_); \
2847 return t->rawIteratorAt((*mColumnIterator).back()); \
2850 auto _Getter_first() const \
2852 return _Getter_##_first_as<binding_t>(); \
2855 auto _Getter_last() const \
2857 return _Getter_##_last_as<binding_t>(); \
2860 template <typename T> \
2861 bool setCurrent(T const* current) \
2863 if constexpr (o2::soa::is_binding_compatible_v<T, binding_t>()) { \
2864 assert(current != nullptr); \
2865 this->mBinding.bind(current); \
2871 bool setCurrentRaw(o2::soa::Binding current) \
2873 this->mBinding = current; \
2876 binding_t const* getCurrent() const { return mBinding.get<binding_t>(); } \
2877 o2::soa::Binding getCurrentRaw() const { return mBinding; } \
2878 o2::soa::Binding mBinding; \
2881#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_)
2882#define DECLARE_SOA_ARRAY_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_ARRAY_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, _Name_##s, "")
2883#define DECLARE_SOA_ARRAY_INDEX_COLUMN_CUSTOM(_Name_, _Getter_, _Label_) DECLARE_SOA_ARRAY_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, int32_t, _Name_##s, _Label_, "")
2886#define DECLARE_SOA_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, _Type_, _Table_, _Label_, _Suffix_) \
2887 struct _Name_##Id : o2::soa::Column<_Type_, _Name_##Id> { \
2888 static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
2889 static_assert((*_Suffix_ == '\0') || (*_Suffix_ == '_'), "Suffix has to begin with _"); \
2890 static constexpr const char* mLabel = "fIndex" _Label_ _Suffix_; \
2891 static constexpr const uint32_t hash = compile_time_hash(namespace_prefix<_Name_##Id>(), std::string_view{#_Getter_ "Id"}); \
2892 using base = o2::soa::Column<_Type_, _Name_##Id>; \
2893 using type = _Type_; \
2894 using column_t = _Name_##Id; \
2895 using binding_t = _Table_; \
2896 static constexpr auto index_targets = getIndexTargets<_Table_>(); \
2897 _Name_##Id(arrow::ChunkedArray const* column) \
2898 : o2::soa::Column<_Type_, _Name_##Id>(o2::soa::ColumnIterator<type>(column)) \
2902 _Name_##Id() = default; \
2903 _Name_##Id(_Name_##Id const& other) = default; \
2904 _Name_##Id& operator=(_Name_##Id const& other) = default; \
2905 type inline getId() const \
2907 return _Getter_##Id(); \
2910 type _Getter_##Id() const \
2912 return *mColumnIterator; \
2915 bool has_##_Getter_() const \
2917 return *mColumnIterator >= 0; \
2920 template <typename T> \
2921 auto _Getter_##_as() const \
2923 if (O2_BUILTIN_UNLIKELY(mBinding.ptr == nullptr)) { \
2924 o2::soa::notBoundTable(#_Table_); \
2926 if (O2_BUILTIN_UNLIKELY(!has_##_Getter_())) { \
2927 o2::soa::accessingInvalidIndexFor(#_Getter_); \
2929 auto t = mBinding.get<T>(); \
2930 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2931 o2::soa::dereferenceWithWrongType(#_Getter_, #_Table_); \
2933 return t->rawIteratorAt(*mColumnIterator); \
2936 auto _Getter_() const \
2938 return _Getter_##_as<binding_t>(); \
2941 template <typename T> \
2942 bool setCurrent(T* current) \
2944 if constexpr (o2::soa::is_binding_compatible_v<T, binding_t>()) { \
2945 assert(current != nullptr); \
2946 this->mBinding.bind(current); \
2952 bool setCurrentRaw(o2::soa::Binding current) \
2954 this->mBinding = current; \
2957 binding_t const* getCurrent() const { return mBinding.get<binding_t>(); } \
2958 o2::soa::Binding getCurrentRaw() const { return mBinding; } \
2959 o2::soa::Binding mBinding; \
2961 [[maybe_unused]] static constexpr o2::framework::expressions::BindingNode _Getter_##Id { "fIndex" _Label_ _Suffix_, _Name_##Id::hash, o2::framework::expressions::selectArrowType<_Type_>() }
2963#define DECLARE_SOA_INDEX_COLUMN_FULL(_Name_, _Getter_, _Type_, _Table_, _Suffix_) DECLARE_SOA_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, _Type_, _Table_, #_Table_, _Suffix_)
2964#define DECLARE_SOA_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, _Name_##s, "")
2965#define DECLARE_SOA_INDEX_COLUMN_CUSTOM(_Name_, _Getter_, _Label_) DECLARE_SOA_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, int32_t, _Name_##s, _Label_, "")
2968#define DECLARE_SOA_SELF_INDEX_COLUMN_COMPLETE(_Name_, _Getter_, _Type_, _Label_, _IndexTarget_) \
2969 struct _Name_##Id : o2::soa::Column<_Type_, _Name_##Id> { \
2970 static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
2971 static constexpr const char* mLabel = "fIndex" _Label_; \
2972 static constexpr const uint32_t hash = compile_time_hash(namespace_prefix<_Name_##Id>(), std::string_view{#_Getter_ "Id"}); \
2973 using base = o2::soa::Column<_Type_, _Name_##Id>; \
2974 using type = _Type_; \
2975 using column_t = _Name_##Id; \
2976 using self_index_t = std::true_type; \
2977 using compatible_signature = std::conditional<aod::is_aod_hash<_IndexTarget_>, _IndexTarget_, void>; \
2978 _Name_##Id(arrow::ChunkedArray const* column) \
2979 : o2::soa::Column<_Type_, _Name_##Id>(o2::soa::ColumnIterator<type>(column)) \
2983 _Name_##Id() = default; \
2984 _Name_##Id(_Name_##Id const& other) = default; \
2985 _Name_##Id& operator=(_Name_##Id const& other) = default; \
2986 type inline getId() const \
2988 return _Getter_##Id(); \
2991 type _Getter_##Id() const \
2993 return *mColumnIterator; \
2996 bool has_##_Getter_() const \
2998 return *mColumnIterator >= 0; \
3001 template <typename T> \
3002 auto _Getter_##_as() const \
3004 if (O2_BUILTIN_UNLIKELY(!has_##_Getter_())) { \
3005 o2::soa::accessingInvalidIndexFor(#_Getter_); \
3007 auto t = mBinding.get<T>(); \
3008 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
3009 o2::soa::dereferenceWithWrongType(#_Getter_, "self"); \
3011 return t->rawIteratorAt(*mColumnIterator); \
3014 bool setCurrentRaw(o2::soa::Binding current) \
3016 this->mBinding = current; \
3019 o2::soa::Binding getCurrentRaw() const { return mBinding; } \
3020 o2::soa::Binding mBinding; \
3022 [[maybe_unused]] static constexpr o2::framework::expressions::BindingNode _Getter_##Id { "fIndex" _Label_, _Name_##Id::hash, o2::framework::expressions::selectArrowType<_Type_>() }
3024#define DECLARE_SOA_SELF_INDEX_COLUMN_FULL(_Name_, _Getter_, _Type_, _Label_) DECLARE_SOA_SELF_INDEX_COLUMN_COMPLETE(_Name_, _Getter_, _Type_, _Label_, void)
3025#define DECLARE_SOA_SELF_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_SELF_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, #_Name_)
3027#define DECLARE_SOA_SELF_SLICE_INDEX_COLUMN_COMPLETE(_Name_, _Getter_, _Type_, _Label_, _IndexTarget_) \
3028 struct _Name_##IdSlice : o2::soa::Column<_Type_[2], _Name_##IdSlice> { \
3029 static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
3030 static constexpr const char* mLabel = "fIndexSlice" _Label_; \
3031 static constexpr const uint32_t hash = 0; \
3032 using base = o2::soa::Column<_Type_[2], _Name_##IdSlice>; \
3033 using type = _Type_[2]; \
3034 using column_t = _Name_##IdSlice; \
3035 using self_index_t = std::true_type; \
3036 using compatible_signature = std::conditional<aod::is_aod_hash<_IndexTarget_>, _IndexTarget_, void>; \
3037 _Name_##IdSlice(arrow::ChunkedArray const* column) \
3038 : o2::soa::Column<_Type_[2], _Name_##IdSlice>(o2::soa::ColumnIterator<type>(column)) \
3042 _Name_##IdSlice() = default; \
3043 _Name_##IdSlice(_Name_##IdSlice const& other) = default; \
3044 _Name_##IdSlice& operator=(_Name_##IdSlice const& other) = default; \
3045 std::array<_Type_, 2> inline getIds() const \
3047 return _Getter_##Ids(); \
3050 bool has_##_Getter_() const \
3052 auto a = *mColumnIterator; \
3053 return a[0] >= 0 && a[1] >= 0; \
3056 std::array<_Type_, 2> _Getter_##Ids() const \
3058 auto a = *mColumnIterator; \
3059 return std::array{a[0], a[1]}; \
3062 template <typename T> \
3063 auto _Getter_##_as() const \
3065 auto t = mBinding.get<T>(); \
3066 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
3067 o2::soa::dereferenceWithWrongType(#_Getter_, "self"); \
3069 if (O2_BUILTIN_UNLIKELY(!has_##_Getter_())) { \
3070 return t->emptySlice(); \
3072 auto a = *mColumnIterator; \
3073 auto r = t->rawSlice(a[0], a[1]); \
3074 t->copyIndexBindings(r); \
3075 r.bindInternalIndicesTo(t); \
3079 bool setCurrentRaw(o2::soa::Binding current) \
3081 this->mBinding = current; \
3084 o2::soa::Binding getCurrentRaw() const { return mBinding; } \
3085 o2::soa::Binding mBinding; \
3088#define DECLARE_SOA_SELF_SLICE_INDEX_COLUMN_FULL(_Name_, _Getter_, _Type_, _Label_) DECLARE_SOA_SELF_SLICE_INDEX_COLUMN_COMPLETE(_Name_, _Getter_, _Type_, _Label_, void)
3089#define DECLARE_SOA_SELF_SLICE_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_SELF_SLICE_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, "_" #_Name_)
3091#define DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN_COMPLETE(_Name_, _Getter_, _Type_, _Label_, _IndexTarget_) \
3092 struct _Name_##Ids : o2::soa::Column<std::vector<_Type_>, _Name_##Ids> { \
3093 static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
3094 static constexpr const char* mLabel = "fIndexArray" _Label_; \
3095 static constexpr const uint32_t hash = 0; \
3096 using base = o2::soa::Column<std::vector<_Type_>, _Name_##Ids>; \
3097 using type = std::vector<_Type_>; \
3098 using column_t = _Name_##Ids; \
3099 using self_index_t = std::true_type; \
3100 using compatible_signature = std::conditional<aod::is_aod_hash<_IndexTarget_>, _IndexTarget_, void>; \
3101 _Name_##Ids(arrow::ChunkedArray const* column) \
3102 : o2::soa::Column<std::vector<_Type_>, _Name_##Ids>(o2::soa::ColumnIterator<type>(column)) \
3106 _Name_##Ids() = default; \
3107 _Name_##Ids(_Name_##Ids const& other) = default; \
3108 _Name_##Ids& operator=(_Name_##Ids const& other) = default; \
3109 gsl::span<const _Type_> inline getIds() const \
3111 return _Getter_##Ids(); \
3114 gsl::span<const _Type_> _Getter_##Ids() const \
3116 return *mColumnIterator; \
3119 bool has_##_Getter_() const \
3121 return !(*mColumnIterator).empty(); \
3124 template <typename T> \
3125 auto _Getter_##_as() const \
3127 auto t = mBinding.get<T>(); \
3128 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
3129 o2::soa::dereferenceWithWrongType(#_Getter_, "self"); \
3131 auto result = std::vector<typename T::unfiltered_iterator>(); \
3132 for (auto& i : *mColumnIterator) { \
3133 result.push_back(t->rawIteratorAt(i)); \
3138 template <typename T> \
3139 auto _Getter_##_first_as() const \
3141 return mBinding.get<T>()->rawIteratorAt((*mColumnIterator)[0]); \
3144 template <typename T> \
3145 auto _Getter_##_last_as() const \
3147 return mBinding.get<T>()->rawIteratorAt((*mColumnIterator).back()); \
3150 bool setCurrentRaw(o2::soa::Binding current) \
3152 this->mBinding = current; \
3155 o2::soa::Binding getCurrentRaw() const { return mBinding; } \
3156 o2::soa::Binding mBinding; \
3159#define DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN_FULL(_Name_, _Getter_, _Type_, _Label_) DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN_COMPLETE(_Name_, _Getter_, _Type_, _Label_, void)
3160#define DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, "_" #_Name_)
3190#define DECLARE_SOA_DYNAMIC_COLUMN(_Name_, _Getter_, ...) \
3191 struct _Name_##Callback { \
3192 static inline constexpr auto getLambda() { return __VA_ARGS__; } \
3195 struct _Name_##Helper { \
3196 using callable_t = decltype(o2::framework::FunctionMetadata(std::declval<decltype(_Name_##Callback::getLambda())>())); \
3197 using return_type = typename callable_t::return_type; \
3199 template <typename... Bindings> \
3200 struct _Name_ : o2::soa::DynamicColumn<typename _Name_##Helper::callable_t::type, _Name_<Bindings...>> { \
3201 using base = o2::soa::DynamicColumn<typename _Name_##Helper::callable_t::type, _Name_<Bindings...>>; \
3202 using helper = _Name_##Helper; \
3203 using callback_holder_t = _Name_##Callback; \
3204 using callable_t = helper::callable_t; \
3205 using callback_t = callable_t::type; \
3206 static constexpr const uint32_t hash = 0; \
3208 _Name_(arrow::ChunkedArray const*) \
3211 _Name_() = default; \
3212 _Name_(_Name_ const& other) = default; \
3213 _Name_& operator=(_Name_ const& other) = default; \
3214 static constexpr const char* mLabel = #_Name_; \
3215 using type = typename callable_t::return_type; \
3217 template <typename... FreeArgs> \
3218 type _Getter_(FreeArgs... freeArgs) const \
3220 return boundGetter(std::make_index_sequence<std::tuple_size_v<decltype(boundIterators)>>{}, freeArgs...); \
3222 template <typename... FreeArgs> \
3223 type getDynamicValue(FreeArgs... freeArgs) const \
3225 return boundGetter(std::make_index_sequence<std::tuple_size_v<decltype(boundIterators)>>{}, freeArgs...); \
3230 return _Getter_(); \
3233 template <size_t... Is, typename... FreeArgs> \
3234 type boundGetter(std::integer_sequence<size_t, Is...>&&, FreeArgs... freeArgs) const \
3236 return __VA_ARGS__((**std::get<Is>(boundIterators))..., freeArgs...); \
3239 using bindings_t = typename o2::framework::pack<Bindings...>; \
3240 std::tuple<o2::soa::ColumnIterator<typename Bindings::type> const*...> boundIterators; \
3243#define DECLARE_SOA_TABLE_METADATA(_Name_, _Desc_, _Version_, ...) \
3244 using _Name_##Metadata = TableMetadata<Hash<_Desc_ "/" #_Version_ ""_h>, __VA_ARGS__>;
3246#define DECLARE_SOA_TABLE_METADATA_TRAIT(_Name_, _Desc_, _Version_) \
3248 struct MetadataTrait<Hash<_Desc_ "/" #_Version_ ""_h>> { \
3249 using metadata = _Name_##Metadata; \
3252#define DECLARE_SOA_TABLE_FULL_VERSIONED_(_Name_, _Label_, _Origin_, _Desc_, _Version_) \
3253 O2HASH(_Desc_ "/" #_Version_); \
3254 template <typename O> \
3255 using _Name_##From = o2::soa::Table<Hash<_Label_ ""_h>, Hash<_Desc_ "/" #_Version_ ""_h>, O>; \
3256 using _Name_ = _Name_##From<Hash<_Origin_ ""_h>>; \
3258 struct MetadataTrait<Hash<_Desc_ "/" #_Version_ ""_h>> { \
3259 using metadata = _Name_##Metadata; \
3262#define DECLARE_SOA_STAGE(_Name_, _Origin_, _Desc_, _Version_) \
3263 template <typename O> \
3264 using _Name_##From = o2::soa::Table<Hash<#_Name_ ""_h>, Hash<_Desc_ "/" #_Version_ ""_h>, O>; \
3265 using _Name_ = _Name_##From<Hash<_Origin_ ""_h>>;
3267#define DECLARE_SOA_TABLE_FULL_VERSIONED(_Name_, _Label_, _Origin_, _Desc_, _Version_, ...) \
3268 DECLARE_SOA_TABLE_METADATA(_Name_, _Desc_, _Version_, __VA_ARGS__); \
3269 DECLARE_SOA_TABLE_FULL_VERSIONED_(_Name_, _Label_, _Origin_, _Desc_, _Version_);
3271#define DECLARE_SOA_TABLE_FULL(_Name_, _Label_, _Origin_, _Desc_, ...) \
3273 DECLARE_SOA_TABLE_METADATA(_Name_, _Desc_, 0, __VA_ARGS__); \
3274 DECLARE_SOA_TABLE_FULL_VERSIONED_(_Name_, _Label_, _Origin_, _Desc_, 0)
3276#define DECLARE_SOA_TABLE(_Name_, _Origin_, _Desc_, ...) \
3277 DECLARE_SOA_TABLE_FULL(_Name_, #_Name_, _Origin_, _Desc_, __VA_ARGS__)
3279#define DECLARE_SOA_TABLE_VERSIONED(_Name_, _Origin_, _Desc_, _Version_, ...) \
3281 DECLARE_SOA_TABLE_METADATA(_Name_, _Desc_, _Version_, __VA_ARGS__); \
3282 DECLARE_SOA_TABLE_FULL_VERSIONED_(_Name_, #_Name_, _Origin_, _Desc_, _Version_)
3284#define DECLARE_SOA_TABLE_STAGED_VERSIONED(_BaseName_, _Desc_, _Version_, ...) \
3285 O2HASH(_Desc_ "/" #_Version_); \
3286 O2HASH(#_BaseName_); \
3287 O2HASH("Stored" #_BaseName_); \
3288 DECLARE_SOA_TABLE_METADATA(_BaseName_, _Desc_, _Version_, __VA_ARGS__); \
3289 using Stored##_BaseName_##Metadata = _BaseName_##Metadata; \
3290 DECLARE_SOA_TABLE_METADATA_TRAIT(_BaseName_, _Desc_, _Version_); \
3291 DECLARE_SOA_STAGE(_BaseName_, "AOD", _Desc_, _Version_); \
3292 DECLARE_SOA_STAGE(Stored##_BaseName_, "AOD1", _Desc_, _Version_);
3294#define DECLARE_SOA_TABLE_STAGED(_BaseName_, _Desc_, ...) \
3295 DECLARE_SOA_TABLE_STAGED_VERSIONED(_BaseName_, _Desc_, 0, __VA_ARGS__);
3297#define DECLARE_SOA_EXTENDED_TABLE_NG(_Name_, _OriginalTable_, _Desc_, _Version_, ...) \
3298 O2HASH(_Desc_ "/" #_Version_); \
3299 O2HASH(#_Name_ "Extension"); \
3300 template <typename O> \
3301 using _Name_##ExtensionFrom = soa::Table<o2::aod::Hash<#_Name_ "Extension"_h>, o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, O>; \
3302 using _Name_##Extension = _Name_##ExtensionFrom<o2::aod::Hash<"AOD"_h>>; \
3303 struct _Name_##ExtensionMetadata : TableMetadata<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, __VA_ARGS__> { \
3304 using base_table_t = _OriginalTable_; \
3305 template <o2::aod::is_origin_hash O> \
3306 using extension_table_t_from = _Name_##ExtensionFrom<O>; \
3307 using extension_table_t = _Name_##Extension; \
3308 using expression_pack_t = framework::pack<__VA_ARGS__>; \
3309 static constexpr auto N = _OriginalTable_::originals.size(); \
3310 template <o2::aod::is_origin_hash O = o2::aod::Hash<"AOD"_h>> \
3311 static consteval auto generateSources() \
3313 return _OriginalTable_##From<O>::originals; \
3317 struct MetadataTrait<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>> { \
3318 using metadata = _Name_##ExtensionMetadata; \
3320 template <typename O> \
3321 using _Name_##From = o2::soa::Join<_OriginalTable_##From<O>, _Name_##ExtensionFrom<O>>; \
3322 using _Name_ = _Name_##From<o2::aod::Hash<"AOD"_h>>;
3324#define DECLARE_SOA_EXTENDED_TABLE(_Name_, _Table_, _Description_, _Version_, ...) \
3325 DECLARE_SOA_EXTENDED_TABLE_NG(_Name_, _Table_, _Description_, _Version_, __VA_ARGS__)
3327#define DECLARE_SOA_EXTENDED_TABLE_USER(_Name_, _Table_, _Description_, ...) \
3328 DECLARE_SOA_EXTENDED_TABLE_NG(_Name_, _Table_, "EX" _Description_, 0, __VA_ARGS__)
3330#define DECLARE_SOA_CONFIGURABLE_EXTENDED_TABLE_NG(_Name_, _OriginalTable_, _Desc_, _Version_, ...) \
3331 O2HASH(_Desc_ "/" #_Version_); \
3332 O2HASH(#_Name_ "CfgExtension"); \
3333 template <typename O> \
3334 using _Name_##CfgExtensionFrom = soa::Table<o2::aod::Hash<#_Name_ "CfgExtension"_h>, o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, O>; \
3335 using _Name_##CfgExtension = _Name_##CfgExtensionFrom<o2::aod::Hash<"AOD"_h>>; \
3336 struct _Name_##CfgExtensionMetadata : TableMetadata<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, __VA_ARGS__> { \
3337 using base_table_t = _OriginalTable_; \
3338 template <o2::aod::is_origin_hash O> \
3339 using extension_table_t_from = _Name_##CfgExtensionFrom<O>; \
3340 using extension_table_t = _Name_##CfgExtension; \
3341 using placeholders_pack_t = framework::pack<__VA_ARGS__>; \
3342 using configurable_t = std::true_type; \
3343 static constexpr auto N = _OriginalTable_::originals.size(); \
3344 template <o2::aod::is_origin_hash O = o2::aod::Hash<"AOD"_h>> \
3345 static consteval auto generateSources() \
3347 return _OriginalTable_##From<O>::originals; \
3351 struct MetadataTrait<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>> { \
3352 using metadata = _Name_##CfgExtensionMetadata; \
3354 template <typename O> \
3355 using _Name_##From = o2::soa::Join<_OriginalTable_##From<O>, _Name_##CfgExtensionFrom<O>>; \
3356 using _Name_ = _Name_##From<o2::aod::Hash<"AOD"_h>>;
3358#define DECLARE_SOA_CONFIGURABLE_EXTENDED_TABLE(_Name_, _OriginalTable_, _Description_, ...) \
3359 DECLARE_SOA_CONFIGURABLE_EXTENDED_TABLE_NG(_Name_, _OriginalTable_, "EX" _Description_, 0, __VA_ARGS__)
3361#define DECLARE_SOA_INDEX_TABLE_NG(_Name_, _Key_, _Version_, _Desc_, _Exclusive_, ...) \
3363 O2HASH(_Desc_ "/" #_Version_); \
3364 struct _Name_##Metadata : o2::aod::TableMetadata<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, soa::Index<>, __VA_ARGS__> { \
3365 static constexpr bool exclusive = _Exclusive_; \
3366 template <o2::aod::is_origin_hash O> \
3367 using KeyFrom = _Key_##From<O>; \
3368 using Key = _Key_; \
3369 using index_pack_t = framework::pack<__VA_ARGS__>; \
3370 template <o2::aod::is_origin_hash O = o2::aod::Hash<"AOD"_h>> \
3371 static consteval auto generateSources() \
3373 return []<soa::is_index_column... Cs>(framework::pack<Cs...>) { \
3374 constexpr auto first = o2::soa::mergeOriginals<typename Cs::binding_t...>(); \
3375 constexpr auto second = o2::aod::filterForKey<first.size(), first, Key>(); \
3376 return o2::aod::replaceOrigin<second.size(), second, O>(); \
3377 }(framework::pack<__VA_ARGS__>{}); \
3379 static constexpr auto N = []<typename... Cs>(framework::pack<Cs...>) { \
3380 constexpr auto a = o2::soa::mergeOriginals<typename Cs::binding_t...>(); \
3381 return o2::aod::filterForKey<a.size(), a, Key>(); \
3382 }(framework::pack<__VA_ARGS__>{}) \
3386 struct MetadataTrait<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>> { \
3387 using metadata = _Name_##Metadata; \
3389 template <o2::aod::is_origin_hash O> \
3390 using _Name_##From = o2::soa::IndexTable<o2::aod::Hash<#_Name_ ""_h>, o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, O, _Key_##From<O>, __VA_ARGS__>; \
3391 using _Name_ = _Name_##From<o2::aod::Hash<"AOD"_h>>;
3393#define DECLARE_SOA_INDEX_TABLE(_Name_, _Key_, _Description_, ...) \
3394 DECLARE_SOA_INDEX_TABLE_NG(_Name_, _Key_, 0, _Description_, false, __VA_ARGS__)
3396#define DECLARE_SOA_INDEX_TABLE_EXCLUSIVE(_Name_, _Key_, _Description_, ...) \
3397 DECLARE_SOA_INDEX_TABLE_NG(_Name_, _Key_, 0, _Description_, true, __VA_ARGS__)
3399#define DECLARE_SOA_INDEX_TABLE_USER(_Name_, _Key_, _Description_, ...) \
3400 DECLARE_SOA_INDEX_TABLE_NG(_Name_, _Key_, 0, _Description_, false, __VA_ARGS__)
3402#define DECLARE_SOA_INDEX_TABLE_EXCLUSIVE_USER(_Name_, _Key_, _Description_, ...) \
3403 DECLARE_SOA_INDEX_TABLE_NG(_Name_, _Key_, 0, _Description_, true, __VA_ARGS__)
3410#define DECLARE_SOA_TIMESTAMPED_TABLE_FULL(_Name_, _Label_, _TimestampSource_, _TimestampColumn_, _Version_, _Desc_, ...) \
3411 O2HASH(_Desc_ "/" #_Version_); \
3412 template <typename O> \
3413 using _Name_##TimestampFrom = soa::Table<o2::aod::Hash<_Label_ ""_h>, o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, O>; \
3414 using _Name_##Timestamp = _Name_##TimestampFrom<o2::aod::Hash< \
3417 struct _Name_##TimestampMetadata : TableMetadata<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, __VA_ARGS__> { \
3418 template <typename O = o2::aod::Hash<"AOD" \
3420 using base_table_t = _TimestampSource_##From<O>; \
3421 template <typename O = o2::aod::Hash<"AOD" \
3423 using extension_table_t = _Name_##TimestampFrom<O>; \
3424 static constexpr const auto ccdb_urls = []<typename... Cs>(framework::pack<Cs...>) { \
3425 return std::array<std::string_view, sizeof...(Cs)>{Cs::query...}; \
3426 }(framework::pack<__VA_ARGS__>{}); \
3427 static constexpr const auto ccdb_bindings = []<typename... Cs>(framework::pack<Cs...>) { \
3428 return std::array<std::string_view, sizeof...(Cs)>{Cs::mLabel...}; \
3429 }(framework::pack<__VA_ARGS__>{}); \
3430 static constexpr auto N = _TimestampSource_::originals.size(); \
3431 template <o2::aod::is_origin_hash O = o2::aod::Hash<"AOD"_h>> \
3432 static consteval auto generateSources() \
3434 return _TimestampSource_##From<O>::originals; \
3436 static constexpr auto timestamp_column_label = _TimestampColumn_::mLabel; \
3440 struct MetadataTrait<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>> { \
3441 using metadata = _Name_##TimestampMetadata; \
3443 template <typename O> \
3444 using _Name_##From = o2::soa::Join<_TimestampSource_, _Name_##TimestampFrom<O>>; \
3445 using _Name_ = _Name_##From<o2::aod::Hash< \
3449#define DECLARE_SOA_TIMESTAMPED_TABLE(_Name_, _TimestampSource_, _TimestampColumn_, _Version_, _Desc_, ...) \
3450 O2HASH(#_Name_ "Timestamped"); \
3451 DECLARE_SOA_TIMESTAMPED_TABLE_FULL(_Name_, #_Name_ "Timestamped", _TimestampSource_, _TimestampColumn_, _Version_, _Desc_, __VA_ARGS__)
3455template <
typename...
Ts>
3456struct Join :
Table<o2::aod::Hash<"JOIN"_h>, o2::aod::Hash<"JOIN/0"_h>, o2::aod::Hash<"JOIN"_h>, Ts...> {
3466 Join(std::vector<std::shared_ptr<arrow::Table>>&& tables, uint64_t
offset = 0)
3478 template <
typename... TA>
3522 template <
typename T1,
typename Policy,
bool OPT>
3550 template <
typename T>
3553 return []<
size_t... Is>(std::index_sequence<Is...>) {
3554 return (std::ranges::any_of(
originals, [](
TableRef const&
ref) {
return ref.desc_hash == T::originals[Is].desc_hash; }) && ...);
3555 }(std::make_index_sequence<T::originals.size()>());
3559template <
typename...
Ts>
3565template <
typename T>
3568template <
typename T>
3571template <
typename...
Ts>
3572struct Concat :
Table<o2::aod::Hash<"CONC"_h>, o2::aod::Hash<"CONC/0"_h>, o2::aod::Hash<"CONC"_h>, Ts...> {
3575 Concat(std::vector<std::shared_ptr<arrow::Table>>&& tables, uint64_t
offset = 0)
3583 bindInternalIndicesTo(
this);
3586 using base::originals;
3588 using base::bindExternalIndices;
3589 using base::bindInternalIndicesTo;
3603template <
typename...
Ts>
3609template <soa::is_table T>
3616 static constexpr const uint32_t binding_origin = T::binding_origin;
3618 template <
typename... TA>
3622 if constexpr (binding_origin == TA::binding_origin) {
3623 this->bindExternalIndex(cur);
3624 mFilteredBegin.bindExternalIndex(cur);
3633 using iterator = T::template iterator_template_o<FilteredIndexPolicy, self_t>;
3639 mSelectedRows{getSpan(selection)}
3641 if (this->tableSize() != 0) {
3642 mFilteredBegin = table_t::filtered_begin(mSelectedRows);
3645 mFilteredBegin.bindInternalIndices(
this);
3650 mSelectedRowsCache{
std::move(selection)},
3653 mSelectedRows = std::span{mSelectedRowsCache};
3654 if (this->tableSize() != 0) {
3655 mFilteredBegin = table_t::filtered_begin(mSelectedRows);
3658 mFilteredBegin.bindInternalIndices(
this);
3661 FilteredBase(std::vector<std::shared_ptr<arrow::Table>>&& tables, std::span<int64_t const>
const& selection, uint64_t
offset = 0)
3663 mSelectedRows{selection}
3665 if (this->tableSize() != 0) {
3666 mFilteredBegin = table_t::filtered_begin(mSelectedRows);
3669 mFilteredBegin.bindInternalIndices(
this);
3696 return mFilteredBegin;
3701 return mFilteredBegin;
3706 return mFilteredBegin +
i;
3711 return mSelectedRows.size();
3716 return table_t::asArrowTable()->num_rows();
3721 return mSelectedRows;
3728 std::iota(newSelection.begin(), newSelection.end(),
start);
3729 return self_t{{this->asArrowTable()}, std::move(newSelection), 0};
3739 if (sel ==
nullptr) {
3740 return std::span<int64_t const>{};
3742 auto array = std::static_pointer_cast<arrow::Int64Array>(sel->ToArray());
3745 return std::span{
start, stop};
3752 mFilteredBegin.bindExternalIndicesRaw(std::forward<std::vector<o2::soa::Binding>>(ptrs));
3755 template <
typename I>
3758 mFilteredBegin.bindInternalIndices(
ptr);
3761 template <
typename T1,
typename... Cs>
3764 dest.bindExternalIndicesRaw(mFilteredBegin.getIndexBindings());
3767 template <
typename T1>
3773 template <
typename T1>
3789 template <
typename T1,
bool OPT>
3795 template <
typename T1,
bool OPT>
3804 copyIndexBindings(t);
3810 auto locate = std::find(mSelectedRows.begin(), mSelectedRows.end(),
i);
3811 if (locate == mSelectedRows.end()) {
3814 return static_cast<int>(std::distance(mSelectedRows.begin(), locate));
3821 std::set_union(mSelectedRows.begin(), mSelectedRows.end(), selection.begin(), selection.end(), std::back_inserter(rowsUnion));
3822 mSelectedRowsCache.clear();
3823 mSelectedRowsCache = rowsUnion;
3831 std::set_intersection(mSelectedRows.begin(), mSelectedRows.end(), selection.begin(), selection.end(), std::back_inserter(intersection));
3832 mSelectedRowsCache.clear();
3833 mSelectedRowsCache = intersection;
3841 std::set_union(mSelectedRows.begin(), mSelectedRows.end(), selection.begin(), selection.end(), std::back_inserter(rowsUnion));
3842 mSelectedRowsCache.clear();
3843 mSelectedRowsCache = rowsUnion;
3851 std::set_intersection(mSelectedRows.begin(), mSelectedRows.end(), selection.begin(), selection.end(), std::back_inserter(intersection));
3852 mSelectedRowsCache.clear();
3853 mSelectedRowsCache = intersection;
3866 mSelectedRows = std::span{mSelectedRowsCache};
3869 if (tableSize() == 0) {
3870 mFilteredBegin = *mFilteredEnd;
3872 mFilteredBegin.resetSelection(mSelectedRows);
3876 std::span<int64_t const> mSelectedRows;
3878 bool mCached =
false;
3879 iterator mFilteredBegin;
3880 std::shared_ptr<RowViewSentinel> mFilteredEnd;
3883template <
typename T>
3892 using iterator = T::template iterator_template_o<FilteredIndexPolicy, self_t>;
3898 return iterator(this->cached_begin());
3912 Filtered(std::vector<std::shared_ptr<arrow::Table>>&& tables, std::span<int64_t const>
const& selection, uint64_t
offset = 0)
3936 this->sumWithSelection(selection);
3942 this->sumWithSelection(selection);
3948 return operator+=(
other.getSelectedRows());
3967 return operator*(
other.getSelectedRows());
3972 this->intersectWithSelection(selection);
3978 this->intersectWithSelection(selection);
3984 return operator*=(
other.getSelectedRows());
4000 std::iota(newSelection.begin(), newSelection.end(),
start);
4001 return self_t{{this->asArrowTable()}, std::move(newSelection), 0};
4009 template <
typename T1>
4025 template <
typename T1,
bool OPT>
4031 template <
typename T1,
bool OPT>
4040 copyIndexBindings(t);
4045template <
typename T>
4054 using iterator =
typename T::template iterator_template_o<FilteredIndexPolicy, self_t>;
4060 return iterator(this->cached_begin());
4071 for (
auto& table : tables) {
4079 for (
auto& table : tables) {
4087 for (
auto& table : tables) {
4113 this->sumWithSelection(selection);
4119 this->sumWithSelection(selection);
4125 return operator+=(
other.getSelectedRows());
4131 copy.intersectionWithSelection(selection);
4138 copy.intersectionWithSelection(selection);
4144 return operator*(
other.getSelectedRows());
4149 this->intersectWithSelection(selection);
4155 this->intersectWithSelection(selection);
4161 return operator*=(
other.getSelectedRows());
4175 std::iota(newSelection.begin(), newSelection.end(),
start);
4176 return self_t{{this->asArrowTable()}, std::move(newSelection), 0};
4194 template <
typename T1,
bool OPT>
4200 template <
typename T1,
bool OPT>
4207 std::vector<std::shared_ptr<arrow::Table>> extractTablesFromFiltered(std::vector<
Filtered<T>>& tables)
4209 std::vector<std::shared_ptr<arrow::Table>> outTables;
4210 for (
auto& table : tables) {
4211 outTables.push_back(table.asArrowTable());
4222template <
typename L,
typename D,
typename O,
typename Key,
typename H,
typename...
Ts>
4232 static constexpr const uint32_t binding_origin = Key::binding_origin;
4235 template <
typename... TA>
4239 if constexpr (binding_origin == TA::binding_origin) {
4240 this->bindExternalIndex(cur);
4267template <
typename T,
bool APPLY>
4269 static constexpr bool applyFilters = APPLY;
4276 SmallGroupsBase(std::vector<std::shared_ptr<arrow::Table>>&& tables, std::span<int64_t const>
const& selection, uint64_t
offset = 0)
4280template <
typename T>
4283template <
typename T>
4286template <
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)
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
SliceInfoPtr getCacheFor(Entry const &bindingKey) const
std::shared_ptr< arrow::Table > getSliceFor(int value, std::shared_ptr< arrow::Table > const &input, uint64_t &offset) const
static constexpr bool optional
PresliceBase(expressions::BindingNode index_)
std::span< const int64_t > getSliceFor(int value) const
const std::string binding
const std::string binding
Entry const & getBindingKey() const
SliceInfoUnsortedPtr sliceInfo
std::span< const int64_t > getSliceFor(int value) const
void updateSliceInfo(SliceInfoUnsortedPtr &&si)
void updateSliceInfo(SliceInfoPtr &&si)
std::shared_ptr< arrow::Table > getSliceFor(int value, std::shared_ptr< arrow::Table > const &input, uint64_t &offset) const
ArrowTableSlicingCache * ptr
std::pair< int64_t, int64_t > getSliceFor(int value) const
An expression tree node corresponding to a column binding.
A struct, containing the root of the expression tree.
From https://en.cppreference.com/w/cpp/utility/variant/visit.
static std::shared_ptr< arrow::Table > joinTables(std::vector< std::shared_ptr< arrow::Table > > &&tables)
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