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);
402template <aod::is_aod_hash L, aod::is_aod_hash D, aod::is_origin_hash O,
typename... Ts>
407 void const*
ptr =
nullptr;
409 std::span<TableRef const>
refs;
411 template <
typename T>
415 hash = o2::framework::TypeIdHelpers::uniqueId<T>();
416 refs = std::span{T::originals};
419 template <
typename T>
422 if (
hash == o2::framework::TypeIdHelpers::uniqueId<T>()) {
423 return static_cast<T const*
>(
ptr);
452template <
typename B,
typename E>
454 constexpr static bool value =
false;
457template <aod::is_aod_hash A, aod::is_aod_hash B>
459 constexpr static bool value =
false;
462template <
typename B,
typename E>
465template <aod::is_aod_hash A, aod::is_aod_hash B>
504template <
typename T,
typename ChunkingPolicy = Chunked>
507 static constexpr char SCALE_FACTOR = std::same_as<std::decay_t<T>,
bool> ? 3 : 0;
523 auto array = getCurrentArray();
538 auto previousArray = getCurrentArray();
542 auto array = getCurrentArray();
549 auto previousArray = getCurrentArray();
553 auto array = getCurrentArray();
575 auto array = getCurrentArray();
582 requires
std::same_as<
bool,
std::decay_t<T>>
598 decltype(
auto)
operator*()
const
599 requires((!std::same_as<bool, std::decay_t<T>>) && std::same_as<
arrow_array_for_t<T>, arrow::BinaryViewArray>)
606 decltype(
auto)
operator*()
const
629 void checkSkipChunk() const
638 void checkSkipChunk() const
646 void checkSkipChunk() const
647 requires(ChunkingPolicy::
chunked == false)
651 auto getCurrentArray() const
655 mOffset = chunkToUse->offset();
656 chunkToUse = std::dynamic_pointer_cast<arrow::FixedSizeListArray>(chunkToUse)->values();
657 return std::static_pointer_cast<arrow_array_for_t<value_for_t<T>>>(chunkToUse);
660 auto getCurrentArray() const
664 mOffset = chunkToUse->offset();
665 chunkToUse = std::dynamic_pointer_cast<arrow::ListArray>(chunkToUse)->values();
666 mOffset = chunkToUse->offset();
667 return std::static_pointer_cast<arrow_array_for_t<value_for_t<T>>>(chunkToUse);
670 auto getCurrentArray() const
674 mOffset = chunkToUse->offset();
675 return std::static_pointer_cast<arrow_array_for_t<T>>(chunkToUse);
679template <
typename T,
typename INHERIT>
695 static constexpr const char*
const&
columnLabel() {
return INHERIT::mLabel; }
703 return std::make_shared<arrow::Field>(inherited_t::mLabel, soa::asArrowDataType<type>());
713template <
typename F,
typename INHERIT>
717 static constexpr const char*
const&
columnLabel() {
return INHERIT::mLabel; }
720template <
typename INHERIT>
723 static constexpr const uint32_t
hash = 0;
725 static constexpr const char*
const&
columnLabel() {
return INHERIT::mLabel; }
728template <
typename INHERIT>
731 static constexpr const uint32_t
hash = 0;
733 static constexpr const char*
const&
columnLabel() {
return INHERIT::mLabel; }
736template <
size_t M = 0>
740 constexpr inline static auto value = M;
755 static constexpr const char*
mLabel =
"Marker";
758template <int64_t START = 0, int64_t
END = -1>
761 constexpr inline static int64_t
start = START;
762 constexpr inline static int64_t
end =
END;
822 static constexpr const char*
mLabel =
"Index";
846using is_dynamic_t = std::conditional_t<is_dynamic_column<T>, std::true_type, std::false_type>;
852using is_indexing_t = std::conditional_t<is_indexing_column<T>, std::true_type, std::false_type>;
873 mSelectedRows(selection),
874 mMaxSelection(selection.
size()),
882 mSelectedRows = selection;
883 mMaxSelection = selection.size();
893 [[nodiscard]] std::tuple<int64_t const*, int64_t const*>
896 return std::make_tuple(&
mRowIndex, &mSelectionRow);
899 [[nodiscard]] std::tuple<uint64_t const*>
902 return std::make_tuple(&
mOffset);
909 mMaxSelection = std::min(
end, mMaxSelection);
927 return lh.mSelectionRow == rh.mSelectionRow;
940 this->mSelectionRow = this->mMaxSelection;
946 return mSelectionRow;
949 [[nodiscard]]
auto size()
const
951 return mMaxSelection;
960 inline void updateRow()
964 std::span<int64_t const> mSelectedRows;
965 int64_t mSelectionRow = 0;
966 int64_t mMaxSelection = 0;
1001 [[nodiscard]] std::tuple<int64_t const*, int64_t const*>
1007 [[nodiscard]] std::tuple<uint64_t const*>
1010 return std::make_tuple(&
mOffset);
1051template <
typename T>
1056template <
typename C>
1062template <
typename T,
typename B>
1064 { t.B::mColumnIterator };
1067template <
typename...
C>
1070template <
typename D,
typename O,
typename IP,
typename... C>
1085 if (this->
size() != 0) {
1095 if (this->
size() != 0) {
1102 this->limitRange(this->rangeStart(), this->rangeEnd());
1108 C(static_cast<
C const&>(
other))...
1110 if (this->
size() != 0) {
1117 IP::operator=(
static_cast<IP const&
>(
other));
1118 (
void(
static_cast<C&
>(*
this) =
static_cast<C>(
other)), ...);
1119 if (this->
size() != 0) {
1126 requires std::same_as<IP, DefaultIndexPolicy>
1128 C(
static_cast<C const&
>(
other))...
1130 if (this->
size() != 0) {
1137 this->moveByIndex(1);
1150 this->moveByIndex(-1);
1165 copy.moveByIndex(inc);
1179 template <
typename... CL,
typename TA>
1182 (CL::setCurrent(current), ...);
1185 template <
typename CL>
1188 return CL::getCurrentRaw();
1191 template <
typename... Cs>
1194 return std::vector<o2::soa::Binding>{
static_cast<Cs const&
>(*this).getCurrentRaw()...};
1202 template <
typename... TA>
1208 template <
typename... Cs>
1211 (Cs::setCurrentRaw(ptrs[framework::has_type_at_v<Cs>(p)]), ...);
1214 template <
typename... Cs,
typename I>
1219 (Cs::setCurrentRaw(
b), ...);
1227 template <
typename I>
1235 template <
typename... PC>
1238 (PC::mColumnIterator.moveToEnd(), ...);
1248 [
this]<soa::is_dynamic_column T>(T*) ->
void { bindDynamicColumn<T>(
typename T::bindings_t{}); },
1249 [
this]<
typename T>(
T*) ->
void {},
1251 (
f(
static_cast<C*
>(
nullptr)), ...);
1252 if constexpr (has_index<
C...>) {
1253 this->setIndices(this->getIndices());
1254 this->setOffsets(this->getOffsets());
1258 template <
typename DC,
typename...
B>
1261 DC::boundIterators = std::make_tuple(getDynamicBinding<B>()...);
1269 template <
typename B>
1270 requires(can_bind<self_t, B>)
1271 decltype(
auto) getDynamicBinding()
1273 static_assert(std::same_as<decltype(&(static_cast<B*>(
this)->mColumnIterator)), std::decay_t<
decltype(B::mColumnIterator)>*>,
"foo");
1274 return &(
static_cast<B*
>(
this)->mColumnIterator);
1278 template <
typename B>
1279 decltype(
auto) getDynamicBinding()
1281 return static_cast<std::decay_t<decltype(B::mColumnIterator)
>*>(
nullptr);
1286 static std::shared_ptr<arrow::Table>
joinTables(std::vector<std::shared_ptr<arrow::Table>>&& tables);
1287 static std::shared_ptr<arrow::Table>
joinTables(std::vector<std::shared_ptr<arrow::Table>>&& tables, std::span<const char* const>
labels);
1288 static std::shared_ptr<arrow::Table>
joinTables(std::vector<std::shared_ptr<arrow::Table>>&& tables, std::span<const std::string>
labels);
1289 static std::shared_ptr<arrow::Table>
concatTables(std::vector<std::shared_ptr<arrow::Table>>&& tables);
1293template <
typename T>
1296template <
typename T>
1298 T::originals.size();
1301template <
typename T>
1306template <
typename T>
1308 T::ccdb_urls.size();
1311template <
typename T>
1316template <
typename T>
1318 typename T::expression_pack_t{};
1321template <
typename T>
1323 typename T::index_pack_t{};
1326template <
size_t N1, std::array<TableRef, N1> os1,
size_t N2, std::array<TableRef, N2> os2>
1329 return []<
size_t... Is>(std::index_sequence<Is...>) {
1330 return ([]<
size_t... Ks>(std::index_sequence<Ks...>) {
1331 constexpr auto h = os1[Is].desc_hash;
1334 }(std::make_index_sequence<N2>()) ||
1336 }(std::make_index_sequence<N1>());
1339template <with_originals T, with_originals B>
1342 return is_compatible<T::originals.size(), T::originals, B::originals.size(), B::originals>();
1345template <
typename T,
typename B>
1346using is_binding_compatible = std::conditional_t<is_binding_compatible_v<T, typename B::binding_t>(), std::true_type, std::false_type>;
1348template <
typename L,
typename D,
typename O,
typename Key,
typename H,
typename...
Ts>
1351template <
typename T>
1354template <soa::is_table T>
1355static constexpr std::string getLabelForTable()
1357 return std::string{aod::label<std::decay_t<T>::originals[0]>()};
1360template <soa::is_table T>
1362static constexpr std::string getLabelFromType()
1364 return getLabelForTable<T>();
1367template <soa::is_iterator T>
1368static constexpr std::string getLabelFromType()
1370 return getLabelForTable<typename std::decay_t<T>::parent_t>();
1373template <soa::is_index_table T>
1374static constexpr std::string getLabelFromType()
1376 return getLabelForTable<typename std::decay_t<T>::first_t>();
1378template <soa::with_base_table T>
1379static constexpr std::string getLabelFromType()
1384template <
typename...
C>
1387 auto caseInsensitiveCompare = [](
const std::string_view& str1,
const std::string& str2) {
1388 return std::ranges::equal(
1390 [](
char c1,
char c2) {
1391 return std::tolower(
static_cast<unsigned char>(c1)) ==
1392 std::tolower(
static_cast<unsigned char>(c2));
1395 return (caseInsensitiveCompare(C::inherited_t::mLabel,
key) || ...);
1398template <TableRef ref>
1399static constexpr std::pair<bool, std::string> hasKey(std::string
const&
key)
1404template <TableRef ref>
1405static constexpr std::pair<bool, framework::ConcreteDataMatcher> hasKeyM(std::string
const&
key)
1410template <
typename...
C>
1413 return std::vector{hasKey<C>(
key)...};
1419template <with_originals T,
bool OPT = false>
1420static constexpr std::string getLabelFromTypeForKey(std::string
const&
key)
1422 if constexpr (T::originals.size() == 1) {
1423 auto locate = hasKey<T::originals[0]>(
key);
1425 return locate.second;
1428 auto locate = [&]<
size_t... Is>(std::index_sequence<Is...>) {
1429 return std::vector{hasKey<T::originals[Is]>(
key)...};
1430 }(std::make_index_sequence<T::originals.size()>{});
1431 auto it = std::find_if(locate.begin(), locate.end(), [](
auto const&
x) { return x.first; });
1432 if (it != locate.end()) {
1436 if constexpr (!OPT) {
1444template <with_originals T,
bool OPT = false>
1447 if constexpr (T::originals.size() == 1) {
1448 auto locate = hasKeyM<T::originals[0]>(
key);
1450 return locate.second;
1453 auto locate = [&]<
size_t... Is>(std::index_sequence<Is...>) {
1454 return std::vector{hasKeyM<T::originals[Is]>(
key)...};
1455 }(std::make_index_sequence<T::originals.size()>{});
1456 auto it = std::find_if(locate.begin(), locate.end(), [](
auto const&
x) { return x.first; });
1457 if (it != locate.end()) {
1461 if constexpr (!OPT) {
1469template <
typename B,
typename...
C>
1472 return (o2::soa::is_binding_compatible_v<B, typename C::binding_t>() || ...);
1475template <
typename B,
typename...
C>
1478 return ((C::sorted && o2::soa::is_binding_compatible_v<B, typename C::binding_t>()) || ...);
1481template <
typename B,
typename Z>
1482consteval static bool relatedByIndex()
1484 return hasIndexTo<B>(
typename Z::table_t::external_index_columns_t{});
1487template <
typename B,
typename Z>
1488consteval static bool relatedBySortedIndex()
1490 return hasSortedIndexTo<B>(
typename Z::table_t::external_index_columns_t{});
1509 std::shared_ptr<arrow::Table>
getSliceFor(
int value, std::shared_ptr<arrow::Table>
const& input, uint64_t&
offset)
const;
1519template <
typename T>
1522template <
typename T, is_preslice_policy Policy,
bool OPT = false>
1530 : 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})}, {}}
1536 if constexpr (OPT) {
1537 if (Policy::isMissing()) {
1546 if constexpr (OPT) {
1547 if (Policy::isMissing()) {
1551 return Policy::getSliceFor(
value);
1555template <
typename T>
1557template <
typename T>
1559template <
typename T>
1561template <
typename T>
1564template <
typename T>
1586template <
typename T>
1593template <soa::is_table T>
1595template <
typename T>
1598template <
typename T>
1601template <
typename T>
1604template <
typename T>
1608template <
typename T>
1611template <
typename T>
1614template <
typename T>
1618template <
typename... Is>
1626template <
typename T,
typename C,
typename Policy,
bool OPT>
1627 requires std::same_as<Policy, framework::PreslicePolicySorted> && (o2::soa::is_binding_compatible_v<C, T>())
1630 if constexpr (OPT) {
1631 if (container.isMissing()) {
1637 auto t =
typename T::self_t({out},
offset);
1638 if (t.tableSize() != 0) {
1639 table->copyIndexBindings(t);
1640 t.bindInternalIndicesTo(table);
1645template <soa::is_filtered_table T>
1649 if (t.tableSize() != 0) {
1651 t.bindInternalIndicesTo(table);
1652 t.intersectWithSelection(table->getSelectedRows());
1657template <soa::is_table T>
1662 if (t.tableSize() != 0) {
1664 t.bindInternalIndicesTo(table);
1669template <
typename T,
typename C,
typename Policy,
bool OPT>
1670 requires std::same_as<Policy, framework::PreslicePolicyGeneral> && (o2::soa::is_binding_compatible_v<C, T>())
1673 if constexpr (OPT) {
1674 if (container.isMissing()) {
1684template <soa::is_filtered_table T>
1687 if (
offset >=
static_cast<uint64_t
>(table->tableSize())) {
1689 if (fresult.tableSize() != 0) {
1696 if (fresult.tableSize() != 0) {
1702template <soa::is_filtered_table T,
typename C,
bool OPT>
1703 requires(o2::soa::is_binding_compatible_v<C, T>())
1706 if constexpr (OPT) {
1707 if (container.isMissing()) {
1716template <soa::is_table T>
1719 auto localCache = cache.
ptr->
getCacheFor({
"", o2::soa::getMatcherFromTypeForKey<T>(
node.name),
node.name});
1721 auto t =
typename T::self_t({table->asArrowTable()->Slice(
static_cast<uint64_t
>(
offset),
count)},
static_cast<uint64_t
>(
offset));
1722 if (t.tableSize() != 0) {
1723 table->copyIndexBindings(t);
1728template <soa::is_filtered_table T>
1731 auto localCache = cache.
ptr->
getCacheFor({
"", o2::soa::getMatcherFromTypeForKey<T>(
node.name),
node.name});
1733 auto slice = table->asArrowTable()->Slice(
static_cast<uint64_t
>(
offset),
count);
1737template <soa::is_table T>
1742 auto t =
typename T::self_t({table->asArrowTable()}, localCache.getSliceFor(
value));
1743 if (t.tableSize() != 0) {
1744 t.intersectWithSelection(table->getSelectedRows());
1745 table->copyIndexBindings(t);
1749 auto t =
Filtered<T>({table->asArrowTable()}, localCache.getSliceFor(
value));
1750 if (t.tableSize() != 0) {
1751 table->copyIndexBindings(t);
1757template <with_originals T>
1765template <
typename D,
typename O,
typename IP,
typename...
C>
1802 return std::array<TableRef, 1>{
ref};
1818 static constexpr const auto ref =
TableRef{L::hash, D::hash, O::hash, o2::aod::version(D::str)};
1823 static constexpr const auto originalLabels = []<
size_t N, std::array<TableRef, N> refs,
size_t... Is>(std::index_sequence<Is...>) {
return std::array<const char*, N>{o2::aod::label<refs[Is]>()...}; }.template operator()<
originals.size(),
originals>(std::make_index_sequence<
originals.size()>());
1825 template <
size_t N, std::array<TableRef, N> bindings>
1826 requires(
ref.origin_hash ==
"CONC"_h)
1832 template <
size_t N, std::array<TableRef, N> bindings>
1833 requires(
ref.origin_hash ==
"JOIN"_h)
1838 return std::find(bindings.begin(), bindings.end(),
r) != bindings.end();
1842 template <
size_t N, std::array<TableRef, N> bindings>
1843 requires(!(
ref.origin_hash ==
"CONC"_h ||
ref.origin_hash ==
"JOIN"_h))
1846 return std::find(bindings.begin(), bindings.end(),
self_t::ref) != bindings.end();
1849 template <TableRef r>
1862 template <
typename IP>
1865 template <
typename IP,
typename Parent,
typename... T>
1882 template <
typename P,
typename... Os>
1884 requires(P::ref.desc_hash == Parent::ref.desc_hash)
1890 template <
typename P>
1897 template <
typename P>
1899 requires std::same_as<IP, DefaultIndexPolicy>
1905 template <
typename P,
typename O1,
typename... Os>
1907 requires(P::ref.desc_hash == Parent::ref.desc_hash)
1912 template <
typename P,
typename O1,
typename... Os>
1914 requires(P::ref.desc_hash == Parent::ref.desc_hash)
1919 template <
typename P>
1925 template <
typename P>
1931 template <
typename P>
1933 requires std::same_as<IP, DefaultIndexPolicy>
1940 this->mRowIndex =
other.index;
1943 template <
typename P>
1946 this->mRowIndex =
other.mRowIndex;
1949 template <
typename P,
typename... Os>
1951 requires std::same_as<typename P::table_t, typename Parent::table_t>
1953 this->mRowIndex =
other.mRowIndex;
1956 template <
typename TI>
1959 using decayed = std::decay_t<TI>;
1961 constexpr auto idx = framework::has_type_at_v<decayed>(
bindings_pack_t{});
1963 }
else if constexpr (std::same_as<decayed, Parent>) {
1964 return this->globalIndex();
1966 return this->globalIndex();
1968 return static_cast<int32_t
>(-1);
1972 template <
typename CD,
typename... CDArgs>
1975 using decayed = std::decay_t<CD>;
1977 return static_cast<decayed
>(*this).template getDynamicValue<CDArgs...>();
1980 template <
typename B,
typename CC>
1983 using COL = std::decay_t<CC>;
1985 return static_cast<B>(
static_cast<COL
>(*this).get());
1988 template <
typename B,
typename... CCs>
1991 static_assert(std::same_as<B, float> || std::same_as<B, double>,
"The common return type should be float or double");
1992 return {getValue<B, CCs>()...};
2003 copy.moveByIndex(inc);
2018 template <
typename IP,
typename Parent,
typename... T>
2021 template <
typename IP,
typename Parent>
2024 if constexpr (
sizeof...(Ts) == 0) {
2035 template <
typename IP,
typename Parent>
2052 mEnd{table->num_rows()},
2055 if (mTable->num_rows() == 0) {
2057 mColumnChunks[ci] =
nullptr;
2063 mColumnChunks[ci] = lookups[ci];
2066 mBegin.bindInternalIndices(
this);
2070 Table(std::vector<std::shared_ptr<arrow::Table>>&& tables, uint64_t
offset = 0)
2071 requires(
ref.origin_hash !=
"CONC"_h)
2076 Table(std::vector<std::shared_ptr<arrow::Table>>&& tables, uint64_t
offset = 0)
2077 requires(
ref.origin_hash ==
"CONC"_h)
2082 template <
typename Key>
2086 return std::array<bool,
sizeof...(Cs)>{[]() {
2087 if constexpr (
requires { Cs::index_targets.size(); }) {
2088 return Key::template
isIndexTargetOf<Cs::index_targets.size(), Cs::index_targets>();
2094 constexpr auto pos = std::find(map.begin(), map.end(),
true);
2095 if constexpr (
pos != map.end()) {
2096 return mColumnChunks[std::distance(map.begin(),
pos)];
2098 static_assert(framework::always_static_assert_v<Key>,
"This table does not have an index to given Key");
2128 return filtered_iterator(mColumnChunks, {selection, mTable->num_rows(), mOffset});
2166 return mTable->num_rows();
2176 template <
typename... TA>
2179 mBegin.bindExternalIndices(current...);
2182 template <
typename I>
2185 mBegin.bindInternalIndices(
ptr);
2193 template <
typename... Cs>
2196 (
static_cast<Cs
>(mBegin).setCurrentRaw(
binding), ...);
2201 mBegin.bindExternalIndicesRaw(std::forward<std::vector<o2::soa::Binding>>(ptrs));
2204 template <
typename T,
typename... Cs>
2207 dest.bindExternalIndicesRaw(mBegin.getIndexBindings());
2210 template <
typename T>
2233 template <
typename T1,
typename Policy,
bool OPT>
2246 return self_t{mTable->Slice(0, 0), 0};
2250 template <
typename T>
2251 arrow::ChunkedArray* lookupColumn()
2254 auto label = T::columnLabel();
2260 std::shared_ptr<arrow::Table> mTable =
nullptr;
2261 uint64_t mOffset = 0;
2268template <uint32_t
D, soa::is_column...
C>
2274namespace row_helpers
2276template <
typename R,
typename T,
typename C>
2279 return static_cast<R>(
static_cast<C>(rowIterator).get());
2284template <
typename R,
typename T>
2285using ColumnGetterFunction =
R (*)(
const T&);
2287template <
typename T,
typename R>
2292 { t.get() } -> std::convertible_to<R>;
2295template <
typename T,
typename R>
2297 { t.get() } -> std::convertible_to<R>;
2300template <
typename R,
typename T, persistent_with_common_getter<R> C>
2301ColumnGetterFunction<R, T> createGetterPtr(
const std::string_view& targetColumnLabel)
2303 return targetColumnLabel == C::columnLabel() ? &getColumnValue<R, T, C> :
nullptr;
2306template <
typename R,
typename T, dynamic_with_common_getter<R> C>
2307ColumnGetterFunction<R, T> createGetterPtr(
const std::string_view& targetColumnLabel)
2313 if (targetColumnLabel.starts_with(
"f") && targetColumnLabel.substr(1) ==
columnLabel) {
2314 return &getColumnValue<R, T, C>;
2319 return &getColumnValue<R, T, C>;
2325template <
typename R,
typename T,
typename... Cs>
2328 ColumnGetterFunction<R, T>
func;
2330 (
void)((
func = createGetterPtr<R, T, Cs>(targetColumnLabel),
func) || ...);
2339template <
typename T,
typename R>
2340using 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;
2343template <
typename R,
typename T>
2348 if (targetColumnLabel.size() == 0) {
2352 return getColumnGetterByLabel<R, typename T::iterator>(TypesWithCommonGetter{}, targetColumnLabel);
2377template <
typename T>
2378consteval static std::string_view namespace_prefix()
2380 constexpr auto name = o2::framework::type_name<T>();
2381 const auto pos =
name.rfind(std::string_view{
":"});
2382 return name.substr(0,
pos + 1);
2386#define DECLARE_EQUIVALENT_FOR_INDEX(_Base_, _Equiv_) \
2388 struct EquivalentIndexNG<o2::aod::Hash<_Base_::ref.desc_hash>, o2::aod::Hash<_Equiv_::ref.desc_hash>> { \
2389 constexpr static bool value = true; \
2392#define DECLARE_EQUIVALENT_FOR_INDEX_NG(_Base_, _Equiv_) \
2394 struct EquivalentIndexNG<o2::aod::Hash<_Base_ ""_h>, o2::aod::Hash<_Equiv_ ""_h>> { \
2395 constexpr static bool value = true; \
2398#define DECLARE_SOA_COLUMN_FULL(_Name_, _Getter_, _Type_, _Label_) \
2399 struct _Name_ : o2::soa::Column<_Type_, _Name_> { \
2400 static constexpr const char* mLabel = _Label_; \
2401 static constexpr const uint32_t hash = compile_time_hash(namespace_prefix<_Name_>(), std::string_view{#_Getter_}); \
2402 static_assert(!((*(mLabel + 1) == 'I' && *(mLabel + 2) == 'n' && *(mLabel + 3) == 'd' && *(mLabel + 4) == 'e' && *(mLabel + 5) == 'x')), "Index is not a valid column name"); \
2403 using base = o2::soa::Column<_Type_, _Name_>; \
2404 using type = _Type_; \
2405 using column_t = _Name_; \
2406 _Name_(arrow::ChunkedArray const* column) \
2407 : o2::soa::Column<_Type_, _Name_>(o2::soa::ColumnIterator<type>(column)) \
2411 _Name_() = default; \
2412 _Name_(_Name_ const& other) = default; \
2413 _Name_& operator=(_Name_ const& other) = default; \
2415 decltype(auto) _Getter_() const \
2417 return *mColumnIterator; \
2420 decltype(auto) get() const \
2422 return _Getter_(); \
2425 [[maybe_unused]] static constexpr o2::framework::expressions::BindingNode _Getter_ { _Label_, _Name_::hash, o2::framework::expressions::selectArrowType<_Type_>() }
2427#define DECLARE_SOA_CCDB_COLUMN_FULL(_Name_, _Label_, _Getter_, _ConcreteType_, _CCDBQuery_) \
2428 struct _Name_ : o2::soa::Column<std::span<std::byte>, _Name_> { \
2429 static constexpr const char* mLabel = _Label_; \
2430 static constexpr const char* query = _CCDBQuery_; \
2431 static constexpr const uint32_t hash = crc32(namespace_prefix<_Name_>(), std::string_view{#_Getter_}); \
2432 using base = o2::soa::Column<std::span<std::byte>, _Name_>; \
2433 using type = std::span<std::byte>; \
2434 using column_t = _Name_; \
2435 _Name_(arrow::ChunkedArray const* column) \
2436 : o2::soa::Column<std::span<std::byte>, _Name_>(o2::soa::ColumnIterator<std::span<std::byte>>(column)) \
2440 _Name_() = default; \
2441 _Name_(_Name_ const& other) = default; \
2442 _Name_& operator=(_Name_ const& other) = default; \
2444 decltype(auto) _Getter_() const \
2446 static std::byte* payload = nullptr; \
2447 static _ConcreteType_* deserialised = nullptr; \
2448 static TClass* c = TClass::GetClass(#_ConcreteType_); \
2449 auto span = *mColumnIterator; \
2450 if (payload != (std::byte*)span.data()) { \
2451 payload = (std::byte*)span.data(); \
2452 delete deserialised; \
2453 TBufferFile f(TBufferFile::EMode::kRead, span.size(), (char*)span.data(), kFALSE); \
2454 deserialised = (_ConcreteType_*)soa::extractCCDBPayload((char*)payload, span.size(), c, "ccdb_object"); \
2456 return *deserialised; \
2462 return _Getter_(); \
2466#define DECLARE_SOA_CCDB_COLUMN(_Name_, _Getter_, _ConcreteType_, _CCDBQuery_) \
2467 DECLARE_SOA_CCDB_COLUMN_FULL(_Name_, "f" #_Name_, _Getter_, _ConcreteType_, _CCDBQuery_)
2469#define DECLARE_SOA_COLUMN(_Name_, _Getter_, _Type_) \
2470 DECLARE_SOA_COLUMN_FULL(_Name_, _Getter_, _Type_, "f" #_Name_)
2474#define MAKEINT(_Size_) uint##_Size_##_t
2476#define DECLARE_SOA_BITMAP_COLUMN_FULL(_Name_, _Getter_, _Size_, _Label_) \
2477 struct _Name_ : o2::soa::Column<MAKEINT(_Size_), _Name_> { \
2478 static constexpr const char* mLabel = _Label_; \
2479 static constexpr const uint32_t hash = compile_time_hash(namespace_prefix<_Name_>(), std::string_view{#_Getter_}); \
2480 static_assert(!((*(mLabel + 1) == 'I' && *(mLabel + 2) == 'n' && *(mLabel + 3) == 'd' && *(mLabel + 4) == 'e' && *(mLabel + 5) == 'x')), "Index is not a valid column name"); \
2481 using base = o2::soa::Column<MAKEINT(_Size_), _Name_>; \
2482 using type = MAKEINT(_Size_); \
2483 _Name_(arrow::ChunkedArray const* column) \
2484 : o2::soa::Column<type, _Name_>(o2::soa::ColumnIterator<type>(column)) \
2488 _Name_() = default; \
2489 _Name_(_Name_ const& other) = default; \
2490 _Name_& operator=(_Name_ const& other) = default; \
2492 decltype(auto) _Getter_##_raw() const \
2494 return *mColumnIterator; \
2497 bool _Getter_##_bit(int bit) const \
2499 return (*mColumnIterator & (static_cast<type>(1) << bit)) >> bit; \
2502 [[maybe_unused]] static constexpr o2::framework::expressions::BindingNode _Getter_ { _Label_, _Name_::hash, o2::framework::expressions::selectArrowType<MAKEINT(_Size_)>() }
2504#define DECLARE_SOA_BITMAP_COLUMN(_Name_, _Getter_, _Size_) \
2505 DECLARE_SOA_BITMAP_COLUMN_FULL(_Name_, _Getter_, _Size_, "f" #_Name_)
2509#define DECLARE_SOA_EXPRESSION_COLUMN_FULL(_Name_, _Getter_, _Type_, _Label_, _Expression_) \
2510 struct _Name_ : o2::soa::Column<_Type_, _Name_> { \
2511 static constexpr const char* mLabel = _Label_; \
2512 static constexpr const uint32_t hash = compile_time_hash(namespace_prefix<_Name_>(), std::string_view{#_Getter_}); \
2513 using base = o2::soa::Column<_Type_, _Name_>; \
2514 using type = _Type_; \
2515 using column_t = _Name_; \
2516 using spawnable_t = std::true_type; \
2517 _Name_(arrow::ChunkedArray const* column) \
2518 : o2::soa::Column<_Type_, _Name_>(o2::soa::ColumnIterator<type>(column)) \
2522 _Name_() = default; \
2523 _Name_(_Name_ const& other) = default; \
2524 _Name_& operator=(_Name_ const& other) = default; \
2526 decltype(auto) _Getter_() const \
2528 return *mColumnIterator; \
2531 decltype(auto) get() const \
2533 return _Getter_(); \
2536 static o2::framework::expressions::Projector Projector() \
2538 return _Expression_; \
2541 [[maybe_unused]] static constexpr o2::framework::expressions::BindingNode _Getter_ { _Label_, _Name_::hash, o2::framework::expressions::selectArrowType<_Type_>() }
2543#define DECLARE_SOA_EXPRESSION_COLUMN(_Name_, _Getter_, _Type_, _Expression_) \
2544 DECLARE_SOA_EXPRESSION_COLUMN_FULL(_Name_, _Getter_, _Type_, "f" #_Name_, _Expression_);
2548#define DECLARE_SOA_CONFIGURABLE_EXPRESSION_COLUMN(_Name_, _Getter_, _Type_, _Label_) \
2549 struct _Name_ : o2::soa::Column<_Type_, _Name_> { \
2550 static constexpr const char* mLabel = _Label_; \
2551 static constexpr const uint32_t hash = compile_time_hash(namespace_prefix<_Name_>(), std::string_view{#_Getter_}); \
2552 static constexpr const int32_t mHash = _Label_ ""_h; \
2553 using base = o2::soa::Column<_Type_, _Name_>; \
2554 using type = _Type_; \
2555 using column_t = _Name_; \
2556 using spawnable_t = std::true_type; \
2557 _Name_(arrow::ChunkedArray const* column) \
2558 : o2::soa::Column<_Type_, _Name_>(o2::soa::ColumnIterator<type>(column)) \
2562 _Name_() = default; \
2563 _Name_(_Name_ const& other) = default; \
2564 _Name_& operator=(_Name_ const& other) = default; \
2566 decltype(auto) _Getter_() const \
2568 return *mColumnIterator; \
2571 decltype(auto) get() const \
2573 return _Getter_(); \
2576 [[maybe_unused]] static constexpr o2::framework::expressions::BindingNode _Getter_ { _Label_, _Name_::hash, o2::framework::expressions::selectArrowType<_Type_>() }
2599template <o2::soa::is_table T>
2602 return T::originals;
2605#define DECLARE_SOA_SLICE_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, _Type_, _Table_, _Label_, _Suffix_) \
2606 struct _Name_##IdSlice : o2::soa::Column<_Type_[2], _Name_##IdSlice> { \
2607 static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
2608 static_assert((*_Suffix_ == '\0') || (*_Suffix_ == '_'), "Suffix has to begin with _"); \
2609 static constexpr const char* mLabel = "fIndexSlice" _Label_ _Suffix_; \
2610 static constexpr const uint32_t hash = 0; \
2611 using base = o2::soa::Column<_Type_[2], _Name_##IdSlice>; \
2612 using type = _Type_[2]; \
2613 using column_t = _Name_##IdSlice; \
2614 using binding_t = _Table_; \
2615 static constexpr auto index_targets = getIndexTargets<_Table_>(); \
2616 _Name_##IdSlice(arrow::ChunkedArray const* column) \
2617 : o2::soa::Column<_Type_[2], _Name_##IdSlice>(o2::soa::ColumnIterator<type>(column)) \
2621 _Name_##IdSlice() = default; \
2622 _Name_##IdSlice(_Name_##IdSlice const& other) = default; \
2623 _Name_##IdSlice& operator=(_Name_##IdSlice const& other) = default; \
2624 std::array<_Type_, 2> inline getIds() const \
2626 return _Getter_##Ids(); \
2629 bool has_##_Getter_() const \
2631 auto a = *mColumnIterator; \
2632 return a[0] >= 0 && a[1] >= 0; \
2635 std::array<_Type_, 2> _Getter_##Ids() const \
2637 auto a = *mColumnIterator; \
2638 return std::array{a[0], a[1]}; \
2641 template <typename T> \
2642 auto _Getter_##_as() const \
2644 if (O2_BUILTIN_UNLIKELY(mBinding.ptr == nullptr)) { \
2645 o2::soa::notBoundTable(#_Table_); \
2647 auto t = mBinding.get<T>(); \
2648 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2649 o2::soa::dereferenceWithWrongType(#_Getter_, #_Table_); \
2651 if (O2_BUILTIN_UNLIKELY(!has_##_Getter_())) { \
2652 return t->emptySlice(); \
2654 auto a = *mColumnIterator; \
2655 auto r = t->rawSlice(a[0], a[1]); \
2656 t->copyIndexBindings(r); \
2657 r.bindInternalIndicesTo(t); \
2661 auto _Getter_() const \
2663 return _Getter_##_as<binding_t>(); \
2666 template <typename T> \
2667 bool setCurrent(T const* current) \
2669 if constexpr (o2::soa::is_binding_compatible_v<T, binding_t>()) { \
2670 assert(current != nullptr); \
2671 this->mBinding.bind(current); \
2677 bool setCurrentRaw(o2::soa::Binding current) \
2679 this->mBinding = current; \
2682 binding_t const* getCurrent() const { return mBinding.get<binding_t>(); } \
2683 o2::soa::Binding getCurrentRaw() const { return mBinding; } \
2684 o2::soa::Binding mBinding; \
2687#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_)
2688#define DECLARE_SOA_SLICE_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_SLICE_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, _Name_##s, "")
2689#define DECLARE_SOA_SLICE_INDEX_COLUMN_CUSTOM(_Name_, _Getter_, _Label_) DECLARE_SOA_SLICE_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, int32_t, _Name_##s, _Label_, "")
2692#define DECLARE_SOA_ARRAY_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, _Type_, _Table_, _Label_, _Suffix_) \
2693 struct _Name_##Ids : o2::soa::Column<std::vector<_Type_>, _Name_##Ids> { \
2694 static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
2695 static_assert((*_Suffix_ == '\0') || (*_Suffix_ == '_'), "Suffix has to begin with _"); \
2696 static constexpr const char* mLabel = "fIndexArray" _Label_ _Suffix_; \
2697 static constexpr const uint32_t hash = 0; \
2698 using base = o2::soa::Column<std::vector<_Type_>, _Name_##Ids>; \
2699 using type = std::vector<_Type_>; \
2700 using column_t = _Name_##Ids; \
2701 using binding_t = _Table_; \
2702 static constexpr auto index_targets = getIndexTargets<_Table_>(); \
2703 _Name_##Ids(arrow::ChunkedArray const* column) \
2704 : o2::soa::Column<std::vector<_Type_>, _Name_##Ids>(o2::soa::ColumnIterator<type>(column)) \
2708 _Name_##Ids() = default; \
2709 _Name_##Ids(_Name_##Ids const& other) = default; \
2710 _Name_##Ids& operator=(_Name_##Ids const& other) = default; \
2712 gsl::span<const _Type_> inline getIds() const \
2714 return _Getter_##Ids(); \
2717 gsl::span<const _Type_> _Getter_##Ids() const \
2719 return *mColumnIterator; \
2722 bool has_##_Getter_() const \
2724 return !(*mColumnIterator).empty(); \
2727 template <typename T> \
2728 auto _Getter_##_as() const \
2730 if (O2_BUILTIN_UNLIKELY(mBinding.ptr == nullptr)) { \
2731 o2::soa::notBoundTable(#_Table_); \
2733 auto t = mBinding.get<T>(); \
2734 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2735 o2::soa::dereferenceWithWrongType(#_Getter_, #_Table_); \
2737 return getIterators<T>(); \
2740 template <typename T> \
2741 auto filtered_##_Getter_##_as() const \
2743 if (O2_BUILTIN_UNLIKELY(mBinding.ptr == nullptr)) { \
2744 o2::soa::notBoundTable(#_Table_); \
2746 auto t = mBinding.get<T>(); \
2747 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2748 o2::soa::dereferenceWithWrongType(#_Getter_, #_Table_); \
2750 return getFilteredIterators<T>(); \
2753 template <typename T> \
2754 auto getIterators() const \
2756 auto result = std::vector<typename T::unfiltered_iterator>(); \
2757 for (auto& i : *mColumnIterator) { \
2758 result.push_back(mBinding.get<T>()->rawIteratorAt(i)); \
2763 template <typename T> \
2764 std::vector<typename T::iterator> getFilteredIterators() const \
2766 if constexpr (o2::soa::is_filtered_table<T>) { \
2767 auto result = std::vector<typename T::iterator>(); \
2768 for (auto const& i : *mColumnIterator) { \
2769 auto pos = mBinding.get<T>()->isInSelectedRows(i); \
2771 result.emplace_back(mBinding.get<T>()->iteratorAt(pos)); \
2776 static_assert(o2::framework::always_static_assert_v<T>, "T is not a Filtered type"); \
2781 auto _Getter_() const \
2783 return _Getter_##_as<binding_t>(); \
2786 template <typename T> \
2787 auto _Getter_##_first_as() const \
2789 if (O2_BUILTIN_UNLIKELY(mBinding.ptr == nullptr)) { \
2790 o2::soa::notBoundTable(#_Table_); \
2792 auto t = mBinding.get<T>(); \
2793 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2794 o2::soa::dereferenceWithWrongType(#_Getter_, #_Table_); \
2796 return t->rawIteratorAt((*mColumnIterator)[0]); \
2799 template <typename T> \
2800 auto _Getter_##_last_as() const \
2802 if (O2_BUILTIN_UNLIKELY(mBinding.ptr == nullptr)) { \
2803 o2::soa::notBoundTable(#_Table_); \
2805 auto t = mBinding.get<T>(); \
2806 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2807 o2::soa::dereferenceWithWrongType(#_Getter_, #_Table_); \
2809 return t->rawIteratorAt((*mColumnIterator).back()); \
2812 auto _Getter_first() const \
2814 return _Getter_##_first_as<binding_t>(); \
2817 auto _Getter_last() const \
2819 return _Getter_##_last_as<binding_t>(); \
2822 template <typename T> \
2823 bool setCurrent(T const* current) \
2825 if constexpr (o2::soa::is_binding_compatible_v<T, binding_t>()) { \
2826 assert(current != nullptr); \
2827 this->mBinding.bind(current); \
2833 bool setCurrentRaw(o2::soa::Binding current) \
2835 this->mBinding = current; \
2838 binding_t const* getCurrent() const { return mBinding.get<binding_t>(); } \
2839 o2::soa::Binding getCurrentRaw() const { return mBinding; } \
2840 o2::soa::Binding mBinding; \
2843#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_)
2844#define DECLARE_SOA_ARRAY_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_ARRAY_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, _Name_##s, "")
2845#define DECLARE_SOA_ARRAY_INDEX_COLUMN_CUSTOM(_Name_, _Getter_, _Label_) DECLARE_SOA_ARRAY_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, int32_t, _Name_##s, _Label_, "")
2848#define DECLARE_SOA_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, _Type_, _Table_, _Label_, _Suffix_) \
2849 struct _Name_##Id : o2::soa::Column<_Type_, _Name_##Id> { \
2850 static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
2851 static_assert((*_Suffix_ == '\0') || (*_Suffix_ == '_'), "Suffix has to begin with _"); \
2852 static constexpr const char* mLabel = "fIndex" _Label_ _Suffix_; \
2853 static constexpr const uint32_t hash = compile_time_hash(namespace_prefix<_Name_##Id>(), std::string_view{#_Getter_ "Id"}); \
2854 using base = o2::soa::Column<_Type_, _Name_##Id>; \
2855 using type = _Type_; \
2856 using column_t = _Name_##Id; \
2857 using binding_t = _Table_; \
2858 static constexpr auto index_targets = getIndexTargets<_Table_>(); \
2859 _Name_##Id(arrow::ChunkedArray const* column) \
2860 : o2::soa::Column<_Type_, _Name_##Id>(o2::soa::ColumnIterator<type>(column)) \
2864 _Name_##Id() = default; \
2865 _Name_##Id(_Name_##Id const& other) = default; \
2866 _Name_##Id& operator=(_Name_##Id const& other) = default; \
2867 type inline getId() const \
2869 return _Getter_##Id(); \
2872 type _Getter_##Id() const \
2874 return *mColumnIterator; \
2877 bool has_##_Getter_() const \
2879 return *mColumnIterator >= 0; \
2882 template <typename T> \
2883 auto _Getter_##_as() const \
2885 if (O2_BUILTIN_UNLIKELY(mBinding.ptr == nullptr)) { \
2886 o2::soa::notBoundTable(#_Table_); \
2888 if (O2_BUILTIN_UNLIKELY(!has_##_Getter_())) { \
2889 o2::soa::accessingInvalidIndexFor(#_Getter_); \
2891 auto t = mBinding.get<T>(); \
2892 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2893 o2::soa::dereferenceWithWrongType(#_Getter_, #_Table_); \
2895 return t->rawIteratorAt(*mColumnIterator); \
2898 auto _Getter_() const \
2900 return _Getter_##_as<binding_t>(); \
2903 template <typename T> \
2904 bool setCurrent(T* current) \
2906 if constexpr (o2::soa::is_binding_compatible_v<T, binding_t>()) { \
2907 assert(current != nullptr); \
2908 this->mBinding.bind(current); \
2914 bool setCurrentRaw(o2::soa::Binding current) \
2916 this->mBinding = current; \
2919 binding_t const* getCurrent() const { return mBinding.get<binding_t>(); } \
2920 o2::soa::Binding getCurrentRaw() const { return mBinding; } \
2921 o2::soa::Binding mBinding; \
2923 [[maybe_unused]] static constexpr o2::framework::expressions::BindingNode _Getter_##Id { "fIndex" _Label_ _Suffix_, _Name_##Id::hash, o2::framework::expressions::selectArrowType<_Type_>() }
2925#define DECLARE_SOA_INDEX_COLUMN_FULL(_Name_, _Getter_, _Type_, _Table_, _Suffix_) DECLARE_SOA_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, _Type_, _Table_, #_Table_, _Suffix_)
2926#define DECLARE_SOA_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, _Name_##s, "")
2927#define DECLARE_SOA_INDEX_COLUMN_CUSTOM(_Name_, _Getter_, _Label_) DECLARE_SOA_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, int32_t, _Name_##s, _Label_, "")
2930#define DECLARE_SOA_SELF_INDEX_COLUMN_COMPLETE(_Name_, _Getter_, _Type_, _Label_, _IndexTarget_) \
2931 struct _Name_##Id : o2::soa::Column<_Type_, _Name_##Id> { \
2932 static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
2933 static constexpr const char* mLabel = "fIndex" _Label_; \
2934 static constexpr const uint32_t hash = compile_time_hash(namespace_prefix<_Name_##Id>(), std::string_view{#_Getter_ "Id"}); \
2935 using base = o2::soa::Column<_Type_, _Name_##Id>; \
2936 using type = _Type_; \
2937 using column_t = _Name_##Id; \
2938 using self_index_t = std::true_type; \
2939 using compatible_signature = std::conditional<aod::is_aod_hash<_IndexTarget_>, _IndexTarget_, void>; \
2940 _Name_##Id(arrow::ChunkedArray const* column) \
2941 : o2::soa::Column<_Type_, _Name_##Id>(o2::soa::ColumnIterator<type>(column)) \
2945 _Name_##Id() = default; \
2946 _Name_##Id(_Name_##Id const& other) = default; \
2947 _Name_##Id& operator=(_Name_##Id const& other) = default; \
2948 type inline getId() const \
2950 return _Getter_##Id(); \
2953 type _Getter_##Id() const \
2955 return *mColumnIterator; \
2958 bool has_##_Getter_() const \
2960 return *mColumnIterator >= 0; \
2963 template <typename T> \
2964 auto _Getter_##_as() const \
2966 if (O2_BUILTIN_UNLIKELY(!has_##_Getter_())) { \
2967 o2::soa::accessingInvalidIndexFor(#_Getter_); \
2969 auto t = mBinding.get<T>(); \
2970 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2971 o2::soa::dereferenceWithWrongType(#_Getter_, "self"); \
2973 return t->rawIteratorAt(*mColumnIterator); \
2976 bool setCurrentRaw(o2::soa::Binding current) \
2978 this->mBinding = current; \
2981 o2::soa::Binding getCurrentRaw() const { return mBinding; } \
2982 o2::soa::Binding mBinding; \
2984 [[maybe_unused]] static constexpr o2::framework::expressions::BindingNode _Getter_##Id { "fIndex" _Label_, _Name_##Id::hash, o2::framework::expressions::selectArrowType<_Type_>() }
2986#define DECLARE_SOA_SELF_INDEX_COLUMN_FULL(_Name_, _Getter_, _Type_, _Label_) DECLARE_SOA_SELF_INDEX_COLUMN_COMPLETE(_Name_, _Getter_, _Type_, _Label_, void)
2987#define DECLARE_SOA_SELF_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_SELF_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, #_Name_)
2989#define DECLARE_SOA_SELF_SLICE_INDEX_COLUMN_COMPLETE(_Name_, _Getter_, _Type_, _Label_, _IndexTarget_) \
2990 struct _Name_##IdSlice : o2::soa::Column<_Type_[2], _Name_##IdSlice> { \
2991 static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
2992 static constexpr const char* mLabel = "fIndexSlice" _Label_; \
2993 static constexpr const uint32_t hash = 0; \
2994 using base = o2::soa::Column<_Type_[2], _Name_##IdSlice>; \
2995 using type = _Type_[2]; \
2996 using column_t = _Name_##IdSlice; \
2997 using self_index_t = std::true_type; \
2998 using compatible_signature = std::conditional<aod::is_aod_hash<_IndexTarget_>, _IndexTarget_, void>; \
2999 _Name_##IdSlice(arrow::ChunkedArray const* column) \
3000 : o2::soa::Column<_Type_[2], _Name_##IdSlice>(o2::soa::ColumnIterator<type>(column)) \
3004 _Name_##IdSlice() = default; \
3005 _Name_##IdSlice(_Name_##IdSlice const& other) = default; \
3006 _Name_##IdSlice& operator=(_Name_##IdSlice const& other) = default; \
3007 std::array<_Type_, 2> inline getIds() const \
3009 return _Getter_##Ids(); \
3012 bool has_##_Getter_() const \
3014 auto a = *mColumnIterator; \
3015 return a[0] >= 0 && a[1] >= 0; \
3018 std::array<_Type_, 2> _Getter_##Ids() const \
3020 auto a = *mColumnIterator; \
3021 return std::array{a[0], a[1]}; \
3024 template <typename T> \
3025 auto _Getter_##_as() const \
3027 auto t = mBinding.get<T>(); \
3028 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
3029 o2::soa::dereferenceWithWrongType(#_Getter_, "self"); \
3031 if (O2_BUILTIN_UNLIKELY(!has_##_Getter_())) { \
3032 return t->emptySlice(); \
3034 auto a = *mColumnIterator; \
3035 auto r = t->rawSlice(a[0], a[1]); \
3036 t->copyIndexBindings(r); \
3037 r.bindInternalIndicesTo(t); \
3041 bool setCurrentRaw(o2::soa::Binding current) \
3043 this->mBinding = current; \
3046 o2::soa::Binding getCurrentRaw() const { return mBinding; } \
3047 o2::soa::Binding mBinding; \
3050#define DECLARE_SOA_SELF_SLICE_INDEX_COLUMN_FULL(_Name_, _Getter_, _Type_, _Label_) DECLARE_SOA_SELF_SLICE_INDEX_COLUMN_COMPLETE(_Name_, _Getter_, _Type_, _Label_, void)
3051#define DECLARE_SOA_SELF_SLICE_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_SELF_SLICE_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, "_" #_Name_)
3053#define DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN_COMPLETE(_Name_, _Getter_, _Type_, _Label_, _IndexTarget_) \
3054 struct _Name_##Ids : o2::soa::Column<std::vector<_Type_>, _Name_##Ids> { \
3055 static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
3056 static constexpr const char* mLabel = "fIndexArray" _Label_; \
3057 static constexpr const uint32_t hash = 0; \
3058 using base = o2::soa::Column<std::vector<_Type_>, _Name_##Ids>; \
3059 using type = std::vector<_Type_>; \
3060 using column_t = _Name_##Ids; \
3061 using self_index_t = std::true_type; \
3062 using compatible_signature = std::conditional<aod::is_aod_hash<_IndexTarget_>, _IndexTarget_, void>; \
3063 _Name_##Ids(arrow::ChunkedArray const* column) \
3064 : o2::soa::Column<std::vector<_Type_>, _Name_##Ids>(o2::soa::ColumnIterator<type>(column)) \
3068 _Name_##Ids() = default; \
3069 _Name_##Ids(_Name_##Ids const& other) = default; \
3070 _Name_##Ids& operator=(_Name_##Ids const& other) = default; \
3071 gsl::span<const _Type_> inline getIds() const \
3073 return _Getter_##Ids(); \
3076 gsl::span<const _Type_> _Getter_##Ids() const \
3078 return *mColumnIterator; \
3081 bool has_##_Getter_() const \
3083 return !(*mColumnIterator).empty(); \
3086 template <typename T> \
3087 auto _Getter_##_as() const \
3089 auto t = mBinding.get<T>(); \
3090 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
3091 o2::soa::dereferenceWithWrongType(#_Getter_, "self"); \
3093 return getIterators<T>(); \
3096 template <typename T> \
3097 auto getIterators() const \
3099 auto result = std::vector<typename T::unfiltered_iterator>(); \
3100 for (auto& i : *mColumnIterator) { \
3101 result.push_back(mBinding.get<T>()->rawIteratorAt(i)); \
3106 template <typename T> \
3107 auto _Getter_##_first_as() const \
3109 return mBinding.get<T>()->rawIteratorAt((*mColumnIterator)[0]); \
3112 template <typename T> \
3113 auto _Getter_##_last_as() const \
3115 return mBinding.get<T>()->rawIteratorAt((*mColumnIterator).back()); \
3118 bool setCurrentRaw(o2::soa::Binding current) \
3120 this->mBinding = current; \
3123 o2::soa::Binding getCurrentRaw() const { return mBinding; } \
3124 o2::soa::Binding mBinding; \
3127#define DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN_FULL(_Name_, _Getter_, _Type_, _Label_) DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN_COMPLETE(_Name_, _Getter_, _Type_, _Label_, void)
3128#define DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, "_" #_Name_)
3158#define DECLARE_SOA_DYNAMIC_COLUMN(_Name_, _Getter_, ...) \
3159 struct _Name_##Callback { \
3160 static inline constexpr auto getLambda() { return __VA_ARGS__; } \
3163 struct _Name_##Helper { \
3164 using callable_t = decltype(o2::framework::FunctionMetadata(std::declval<decltype(_Name_##Callback::getLambda())>())); \
3165 using return_type = typename callable_t::return_type; \
3167 template <typename... Bindings> \
3168 struct _Name_ : o2::soa::DynamicColumn<typename _Name_##Helper::callable_t::type, _Name_<Bindings...>> { \
3169 using base = o2::soa::DynamicColumn<typename _Name_##Helper::callable_t::type, _Name_<Bindings...>>; \
3170 using helper = _Name_##Helper; \
3171 using callback_holder_t = _Name_##Callback; \
3172 using callable_t = helper::callable_t; \
3173 using callback_t = callable_t::type; \
3174 static constexpr const uint32_t hash = 0; \
3176 _Name_(arrow::ChunkedArray const*) \
3179 _Name_() = default; \
3180 _Name_(_Name_ const& other) = default; \
3181 _Name_& operator=(_Name_ const& other) = default; \
3182 static constexpr const char* mLabel = #_Name_; \
3183 using type = typename callable_t::return_type; \
3185 template <typename... FreeArgs> \
3186 type _Getter_(FreeArgs... freeArgs) const \
3188 return boundGetter(std::make_index_sequence<std::tuple_size_v<decltype(boundIterators)>>{}, freeArgs...); \
3190 template <typename... FreeArgs> \
3191 type getDynamicValue(FreeArgs... freeArgs) const \
3193 return boundGetter(std::make_index_sequence<std::tuple_size_v<decltype(boundIterators)>>{}, freeArgs...); \
3198 return _Getter_(); \
3201 template <size_t... Is, typename... FreeArgs> \
3202 type boundGetter(std::integer_sequence<size_t, Is...>&&, FreeArgs... freeArgs) const \
3204 return __VA_ARGS__((**std::get<Is>(boundIterators))..., freeArgs...); \
3207 using bindings_t = typename o2::framework::pack<Bindings...>; \
3208 std::tuple<o2::soa::ColumnIterator<typename Bindings::type> const*...> boundIterators; \
3211#define DECLARE_SOA_TABLE_METADATA(_Name_, _Desc_, _Version_, ...) \
3212 using _Name_##Metadata = TableMetadata<Hash<_Desc_ "/" #_Version_ ""_h>, __VA_ARGS__>;
3214#define DECLARE_SOA_TABLE_METADATA_TRAIT(_Name_, _Desc_, _Version_) \
3216 struct MetadataTrait<Hash<_Desc_ "/" #_Version_ ""_h>> { \
3217 using metadata = _Name_##Metadata; \
3220#define DECLARE_SOA_TABLE_FULL_VERSIONED_(_Name_, _Label_, _Origin_, _Desc_, _Version_) \
3221 O2HASH(_Desc_ "/" #_Version_); \
3222 template <typename O> \
3223 using _Name_##From = o2::soa::Table<Hash<_Label_ ""_h>, Hash<_Desc_ "/" #_Version_ ""_h>, O>; \
3224 using _Name_ = _Name_##From<Hash<_Origin_ ""_h>>; \
3226 struct MetadataTrait<Hash<_Desc_ "/" #_Version_ ""_h>> { \
3227 using metadata = _Name_##Metadata; \
3230#define DECLARE_SOA_STAGE(_Name_, _Origin_, _Desc_, _Version_) \
3231 template <typename O> \
3232 using _Name_##From = o2::soa::Table<Hash<#_Name_ ""_h>, Hash<_Desc_ "/" #_Version_ ""_h>, O>; \
3233 using _Name_ = _Name_##From<Hash<_Origin_ ""_h>>;
3235#define DECLARE_SOA_TABLE_FULL_VERSIONED(_Name_, _Label_, _Origin_, _Desc_, _Version_, ...) \
3236 DECLARE_SOA_TABLE_METADATA(_Name_, _Desc_, _Version_, __VA_ARGS__); \
3237 DECLARE_SOA_TABLE_FULL_VERSIONED_(_Name_, _Label_, _Origin_, _Desc_, _Version_);
3239#define DECLARE_SOA_TABLE_FULL(_Name_, _Label_, _Origin_, _Desc_, ...) \
3241 DECLARE_SOA_TABLE_METADATA(_Name_, _Desc_, 0, __VA_ARGS__); \
3242 DECLARE_SOA_TABLE_FULL_VERSIONED_(_Name_, _Label_, _Origin_, _Desc_, 0)
3244#define DECLARE_SOA_TABLE(_Name_, _Origin_, _Desc_, ...) \
3245 DECLARE_SOA_TABLE_FULL(_Name_, #_Name_, _Origin_, _Desc_, __VA_ARGS__)
3247#define DECLARE_SOA_TABLE_VERSIONED(_Name_, _Origin_, _Desc_, _Version_, ...) \
3249 DECLARE_SOA_TABLE_METADATA(_Name_, _Desc_, _Version_, __VA_ARGS__); \
3250 DECLARE_SOA_TABLE_FULL_VERSIONED_(_Name_, #_Name_, _Origin_, _Desc_, _Version_)
3252#define DECLARE_SOA_TABLE_STAGED_VERSIONED(_BaseName_, _Desc_, _Version_, ...) \
3253 O2HASH(_Desc_ "/" #_Version_); \
3254 O2HASH(#_BaseName_); \
3255 O2HASH("Stored" #_BaseName_); \
3256 DECLARE_SOA_TABLE_METADATA(_BaseName_, _Desc_, _Version_, __VA_ARGS__); \
3257 using Stored##_BaseName_##Metadata = _BaseName_##Metadata; \
3258 DECLARE_SOA_TABLE_METADATA_TRAIT(_BaseName_, _Desc_, _Version_); \
3259 DECLARE_SOA_STAGE(_BaseName_, "AOD", _Desc_, _Version_); \
3260 DECLARE_SOA_STAGE(Stored##_BaseName_, "AOD1", _Desc_, _Version_);
3262#define DECLARE_SOA_TABLE_STAGED(_BaseName_, _Desc_, ...) \
3263 DECLARE_SOA_TABLE_STAGED_VERSIONED(_BaseName_, _Desc_, 0, __VA_ARGS__);
3265#define DECLARE_SOA_EXTENDED_TABLE_FULL(_Name_, _Label_, _OriginalTable_, _Origin_, _Desc_, _Version_, ...) \
3266 O2HASH(_Desc_ "/" #_Version_); \
3267 template <typename O> \
3268 using _Name_##ExtensionFrom = soa::Table<o2::aod::Hash<_Label_ ""_h>, o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, O>; \
3269 using _Name_##Extension = _Name_##ExtensionFrom<o2::aod::Hash<_Origin_ ""_h>>; \
3270 template <typename O = o2::aod::Hash<_Origin_ ""_h>> \
3271 struct _Name_##ExtensionMetadataFrom : TableMetadata<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, __VA_ARGS__> { \
3272 using base_table_t = _OriginalTable_; \
3273 using extension_table_t = _Name_##ExtensionFrom<O>; \
3274 using expression_pack_t = framework::pack<__VA_ARGS__>; \
3275 static constexpr auto sources = _OriginalTable_::originals; \
3277 using _Name_##ExtensionMetadata = _Name_##ExtensionMetadataFrom<o2::aod::Hash<_Origin_ ""_h>>; \
3279 struct MetadataTrait<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>> { \
3280 using metadata = _Name_##ExtensionMetadata; \
3282 template <typename O> \
3283 using _Name_##From = o2::soa::JoinFull<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, _OriginalTable_, _Name_##ExtensionFrom<O>>; \
3284 using _Name_ = _Name_##From<o2::aod::Hash<_Origin_ ""_h>>;
3286#define DECLARE_SOA_EXTENDED_TABLE(_Name_, _Table_, _Description_, _Version_, ...) \
3287 O2HASH(#_Name_ "Extension"); \
3288 DECLARE_SOA_EXTENDED_TABLE_FULL(_Name_, #_Name_ "Extension", _Table_, "DYN", _Description_, _Version_, __VA_ARGS__)
3290#define DECLARE_SOA_EXTENDED_TABLE_USER(_Name_, _Table_, _Description_, ...) \
3291 O2HASH(#_Name_ "Extension"); \
3292 DECLARE_SOA_EXTENDED_TABLE_FULL(_Name_, #_Name_ "Extension", _Table_, "AOD", "EX" _Description_, 0, __VA_ARGS__)
3294#define DECLARE_SOA_CONFIGURABLE_EXTENDED_TABLE_FULL(_Name_, _Label_, _OriginalTable_, _Origin_, _Desc_, _Version_, ...) \
3295 O2HASH(_Desc_ "/" #_Version_); \
3296 template <typename O> \
3297 using _Name_##CfgExtensionFrom = soa::Table<o2::aod::Hash<_Label_ ""_h>, o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, O>; \
3298 using _Name_##CfgExtension = _Name_##CfgExtensionFrom<o2::aod::Hash<_Origin_ ""_h>>; \
3299 template <typename O = o2::aod::Hash<_Origin_ ""_h>> \
3300 struct _Name_##CfgExtensionMetadataFrom : TableMetadata<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, __VA_ARGS__> { \
3301 using base_table_t = _OriginalTable_; \
3302 using extension_table_t = _Name_##CfgExtensionFrom<O>; \
3303 using placeholders_pack_t = framework::pack<__VA_ARGS__>; \
3304 using configurable_t = std::true_type; \
3305 static constexpr auto sources = _OriginalTable_::originals; \
3307 using _Name_##CfgExtensionMetadata = _Name_##CfgExtensionMetadataFrom<o2::aod::Hash<_Origin_ ""_h>>; \
3309 struct MetadataTrait<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>> { \
3310 using metadata = _Name_##CfgExtensionMetadata; \
3312 template <typename O> \
3313 using _Name_##From = o2::soa::JoinFull<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, _OriginalTable_, _Name_##CfgExtensionFrom<O>>; \
3314 using _Name_ = _Name_##From<o2::aod::Hash<_Origin_ ""_h>>;
3316#define DECLARE_SOA_CONFIGURABLE_EXTENDED_TABLE(_Name_, _Table_, _Description_, ...) \
3317 O2HASH(#_Name_ "CfgExtension"); \
3318 DECLARE_SOA_CONFIGURABLE_EXTENDED_TABLE_FULL(_Name_, #_Name_ "CfgExtension", _Table_, "AOD", "EX" _Description_, 0, __VA_ARGS__)
3320#define DECLARE_SOA_INDEX_TABLE_FULL(_Name_, _Key_, _Origin_, _Version_, _Desc_, _Exclusive_, ...) \
3322 O2HASH(_Desc_ "/" #_Version_); \
3323 template <typename O = o2::aod::Hash<_Origin_ ""_h>> \
3324 struct _Name_##MetadataFrom : o2::aod::TableMetadata<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, soa::Index<>, __VA_ARGS__> { \
3325 static constexpr bool exclusive = _Exclusive_; \
3326 using Key = _Key_; \
3327 using index_pack_t = framework::pack<__VA_ARGS__>; \
3328 static constexpr const auto sources = []<typename... Cs>(framework::pack<Cs...>) { \
3329 constexpr auto a = o2::soa::mergeOriginals<typename Cs::binding_t...>(); \
3330 return o2::aod::filterForKey<a.size(), a, Key>(); \
3331 }(framework::pack<__VA_ARGS__>{}); \
3332 static_assert(sources.size() - Key::originals.size() + 1 == framework::pack_size(index_pack_t{}), "One of the referred tables does not have index to Key"); \
3334 using _Name_##Metadata = _Name_##MetadataFrom<o2::aod::Hash<_Origin_ ""_h>>; \
3336 template <typename O = o2::aod::Hash<_Origin_ ""_h>> \
3337 using _Name_##From = o2::soa::IndexTable<o2::aod::Hash<#_Name_ ""_h>, o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, O, _Key_, __VA_ARGS__>; \
3338 using _Name_ = _Name_##From<o2::aod::Hash<_Origin_ ""_h>>; \
3341 struct MetadataTrait<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>> { \
3342 using metadata = _Name_##Metadata; \
3350#define DECLARE_SOA_TIMESTAMPED_TABLE_FULL(_Name_, _Label_, _TimestampSource_, _TimestampColumn_, _Origin_, _Version_, _Desc_, ...) \
3351 O2HASH(_Desc_ "/" #_Version_); \
3352 template <typename O> \
3353 using _Name_##TimestampFrom = soa::Table<o2::aod::Hash<_Label_ ""_h>, o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, O>; \
3354 using _Name_##Timestamp = _Name_##TimestampFrom<o2::aod::Hash<_Origin_ ""_h>>; \
3355 template <typename O = o2::aod::Hash<_Origin_ ""_h>> \
3356 struct _Name_##TimestampMetadataFrom : TableMetadata<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, __VA_ARGS__> { \
3357 using base_table_t = _TimestampSource_; \
3358 using extension_table_t = _Name_##TimestampFrom<O>; \
3359 static constexpr const auto ccdb_urls = []<typename... Cs>(framework::pack<Cs...>) { \
3360 return std::array<std::string_view, sizeof...(Cs)>{Cs::query...}; \
3361 }(framework::pack<__VA_ARGS__>{}); \
3362 static constexpr const auto ccdb_bindings = []<typename... Cs>(framework::pack<Cs...>) { \
3363 return std::array<std::string_view, sizeof...(Cs)>{Cs::mLabel...}; \
3364 }(framework::pack<__VA_ARGS__>{}); \
3365 static constexpr auto sources = _TimestampSource_::originals; \
3366 static constexpr auto timestamp_column_label = _TimestampColumn_::mLabel; \
3369 using _Name_##TimestampMetadata = _Name_##TimestampMetadataFrom<o2::aod::Hash<_Origin_ ""_h>>; \
3371 struct MetadataTrait<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>> { \
3372 using metadata = _Name_##TimestampMetadata; \
3374 template <typename O> \
3375 using _Name_##From = o2::soa::JoinFull<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, _TimestampSource_, _Name_##TimestampFrom<O>>; \
3376 using _Name_ = _Name_##From<o2::aod::Hash<_Origin_ ""_h>>;
3378#define DECLARE_SOA_TIMESTAMPED_TABLE(_Name_, _TimestampSource_, _TimestampColumn_, _Version_, _Desc_, ...) \
3379 O2HASH(#_Name_ "Timestamped"); \
3380 DECLARE_SOA_TIMESTAMPED_TABLE_FULL(_Name_, #_Name_ "Timestamped", _TimestampSource_, _TimestampColumn_, "ATIM", _Version_, _Desc_, __VA_ARGS__)
3382#define DECLARE_SOA_INDEX_TABLE(_Name_, _Key_, _Description_, ...) \
3383 DECLARE_SOA_INDEX_TABLE_FULL(_Name_, _Key_, "IDX", 0, _Description_, false, __VA_ARGS__)
3385#define DECLARE_SOA_INDEX_TABLE_EXCLUSIVE(_Name_, _Key_, _Description_, ...) \
3386 DECLARE_SOA_INDEX_TABLE_FULL(_Name_, _Key_, "IDX", 0, _Description_, true, __VA_ARGS__)
3388#define DECLARE_SOA_INDEX_TABLE_USER(_Name_, _Key_, _Description_, ...) \
3389 DECLARE_SOA_INDEX_TABLE_FULL(_Name_, _Key_, "AOD", 0, _Description_, false, __VA_ARGS__)
3391#define DECLARE_SOA_INDEX_TABLE_EXCLUSIVE_USER(_Name_, _Key_, _Description_, ...) \
3392 DECLARE_SOA_INDEX_TABLE_FULL(_Name_, _Key_, "AOD", 0, _Description_, true, __VA_ARGS__)
3396template <
typename D,
typename...
Ts>
3397struct JoinFull :
Table<o2::aod::Hash<"JOIN"_h>, D, o2::aod::Hash<"JOIN"_h>, Ts...> {
3450 template <
typename T1,
typename Policy,
bool OPT>
3478 template <
typename T>
3485template <
typename...
Ts>
3488template <
typename...
Ts>
3494template <
typename T>
3497template <
typename T>
3500template <
typename...
Ts>
3501struct Concat :
Table<o2::aod::Hash<"CONC"_h>, o2::aod::Hash<"CONC/0"_h>, o2::aod::Hash<"CONC"_h>, Ts...> {
3504 Concat(std::vector<std::shared_ptr<arrow::Table>>&& tables, uint64_t
offset = 0)
3512 bindInternalIndicesTo(
this);
3515 using base::originals;
3517 using base::bindExternalIndices;
3518 using base::bindInternalIndicesTo;
3532template <
typename...
Ts>
3538template <soa::is_table T>
3549 using iterator = T::template iterator_template_o<FilteredIndexPolicy, self_t>;
3555 mSelectedRows{getSpan(selection)}
3557 if (this->tableSize() != 0) {
3558 mFilteredBegin = table_t::filtered_begin(mSelectedRows);
3561 mFilteredBegin.bindInternalIndices(
this);
3566 mSelectedRowsCache{
std::move(selection)},
3569 mSelectedRows = std::span{mSelectedRowsCache};
3570 if (this->tableSize() != 0) {
3571 mFilteredBegin = table_t::filtered_begin(mSelectedRows);
3574 mFilteredBegin.bindInternalIndices(
this);
3577 FilteredBase(std::vector<std::shared_ptr<arrow::Table>>&& tables, std::span<int64_t const>
const& selection, uint64_t
offset = 0)
3579 mSelectedRows{selection}
3581 if (this->tableSize() != 0) {
3582 mFilteredBegin = table_t::filtered_begin(mSelectedRows);
3585 mFilteredBegin.bindInternalIndices(
this);
3612 return mFilteredBegin;
3617 return mFilteredBegin;
3622 return mFilteredBegin +
i;
3627 return mSelectedRows.size();
3632 return table_t::asArrowTable()->num_rows();
3637 return mSelectedRows;
3643 newSelection.resize(
static_cast<int64_t
>(
end -
start + 1));
3644 std::iota(newSelection.begin(), newSelection.end(),
start);
3645 return self_t{{this->asArrowTable()}, std::move(newSelection), 0};
3655 if (sel ==
nullptr) {
3656 return std::span<int64_t const>{};
3658 auto array = std::static_pointer_cast<arrow::Int64Array>(sel->ToArray());
3661 return std::span{
start, stop};
3666 template <
typename... TA>
3669 table_t::bindExternalIndices(current...);
3670 mFilteredBegin.bindExternalIndices(current...);
3675 mFilteredBegin.bindExternalIndicesRaw(std::forward<std::vector<o2::soa::Binding>>(ptrs));
3678 template <
typename I>
3681 mFilteredBegin.bindInternalIndices(
ptr);
3684 template <
typename T1,
typename... Cs>
3687 dest.bindExternalIndicesRaw(mFilteredBegin.getIndexBindings());
3690 template <
typename T1>
3696 template <
typename T1>
3712 template <
typename T1,
bool OPT>
3718 template <
typename T1,
bool OPT>
3727 copyIndexBindings(t);
3733 auto locate = std::find(mSelectedRows.begin(), mSelectedRows.end(),
i);
3734 if (locate == mSelectedRows.end()) {
3737 return static_cast<int>(std::distance(mSelectedRows.begin(), locate));
3744 std::set_union(mSelectedRows.begin(), mSelectedRows.end(), selection.begin(), selection.end(), std::back_inserter(rowsUnion));
3745 mSelectedRowsCache.clear();
3746 mSelectedRowsCache = rowsUnion;
3754 std::set_intersection(mSelectedRows.begin(), mSelectedRows.end(), selection.begin(), selection.end(), std::back_inserter(intersection));
3755 mSelectedRowsCache.clear();
3756 mSelectedRowsCache = intersection;
3764 std::set_union(mSelectedRows.begin(), mSelectedRows.end(), selection.begin(), selection.end(), std::back_inserter(rowsUnion));
3765 mSelectedRowsCache.clear();
3766 mSelectedRowsCache = rowsUnion;
3774 std::set_intersection(mSelectedRows.begin(), mSelectedRows.end(), selection.begin(), selection.end(), std::back_inserter(intersection));
3775 mSelectedRowsCache.clear();
3776 mSelectedRowsCache = intersection;
3789 mSelectedRows = std::span{mSelectedRowsCache};
3791 mFilteredEnd.reset(
new RowViewSentinel{
static_cast<int64_t
>(mSelectedRows.size())});
3792 if (tableSize() == 0) {
3793 mFilteredBegin = *mFilteredEnd;
3795 mFilteredBegin.resetSelection(mSelectedRows);
3799 std::span<int64_t const> mSelectedRows;
3801 bool mCached =
false;
3802 iterator mFilteredBegin;
3803 std::shared_ptr<RowViewSentinel> mFilteredEnd;
3806template <
typename T>
3815 using iterator = T::template iterator_template_o<FilteredIndexPolicy, self_t>;
3821 return iterator(this->cached_begin());
3835 Filtered(std::vector<std::shared_ptr<arrow::Table>>&& tables, std::span<int64_t const>
const& selection, uint64_t
offset = 0)
3859 this->sumWithSelection(selection);
3865 this->sumWithSelection(selection);
3871 return operator+=(
other.getSelectedRows());
3890 return operator*(
other.getSelectedRows());
3895 this->intersectWithSelection(selection);
3901 this->intersectWithSelection(selection);
3907 return operator*=(
other.getSelectedRows());
3922 newSelection.resize(
static_cast<int64_t
>(
end -
start + 1));
3923 std::iota(newSelection.begin(), newSelection.end(),
start);
3924 return self_t{{this->asArrowTable()}, std::move(newSelection), 0};
3932 template <
typename T1>
3948 template <
typename T1,
bool OPT>
3954 template <
typename T1,
bool OPT>
3963 copyIndexBindings(t);
3968template <
typename T>
3977 using iterator =
typename T::template iterator_template_o<FilteredIndexPolicy, self_t>;
3983 return iterator(this->cached_begin());
3994 for (
auto& table : tables) {
4002 for (
auto& table : tables) {
4010 for (
auto& table : tables) {
4036 this->sumWithSelection(selection);
4042 this->sumWithSelection(selection);
4048 return operator+=(
other.getSelectedRows());
4054 copy.intersectionWithSelection(selection);
4061 copy.intersectionWithSelection(selection);
4067 return operator*(
other.getSelectedRows());
4072 this->intersectWithSelection(selection);
4078 this->intersectWithSelection(selection);
4084 return operator*=(
other.getSelectedRows());
4097 newSelection.resize(
static_cast<int64_t
>(
end -
start + 1));
4098 std::iota(newSelection.begin(), newSelection.end(),
start);
4099 return self_t{{this->asArrowTable()}, std::move(newSelection), 0};
4117 template <
typename T1,
bool OPT>
4123 template <
typename T1,
bool OPT>
4130 std::vector<std::shared_ptr<arrow::Table>> extractTablesFromFiltered(std::vector<
Filtered<T>>& tables)
4132 std::vector<std::shared_ptr<arrow::Table>> outTables;
4133 for (
auto& table : tables) {
4134 outTables.push_back(table.asArrowTable());
4145template <
typename L,
typename D,
typename O,
typename Key,
typename H,
typename...
Ts>
4176template <
typename T,
bool APPLY>
4178 static constexpr bool applyFilters = APPLY;
4185 SmallGroupsBase(std::vector<std::shared_ptr<arrow::Table>>&& tables, std::span<int64_t const>
const& selection, uint64_t
offset = 0)
4189template <
typename T>
4192template <
typename T>
4195template <
typename T>
header::DataDescription description
std::vector< std::string > labels
#define O2HASH(_Str_)
Pre-declare Hash specialization for a generic string.
#define O2ORIGIN(_Str_)
Pre-declare Hash specialization for an origin string.
consteval auto getIndexTargets()
SLICE.
o2::monitoring::tags::Key Key
#define O2_BUILTIN_UNREACHABLE
#define O2_BUILTIN_LIKELY(x)
#define O2_BUILTIN_UNLIKELY(x)
std::unique_ptr< expressions::Node > node
Class for time synchronization of RawReader instances.
int64_t const * mCurrentPos
ColumnIterator(arrow::ChunkedArray const *column)
ColumnIterator(ColumnIterator< T, ChunkingPolicy > const &)=default
void moveToEnd()
Move the iterator to the end of the column.
ColumnIterator< T > & moveToPos()
ColumnIterator< T, ChunkingPolicy > & operator=(ColumnIterator< T, ChunkingPolicy > const &)=default
unwrap_t< T > const * mCurrent
unwrap_t< T > const * mLast
ColumnIterator(ColumnIterator< T, ChunkingPolicy > &&)=default
arrow::ChunkedArray const * mColumn
ColumnIterator< T, ChunkingPolicy > & operator=(ColumnIterator< T, ChunkingPolicy > &&)=default
void moveToChunk(int chunk)
void nextChunk() const
Move the iterator to the next chunk.
auto sliceByCachedUnsorted(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
int64_t tableSize() const
FilteredBase(std::vector< std::shared_ptr< arrow::Table > > &&tables, gandiva::Selection const &selection, uint64_t offset=0)
typename T::external_index_columns_t external_index_columns_t
auto select(framework::expressions::Filter const &f) const
static auto getSpan(gandiva::Selection const &sel)
T::template iterator_template_o< FilteredIndexPolicy, self_t > iterator
auto rawSliceBy(o2::framework::Preslice< T1 > const &container, int value) const
T::template iterator_template_o< DefaultIndexPolicy, self_t > unfiltered_iterator
void copyIndexBindings(T1 &dest) const
auto const & getSelectedRows() const
void sumWithSelection(std::span< int64_t const > const &selection)
void intersectWithSelection(std::span< int64_t const > const &selection)
typename T::columns_t columns_t
void bindExternalIndices(TA *... current)
void sumWithSelection(SelectionVector const &selection)
void bindInternalIndicesTo(I const *ptr)
void intersectWithSelection(SelectionVector const &selection)
auto sliceBy(o2::framework::PresliceBase< T1, framework::PreslicePolicyGeneral, OPT > const &container, int value) const
FilteredBase(std::vector< std::shared_ptr< arrow::Table > > &&tables, std::span< int64_t const > const &selection, uint64_t offset=0)
auto rawSlice(uint64_t start, uint64_t end) const
auto sliceBy(o2::framework::PresliceBase< T1, framework::PreslicePolicySorted, OPT > const &container, int value) const
iterator iteratorAt(uint64_t i) const
typename T::table_t table_t
typename T::persistent_columns_t persistent_columns_t
RowViewSentinel end() const
FilteredBase(std::vector< std::shared_ptr< arrow::Table > > &&tables, SelectionVector &&selection, uint64_t offset=0)
void bindExternalIndicesRaw(std::vector< o2::soa::Binding > &&ptrs)
const_iterator begin() const
unfiltered_iterator rawIteratorAt(uint64_t i) const
int isInSelectedRows(int i) const
auto sliceByCached(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
void doCopyIndexBindings(framework::pack< Cs... >, T1 &dest) const
auto const & cached_begin() const
auto sliceBy(o2::framework::PresliceBase< T1, framework::PreslicePolicySorted, OPT > const &container, int value) const
Filtered< Filtered< T > > operator*(std::span< int64_t const > const &selection)
typename FilteredBase< typename T::table_t >::table_t table_t
typename T::template iterator_template_o< DefaultIndexPolicy, self_t > unfiltered_iterator
Filtered< Filtered< T > > operator+(SelectionVector const &selection)
auto sliceBy(o2::framework::PresliceBase< T1, framework::PreslicePolicyGeneral, OPT > const &container, int value) const
Filtered< Filtered< T > > operator+=(std::span< int64_t const > const &selection)
typename T::template iterator_template_o< FilteredIndexPolicy, self_t > iterator
typename T::columns_t columns_t
const_iterator begin() const
Filtered(std::vector< Filtered< T > > &&tables, std::span< int64_t const > const &selection, uint64_t offset=0)
Filtered< Filtered< T > > operator+(std::span< int64_t const > const &selection)
Filtered(std::vector< Filtered< T > > &&tables, SelectionVector &&selection, uint64_t offset=0)
unfiltered_iterator rawIteratorAt(uint64_t i) const
Filtered< Filtered< T > > operator*=(std::span< int64_t const > const &selection)
Filtered< Filtered< T > > operator+=(Filtered< T > const &other)
Filtered< Filtered< T > > operator+=(SelectionVector const &selection)
Filtered< Filtered< T > > operator*=(SelectionVector const &selection)
auto rawSlice(uint64_t start, uint64_t end) const
Filtered< Filtered< T > > operator+(Filtered< T > const &other)
Filtered(std::vector< Filtered< T > > &&tables, gandiva::Selection const &selection, uint64_t offset=0)
Filtered< Filtered< T > > operator*=(Filtered< T > const &other)
auto sliceByCached(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
Filtered< Filtered< T > > operator*(Filtered< T > const &other)
Filtered< Filtered< T > > operator*(SelectionVector const &selection)
auto sliceByCachedUnsorted(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
Filtered< T > operator*(std::span< int64_t const > const &selection)
Filtered< T > operator+=(Filtered< T > const &other)
auto sliceBy(o2::framework::PresliceBase< T1, framework::PreslicePolicyGeneral, OPT > const &container, int value) const
Filtered(std::vector< std::shared_ptr< arrow::Table > > &&tables, SelectionVector &&selection, uint64_t offset=0)
Filtered< T > operator+(std::span< int64_t const > const &selection)
auto sliceByCachedUnsorted(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
Filtered< T > operator+(Filtered< T > const &other)
Filtered< T > operator*=(SelectionVector const &selection)
Filtered(std::vector< std::shared_ptr< arrow::Table > > &&tables, std::span< int64_t const > const &selection, uint64_t offset=0)
const_iterator begin() const
T::template iterator_template_o< FilteredIndexPolicy, self_t > iterator
auto sliceByCached(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
auto select(framework::expressions::Filter const &f) const
Filtered< T > operator+(SelectionVector const &selection)
T::template iterator_template_o< DefaultIndexPolicy, self_t > unfiltered_iterator
unfiltered_iterator rawIteratorAt(uint64_t i) const
Filtered< T > operator*(SelectionVector const &selection)
Filtered< T > operator*=(Filtered< T > const &other)
Filtered< T > operator*(Filtered< T > const &other)
auto rawSliceBy(o2::framework::Preslice< T1 > const &container, int value) const
Filtered< T > operator+=(SelectionVector const &selection)
auto rawSlice(uint64_t start, uint64_t end) const
Filtered(std::vector< std::shared_ptr< arrow::Table > > &&tables, gandiva::Selection const &selection, uint64_t offset=0)
auto sliceBy(o2::framework::PresliceBase< T1, framework::PreslicePolicySorted, OPT > const &container, int value) const
Filtered< T > operator*=(std::span< int64_t const > const &selection)
Filtered< T > operator+=(std::span< int64_t const > const &selection)
typename T::table_t table_t
typename T::columns_t columns_t
decltype([]< typename... C >(framework::pack< C... > &&) -> framework::selected_pack< soa::is_self_index_t, C... > {}(columns_t{})) internal_index_columns_t
void bindInternalIndicesExplicit(o2::soa::Binding binding)
iterator iteratorAt(uint64_t i) const
decltype([]< typename... C >(framework::pack< C... > &&) -> framework::selected_pack< soa::is_persistent_column_t, C... > {}(columns_t{})) persistent_columns_t
static constexpr const auto ref
auto offset() const
Return offset.
static consteval bool hasOriginal()
unfiltered_iterator begin()
int64_t tableSize() const
auto rawSlice(uint64_t start, uint64_t end) const
void bindExternalIndices(TA *... current)
auto select(framework::expressions::Filter const &f) const
unfiltered_iterator unfiltered_const_iterator
static consteval auto full_iter()
auto const & cached_begin() const
auto sliceByCachedUnsorted(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
TableIteratorBase< IP, Parent, T... > iterator_template
void bindExternalIndicesRaw(std::vector< o2::soa::Binding > &&ptrs)
auto sliceBy(o2::framework::PresliceBase< T1, Policy, OPT > const &container, int value) const
static constexpr auto hashes()
iterator unfiltered_iterator
std::shared_ptr< arrow::Table > asArrowTable() const
Return a type erased arrow table backing store for / the type safe table.
filtered_iterator filtered_begin(std::span< int64_t const > selection)
void doCopyIndexBindings(framework::pack< Cs... >, T &dest) const
int64_t size() const
Size of the table, in rows.
Table(std::vector< std::shared_ptr< arrow::Table > > &&tables, uint64_t offset=0)
decltype(getColumns< ref, Ts... >()) columns_t
arrow::ChunkedArray * getIndexToKey()
decltype([]< typename... C >(framework::pack< C... >) -> framework::pack< typename C::type... > {}(persistent_columns_t{})) column_types
static consteval auto isIndexTargetOf()
iterator_template_o< FilteredIndexPolicy, table_t > filtered_iterator
unfiltered_const_iterator begin() const
void copyIndexBindings(T &dest) const
static constexpr const auto originalLabels
Table(std::vector< std::shared_ptr< arrow::Table > > &&tables, uint64_t offset=0)
Table< L, D, O, Ts... > self_t
static consteval auto isIndexTargetOf()
decltype(full_iter< IP, Parent >()) iterator_template_o
void doBindInternalIndicesExplicit(framework::pack< Cs... >, o2::soa::Binding binding)
static constexpr const auto originals
decltype([]< typename... C >(framework::pack< C... > &&) -> framework::selected_pack< soa::is_external_index_t, C... > {}(columns_t{})) external_index_columns_t
Table(std::shared_ptr< arrow::Table > table, uint64_t offset=0)
RowViewSentinel end() const
auto sliceByCached(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
void bindInternalIndicesTo(I const *ptr)
unfiltered_iterator rawIteratorAt(uint64_t i) const
iterator_template_o< DefaultIndexPolicy, table_t > iterator
hash identification concepts
Helper to check if a type T is an iterator.
column identification concepts
GLuint GLsizei const GLuint const GLintptr * offsets
GLuint const GLchar * name
GLboolean GLboolean GLboolean b
GLsizei const GLfloat * value
GLint GLint GLsizei GLint GLenum GLenum type
GLuint GLsizei GLsizei * length
GLuint GLsizei const GLchar * label
GLsizei GLenum const void * indices
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GLenum GLenum GLsizei len
GLboolean GLboolean GLboolean GLboolean a
std::shared_ptr< gandiva::SelectionVector > Selection
consteval const char * origin_str()
consteval const char * signature()
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 PrimaryVertex explicitly as messageable.
std::decay_t< decltype(select_pack< Condition >(pack<>{}, Pack{}, CondPack{}))> selected_pack_multicondition
std::decay_t< decltype(prune_voids_pack(pack<>{}, with_condition_pack< Condition, Types... >{}))> selected_pack
decltype(intersected_pack(Ps{}...)) full_intersected_pack_t
typename pack_element< I, T >::type pack_element_t
consteval size_t has_type_at_v(pack< Ts... >)
constexpr std::size_t pack_size(pack< Ts... > const &)
template function to determine number of types in a pack
decltype(concatenate_pack_unique(Ps{}...)) concatenated_pack_unique_t
std::string strToUpper(std::string &&str)
typename pack_element< 0, T >::type pack_head_t
std::string cutString(std::string &&str)
std::vector< std::vector< int64_t > > ListVector
R getColumnValue(const T &rowIterator)
ColumnGetterFunction< R, typename T::iterator > getColumnGetterByLabel(const std::string_view &targetColumnLabel)
void * extractCCDBPayload(char *payload, size_t size, TClass const *cl, const char *what)
consteval auto computeOriginals()
auto createFieldsFromColumns(framework::pack< C... >)
SelectionVector selectionToVector(gandiva::Selection const &sel)
constexpr bool is_persistent_v
constexpr bool is_ng_index_equivalent_v
consteval auto remove_if(L l)
constexpr auto join(Ts const &... t)
auto doSliceBy(T const *table, o2::framework::PresliceBase< C, Policy, OPT > const &container, int value)
void notBoundTable(const char *tableName)
SelectionVector sliceSelection(std::span< int64_t const > const &mSelectedRows, int64_t nrows, uint64_t offset)
auto doFilteredSliceBy(T const *table, o2::framework::PresliceBase< C, framework::PreslicePolicySorted, OPT > const &container, int value)
constexpr auto concat(Ts const &... t)
consteval auto intersectOriginals()
consteval auto getColumns()
std::vector< int64_t > SelectionVector
std::conditional_t< is_binding_compatible_v< T, typename B::binding_t >(), std::true_type, std::false_type > is_binding_compatible
consteval auto mergeOriginals()
constexpr bool is_soa_filtered_v
typename std::conditional_t< is_index_column< C >, std::true_type, std::false_type > is_external_index_t
void missingFilterDeclaration(int hash, int ai)
auto doSliceByCachedUnsorted(T const *table, framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache)
auto doSliceByCached(T const *table, framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache)
void accessingInvalidIndexFor(const char *getter)
auto select(T const &t, framework::expressions::Filter const &f)
consteval auto base_iter(framework::pack< C... > &&) -> TableIterator< D, O, IP, C... >
constexpr bool is_index_equivalent_v
constexpr bool is_soa_join_v
void dereferenceWithWrongType(const char *getter, const char *target)
std::conditional_t< is_indexing_column< T >, std::true_type, std::false_type > is_indexing_t
consteval bool is_binding_compatible_v()
auto prepareFilteredSlice(T const *table, std::shared_ptr< arrow::Table > slice, uint64_t offset)
typename unwrap< T >::type unwrap_t
void getterNotFound(const char *targetColumnLabel)
auto doFilteredSliceByCached(T const *table, framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache)
void missingOptionalPreslice(const char *label, const char *key)
auto doSliceByHelper(T const *table, std::span< const int64_t > const &selection)
consteval bool is_compatible()
arrow::ChunkedArray * getIndexFromLabel(arrow::Table *table, std::string_view label)
consteval auto merge()
Helpers to manipulate TableRef arrays.
consteval auto merge_if(L l)
std::conditional_t< is_persistent_column< C >, std::true_type, std::false_type > is_persistent_column_t
typename arrow_array_for< T >::type arrow_array_for_t
void notFoundColumn(const char *label, const char *key)
std::conditional_t< is_dynamic_column< T >, std::true_type, std::false_type > is_dynamic_t
typename std::conditional_t< is_self_index_column< C >, std::true_type, std::false_type > is_self_index_t
Defining DataPointCompositeObject explicitly as copiable.
FIXME: do not use data model tables.
static constexpr uint32_t hash
static constexpr char const *const str
SliceInfoUnsortedPtr getCacheUnsortedFor(Entry const &bindingKey) const
SliceInfoPtr getCacheFor(Entry const &bindingKey) const
std::shared_ptr< arrow::Table > getSliceFor(int value, std::shared_ptr< arrow::Table > const &input, uint64_t &offset) const
static constexpr bool optional
PresliceBase(expressions::BindingNode index_)
std::span< const int64_t > getSliceFor(int value) const
const std::string binding
const std::string binding
Entry const & getBindingKey() const
SliceInfoUnsortedPtr sliceInfo
std::span< const int64_t > getSliceFor(int value) const
void updateSliceInfo(SliceInfoUnsortedPtr &&si)
void updateSliceInfo(SliceInfoPtr &&si)
std::shared_ptr< arrow::Table > getSliceFor(int value, std::shared_ptr< arrow::Table > const &input, uint64_t &offset) const
ArrowTableSlicingCache * ptr
std::pair< int64_t, int64_t > getSliceFor(int value) const
An expression tree node corresponding to a column binding.
A struct, containing the root of the expression tree.
From https://en.cppreference.com/w/cpp/utility/variant/visit.
static std::shared_ptr< arrow::Table > joinTables(std::vector< std::shared_ptr< arrow::Table > > &&tables)
static std::shared_ptr< arrow::Table > concatTables(std::vector< std::shared_ptr< arrow::Table > > &&tables)
Type-checking index column binding.
std::span< TableRef const > refs
void bind(T const *table)
static constexpr bool chunked
arrow::ChunkedArray * second
Column(ColumnIterator< T > const &it)
static constexpr const char *const & columnLabel()
ColumnIterator< T > const & getIterator() const
Column & operator=(Column const &)=default
Column(Column &&)=default
static auto asArrowField()
Column & operator=(Column &&)=default
Column(Column const &)=default
ColumnIterator< T > mColumnIterator
table_t::template iterator_template< DefaultIndexPolicy, self_t, Ts... > iterator
Concat(Ts const &... t, uint64_t offset=0)
typename table_t::persistent_columns_t persistent_columns_t
typename table_t::columns_t columns_t
const_iterator unfiltered_const_iterator
iterator unfiltered_iterator
table_t::template iterator_template< FilteredIndexPolicy, self_t, Ts... > filtered_iterator
Concat(std::vector< std::shared_ptr< arrow::Table > > &&tables, uint64_t offset=0)
filtered_iterator filtered_const_iterator
DefaultIndexPolicy(int64_t nRows, uint64_t offset)
friend bool operator==(DefaultIndexPolicy const &lh, DefaultIndexPolicy const &rh)
bool operator==(RowViewSentinel const &sentinel) const
DefaultIndexPolicy(FilteredIndexPolicy const &other)
std::tuple< uint64_t const * > getOffsets() const
DefaultIndexPolicy & operator=(DefaultIndexPolicy &&)=default
void setCursor(int64_t i)
void limitRange(int64_t start, int64_t end)
DefaultIndexPolicy(DefaultIndexPolicy &&)=default
DefaultIndexPolicy(DefaultIndexPolicy const &)=default
DefaultIndexPolicy & operator=(DefaultIndexPolicy const &)=default
std::tuple< int64_t const *, int64_t const * > getIndices() const
DefaultIndexPolicy()=default
Needed to be able to copy the policy.
void moveByIndex(int64_t i)
static constexpr const char *const & columnLabel()
FilteredIndexPolicy & operator=(FilteredIndexPolicy &&)=default
std::tuple< int64_t const *, int64_t const * > getIndices() const
FilteredIndexPolicy & operator=(FilteredIndexPolicy const &)=default
auto getSelectionRow() const
FilteredIndexPolicy()=default
FilteredIndexPolicy(std::span< int64_t const > selection, int64_t rows, uint64_t offset=0)
friend bool operator==(FilteredIndexPolicy const &lh, FilteredIndexPolicy const &rh)
void resetSelection(std::span< int64_t const > selection)
void setCursor(int64_t i)
FilteredIndexPolicy(FilteredIndexPolicy const &)=default
bool operator==(RowViewSentinel const &sentinel) const
std::tuple< uint64_t const * > getOffsets() const
void limitRange(int64_t start, int64_t end)
FilteredIndexPolicy(FilteredIndexPolicy &&)=default
void moveByIndex(int64_t i)
static constexpr bool chunked
static constexpr const char *const & columnLabel()
static constexpr const uint32_t hash
uint64_t mOffset
Offset within a larger table.
int64_t mRowIndex
Position inside the current table.
IndexTable(std::vector< std::shared_ptr< arrow::Table > > tables, uint64_t offset=0)
IndexTable(std::shared_ptr< arrow::Table > table, uint64_t offset=0)
typename base_t::template iterator_template_o< DefaultIndexPolicy, self_t > iterator
filtered_iterator const_filtered_iterator
IndexTable(IndexTable &&)=default
IndexTable & operator=(IndexTable const &)=default
IndexTable & operator=(IndexTable &&)=default
typename H::binding_t first_t
typename base_t::template iterator_template_o< FilteredIndexPolicy, self_t > filtered_iterator
IndexTable(IndexTable const &)=default
Index(Index const &)=default
void setIndices(std::tuple< int64_t const *, int64_t const * > indices)
Index & operator=(Index &&)=default
Index(arrow::ChunkedArray const *)
int64_t filteredIndex() const
constexpr int64_t rangeEnd()
constexpr int64_t rangeStart()
Index & operator=(Index const &)=default
int64_t globalIndex() const
std::tuple< int64_t const *, int64_t const * > rowIndices
void setOffsets(std::tuple< uint64_t const * > offsets)
static constexpr const char * mLabel
std::tuple< uint64_t const * > rowOffsets
iterator unfiltered_iterator
auto sliceBy(o2::framework::PresliceBase< T1, Policy, OPT > const &container, int value) const
auto rawSlice(uint64_t start, uint64_t end) const
auto sliceByCachedUnsorted(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
JoinFull(std::vector< std::shared_ptr< arrow::Table > > &&tables, uint64_t offset=0)
static constexpr const auto originalLabels
const_iterator unfiltered_const_iterator
filtered_iterator filtered_const_iterator
static consteval bool contains()
iterator iteratorAt(uint64_t i) const
typename table_t::columns_t columns_t
table_t::template iterator_template< DefaultIndexPolicy, self_t, Ts... > iterator
table_t::template iterator_template< FilteredIndexPolicy, self_t, Ts... > filtered_iterator
static constexpr const auto originals
JoinFull< D, Ts... > self_t
const_iterator begin() const
typename table_t::persistent_columns_t persistent_columns_t
iterator rawIteratorAt(uint64_t i) const
Table< o2::aod::Hash<"JOIN"_h >, D, o2::aod::Hash<"JOIN"_h >, Ts... > base
JoinFull(std::shared_ptr< arrow::Table > &&table, uint64_t offset=0)
auto sliceByCached(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
static constexpr const uint32_t hash
static constexpr const char *const & columnLabel()
Marker & operator=(Marker const &)=default
static constexpr auto value
static constexpr const char * mLabel
Marker(arrow::ChunkedArray const *)
Marker(Marker const &)=default
Marker & operator=(Marker &&)=default
Marker(Marker &&)=default
SmallGroupsBase(std::vector< std::shared_ptr< arrow::Table > > &&tables, SelectionVector &&selection, uint64_t offset=0)
SmallGroupsBase(std::vector< std::shared_ptr< arrow::Table > > &&tables, std::span< int64_t const > const &selection, uint64_t offset=0)
SmallGroupsBase(std::vector< std::shared_ptr< arrow::Table > > &&tables, gandiva::Selection const &selection, uint64_t offset=0)
framework::selected_pack< soa::is_persistent_column_t, C... > persistent_columns_t
void doSetCurrentIndexRaw(framework::pack< Cs... > p, std::vector< o2::soa::Binding > &&ptrs)
void bindInternalIndices(I const *table)
TableIterator(TableIterator< D, O, FilteredIndexPolicy, C... > const &other)
TableIterator(self_t const &other)
TableIterator operator-(int64_t dec) const
TableIterator(arrow::ChunkedArray *columnData[sizeof...(C)], IP &&policy)
TableIterator & operator=(TableIterator other)
TableIterator & operator++()
void doSetCurrentInternal(framework::pack< Cs... >, I const *ptr)
auto getIndexBindingsImpl(framework::pack< Cs... >) const
TableIterator operator--(int)
void bindExternalIndicesRaw(std::vector< o2::soa::Binding > &&ptrs)
TableIterator(arrow::ChunkedArray *columnData[sizeof...(C)], IP &&policy)
decltype([]< typename... Cs >(framework::pack< Cs... >) -> framework::pack< typename Cs::binding_t... > {}(external_index_columns_t{})) bindings_pack_t
void bindExternalIndices(TA *... current)
TableIterator & operator--()
framework::selected_pack< soa::is_external_index_t, C... > external_index_columns_t
TableIterator const & operator*() const
TableIterator operator++(int)
framework::selected_pack< soa::is_self_index_t, C... > internal_index_columns_t
auto getIndexBindings() const
void doSetCurrentIndex(framework::pack< CL... >, TA *current)
TableIterator operator+(int64_t inc) const
Allow incrementing by more than one the iterator.
Generic identifier for a table type.
constexpr TableRef & operator=(TableRef const &)=default
constexpr bool descriptionCompatible(uint32_t _desc_hash) const noexcept
constexpr bool operator==(TableRef const &other) const noexcept
constexpr TableRef(TableRef &&)=default
constexpr TableRef(TableRef const &)=default
consteval TableRef(uint32_t _label, uint32_t _desc, uint32_t _origin, uint32_t _version)
constexpr bool descriptionCompatible(TableRef const &other) const noexcept
constexpr TableRef & operator=(TableRef &&)=default
TableIteratorBase const & operator*() const
TableIteratorBase(TableIteratorBase< IP, P, T... > const &other)
typename Parent::columns_t columns_t
TableIteratorBase(TableIteratorBase< IP, P, O1, Os... > const &other)
typename Parent::external_index_columns_t external_index_columns_t
TableIteratorBase operator-(int64_t dec) const
void matchTo(TableIteratorBase< IP, P, T... > const &other)
auto getDynamicColumn() const
TableIteratorBase()=default
void matchTo(TableIteratorBase< IP, P, Os... > const &other)
TableIteratorBase(TableIteratorBase< FilteredIndexPolicy, P, T... > other)
std::array< B, sizeof...(CCs)> getValues() const
static constexpr auto originals
TableIteratorBase(TableIteratorBase< IP, P, T... > &&other) noexcept
decltype([]< typename... C >(framework::pack< C... >) -> framework::pack< typename C::binding_t... > {}(external_index_columns_t{})) bindings_pack_t
TableIteratorBase & operator=(TableIteratorBase< IP, P, Os... > other)
TableIteratorBase(TableIteratorBase< IP, P, O1, Os... > &&other) noexcept
TableIteratorBase & operator=(RowViewSentinel const &other)
TableIteratorBase(arrow::ChunkedArray *columnData[framework::pack_size(columns_t{})], IP &&policy)
TableIteratorBase & operator=(TableIteratorBase< IP, P, T... > other)
TableIteratorBase operator+(int64_t inc) const
Allow incrementing by more than one the iterator.
TableIteratorBase & operator=(TableIteratorBase< FilteredIndexPolicy, P, T... > other)
VectorOfTObjectPtrs other
std::vector< ReadoutWindowData > rows