Project
Loading...
Searching...
No Matches
ASoA.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
12#ifndef O2_FRAMEWORK_ASOA_H_
13#define O2_FRAMEWORK_ASOA_H_
14
15#if defined(__CLING__)
16#error "Please do not include this file in ROOT dictionary generation"
17#endif
18#include "Framework/Concepts.h" // IWYU pragma: export
20#include "Framework/Pack.h" // IWYU pragma: export
21#include "Framework/FunctionalHelpers.h" // IWYU pragma: export
22#include "Headers/DataHeader.h" // IWYU pragma: export
23#include "Headers/DataHeaderHelpers.h" // IWYU pragma: export
24#include "Framework/CompilerBuiltins.h" // IWYU pragma: export
25#include "Framework/Traits.h" // IWYU pragma: export
26#include "Framework/Expressions.h" // IWYU pragma: export
27#include "Framework/ArrowTypes.h" // IWYU pragma: export
28#include "Framework/ArrowTableSlicingCache.h" // IWYU pragma: export
29#include "Framework/SliceCache.h" // IWYU pragma: export
30#include "Framework/VariantHelpers.h" // IWYU pragma: export
31#include <fairmq/Version.h>
32#include <arrow/array/array_binary.h>
33#include <arrow/table.h> // IWYU pragma: export
34#include <arrow/array.h> // IWYU pragma: export
35#include <arrow/util/config.h> // IWYU pragma: export
36#include <gandiva/selection_vector.h> // IWYU pragma: export
37#include <array> // IWYU pragma: export
38#include <cassert>
39#include <fmt/format.h>
40#include <concepts>
41#include <cstring>
42#include <gsl/span> // IWYU pragma: export
43
45{
46struct MetaHeader;
47}
48
49namespace o2::framework
50{
51using ListVector = std::vector<std::vector<int64_t>>;
52using PointerReconstructor = std::function<std::byte*(fair::mq::shmem::MetaHeader&&)>;
53
54std::string cutString(std::string&& str);
55std::string strToUpper(std::string&& str);
56} // namespace o2::framework
57
58struct TClass;
59
60namespace o2::soa
61{
62void accessingInvalidIndexFor(const char* getter);
63void dereferenceWithWrongType(const char* getter, const char* target);
64void missingFilterDeclaration(int hash, int ai);
65void notBoundTable(const char* tableName);
66void* extractCCDBPayload(char* payload, size_t size, TClass const* cl, const char* what);
67
68// ASCII-only lowercase. Column labels are plain identifiers, so we deliberately
69// avoid the locale-aware std::tolower: it goes through the C locale facet on
70// every character and dominated getIndexFromLabel in profiles.
71constexpr inline char asciiToLower(char c)
72{
73 return (c >= 'A' && c <= 'Z') ? static_cast<char>(c + 32) : c;
74}
75
76template <typename... C>
78{
79 return std::vector<std::shared_ptr<arrow::Field>>{C::asArrowField()...};
80}
81} // namespace o2::soa
82
83namespace o2::soa
84{
86struct TableRef {
87 consteval TableRef()
88 : label_hash{0},
89 desc_hash{0},
90 origin_hash{0},
91 version{0}
92 {
93 }
94 consteval TableRef(uint32_t _label, uint32_t _desc, uint32_t _origin, uint32_t _version)
95 : label_hash{_label},
96 desc_hash{_desc},
97 origin_hash{_origin},
98 version{_version}
99 {
100 }
105
106 constexpr bool operator==(TableRef const& other) const noexcept
107 {
108 return (this->label_hash == other.label_hash) &&
109 (this->desc_hash == other.desc_hash) &&
110 (this->origin_hash == other.origin_hash) &&
111 (this->version == other.version);
112 }
113
114 constexpr bool descriptionCompatible(TableRef const& other) const noexcept
115 {
116 return this->desc_hash == other.desc_hash;
117 }
118
119 constexpr bool descriptionCompatible(uint32_t _desc_hash) const noexcept
120 {
121 return this->desc_hash == _desc_hash;
122 }
123
124 constexpr TableRef(TableRef const&) = default;
125 constexpr TableRef& operator=(TableRef const&) = default;
126 constexpr TableRef(TableRef&&) = default;
127 constexpr TableRef& operator=(TableRef&&) = default;
128};
129
131template <size_t N1, size_t N2, std::array<TableRef, N1> ar1, std::array<TableRef, N2> ar2>
132consteval auto merge()
133{
134 constexpr const int duplicates = std::ranges::count_if(ar2.begin(), ar2.end(), [&](TableRef const& a) consteval { return std::any_of(ar1.begin(), ar1.end(), [&](TableRef const& e) { return e == a; }); });
135 std::array<TableRef, N1 + N2 - duplicates> out;
136
137 auto pos = std::copy(ar1.begin(), ar1.end(), out.begin());
138 std::copy_if(ar2.begin(), ar2.end(), pos, [&](TableRef const& a) consteval { return std::none_of(ar1.begin(), ar1.end(), [&](TableRef const& e) { return e == a; }); });
139 return out;
140}
141
142template <size_t N1, size_t N2, std::array<TableRef, N1> ar1, std::array<TableRef, N2> ar2, typename L>
143consteval auto merge_if(L l)
144{
145 constexpr const int to_remove = std::ranges::count_if(ar1.begin(), ar1.end(), [&](TableRef const& a) consteval { return !l(a); });
146 constexpr const int duplicates = std::ranges::count_if(ar2.begin(), ar2.end(), [&](TableRef const& a) consteval { return std::any_of(ar1.begin(), ar1.end(), [&](TableRef const& e) { return e == a; }) || !l(a); });
147 std::array<TableRef, N1 + N2 - duplicates - to_remove> out;
148
149 auto pos = std::copy_if(ar1.begin(), ar1.end(), out.begin(), [&](TableRef const& a) consteval { return l(a); });
150 std::copy_if(ar2.begin(), ar2.end(), pos, [&](TableRef const& a) consteval { return std::none_of(ar1.begin(), ar1.end(), [&](TableRef const& e) { return e == a; }) && l(a); });
151 return out;
152}
153
154template <size_t N, std::array<TableRef, N> ar, typename L>
155consteval auto remove_if(L l)
156{
157 constexpr const int to_remove = std::ranges::count_if(ar.begin(), ar.end(), [&l](TableRef const& e) consteval { return l(e); });
158 std::array<TableRef, N - to_remove> out;
159 std::copy_if(ar.begin(), ar.end(), out.begin(), [&l](TableRef const& e) consteval { return !l(e); });
160 return out;
161}
162
163template <size_t N1, size_t N2, std::array<TableRef, N1> ar1, std::array<TableRef, N2> ar2>
164consteval auto intersect()
165{
166 constexpr const int duplicates = std::ranges::count_if(ar2.begin(), ar2.end(), [&](TableRef const& a) consteval { return std::any_of(ar1.begin(), ar1.end(), [&](TableRef const& e) { return e == a; }); });
167 std::array<TableRef, duplicates> out;
168 std::copy_if(ar1.begin(), ar1.end(), out.begin(), [](TableRef const& a) consteval { return std::find(ar2.begin(), ar2.end(), a) != ar2.end(); });
169 return out;
170}
171
172template <typename T, typename... Ts>
173consteval auto mergeOriginals()
174 requires(sizeof...(Ts) == 1)
175{
177 return merge<T::originals.size(), T1::originals.size(), T::originals, T1::originals>();
178}
179
180template <typename T, typename... Ts>
181consteval auto mergeOriginals()
182 requires(sizeof...(Ts) > 1)
183{
184 constexpr auto tail = mergeOriginals<Ts...>();
185 return merge<T::originals.size(), tail.size(), T::originals, tail>();
186}
187
188template <typename T, typename... Ts>
189 requires(sizeof...(Ts) == 1)
190consteval auto intersectOriginals()
191{
193 return intersect<T::originals.size(), T1::originals.size(), T::originals, T1::originals>();
194}
195
196template <typename T, typename... Ts>
197 requires(sizeof...(Ts) > 1)
198consteval auto intersectOriginals()
199{
200 constexpr auto tail = intersectOriginals<Ts...>();
201 return intersect<T::originals.size(), tail.size(), T::originals, tail>();
202}
203} // namespace o2::soa
204
205namespace o2::soa
206{
208template <typename C>
210
211template <typename C>
212using is_persistent_column_t = std::conditional_t<is_persistent_column<C>, std::true_type, std::false_type>;
213
214template <typename C>
215using is_external_index_t = typename std::conditional_t<is_index_column<C>, std::true_type, std::false_type>;
216
217template <typename C>
218using is_self_index_t = typename std::conditional_t<is_self_index_column<C>, std::true_type, std::false_type>;
219} // namespace o2::soa
220
221namespace o2::aod
222{
223namespace
224{
225template <typename Key, size_t N, std::array<bool, N> map>
226static consteval int getIndexPosToKey_impl()
227{
228 constexpr const auto pos = std::find(map.begin(), map.end(), true);
229 if constexpr (pos != map.end()) {
230 return std::distance(map.begin(), pos);
231 } else {
232 return -1;
233 }
234}
235} // namespace
236
238template <typename D, typename... Cs>
240 static constexpr void isTableMetadata() {};
241 using columns = framework::pack<Cs...>;
245
246 template <typename Key, typename... PCs>
247 static consteval std::array<bool, sizeof...(PCs)> getMap(framework::pack<PCs...>)
248 {
249 return std::array<bool, sizeof...(PCs)>{[]() consteval {
250 if constexpr (requires { PCs::index_targets.size(); }) {
251 return Key::template isIndexTargetOf<PCs::index_targets.size(), PCs::index_targets>();
252 } else {
253 return false;
254 }
255 }()...};
256 }
257
258 template <typename Key>
259 static consteval int getIndexPosToKey()
260 {
261 return getIndexPosToKey_impl<Key, framework::pack_size(persistent_columns_t{}), getMap<Key>(persistent_columns_t{})>();
262 }
263
264 static std::shared_ptr<arrow::Schema> getSchema()
265 {
266 return std::make_shared<arrow::Schema>([]<typename... C>(framework::pack<C...>&& p) { return o2::soa::createFieldsFromColumns(p); }(persistent_columns_t{}));
267 }
268};
269
270template <typename D>
272 static constexpr void isMetadataTrait() {};
273 using metadata = void;
274};
275
278template <uint32_t H>
279struct Hash {
280 static constexpr void isHash() {};
281 static constexpr uint32_t hash = H;
282 static constexpr char const* const str{""};
283};
284
286template <size_t N, std::array<soa::TableRef, N> ar, typename Key>
287consteval auto filterForKey()
288{
289 constexpr std::array<bool, N> test = []<size_t... Is>(std::index_sequence<Is...>) consteval {
290 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))...};
291 }(std::make_index_sequence<N>());
292 constexpr int correct = std::ranges::count(test.begin(), test.end(), true);
293 std::array<soa::TableRef, correct> out;
294 std::ranges::copy_if(ar.begin(), ar.end(), out.begin(), [&test](soa::TableRef const& r) consteval { return test[std::distance(ar.begin(), std::find(ar.begin(), ar.end(), r))]; });
295 return out;
296}
297
299#define O2HASH(_Str_) \
300 template <> \
301 struct Hash<_Str_ ""_h> { \
302 static constexpr void isHash() {}; \
303 static constexpr uint32_t hash = _Str_ ""_h; \
304 static constexpr char const* const str{_Str_}; \
305 };
306
308#define O2ORIGIN(_Str_) \
309 template <> \
310 struct Hash<_Str_ ""_h> { \
311 static constexpr void isHash() {}; \
312 static constexpr void isOriginHash() {}; \
313 static constexpr header::DataOrigin origin{_Str_}; \
314 static constexpr uint32_t hash = _Str_ ""_h; \
315 static constexpr char const* const str{_Str_}; \
316 };
317
319static inline constexpr uint32_t version(const char* const str)
320{
321 if (str[0] == '\0') {
322 return 0;
323 }
324 size_t len = 0;
325 uint32_t res = 0;
326 while (str[len] != '/' && str[len] != '\0') {
327 ++len;
328 }
329 if (str[len - 1] == '\0') {
330 return -1;
331 }
332 for (auto i = len + 1; str[i] != '\0'; ++i) {
333 res = res * 10 + (int)(str[i] - '0');
334 }
335 return res;
336}
337
339static inline constexpr std::string_view description_str(const char* const str)
340{
341 size_t len = 0;
342 while (len < 15 && str[len] != '/') {
343 ++len;
344 }
345 return std::string_view{str, len};
346}
347
348static inline constexpr header::DataDescription description(const char* const str)
349{
350 size_t len = 0;
351 while (len < 15 && str[len] != '/') {
352 ++len;
353 }
354 char out[16];
355 for (auto i = 0; i < 16; ++i) {
356 out[i] = 0;
357 }
358 std::memcpy(out, str, len);
359 return {out};
360}
361
362// Helpers to get strings from TableRef
363template <soa::TableRef R>
364consteval const char* label()
365{
366 return o2::aod::Hash<R.label_hash>::str;
367}
368
369template <soa::TableRef R>
370consteval const char* origin_str()
371{
372 return o2::aod::Hash<R.origin_hash>::str;
373}
374
375template <soa::TableRef R>
377{
378 return o2::aod::Hash<R.origin_hash>::origin;
379}
380
381template <soa::TableRef R>
382consteval const char* signature()
383{
384 return o2::aod::Hash<R.desc_hash>::str;
385}
386
387template <soa::TableRef R>
389{
390 return {origin<R>(), description(signature<R>()), R.version};
391}
392
394template <soa::TableRef R>
395static constexpr auto sourceSpec()
396{
397 return fmt::format("{}/{}/{}/{}", label<R>(), origin_str<R>(), description_str(signature<R>()), R.version);
398}
399
401template <size_t N, std::array<soa::TableRef, N> ar, o2::aod::is_origin_hash O>
402consteval auto replaceOrigin()
403{
404 std::array<soa::TableRef, N> res;
405 for (auto i = 0U; i < N; ++i) {
406 res[i].label_hash = ar[i].label_hash;
407 res[i].desc_hash = ar[i].desc_hash;
408 res[i].origin_hash = O::hash;
409 res[i].version = ar[i].version;
410 }
411 return res;
412}
413} // namespace o2::aod
414
415namespace o2::soa
416{
417template <aod::is_aod_hash L, aod::is_aod_hash D, aod::is_origin_hash O, typename... Ts>
418class Table;
419
421struct Binding {
422 void const* ptr = nullptr;
424 // std::span<TableRef const> refs;
425
426 template <typename T>
427 void bind(T const* table)
428 {
429 ptr = table;
430 hash = o2::framework::TypeIdHelpers::uniqueId<T>();
431 // refs = std::span{T::originals};
432 }
433
434 template <typename T>
435 T const* get() const
436 {
437 if (hash == o2::framework::TypeIdHelpers::uniqueId<T>()) {
438 return static_cast<T const*>(ptr);
439 }
440 return nullptr;
441 }
442};
443
444using SelectionVector = std::vector<int64_t>;
445
446template <typename B, typename E>
448 constexpr static bool value = false;
449};
450
451template <aod::is_aod_hash A, aod::is_aod_hash B>
453 constexpr static bool value = false;
454};
455
456template <typename B, typename E>
458
459template <aod::is_aod_hash A, aod::is_aod_hash B>
461
465struct Chunked {
466 constexpr static bool chunked = true;
467};
468
471struct Flat {
472 constexpr static bool chunked = false;
473};
474
476template <typename T>
477struct unwrap {
478 using type = T;
479};
480
481template <typename T>
482struct unwrap<std::vector<T>> {
483 using type = T;
484};
485
486template <>
487struct unwrap<bool> {
488 using type = char;
489};
490
491template <typename T>
492using unwrap_t = typename unwrap<T>::type;
493
498template <typename T, typename ChunkingPolicy = Chunked>
499class ColumnIterator : ChunkingPolicy
500{
501 static constexpr char SCALE_FACTOR = std::same_as<std::decay_t<T>, bool> ? 3 : 0;
502
503 public:
508 ColumnIterator(arrow::ChunkedArray const* column)
509 : mColumn{column},
510 mCurrent{nullptr},
511 mCurrentPos{nullptr},
512 mGlobalOffset{nullptr},
513 mLast{nullptr},
514 mFirstIndex{0},
516 {
517 auto array = getCurrentArray();
518 mCurrent = reinterpret_cast<unwrap_t<T> const*>(array->values()->data());
519 mLast = mCurrent + array->length();
520 }
521
522 ColumnIterator() = default;
525
528
530 void nextChunk() const
531 {
532 auto previousArray = getCurrentArray();
533 mFirstIndex += previousArray->length();
535 auto array = getCurrentArray();
536 mCurrent = reinterpret_cast<unwrap_t<T> const*>(array->values()->data()) - (mFirstIndex >> SCALE_FACTOR);
537 mLast = mCurrent + array->length() + (mFirstIndex >> SCALE_FACTOR);
538 }
539
540 void prevChunk() const
541 {
542 auto previousArray = getCurrentArray();
543 mFirstIndex -= previousArray->length();
545 auto array = getCurrentArray();
546 mCurrent = reinterpret_cast<unwrap_t<T> const*>(array->values()->data()) - (mFirstIndex >> SCALE_FACTOR);
547 mLast = mCurrent + array->length() + (mFirstIndex >> SCALE_FACTOR);
548 }
549
550 void moveToChunk(int chunk)
551 {
552 if (mCurrentChunk < chunk) {
553 while (mCurrentChunk != chunk) {
554 nextChunk();
555 }
556 } else {
557 while (mCurrentChunk != chunk) {
558 prevChunk();
559 }
560 }
561 }
562
565 {
566 mCurrentChunk = mColumn->num_chunks() - 1;
567 auto array = getCurrentArray();
568 mFirstIndex = mColumn->length() - array->length();
569 mCurrent = reinterpret_cast<unwrap_t<T> const*>(array->values()->data()) - (mFirstIndex >> SCALE_FACTOR);
570 mLast = mCurrent + array->length() + (mFirstIndex >> SCALE_FACTOR);
571 }
572
573 auto operator*() const
574 requires std::same_as<bool, std::decay_t<T>>
575 {
576 checkSkipChunk();
577 return (*(mCurrent + ((*mCurrentPos + *mGlobalOffset) >> SCALE_FACTOR)) & (1 << ((*mCurrentPos + *mGlobalOffset) & ((1 << SCALE_FACTOR) - 1)))) != 0;
578 }
579
580 auto operator*() const
581 requires((!std::same_as<bool, std::decay_t<T>>) && std::same_as<arrow_array_for_t<T>, arrow::ListArray>)
582 {
583 checkSkipChunk();
584 auto list = std::static_pointer_cast<arrow::ListArray>(mColumn->chunk(mCurrentChunk));
585 auto offset = list->value_offset(*mCurrentPos + *mGlobalOffset - mFirstIndex);
586 auto length = list->value_length(*mCurrentPos + *mGlobalOffset - mFirstIndex);
587 return gsl::span<unwrap_t<T> const>{mCurrent + mFirstIndex + offset, mCurrent + mFirstIndex + (offset + length)};
588 }
589
590 decltype(auto) operator*() const
591 requires((!std::same_as<bool, std::decay_t<T>>) && std::same_as<arrow_array_for_t<T>, arrow::BinaryViewArray>)
592 {
593 checkSkipChunk();
594 auto array = std::static_pointer_cast<arrow::BinaryViewArray>(mColumn->chunk(mCurrentChunk));
595 return array->GetView(*mCurrentPos + *mGlobalOffset - mFirstIndex);
596 }
597
598 decltype(auto) operator*() const
599 requires((!std::same_as<bool, std::decay_t<T>>) && !std::same_as<arrow_array_for_t<T>, arrow::ListArray> && !std::same_as<arrow_array_for_t<T>, arrow::BinaryViewArray>)
600 {
601 checkSkipChunk();
602 return *(mCurrent + ((*mCurrentPos + *mGlobalOffset) >> SCALE_FACTOR));
603 }
604
605 // Move to the chunk which containts element pos
607 {
608 checkSkipChunk();
609 return *this;
610 }
611
612 mutable unwrap_t<T> const* mCurrent;
615 mutable unwrap_t<T> const* mLast;
616 arrow::ChunkedArray const* mColumn;
617 mutable int mFirstIndex;
618 mutable int mCurrentChunk;
619
620 private:
621 void checkSkipChunk() const
622 requires((ChunkingPolicy::chunked == true) && std::same_as<arrow_array_for_t<T>, arrow::ListArray>)
623 {
624 auto list = std::static_pointer_cast<arrow::ListArray>(mColumn->chunk(mCurrentChunk));
625 if (O2_BUILTIN_UNLIKELY(*mCurrentPos + *mGlobalOffset - mFirstIndex >= list->length())) {
626 nextChunk();
627 }
628 }
629
630 void checkSkipChunk() const
631 requires((ChunkingPolicy::chunked == true) && !std::same_as<arrow_array_for_t<T>, arrow::ListArray>)
632 {
633 if (O2_BUILTIN_UNLIKELY(((mCurrent + ((*mCurrentPos + *mGlobalOffset) >> SCALE_FACTOR)) >= mLast))) {
634 nextChunk();
635 }
636 }
637
638 void checkSkipChunk() const
639 requires(ChunkingPolicy::chunked == false)
640 {
641 }
643 auto getCurrentArray() const
644 requires(std::same_as<arrow_array_for_t<T>, arrow::FixedSizeListArray>)
645 {
646 std::shared_ptr<arrow::Array> chunkToUse = mColumn->chunk(mCurrentChunk);
647 chunkToUse = std::dynamic_pointer_cast<arrow::FixedSizeListArray>(chunkToUse)->values();
648 return std::static_pointer_cast<arrow_array_for_t<value_for_t<T>>>(chunkToUse);
649 }
650
651 auto getCurrentArray() const
652 requires(std::same_as<arrow_array_for_t<T>, arrow::ListArray>)
653 {
654 std::shared_ptr<arrow::Array> chunkToUse = mColumn->chunk(mCurrentChunk);
655 chunkToUse = std::dynamic_pointer_cast<arrow::ListArray>(chunkToUse)->values();
656 return std::static_pointer_cast<arrow_array_for_t<value_for_t<T>>>(chunkToUse);
657 }
658
659 auto getCurrentArray() const
660 requires(!std::same_as<arrow_array_for_t<T>, arrow::FixedSizeListArray> && !std::same_as<arrow_array_for_t<T>, arrow::ListArray>)
661 {
662 std::shared_ptr<arrow::Array> chunkToUse = mColumn->chunk(mCurrentChunk);
663 return std::static_pointer_cast<arrow_array_for_t<T>>(chunkToUse);
664 }
665};
666
667template <typename T, typename INHERIT>
668struct Column {
669 static constexpr void isIteratableColumn() {};
670
671 using inherited_t = INHERIT;
673 : mColumnIterator{it}
674 {
675 }
676
677 Column() = default;
678 Column(Column const&) = default;
679 Column& operator=(Column const&) = default;
680
681 Column(Column&&) = default;
682 Column& operator=(Column&&) = default;
683
684 using type = T;
685 static constexpr const char* const& columnLabel() { return INHERIT::mLabel; }
687 {
688 return mColumnIterator;
689 }
690
691 static auto asArrowField()
692 {
693 return std::make_shared<arrow::Field>(inherited_t::mLabel, soa::asArrowDataType<type>());
694 }
695
699};
700
703template <typename F, typename INHERIT>
705 static constexpr void isDynamicColumn() {};
706 using inherited_t = INHERIT;
707
708 static constexpr const char* const& columnLabel() { return INHERIT::mLabel; }
709};
710
711template <typename INHERIT>
713 static constexpr void isEnumeratingColumn() {};
714 using inherited_t = INHERIT;
715 static constexpr const uint32_t hash = 0;
716
717 static constexpr const char* const& columnLabel() { return INHERIT::mLabel; }
718};
719
720template <typename INHERIT>
722 static constexpr void isMarkingColumn() {};
723 using inherited_t = INHERIT;
724 static constexpr const uint32_t hash = 0;
725
726 static constexpr const char* const& columnLabel() { return INHERIT::mLabel; }
727};
728
729template <size_t M = 0>
730struct Marker : o2::soa::MarkerColumn<Marker<M>> {
731 using type = size_t;
733 constexpr inline static auto value = M;
734
735 Marker() = default;
736 Marker(Marker const&) = default;
737 Marker(Marker&&) = default;
738
739 Marker& operator=(Marker const&) = default;
740 Marker& operator=(Marker&&) = default;
741
742 Marker(arrow::ChunkedArray const*) {}
743 constexpr inline auto mark()
744 {
745 return value;
746 }
747
748 static constexpr const char* mLabel = "Marker";
749};
750
751template <int64_t START = 0, int64_t END = -1>
752struct Index : o2::soa::IndexColumn<Index<START, END>> {
754 constexpr inline static int64_t start = START;
755 constexpr inline static int64_t end = END;
756
757 Index() = default;
758 Index(Index const&) = default;
759 Index(Index&&) = default;
760
761 Index& operator=(Index const&) = default;
762 Index& operator=(Index&&) = default;
763
764 Index(arrow::ChunkedArray const*)
765 {
766 }
767
768 constexpr inline int64_t rangeStart()
769 {
770 return START;
771 }
772
773 constexpr inline int64_t rangeEnd()
774 {
775 return END;
776 }
777
778 [[nodiscard]] int64_t index() const
779 {
780 return index<0>();
781 }
782
783 [[nodiscard]] int64_t filteredIndex() const
784 {
785 return index<1>();
786 }
787
788 [[nodiscard]] int64_t globalIndex() const
789 {
790 return index<0>() + offsets<0>();
791 }
792
793 template <int N = 0>
794 [[nodiscard]] int64_t index() const
795 {
796 return *std::get<N>(rowIndices);
797 }
798
799 template <int N = 0>
800 [[nodiscard]] int64_t offsets() const
801 {
802 return *std::get<N>(rowOffsets);
803 }
804
805 void setIndices(std::tuple<int64_t const*, int64_t const*> indices)
806 {
808 }
809
810 void setOffsets(std::tuple<uint64_t const*> offsets)
811 {
813 }
814
815 static constexpr const char* mLabel = "Index";
816 using type = int64_t;
817
818 std::tuple<int64_t const*, int64_t const*> rowIndices;
821 std::tuple<uint64_t const*> rowOffsets;
822};
823
830
832 static constexpr void isRowViewSentinel() {};
834};
835
837 static constexpr void isFilteredIndexPolicy();
838 // We use -1 in the IndexPolicyBase to indicate that the index is
839 // invalid. What will validate the index is the this->setCursor()
840 // which happens below which will properly setup the first index
841 // by remapping the filtered index 0 to whatever unfiltered index
842 // it belongs to.
843 FilteredIndexPolicy(std::span<int64_t const> selection, int64_t rows, uint64_t offset = 0)
844 : IndexPolicyBase{-1, offset},
845 mSelectedRows(selection),
846 mMaxSelection(selection.size()),
847 nRows{rows}
848 {
849 this->setCursor(0);
850 }
851
852 void resetSelection(std::span<int64_t const> selection)
853 {
854 mSelectedRows = selection;
855 mMaxSelection = selection.size();
856 this->setCursor(0);
857 }
858
864
865 [[nodiscard]] std::tuple<int64_t const*, int64_t const*>
867 {
868 return std::make_tuple(&mRowIndex, &mSelectionRow);
869 }
870
871 [[nodiscard]] std::tuple<uint64_t const*>
873 {
874 return std::make_tuple(&mOffset);
875 }
876
878 {
879 this->setCursor(start);
880 if (end >= 0) {
881 mMaxSelection = std::min(end, mMaxSelection);
882 }
883 }
884
886 {
887 mSelectionRow = i;
888 updateRow();
889 }
890
892 {
893 mSelectionRow += i;
894 updateRow();
895 }
896
897 friend bool operator==(FilteredIndexPolicy const& lh, FilteredIndexPolicy const& rh)
898 {
899 return lh.mSelectionRow == rh.mSelectionRow;
900 }
901
902 bool operator==(RowViewSentinel const& sentinel) const
903 {
904 return O2_BUILTIN_UNLIKELY(mSelectionRow == sentinel.index);
905 }
906
911 {
912 this->mSelectionRow = this->mMaxSelection;
913 this->mRowIndex = -1;
914 }
915
916 [[nodiscard]] auto getSelectionRow() const
917 {
918 return mSelectionRow;
919 }
920
921 [[nodiscard]] auto size() const
922 {
923 return mMaxSelection;
924 }
925
926 [[nodiscard]] auto raw_size() const
927 {
928 return nRows;
929 }
930
931 private:
932 inline void updateRow()
933 {
934 this->mRowIndex = O2_BUILTIN_LIKELY(mSelectionRow < mMaxSelection) ? mSelectedRows[mSelectionRow] : -1;
935 }
936 std::span<int64_t const> mSelectedRows;
937 int64_t mSelectionRow = 0;
938 int64_t mMaxSelection = 0;
939 int64_t nRows = 0;
940};
941
943 static constexpr void isDefaultIndexPolicy() {};
950
956 mMaxRow(nRows)
957 {
958 }
959
965
967 {
968 this->setCursor(start);
969 if (end >= 0) {
970 mMaxRow = std::min(end, mMaxRow);
971 }
972 }
973
974 [[nodiscard]] std::tuple<int64_t const*, int64_t const*>
976 {
977 return std::make_tuple(&mRowIndex, &mRowIndex);
978 }
979
980 [[nodiscard]] std::tuple<uint64_t const*>
982 {
983 return std::make_tuple(&mOffset);
984 }
985
987 {
988 this->mRowIndex = i;
989 }
991 {
992 this->mRowIndex += i;
993 }
994
996 {
997 this->setCursor(mMaxRow);
998 }
999
1000 friend bool operator==(DefaultIndexPolicy const& lh, DefaultIndexPolicy const& rh)
1001 {
1002 return lh.mRowIndex == rh.mRowIndex;
1003 }
1004
1005 bool operator==(RowViewSentinel const& sentinel) const
1006 {
1007 return O2_BUILTIN_UNLIKELY(this->mRowIndex == sentinel.index);
1008 }
1009
1010 [[nodiscard]] auto size() const
1011 {
1012 return mMaxRow;
1013 }
1014
1016};
1017
1020template <typename C>
1023 arrow::ChunkedArray* second;
1024};
1025
1026template <typename C>
1027concept needs_ptr_rec = C::needs_ptr_rec;
1028
1029template <typename D, typename O, typename IP, typename... C>
1030struct TableIterator : IP, C... {
1031 public:
1032 static constexpr void isTableIterator() {};
1033 using self_t = TableIterator<D, O, IP, C...>;
1034 using policy_t = IP;
1039 using bindings_pack_t = decltype([]<typename... Cs>(framework::pack<Cs...>) consteval -> framework::pack<typename Cs::binding_t...> {}(external_index_columns_t{})); // decltype(extractBindings(external_index_columns_t{}));
1040
1041 TableIterator(arrow::ChunkedArray* columnData[sizeof...(C)], IP&& policy)
1042 : IP{policy},
1043 C(columnData[framework::has_type_at_v<C>(all_columns{})])...
1044 {
1045 if (this->size() != 0) {
1046 bind();
1047 }
1048 }
1049
1050 TableIterator(arrow::ChunkedArray* columnData[sizeof...(C)], IP&& policy)
1051 requires(has_index<C...>)
1052 : IP{policy},
1053 C(columnData[framework::has_type_at_v<C>(all_columns{})])...
1054 {
1055 if (this->size() != 0) {
1056 bind();
1057 }
1058 // In case we have an index column might need to constrain the actual
1059 // number of rows in the view to the range provided by the index.
1060 // FIXME: we should really understand what happens to an index when we
1061 // have a RowViewFiltered.
1062 this->limitRange(this->rangeStart(), this->rangeEnd());
1063 }
1064
1065 TableIterator() = default;
1067 : IP{static_cast<IP const&>(other)},
1068 C(static_cast<C const&>(other))...
1069 {
1070 if (this->size() != 0) {
1071 bind();
1072 }
1073 }
1074
1076 {
1077 IP::operator=(static_cast<IP const&>(other));
1078 (void(static_cast<C&>(*this) = static_cast<C>(other)), ...);
1079 if (this->size() != 0) {
1080 bind();
1081 }
1082 return *this;
1083 }
1084
1086 requires std::same_as<IP, DefaultIndexPolicy>
1087 : IP{static_cast<IP const&>(other)},
1088 C(static_cast<C const&>(other))...
1089 {
1090 if (this->size() != 0) {
1091 bind();
1092 }
1093 }
1094
1096 {
1097 this->moveByIndex(1);
1098 return *this;
1099 }
1100
1102 {
1103 self_t copy = *this;
1104 this->operator++();
1105 return copy;
1106 }
1107
1109 {
1110 this->moveByIndex(-1);
1111 return *this;
1112 }
1113
1115 {
1116 self_t copy = *this;
1117 this->operator--();
1118 return copy;
1119 }
1120
1123 {
1124 TableIterator copy = *this;
1125 copy.moveByIndex(inc);
1126 return copy;
1127 }
1128
1130 {
1131 return operator+(-dec);
1132 }
1133
1135 {
1136 return *this;
1137 }
1138
1139 template <typename CL>
1140 auto getCurrent() const
1141 {
1142 return CL::getCurrentRaw();
1143 }
1144
1145 template <typename... Cs>
1147 {
1148 return std::vector<o2::soa::Binding>{static_cast<Cs const&>(*this).getCurrentRaw()...};
1149 }
1150
1151 auto getIndexBindings() const
1152 {
1154 }
1155
1156 template <typename... TA>
1157 void bindExternalIndices(TA*... current)
1158 {
1159 ([this]<soa::is_index_column... CCs>(TA* cur, framework::pack<CCs...>) {
1160 (CCs::setCurrent(cur), ...);
1161 }(current, external_index_columns_t{}),
1162 ...);
1163 }
1164
1165 template <typename TA>
1166 void bindExternalIndex(TA* current)
1167 {
1168 [this]<soa::is_index_column... CCs>(TA* cur, framework::pack<CCs...>) {
1169 (CCs::setCurrent(cur), ...);
1170 }(current, external_index_columns_t{});
1171 }
1172
1173 template <typename... Cs>
1174 void doSetCurrentIndexRaw(framework::pack<Cs...> p, std::vector<o2::soa::Binding>&& ptrs)
1175 {
1176 (Cs::setCurrentRaw(ptrs[framework::has_type_at_v<Cs>(p)]), ...);
1177 }
1178
1179 template <typename... Cs, typename I>
1181 {
1183 b.bind(ptr);
1184 (Cs::setCurrentRaw(b), ...);
1185 }
1186
1187 void bindExternalIndicesRaw(std::vector<o2::soa::Binding>&& ptrs)
1188 {
1189 doSetCurrentIndexRaw(external_index_columns_t{}, std::forward<std::vector<o2::soa::Binding>>(ptrs));
1190 }
1191
1192 template <typename I>
1193 void bindInternalIndices(I const* table)
1194 {
1196 }
1197
1199 {
1200 [&pointerReconstructor, this]<typename... Cs>(framework::pack<Cs...>) {
1201 ([&pointerReconstructor, this]<typename CC>() {
1202 if constexpr (needs_ptr_rec<CC>) {
1203 if (pointerReconstructor) {
1204 CC::ptrRec = &pointerReconstructor;
1205 }
1206 }
1207 }.template operator()<Cs>(),
1208 ...);
1209 }(all_columns{});
1210 }
1211
1212 private:
1214 template <typename... PC>
1215 void doMoveToEnd(framework::pack<PC...>)
1216 {
1217 (PC::mColumnIterator.moveToEnd(), ...);
1218 }
1219
1222 void bind()
1223 {
1224 using namespace o2::soa;
1225 auto f = framework::overloaded{
1226 [this]<soa::is_persistent_column T>(T*) -> void { T::mColumnIterator.mCurrentPos = &this->mRowIndex; T::mColumnIterator.mGlobalOffset = &this->mOffset; },
1227 [this]<soa::is_dynamic_column T>(T*) -> void { bindDynamicColumn<T>(typename T::bindings_t{}); },
1228 [this]<typename T>(T*) -> void {},
1229 };
1230 (f(static_cast<C*>(nullptr)), ...);
1231 if constexpr (has_index<C...>) {
1232 this->setIndices(this->getIndices());
1233 this->setOffsets(this->getOffsets());
1234 }
1235 }
1236
1237 template <typename DC, typename... B>
1238 auto bindDynamicColumn(framework::pack<B...>)
1239 {
1240 DC::boundIterators = std::make_tuple(getDynamicBinding<B>()...);
1241 }
1242
1243 // Sometimes dynamic columns are defined for tables in
1244 // the hope that it will be joined / extended with another one which provides
1245 // the full set of bindings. This is to avoid a compilation
1246 // error if constructor for the table or any other thing involving a missing
1247 // binding is preinstanciated.
1248 template <typename B>
1249 requires(can_bind<self_t, B>)
1250 decltype(auto) getDynamicBinding()
1251 {
1252 static_assert(std::same_as<decltype(&(static_cast<B*>(this)->mColumnIterator)), std::decay_t<decltype(B::mColumnIterator)>*>, "foo");
1253 return &(static_cast<B*>(this)->mColumnIterator);
1254 }
1255
1256 template <typename B>
1257 decltype(auto) getDynamicBinding()
1258 {
1259 return static_cast<std::decay_t<decltype(B::mColumnIterator)>*>(nullptr);
1260 }
1261};
1262
1264 static o2::soa::ArrowTableRef joinTables(std::vector<std::shared_ptr<arrow::Table>>&& tables);
1265 static o2::soa::ArrowTableRef joinTables(std::vector<o2::soa::ArrowTableRef>&& tables);
1266 static o2::soa::ArrowTableRef joinTables(std::vector<o2::soa::ArrowTableRef>&& tables, std::span<const char* const> labels);
1267 static o2::soa::ArrowTableRef joinTables(std::vector<o2::soa::ArrowTableRef>&& tables, std::span<const std::string> labels);
1268 static o2::soa::ArrowTableRef joinTables(std::vector<std::shared_ptr<arrow::Table>>&& tables, std::span<const char* const> labels);
1269 static o2::soa::ArrowTableRef joinTables(std::vector<std::shared_ptr<arrow::Table>>&& tables, std::span<const std::string> labels);
1270 static o2::soa::ArrowTableRef concatTables(std::vector<o2::soa::ArrowTableRef>&& tables);
1271 static o2::soa::ArrowTableRef concatTables(std::vector<std::shared_ptr<arrow::Table>>&& tables);
1272};
1273
1274template <size_t N1, std::array<TableRef, N1> os1, size_t N2, std::array<TableRef, N2> os2>
1275consteval bool is_compatible()
1276{
1277 return []<size_t NN2, size_t... Is>(std::index_sequence<Is...>) consteval {
1278 return ([]<size_t... Ks>(std::index_sequence<Ks...>) consteval {
1279 constexpr auto h = os1[Is].desc_hash;
1280 using H = o2::aod::Hash<h>;
1281 return (((h == os2[Ks].desc_hash) || is_ng_index_equivalent_v<H, o2::aod::Hash<os2[Ks].desc_hash>>) || ...);
1282 }(std::make_index_sequence<NN2>()) ||
1283 ...);
1284 }.template operator()<N2>(std::make_index_sequence<N1>());
1285}
1286
1287template <with_originals T, with_originals B>
1289{
1290 return is_compatible<T::originals.size(), T::originals, B::originals.size(), B::originals>();
1291}
1292
1293template <typename T, typename B>
1294using is_binding_compatible = std::conditional_t<is_binding_compatible_v<T, typename B::binding_t>(), std::true_type, std::false_type>;
1295
1296template <soa::is_table T>
1297static constexpr std::string getLabelForTable()
1298{
1299 return std::string{aod::label<std::decay_t<T>::originals[0]>()};
1300}
1301
1302template <soa::is_table T>
1304static constexpr std::string getLabelFromType()
1305{
1306 return getLabelForTable<T>();
1307}
1308
1309template <soa::is_iterator T>
1310static constexpr std::string getLabelFromType()
1311{
1312 return getLabelForTable<typename std::decay_t<T>::parent_t>();
1313}
1314
1315template <soa::is_index_table T>
1316static constexpr std::string getLabelFromType()
1317{
1318 return getLabelForTable<typename std::decay_t<T>::first_t>();
1319}
1320template <soa::with_base_table T>
1321 requires(!soa::is_iterator<T>)
1322static constexpr std::string getLabelFromType()
1323{
1324 return getLabelForTable<typename aod::MetadataTrait<o2::aod::Hash<T::originals[T::originals.size() - 1].desc_hash>>::metadata::base_table_t>();
1325}
1326
1327template <typename... C>
1328static constexpr auto hasColumnForKey(framework::pack<C...>, std::string_view key)
1329{
1330 auto caseInsensitiveCompare = [](const std::string_view& str1, const std::string_view& str2) {
1331 return std::ranges::equal(
1332 str1, str2,
1333 [](char c1, char c2) {
1334 return asciiToLower(static_cast<unsigned char>(c1)) ==
1335 asciiToLower(static_cast<unsigned char>(c2));
1336 });
1337 };
1338 return (caseInsensitiveCompare(C::inherited_t::mLabel, key) || ...);
1339}
1340
1341template <TableRef ref>
1342static constexpr std::pair<bool, std::string> hasKey(std::string_view key)
1343{
1344 return {hasColumnForKey(typename aod::MetadataTrait<o2::aod::Hash<ref.desc_hash>>::metadata::columns{}, key), aod::label<ref>()};
1345}
1346
1347template <TableRef ref>
1348static constexpr std::pair<bool, framework::ConcreteDataMatcher> hasKeyM(std::string_view key)
1349{
1350 return {hasColumnForKey(typename aod::MetadataTrait<o2::aod::Hash<ref.desc_hash>>::metadata::columns{}, key), aod::matcher<ref>()};
1351}
1352
1353void notFoundColumn(const char* label, const char* key);
1354void missingOptionalPreslice(const char* label, const char* key);
1355
1356template <with_originals T, bool OPT = false>
1357static constexpr std::string getLabelFromTypeForKey(std::string_view key)
1358{
1359 auto locate = []<size_t... Is>(std::index_sequence<Is...>, std::string_view key) {
1360 return std::array{hasKey<T::originals[Is]>(key)...} |
1361 std::views::filter([](auto const& x) { return x.first; });
1362 }(std::make_index_sequence<T::originals.size()>{}, key);
1363 if (!locate.empty()) {
1364 return locate.front().second;
1365 }
1366
1367 if constexpr (!OPT) {
1368 notFoundColumn(getLabelFromType<std::decay_t<T>>().data(), key.data());
1369 } else {
1370 return "[MISSING]";
1371 }
1373}
1374
1375template <with_originals T, bool OPT = false>
1376static constexpr framework::ConcreteDataMatcher getMatcherFromTypeForKey(std::string_view key)
1377{
1378 auto locate = []<size_t... Is>(std::index_sequence<Is...>, std::string_view key) {
1379 return std::array{hasKeyM<T::originals[Is]>(key)...} |
1380 std::views::filter([](auto const& x) { return x.first; });
1381 }(std::make_index_sequence<T::originals.size()>{}, key);
1382 if (!locate.empty()) {
1383 return locate.front().second;
1384 }
1385
1386 if constexpr (!OPT) {
1387 notFoundColumn(getLabelFromType<std::decay_t<T>>().data(), key.data());
1388 } else {
1390 }
1392}
1393
1394template <typename B, typename... C>
1395consteval static bool hasIndexTo(framework::pack<C...>&&)
1396{
1397 return (o2::soa::is_binding_compatible_v<B, typename C::binding_t>() || ...);
1398}
1399
1400template <typename B, typename... C>
1401consteval static bool hasSortedIndexTo(framework::pack<C...>&&)
1402{
1403 return ((C::sorted && o2::soa::is_binding_compatible_v<B, typename C::binding_t>()) || ...);
1404}
1405
1406template <typename B, typename Z>
1407consteval static bool relatedByIndex()
1408{
1409 return hasIndexTo<B>(typename Z::table_t::external_index_columns_t{});
1410}
1411
1412template <typename B, typename Z>
1413consteval static bool relatedBySortedIndex()
1414{
1415 return hasSortedIndexTo<B>(typename Z::table_t::external_index_columns_t{});
1416}
1417} // namespace o2::soa
1418
1419namespace o2::framework
1420{
1423 static constexpr void isPreslicePolicy() {};
1424 const std::string binding;
1426
1427 bool isMissing() const;
1428 Entry const& getBindingKey() const;
1429};
1430
1437
1440
1442 std::span<const int64_t> getSliceFor(int value) const;
1443};
1444
1445template <soa::is_table T, is_preslice_policy Policy, bool OPT = false>
1446struct PresliceBase : public Policy {
1447 static constexpr void isPresliceContainer() {};
1448 constexpr static bool optional = OPT;
1449 using target_t = T;
1450 using policy_t = Policy;
1451 const std::string binding;
1452
1454 : 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})}, {}}
1455 {
1456 }
1457
1459 {
1460 if constexpr (OPT) {
1461 if (Policy::isMissing()) {
1462 return {nullptr, {0, 0}};
1463 }
1464 }
1465 return Policy::getSliceFor(value, input);
1466 }
1467
1468 std::span<const int64_t> getSliceFor(int value) const
1469 {
1470 if constexpr (OPT) {
1471 if (Policy::isMissing()) {
1472 return {};
1473 }
1474 }
1475 return Policy::getSliceFor(value);
1476 }
1477};
1478
1479template <soa::is_table T>
1481template <soa::is_table T>
1483template <soa::is_table T>
1485template <soa::is_table T>
1487
1501 static constexpr void isPresliceGroup() {};
1502};
1503} // namespace o2::framework
1504
1505namespace o2::soa
1506{
1507template <soa::is_table T>
1508class FilteredBase;
1509template <typename T>
1510class Filtered;
1511
1512// FIXME: compatbility declaration to be removed
1513template <typename T>
1515
1517template <typename... Is>
1518static consteval auto extractBindings(framework::pack<Is...>)
1519{
1520 return framework::pack<typename Is::binding_t...>{};
1521}
1522
1524
1525template <typename T, typename C, typename Policy, bool OPT>
1526 requires std::same_as<Policy, framework::PreslicePolicySorted> && (o2::soa::is_binding_compatible_v<C, T>())
1527auto doSliceBy(T const* table, o2::framework::PresliceBase<C, Policy, OPT> const& container, int value)
1528{
1529 if constexpr (OPT) {
1530 if (container.isMissing()) {
1531 missingOptionalPreslice(getLabelFromType<std::decay_t<T>>().data(), container.bindingKey.key.c_str());
1532 }
1533 }
1534 auto out = container.getSliceFor(value, table->asArrowTableRef());
1535 auto t = typename T::self_t({out});
1536 if (t.tableSize() != 0) {
1537 table->copyIndexBindings(t);
1538 t.bindInternalIndicesTo(table);
1539 }
1540 return t;
1541}
1542
1543template <soa::is_filtered_table T>
1544auto doSliceByHelper(T const* table, std::span<const int64_t> const& selection)
1545{
1546 auto t = soa::Filtered<typename T::base_t>({table->asArrowTableRef()}, selection);
1547 if (t.tableSize() != 0) {
1548 table->copyIndexBindings(t);
1549 t.bindInternalIndicesTo(table);
1550 t.intersectWithSelection(table->getSelectedRows()); // intersect filters
1551 }
1552 return t;
1553}
1554
1555template <soa::is_table T>
1556 requires(!soa::is_filtered_table<T>)
1557auto doSliceByHelper(T const* table, std::span<const int64_t> const& selection)
1558{
1559 auto t = soa::Filtered<T>({table->asArrowTableRef()}, selection);
1560 if (t.tableSize() != 0) {
1561 table->copyIndexBindings(t);
1562 t.bindInternalIndicesTo(table);
1563 }
1564 return t;
1565}
1566
1567template <typename T, typename C, typename Policy, bool OPT>
1568 requires std::same_as<Policy, framework::PreslicePolicyGeneral> && (o2::soa::is_binding_compatible_v<C, T>())
1569auto doSliceBy(T const* table, o2::framework::PresliceBase<C, Policy, OPT> const& container, int value)
1570{
1571 if constexpr (OPT) {
1572 if (container.isMissing()) {
1573 missingOptionalPreslice(getLabelFromType<std::decay_t<T>>().data(), container.bindingKey.key.c_str());
1574 }
1575 }
1576 auto selection = container.getSliceFor(value);
1577 return doSliceByHelper(table, selection);
1578}
1579
1580SelectionVector sliceSelection(std::span<int64_t const> const& mSelectedRows, int64_t nrows, uint64_t offset);
1581
1582template <soa::is_filtered_table T>
1584{
1585 if (slice.range.offset >= static_cast<uint64_t>(table->tableSize())) {
1587 if (fresult.tableSize() != 0) {
1588 table->copyIndexBindings(fresult);
1589 }
1590 return fresult;
1591 }
1592 auto slicedSelection = sliceSelection(table->getSelectedRows(), slice.range.size, slice.range.offset);
1593 Filtered<typename T::base_t> fresult{{slice}, std::move(slicedSelection)};
1594 if (fresult.tableSize() != 0) {
1595 table->copyIndexBindings(fresult);
1596 }
1597 return fresult;
1598}
1599
1600template <soa::is_filtered_table T, typename C, bool OPT>
1601 requires(o2::soa::is_binding_compatible_v<C, T>())
1603{
1604 if constexpr (OPT) {
1605 if (container.isMissing()) {
1606 missingOptionalPreslice(getLabelFromType<T>().data(), container.bindingKey.key.c_str());
1607 }
1608 }
1609 auto slice = container.getSliceFor(value, table->asArrowTableRef());
1610 return prepareFilteredSlice(table, slice);
1611}
1612
1614
1615template <soa::is_table T>
1617{
1618 auto localCache = cache.ptr->getCacheFor({"", originReplacement(cache.ptr->newOrigin)(o2::soa::getMatcherFromTypeForKey<T>(node.name)),
1619 node.name});
1620 auto [offset, count] = localCache.getSliceFor(value);
1621 auto t = typename T::self_t({table->asArrowTableRef().slice({static_cast<uint64_t>(offset), count})});
1622 if (t.tableSize() != 0) {
1623 table->copyIndexBindings(t);
1624 }
1625 return t;
1626}
1627
1628template <soa::is_filtered_table T>
1630{
1631 auto localCache = cache.ptr->getCacheFor({"", originReplacement(cache.ptr->newOrigin)(o2::soa::getMatcherFromTypeForKey<T>(node.name)),
1632 node.name});
1633 auto [offset, count] = localCache.getSliceFor(value);
1634 return prepareFilteredSlice(table, table->asArrowTableRef().slice({static_cast<uint64_t>(offset), count}));
1635}
1636
1637template <soa::is_table T>
1639{
1640 auto localCache = cache.ptr->getCacheUnsortedFor({"", originReplacement(cache.ptr->newOrigin)(o2::soa::getMatcherFromTypeForKey<T>(node.name)),
1641 node.name});
1642 if constexpr (soa::is_filtered_table<T>) {
1643 auto t = typename T::self_t({table->asArrowTableRef()}, localCache.getSliceFor(value));
1644 if (t.tableSize() != 0) {
1645 t.intersectWithSelection(table->getSelectedRows());
1646 table->copyIndexBindings(t);
1647 }
1648 return t;
1649 } else {
1650 auto t = Filtered<T>({table->asArrowTableRef()}, localCache.getSliceFor(value));
1651 if (t.tableSize() != 0) {
1652 table->copyIndexBindings(t);
1653 }
1654 return t;
1655 }
1656}
1657
1658template <with_originals T>
1660{
1661 return Filtered<T>({t.asArrowTableRef()}, selectionToVector(framework::expressions::createSelection(t.asArrowTable(), f)));
1662}
1663
1664arrow::ChunkedArray* getIndexFromLabel(arrow::Table* table, std::string_view label);
1665
1666template <typename D, typename O, typename IP, typename... C>
1667consteval auto base_iter(framework::pack<C...>&&) -> TableIterator<D, O, IP, C...>
1668{
1669}
1670template <TableRef ref, typename... Ts>
1671 requires((sizeof...(Ts) > 0) && (soa::is_column<Ts> && ...))
1672consteval auto getColumns()
1673{
1674 return framework::pack<Ts...>{};
1675}
1676
1677template <TableRef ref, typename... Ts>
1678 requires((sizeof...(Ts) > 0) && !(soa::is_column<Ts> || ...) && (ref.origin_hash == "CONC"_h))
1679consteval auto getColumns()
1680{
1681 return framework::full_intersected_pack_t<typename Ts::columns_t...>{};
1682}
1683
1684template <TableRef ref, typename... Ts>
1685 requires((sizeof...(Ts) > 0) && !(soa::is_column<Ts> || ...) && (ref.origin_hash != "CONC"_h))
1686consteval auto getColumns()
1687{
1688 return framework::concatenated_pack_unique_t<typename Ts::columns_t...>{};
1689}
1690
1691template <TableRef ref, typename... Ts>
1692 requires(sizeof...(Ts) == 0 && soa::has_metadata<aod::MetadataTrait<o2::aod::Hash<ref.desc_hash>>>)
1693consteval auto getColumns()
1694{
1695 return typename aod::MetadataTrait<o2::aod::Hash<ref.desc_hash>>::metadata::columns{};
1696}
1697
1698template <TableRef ref, typename... Ts>
1699 requires((sizeof...(Ts) == 0) || (o2::soa::is_column<Ts> && ...))
1700consteval auto computeOriginals()
1701{
1702 return std::array<TableRef, 1>{ref};
1703}
1704
1705template <TableRef ref, typename... Ts>
1706 requires((sizeof...(Ts) > 0) && (!(o2::soa::is_column<Ts> && ...)))
1708{
1709 return o2::soa::mergeOriginals<Ts...>();
1710}
1711
1714template <aod::is_aod_hash L, aod::is_aod_hash D, aod::is_origin_hash O, typename... Ts>
1716{
1717 public:
1718 static constexpr void isSOATable() {};
1719 static constexpr const auto ref = TableRef{L::hash, D::hash, O::hash, o2::aod::version(D::str)};
1720 using self_t = Table<L, D, O, Ts...>;
1722
1723 static constexpr const auto originals = computeOriginals<ref, Ts...>();
1724 static constexpr const auto originalLabels = []<size_t N, std::array<TableRef, N> refs, size_t... Is>(std::index_sequence<Is...>) consteval {
1725 return std::array<const char*, N>{o2::aod::label<refs[Is]>()...};
1726 }.template operator()<originals.size(), originals>(std::make_index_sequence<originals.size()>());
1727 static constexpr const uint32_t binding_origin = originals[0].origin_hash;
1729
1730 template <size_t N, std::array<TableRef, N> bindings>
1731 requires(ref.origin_hash == "CONC"_h)
1732 static consteval auto isIndexTargetOf()
1733 {
1734 return false;
1735 }
1736
1737 template <size_t N, std::array<TableRef, N> bindings>
1738 requires(ref.origin_hash == "JOIN"_h)
1739 static consteval auto isIndexTargetOf()
1740 {
1741 return std::ranges::any_of(self_t::originals,
1742 [](TableRef const& r) consteval {
1743 return std::ranges::any_of(bindings, [&r](TableRef const& b) { return b == r; });
1744 });
1745 }
1746
1747 template <size_t N, std::array<TableRef, N> bindings>
1748 requires(!(ref.origin_hash == "CONC"_h || ref.origin_hash == "JOIN"_h))
1749 static consteval auto isIndexTargetOf()
1750 {
1751 return std::find(bindings.begin(), bindings.end(), self_t::ref) != bindings.end();
1752 }
1753
1754 template <TableRef r>
1755 static consteval bool hasOriginal()
1756 {
1757 return std::ranges::any_of(originals, [](TableRef const& o) consteval { return o.desc_hash == r.desc_hash; });
1758 }
1759
1760 using columns_t = decltype(getColumns<ref, Ts...>());
1761
1762 static constexpr auto column_hashes = []<typename... C>(framework::pack<C...>) consteval {
1763 auto hashes = std::array{C::hash...};
1764 std::ranges::sort(hashes);
1765 return hashes;
1766 }(columns_t{});
1767
1769 using column_types = decltype([]<typename... C>(framework::pack<C...>) consteval -> framework::pack<typename C::type...> {}(persistent_columns_t{}));
1770
1773 template <typename IP>
1774 using base_iterator = decltype(base_iter<D, O, IP>(columns_t{}));
1775
1776 template <typename IP, typename Parent, typename... T>
1778 using columns_t = typename Parent::columns_t;
1779 using external_index_columns_t = typename Parent::external_index_columns_t;
1781 static constexpr auto originals = Parent::originals;
1782 using policy_t = IP;
1783 using parent_t = Parent;
1784
1786
1787 TableIteratorBase(arrow::ChunkedArray* columnData[framework::pack_size(columns_t{})], IP&& policy)
1788 : base_iterator<IP>(columnData, std::forward<decltype(policy)>(policy))
1789 {
1790 }
1791
1792 template <typename P, typename... Os>
1794 requires(P::ref.desc_hash == Parent::ref.desc_hash)
1795 {
1796 static_cast<base_iterator<IP>&>(*this) = static_cast<base_iterator<IP>>(other);
1797 return *this;
1798 }
1799
1800 template <typename P>
1802 {
1803 static_cast<base_iterator<IP>&>(*this) = static_cast<base_iterator<IP>>(other);
1804 return *this;
1805 }
1806
1807 template <typename P>
1809 requires std::same_as<IP, DefaultIndexPolicy>
1810 {
1811 static_cast<base_iterator<IP>&>(*this) = static_cast<base_iterator<FilteredIndexPolicy>>(other);
1812 return *this;
1813 }
1814
1815 template <typename P, typename O1, typename... Os>
1817 requires(P::ref.desc_hash == Parent::ref.desc_hash)
1818 {
1819 *this = other;
1820 }
1821
1822 template <typename P, typename O1, typename... Os>
1824 requires(P::ref.desc_hash == Parent::ref.desc_hash)
1825 {
1826 *this = other;
1827 }
1828
1829 template <typename P>
1834
1835 template <typename P>
1837 {
1838 *this = other;
1839 }
1840
1841 template <typename P>
1843 requires std::same_as<IP, DefaultIndexPolicy>
1844 {
1845 *this = other;
1846 }
1847
1849 {
1850 this->mRowIndex = other.index;
1851 return *this;
1852 }
1853 template <typename P>
1855 {
1856 this->mRowIndex = other.mRowIndex;
1857 }
1858
1859 template <typename P, typename... Os>
1861 requires std::same_as<typename P::table_t, typename Parent::table_t>
1862 {
1863 this->mRowIndex = other.mRowIndex;
1864 }
1865
1866 template <typename TI>
1867 auto getId() const
1868 {
1869 using decayed = std::decay_t<TI>;
1870 if constexpr (framework::has_type<decayed>(bindings_pack_t{})) { // index to another table
1871 constexpr auto idx = framework::has_type_at_v<decayed>(bindings_pack_t{});
1873 } else if constexpr (std::same_as<decayed, Parent>) { // self index
1874 return this->globalIndex();
1875 } else if constexpr (is_indexing_column<decayed>) { // soa::Index<>
1876 return this->globalIndex();
1877 } else {
1878 return static_cast<int32_t>(-1);
1879 }
1880 }
1881
1882 template <typename CD, typename... CDArgs>
1883 auto getDynamicColumn() const
1884 {
1885 using decayed = std::decay_t<CD>;
1886 static_assert(is_dynamic_t<decayed>(), "Requested column is not a dynamic column");
1887 return static_cast<decayed>(*this).template getDynamicValue<CDArgs...>();
1888 }
1889
1890 template <typename B, typename CC>
1891 auto getValue() const
1892 {
1893 using COL = std::decay_t<CC>;
1894 static_assert(is_dynamic_t<COL>() || soa::is_persistent_column<COL>, "Should be persistent or dynamic column with no argument that has a return type convertable to float");
1895 return static_cast<B>(static_cast<COL>(*this).get());
1896 }
1897
1898 template <typename B, typename... CCs>
1899 std::array<B, sizeof...(CCs)> getValues() const
1900 {
1901 static_assert(std::same_as<B, float> || std::same_as<B, double>, "The common return type should be float or double");
1902 return {getValue<B, CCs>()...};
1903 }
1904
1905 using IP::size;
1906
1907 using base_iterator<IP>::operator++;
1908
1911 {
1912 TableIteratorBase copy = *this;
1913 copy.moveByIndex(inc);
1914 return copy;
1915 }
1916
1918 {
1919 return operator+(-dec);
1920 }
1921
1923 {
1924 return *this;
1925 }
1926 };
1927
1928 template <typename IP, typename Parent, typename... T>
1930
1931 template <typename IP, typename Parent>
1932 using iterator_template_o = decltype([]() {
1933 if constexpr (sizeof...(Ts) == 0) {
1935 } else {
1936 if constexpr ((o2::soa::is_column<Ts> && ...)) {
1937 return iterator_template<IP, Parent>{};
1938 } else {
1939 return iterator_template<IP, Parent, Ts...>{};
1940 }
1941 }
1942 }());
1943
1946
1950
1952 : mArrowTableRef(tableRef),
1953 mEnd{tableRef.range.size}
1954 {
1955 if (mArrowTableRef.tablePtr->num_rows() == 0) {
1956 for (size_t ci = 0; ci < framework::pack_size(columns_t{}); ++ci) {
1957 mColumnChunks[ci] = nullptr;
1958 }
1959 mBegin = mEnd;
1960 } else {
1961 auto lookups = [this]<typename... C>(framework::pack<C...>) -> std::array<arrow::ChunkedArray*, framework::pack_size(columns_t{})> { return {lookupColumn<C>()...}; }(columns_t{});
1962 for (size_t ci = 0; ci < framework::pack_size(columns_t{}); ++ci) {
1963 mColumnChunks[ci] = lookups[ci];
1964 }
1965 mBegin = unfiltered_iterator{mColumnChunks, {mEnd.index, mArrowTableRef.range.offset}};
1966 mBegin.bindInternalIndices(this);
1967 }
1968 }
1969
1970 Table(std::shared_ptr<arrow::Table> table)
1971 : Table(o2::soa::ArrowTableRef{table})
1972 {
1973 }
1974
1975 Table(std::vector<o2::soa::ArrowTableRef>&& tables)
1976 requires(ref.origin_hash != "CONC"_h)
1977 : Table(ArrowHelpers::joinTables(std::forward<std::vector<o2::soa::ArrowTableRef>>(tables), std::span{originalLabels}))
1978 {
1979 }
1980
1981 Table(std::vector<o2::soa::ArrowTableRef>&& tables)
1982 requires(ref.origin_hash == "CONC"_h)
1983 : Table(ArrowHelpers::concatTables(std::forward<std::vector<o2::soa::ArrowTableRef>>(tables)))
1984 {
1985 }
1986
1987 Table(std::vector<std::shared_ptr<arrow::Table>>&& tables)
1988 requires(ref.origin_hash != "CONC"_h)
1989 : Table(ArrowHelpers::joinTables(std::forward<std::vector<std::shared_ptr<arrow::Table>>>(tables)))
1990 {
1991 }
1992
1993 Table(std::vector<std::shared_ptr<arrow::Table>>&& tables)
1994 requires(ref.origin_hash == "CONC"_h)
1995 : Table(ArrowHelpers::concatTables(std::forward<std::vector<std::shared_ptr<arrow::Table>>>(tables)))
1996 {
1997 }
1998
1999 template <typename Key>
2000 inline arrow::ChunkedArray* getIndexToKey()
2001 {
2002 constexpr auto map = []<typename... Cs>(framework::pack<Cs...>) consteval {
2003 return std::array<bool, sizeof...(Cs)>{[]() {
2004 if constexpr (requires { Cs::index_targets.size(); }) {
2005 return Key::template isIndexTargetOf<Cs::index_targets.size(), Cs::index_targets>();
2006 } else {
2007 return false;
2008 }
2009 }()...};
2011 constexpr auto pos = std::find(map.begin(), map.end(), true);
2012 if constexpr (pos != map.end()) {
2013 return mColumnChunks[std::distance(map.begin(), pos)];
2014 } else {
2015 static_assert(framework::always_static_assert_v<Key>, "This table does not have an index to given Key");
2016 }
2017 }
2018
2020 {
2021 return mBegin;
2022 }
2023
2024 auto const& cached_begin() const
2025 {
2026 return mBegin;
2027 }
2028
2030 {
2031 return unfiltered_iterator(mBegin);
2032 }
2033
2035 {
2036 return RowViewSentinel{mEnd};
2037 }
2038
2039 filtered_iterator filtered_begin(std::span<int64_t const> selection)
2040 {
2041 // Note that the FilteredIndexPolicy will never outlive the selection which
2042 // is held by the table, so we are safe passing the bare pointer. If it does it
2043 // means that the iterator on a table is outliving the table itself, which is
2044 // a bad idea.
2045 return filtered_iterator(mColumnChunks, {selection, mArrowTableRef.tablePtr->num_rows(), mArrowTableRef.range.offset});
2046 }
2047
2049 {
2050 return rawIteratorAt(i);
2051 }
2052
2054 {
2055 auto it = mBegin;
2056 it.setCursor(i);
2057 return it;
2058 }
2059
2061 {
2062 return unfiltered_const_iterator(mBegin);
2063 }
2064
2065 [[nodiscard]] RowViewSentinel end() const
2066 {
2067 return RowViewSentinel{mEnd};
2068 }
2069
2071 [[nodiscard]] std::shared_ptr<arrow::Table> asArrowTable() const
2072 {
2073 return mArrowTableRef.tablePtr;
2074 }
2075
2076 [[nodiscard]] std::shared_ptr<arrow::Table> asArrowTableConstrained() const
2077 {
2078 return mArrowTableRef.tablePtr->Slice(mArrowTableRef.range.offset, mArrowTableRef.range.size);
2079 }
2080
2081 [[nodiscard]] ArrowTableRef asArrowTableRef() const
2082 {
2083 return mArrowTableRef;
2084 }
2086 auto offset() const
2087 {
2088 return mArrowTableRef.range.offset;
2089 }
2091 [[nodiscard]] int64_t size() const
2092 {
2093 return mArrowTableRef.range.size;
2094 }
2095
2096 [[nodiscard]] int64_t tableSize() const
2097 {
2098 return size();
2099 }
2100
2103 template <typename... TA>
2104 void bindExternalIndices(TA*... current)
2105 {
2106 ([this](TA* cur) {
2107 if constexpr (binding_origin == TA::binding_origin) {
2108 mBegin.bindExternalIndex(cur);
2109 }
2110 }(current),
2111 ...);
2112 }
2113
2114 template <typename TA>
2115 void bindExternalIndex(TA* current)
2116 {
2117 mBegin.bindExternalIndex(current); // unchecked binding for the derived tables
2118 }
2119
2120 template <typename I>
2122 {
2123 mBegin.bindInternalIndices(ptr);
2124 }
2125
2130
2131 template <typename... Cs>
2133 {
2134 (static_cast<Cs>(mBegin).setCurrentRaw(binding), ...);
2135 }
2136
2137 void bindExternalIndicesRaw(std::vector<o2::soa::Binding>&& ptrs)
2138 {
2139 mBegin.bindExternalIndicesRaw(std::forward<std::vector<o2::soa::Binding>>(ptrs));
2140 }
2141
2142 template <typename T, typename... Cs>
2144 {
2145 dest.bindExternalIndicesRaw(mBegin.getIndexBindings());
2146 }
2147
2148 template <typename T>
2149 void copyIndexBindings(T& dest) const
2150 {
2152 }
2153
2155 {
2156 auto t = o2::soa::select(*this, f);
2158 return t;
2159 }
2160
2162 {
2163 return doSliceByCached(this, node, value, cache);
2164 }
2165
2170
2171 template <typename T1, typename Policy, bool OPT>
2173 {
2174 return doSliceBy(this, container, value);
2175 }
2176
2178 {
2179 return self_t{mArrowTableRef.slice({start, static_cast<int64_t>(end - start + 1)})};
2180 }
2181
2182 auto emptySlice() const
2183 {
2184 return self_t{mArrowTableRef.makeEmpty()};
2185 }
2186
2188 {
2189 mBegin.setPointerReconstructor(pointerReconstructor);
2190 }
2191
2192 private:
2193 template <typename T>
2194 arrow::ChunkedArray* lookupColumn()
2195 {
2196 return nullptr;
2197 }
2198
2199 template <soa::is_persistent_column T>
2200 arrow::ChunkedArray* lookupColumn()
2201 {
2202 return getIndexFromLabel(mArrowTableRef.tablePtr.get(), T::columnLabel());
2203 }
2204
2205 ArrowTableRef mArrowTableRef;
2206 // std::shared_ptr<arrow::Table> mTable = nullptr;
2207 // uint64_t mOffset = 0;
2208 // Cached pointers to the ChunkedArray associated to a column
2209 arrow::ChunkedArray* mColumnChunks[framework::pack_size(columns_t{})];
2210 RowViewSentinel mEnd;
2211 iterator mBegin;
2212};
2213
2214template <uint32_t D, soa::is_column... C>
2216
2217void getterNotFound(const char* targetColumnLabel);
2218void emptyColumnLabel();
2219
2220namespace row_helpers
2221{
2222template <typename R, typename T, typename C>
2223R getColumnValue(const T& rowIterator)
2224{
2225 return static_cast<R>(static_cast<C>(rowIterator).get());
2226}
2227
2228namespace
2229{
2230template <typename R, typename T>
2231using ColumnGetterFunction = R (*)(const T&);
2232
2233template <typename T, typename R>
2235 // lambda is callable without additional free args
2236 framework::pack_size(typename T::bindings_t{}) == framework::pack_size(typename T::callable_t::args{}) &&
2237 requires(T t) {
2238 { t.get() } -> std::convertible_to<R>;
2239 };
2240
2241template <typename T, typename R>
2243 { t.get() } -> std::convertible_to<R>;
2244};
2245
2246template <typename R, typename T, persistent_with_common_getter<R> C>
2247ColumnGetterFunction<R, T> createGetterPtr(const std::string_view& targetColumnLabel)
2248{
2249 return targetColumnLabel == C::columnLabel() ? &getColumnValue<R, T, C> : nullptr;
2250}
2251
2252template <typename R, typename T, dynamic_with_common_getter<R> C>
2253ColumnGetterFunction<R, T> createGetterPtr(const std::string_view& targetColumnLabel)
2254{
2255 std::string_view columnLabel(C::columnLabel());
2256
2257 // allows user to use consistent formatting (with prefix) of all column labels
2258 // by default there isn't 'f' prefix for dynamic column labels
2259 if (targetColumnLabel.starts_with("f") && targetColumnLabel.substr(1) == columnLabel) {
2260 return &getColumnValue<R, T, C>;
2261 }
2262
2263 // check also exact match if user is aware of prefix missing
2264 if (targetColumnLabel == columnLabel) {
2265 return &getColumnValue<R, T, C>;
2266 }
2267
2268 return nullptr;
2269}
2270
2271template <typename R, typename T, typename... Cs>
2272ColumnGetterFunction<R, T> getColumnGetterByLabel(o2::framework::pack<Cs...>, const std::string_view& targetColumnLabel)
2273{
2274 ColumnGetterFunction<R, T> func;
2275
2276 (void)((func = createGetterPtr<R, T, Cs>(targetColumnLabel), func) || ...);
2277
2278 if (!func) {
2279 getterNotFound(targetColumnLabel.data());
2280 }
2281
2282 return func;
2283}
2284
2285template <typename T, typename R>
2286using with_common_getter_t = typename std::conditional<persistent_with_common_getter<T, R> || dynamic_with_common_getter<T, R>, std::true_type, std::false_type>::type;
2287} // namespace
2288
2289template <typename R, typename T>
2290ColumnGetterFunction<R, typename T::iterator> getColumnGetterByLabel(const std::string_view& targetColumnLabel)
2291{
2292 using TypesWithCommonGetter = o2::framework::selected_pack_multicondition<with_common_getter_t, framework::pack<R>, typename T::columns_t>;
2293
2294 if (targetColumnLabel.size() == 0) {
2296 }
2297
2298 return getColumnGetterByLabel<R, typename T::iterator>(TypesWithCommonGetter{}, targetColumnLabel);
2299}
2300} // namespace row_helpers
2301} // namespace o2::soa
2302
2303namespace o2::aod
2304{
2305// If you get an error about not satisfying is_origin_hash, you need to add
2306// an entry here.
2308O2ORIGIN("AOD1");
2309O2ORIGIN("AOD2");
2311
2312O2ORIGIN("JOIN");
2313O2HASH("JOIN/0");
2314
2315O2ORIGIN("CONC");
2316O2HASH("CONC/0");
2317
2318O2ORIGIN("TEST");
2319O2HASH("TEST/0");
2320} // namespace o2::aod
2321
2322#define DECLARE_EQUIVALENT_FOR_INDEX(_Base_, _Equiv_) \
2323 template <> \
2324 struct EquivalentIndexNG<o2::aod::Hash<_Base_::ref.desc_hash>, o2::aod::Hash<_Equiv_::ref.desc_hash>> { \
2325 constexpr static bool value = true; \
2326 }
2327
2328#define DECLARE_EQUIVALENT_FOR_INDEX_NG(_Base_, _Equiv_) \
2329 template <> \
2330 struct EquivalentIndexNG<o2::aod::Hash<_Base_ ""_h>, o2::aod::Hash<_Equiv_ ""_h>> { \
2331 constexpr static bool value = true; \
2332 }
2333
2334#define DECLARE_SOA_COLUMN_FULL(_Name_, _Getter_, _Type_, _Label_) \
2335 struct _Name_ : o2::soa::Column<_Type_, _Name_> { \
2336 static constexpr const char* mLabel = _Label_; \
2337 static constexpr const uint32_t hash = compile_time_hash(o2::framework::namespace_prefix<_Name_>(), std::string_view{#_Getter_}); \
2338 static_assert(!((*(mLabel + 1) == 'I' && *(mLabel + 2) == 'n' && *(mLabel + 3) == 'd' && *(mLabel + 4) == 'e' && *(mLabel + 5) == 'x')), "Index is not a valid column name"); \
2339 using base = o2::soa::Column<_Type_, _Name_>; \
2340 using type = _Type_; \
2341 using column_t = _Name_; \
2342 _Name_(arrow::ChunkedArray const* column) \
2343 : o2::soa::Column<_Type_, _Name_>(o2::soa::ColumnIterator<type>(column)) \
2344 { \
2345 } \
2346 \
2347 _Name_() = default; \
2348 _Name_(_Name_ const& other) = default; \
2349 _Name_& operator=(_Name_ const& other) = default; \
2350 \
2351 decltype(auto) _Getter_() const \
2352 { \
2353 return *mColumnIterator; \
2354 } \
2355 \
2356 decltype(auto) get() const \
2357 { \
2358 return _Getter_(); \
2359 } \
2360 }; \
2361 [[maybe_unused]] static constexpr o2::framework::expressions::BindingNode _Getter_ { _Label_, _Name_::hash, o2::framework::expressions::selectArrowType<_Type_>() }
2362
2363#define DECLARE_SOA_CCDB_COLUMN_FULL(_Name_, _Label_, _Getter_, _ConcreteType_, _CCDBQuery_, _RunDependent_, ...) \
2364 struct _Name_ : o2::soa::Column<int64_t[3], _Name_> { \
2365 static constexpr const char* mLabel = _Label_; \
2366 static constexpr const char* query = _CCDBQuery_; \
2367 /* How the object is keyed in CCDB: 0 queries by timestamp alone, 1 additionally sends */ \
2368 /* the run number as "runNumber" metadata (o2::ccdb run-dependent objects), 2 uses the */ \
2369 /* run number in place of the timestamp. A non-zero value needs the column's table to */ \
2370 /* be uniform in the run number, since that is where the run comes from. */ \
2371 static constexpr int run_dependent = _RunDependent_; \
2372 static constexpr const uint32_t hash = compile_time_hash(o2::framework::namespace_prefix<_Name_>(), std::string_view{#_Getter_}); \
2373 static constexpr bool needs_ptr_rec = true; \
2374 /* Post-deserialisation fixup for objects which are not usable straight out of the ROOT */ \
2375 /* streamer, e.g. FlatObjects whose internal pointers must be rectified first. Runs on */ \
2376 /* the receiving device, once per (re)deserialisation, before the object is ever handed */ \
2377 /* out. Returns the object to cache: a finaliser returning a different instance owns */ \
2378 /* disposing of the one it was given. */ \
2379 using finaliser_t = _ConcreteType_* (*)(_ConcreteType_*); \
2380 static constexpr finaliser_t finalise = __VA_ARGS__; \
2381 std::function<std::byte*(fair::mq::shmem::MetaHeader&&)> const* ptrRec = nullptr; \
2382 using base = o2::soa::Column<int64_t[3], _Name_>; \
2383 using type = int64_t[3]; \
2384 using column_t = _Name_; \
2385 _Name_(arrow::ChunkedArray const* column) \
2386 : o2::soa::Column<int64_t[3], _Name_>(o2::soa::ColumnIterator<int64_t[3]>(column)) \
2387 { \
2388 } \
2389 \
2390 _Name_() = default; \
2391 _Name_(_Name_ const& other) = default; \
2392 _Name_& operator=(_Name_ const& other) = default; \
2393 \
2394 decltype(auto) _Getter_() const \
2395 { \
2396 auto& [handle, segment, size] = *mColumnIterator; \
2397 auto span = std::span<std::byte>{(*ptrRec)(fair::mq::shmem::MetaHeader{ \
2398 static_cast<size_t>(size), \
2399 0, handle, 0, 0, \
2400 static_cast<uint16_t>(segment), true}), \
2401 static_cast<size_t>(size)}; \
2402 if constexpr (std::same_as<_ConcreteType_, std::span<std::byte>>) { \
2403 return span; \
2404 } else { \
2405 static std::byte* payload = nullptr; \
2406 static _ConcreteType_* deserialised = nullptr; \
2407 static TClass* c = TClass::GetClass(#_ConcreteType_); \
2408 if (payload != (std::byte*)span.data()) { \
2409 payload = (std::byte*)span.data(); \
2410 delete deserialised; \
2411 TBufferFile f(TBufferFile::EMode::kRead, span.size(), (char*)span.data(), kFALSE); \
2412 auto* streamed = (_ConcreteType_*)soa::extractCCDBPayload((char*)payload, span.size(), c, "ccdb_object"); \
2413 if (!streamed) { \
2414 LOGP(fatal, \
2415 "Could not deserialise a {} from the CCDB payload for {} ({} bytes). Check the configured " \
2416 "path (option \"ccdb:{}\") and that the object exists for this timestamp.", \
2417 #_ConcreteType_, _CCDBQuery_, span.size(), _Label_); \
2418 } \
2419 deserialised = finalise(streamed); \
2420 } \
2421 return *deserialised; \
2422 } \
2423 } \
2424 \
2425 decltype(auto) \
2426 get() const \
2427 { \
2428 return _Getter_(); \
2429 } \
2430 };
2431
2432/* Conventional label, and the object used exactly as the ROOT streamer produced it. Reach
2433 for DECLARE_SOA_CCDB_COLUMN_FULL when it needs finalising first — a FlatObject whose
2434 pointers must be rectified, say. Its finaliser is the trailing argument, so commas in a
2435 lambda body are absorbed by __VA_ARGS__. */
2436#define DECLARE_SOA_CCDB_COLUMN(_Name_, _Getter_, _ConcreteType_, _CCDBQuery_) \
2437 DECLARE_SOA_CCDB_COLUMN_FULL(_Name_, "f" #_Name_, _Getter_, _ConcreteType_, _CCDBQuery_, 0, \
2438 [](_ConcreteType_* ccdbObject) { return ccdbObject; })
2439
2440#define DECLARE_SOA_COLUMN(_Name_, _Getter_, _Type_) \
2441 DECLARE_SOA_COLUMN_FULL(_Name_, _Getter_, _Type_, "f" #_Name_)
2442
2445#define MAKEINT(_Size_) uint##_Size_##_t
2446
2447#define DECLARE_SOA_BITMAP_COLUMN_FULL(_Name_, _Getter_, _Size_, _Label_) \
2448 struct _Name_ : o2::soa::Column<MAKEINT(_Size_), _Name_> { \
2449 static constexpr const char* mLabel = _Label_; \
2450 static constexpr const uint32_t hash = compile_time_hash(o2::framework::namespace_prefix<_Name_>(), std::string_view{#_Getter_}); \
2451 static_assert(!((*(mLabel + 1) == 'I' && *(mLabel + 2) == 'n' && *(mLabel + 3) == 'd' && *(mLabel + 4) == 'e' && *(mLabel + 5) == 'x')), "Index is not a valid column name"); \
2452 using base = o2::soa::Column<MAKEINT(_Size_), _Name_>; \
2453 using type = MAKEINT(_Size_); \
2454 _Name_(arrow::ChunkedArray const* column) \
2455 : o2::soa::Column<type, _Name_>(o2::soa::ColumnIterator<type>(column)) \
2456 { \
2457 } \
2458 \
2459 _Name_() = default; \
2460 _Name_(_Name_ const& other) = default; \
2461 _Name_& operator=(_Name_ const& other) = default; \
2462 \
2463 decltype(auto) _Getter_##_raw() const \
2464 { \
2465 return *mColumnIterator; \
2466 } \
2467 \
2468 bool _Getter_##_bit(int bit) const \
2469 { \
2470 return (*mColumnIterator & (static_cast<type>(1) << bit)) >> bit; \
2471 } \
2472 }; \
2473 [[maybe_unused]] static constexpr o2::framework::expressions::BindingNode _Getter_ { _Label_, _Name_::hash, o2::framework::expressions::selectArrowType<MAKEINT(_Size_)>() }
2474
2475#define DECLARE_SOA_BITMAP_COLUMN(_Name_, _Getter_, _Size_) \
2476 DECLARE_SOA_BITMAP_COLUMN_FULL(_Name_, _Getter_, _Size_, "f" #_Name_)
2477
2480#define DECLARE_SOA_EXPRESSION_COLUMN_FULL(_Name_, _Getter_, _Type_, _Label_, _Expression_) \
2481 struct _Name_ : o2::soa::Column<_Type_, _Name_> { \
2482 static constexpr const char* mLabel = _Label_; \
2483 static constexpr const uint32_t hash = compile_time_hash(o2::framework::namespace_prefix<_Name_>(), std::string_view{#_Getter_}); \
2484 using base = o2::soa::Column<_Type_, _Name_>; \
2485 using type = _Type_; \
2486 using column_t = _Name_; \
2487 using spawnable_t = std::true_type; \
2488 _Name_(arrow::ChunkedArray const* column) \
2489 : o2::soa::Column<_Type_, _Name_>(o2::soa::ColumnIterator<type>(column)) \
2490 { \
2491 } \
2492 \
2493 _Name_() = default; \
2494 _Name_(_Name_ const& other) = default; \
2495 _Name_& operator=(_Name_ const& other) = default; \
2496 \
2497 decltype(auto) _Getter_() const \
2498 { \
2499 return *mColumnIterator; \
2500 } \
2501 \
2502 decltype(auto) get() const \
2503 { \
2504 return _Getter_(); \
2505 } \
2506 \
2507 static o2::framework::expressions::Projector Projector() \
2508 { \
2509 return _Expression_; \
2510 } \
2511 }; \
2512 [[maybe_unused]] static constexpr o2::framework::expressions::BindingNode _Getter_ { _Label_, _Name_::hash, o2::framework::expressions::selectArrowType<_Type_>() }
2513
2514#define DECLARE_SOA_EXPRESSION_COLUMN(_Name_, _Getter_, _Type_, _Expression_) \
2515 DECLARE_SOA_EXPRESSION_COLUMN_FULL(_Name_, _Getter_, _Type_, "f" #_Name_, _Expression_)
2516
2519#define DECLARE_SOA_CONFIGURABLE_EXPRESSION_COLUMN(_Name_, _Getter_, _Type_, _Label_) \
2520 struct _Name_ : o2::soa::Column<_Type_, _Name_> { \
2521 static constexpr const char* mLabel = _Label_; \
2522 static constexpr const uint32_t hash = compile_time_hash(o2::framework::namespace_prefix<_Name_>(), std::string_view{#_Getter_}); \
2523 static constexpr const int32_t mHash = _Label_ ""_h; \
2524 using base = o2::soa::Column<_Type_, _Name_>; \
2525 using type = _Type_; \
2526 using column_t = _Name_; \
2527 using spawnable_t = std::true_type; \
2528 _Name_(arrow::ChunkedArray const* column) \
2529 : o2::soa::Column<_Type_, _Name_>(o2::soa::ColumnIterator<type>(column)) \
2530 { \
2531 } \
2532 \
2533 _Name_() = default; \
2534 _Name_(_Name_ const& other) = default; \
2535 _Name_& operator=(_Name_ const& other) = default; \
2536 \
2537 decltype(auto) _Getter_() const \
2538 { \
2539 return *mColumnIterator; \
2540 } \
2541 \
2542 decltype(auto) get() const \
2543 { \
2544 return _Getter_(); \
2545 } \
2546 }; \
2547 [[maybe_unused]] static constexpr o2::framework::expressions::BindingNode _Getter_ { _Label_, _Name_::hash, o2::framework::expressions::selectArrowType<_Type_>() }
2548
2567
2569
2570template <o2::soa::is_table T>
2571consteval auto getIndexTargets()
2572{
2573 return T::originals;
2574}
2575
2576#define DECLARE_SOA_SLICE_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, _Type_, _Table_, _Label_, _Suffix_) \
2577 struct _Name_##IdSlice : o2::soa::Column<_Type_[2], _Name_##IdSlice> { \
2578 static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
2579 static_assert((*_Suffix_ == '\0') || (*_Suffix_ == '_'), "Suffix has to begin with _"); \
2580 static constexpr const char* mLabel = "fIndexSlice" _Label_ _Suffix_; \
2581 static constexpr const uint32_t hash = 0; \
2582 using base = o2::soa::Column<_Type_[2], _Name_##IdSlice>; \
2583 using type = _Type_[2]; \
2584 using column_t = _Name_##IdSlice; \
2585 using binding_t = _Table_; \
2586 static constexpr auto index_targets = getIndexTargets<_Table_>(); \
2587 _Name_##IdSlice(arrow::ChunkedArray const* column) \
2588 : o2::soa::Column<_Type_[2], _Name_##IdSlice>(o2::soa::ColumnIterator<type>(column)) \
2589 { \
2590 } \
2591 \
2592 _Name_##IdSlice() = default; \
2593 _Name_##IdSlice(_Name_##IdSlice const& other) = default; \
2594 _Name_##IdSlice& operator=(_Name_##IdSlice const& other) = default; \
2595 std::array<_Type_, 2> inline getIds() const \
2596 { \
2597 return _Getter_##Ids(); \
2598 } \
2599 \
2600 bool has_##_Getter_() const \
2601 { \
2602 auto a = *mColumnIterator; \
2603 return a[0] >= 0 && a[1] >= 0; \
2604 } \
2605 \
2606 std::array<_Type_, 2> _Getter_##Ids() const \
2607 { \
2608 auto a = *mColumnIterator; \
2609 return std::array{a[0], a[1]}; \
2610 } \
2611 \
2612 template <typename T> \
2613 auto _Getter_##_as() const \
2614 { \
2615 if (O2_BUILTIN_UNLIKELY(mBinding.ptr == nullptr)) { \
2616 o2::soa::notBoundTable(#_Table_); \
2617 } \
2618 auto t = mBinding.get<T>(); \
2619 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2620 o2::soa::dereferenceWithWrongType(#_Getter_, #_Table_); \
2621 } \
2622 if (O2_BUILTIN_UNLIKELY(!has_##_Getter_())) { \
2623 return t->emptySlice(); \
2624 } \
2625 auto a = *mColumnIterator; \
2626 auto r = t->rawSlice(a[0], a[1]); \
2627 t->copyIndexBindings(r); \
2628 r.bindInternalIndicesTo(t); \
2629 return r; \
2630 } \
2631 \
2632 auto _Getter_() const \
2633 { \
2634 return _Getter_##_as<binding_t>(); \
2635 } \
2636 \
2637 template <typename T> \
2638 bool setCurrent(T const* current) \
2639 { \
2640 if constexpr (o2::soa::is_binding_compatible_v<T, binding_t>()) { \
2641 assert(current != nullptr); \
2642 this->mBinding.bind(current); \
2643 return true; \
2644 } \
2645 return false; \
2646 } \
2647 \
2648 bool setCurrentRaw(o2::soa::Binding current) \
2649 { \
2650 this->mBinding = current; \
2651 return true; \
2652 } \
2653 binding_t const* getCurrent() const { return mBinding.get<binding_t>(); } \
2654 o2::soa::Binding getCurrentRaw() const { return mBinding; } \
2655 o2::soa::Binding mBinding; \
2656 };
2657
2658#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_)
2659#define DECLARE_SOA_SLICE_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_SLICE_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, _Name_##s, "")
2660#define DECLARE_SOA_SLICE_INDEX_COLUMN_CUSTOM(_Name_, _Getter_, _Label_) DECLARE_SOA_SLICE_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, int32_t, _Name_##s, _Label_, "")
2661
2663#define DECLARE_SOA_ARRAY_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, _Type_, _Table_, _Label_, _Suffix_) \
2664 struct _Name_##Ids : o2::soa::Column<std::vector<_Type_>, _Name_##Ids> { \
2665 static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
2666 static_assert((*_Suffix_ == '\0') || (*_Suffix_ == '_'), "Suffix has to begin with _"); \
2667 static constexpr const char* mLabel = "fIndexArray" _Label_ _Suffix_; \
2668 static constexpr const uint32_t hash = 0; \
2669 using base = o2::soa::Column<std::vector<_Type_>, _Name_##Ids>; \
2670 using type = std::vector<_Type_>; \
2671 using column_t = _Name_##Ids; \
2672 using binding_t = _Table_; \
2673 static constexpr auto index_targets = getIndexTargets<_Table_>(); \
2674 _Name_##Ids(arrow::ChunkedArray const* column) \
2675 : o2::soa::Column<std::vector<_Type_>, _Name_##Ids>(o2::soa::ColumnIterator<type>(column)) \
2676 { \
2677 } \
2678 \
2679 _Name_##Ids() = default; \
2680 _Name_##Ids(_Name_##Ids const& other) = default; \
2681 _Name_##Ids& operator=(_Name_##Ids const& other) = default; \
2682 \
2683 gsl::span<const _Type_> inline getIds() const \
2684 { \
2685 return _Getter_##Ids(); \
2686 } \
2687 \
2688 gsl::span<const _Type_> _Getter_##Ids() const \
2689 { \
2690 return *mColumnIterator; \
2691 } \
2692 \
2693 bool has_##_Getter_() const \
2694 { \
2695 return !(*mColumnIterator).empty(); \
2696 } \
2697 \
2698 template <soa::is_table T> \
2699 auto _Getter_##_as() const \
2700 { \
2701 if (O2_BUILTIN_UNLIKELY(mBinding.ptr == nullptr)) { \
2702 o2::soa::notBoundTable(#_Table_); \
2703 } \
2704 auto t = mBinding.get<T>(); \
2705 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2706 o2::soa::dereferenceWithWrongType(#_Getter_, #_Table_); \
2707 } \
2708 auto result = std::vector<typename T::unfiltered_iterator>(); \
2709 result.reserve((*mColumnIterator).size()); \
2710 for (auto& i : *mColumnIterator) { \
2711 result.emplace_back(t->rawIteratorAt(i)); \
2712 } \
2713 return result; \
2714 } \
2715 \
2716 template <soa::is_filtered_table T> \
2717 auto filtered_##_Getter_##_as() const \
2718 { \
2719 if (O2_BUILTIN_UNLIKELY(mBinding.ptr == nullptr)) { \
2720 o2::soa::notBoundTable(#_Table_); \
2721 } \
2722 auto t = mBinding.get<T>(); \
2723 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2724 o2::soa::dereferenceWithWrongType(#_Getter_, #_Table_); \
2725 } \
2726 auto result = std::vector<typename T::iterator>(); \
2727 result.reserve((*mColumnIterator).size()); \
2728 for (auto const& i : *mColumnIterator) { \
2729 auto pos = t->isInSelectedRows(i); \
2730 if (pos > 0) { \
2731 result.emplace_back(t->iteratorAt(pos)); \
2732 } \
2733 } \
2734 return result; \
2735 } \
2736 \
2737 auto _Getter_() const \
2738 { \
2739 return _Getter_##_as<binding_t>(); \
2740 } \
2741 \
2742 template <typename T> \
2743 auto _Getter_##_first_as() const \
2744 { \
2745 if (O2_BUILTIN_UNLIKELY(mBinding.ptr == nullptr)) { \
2746 o2::soa::notBoundTable(#_Table_); \
2747 } \
2748 auto t = mBinding.get<T>(); \
2749 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2750 o2::soa::dereferenceWithWrongType(#_Getter_, #_Table_); \
2751 } \
2752 return t->rawIteratorAt((*mColumnIterator)[0]); \
2753 } \
2754 \
2755 template <typename T> \
2756 auto _Getter_##_last_as() const \
2757 { \
2758 if (O2_BUILTIN_UNLIKELY(mBinding.ptr == nullptr)) { \
2759 o2::soa::notBoundTable(#_Table_); \
2760 } \
2761 auto t = mBinding.get<T>(); \
2762 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2763 o2::soa::dereferenceWithWrongType(#_Getter_, #_Table_); \
2764 } \
2765 return t->rawIteratorAt((*mColumnIterator).back()); \
2766 } \
2767 \
2768 auto _Getter_first() const \
2769 { \
2770 return _Getter_##_first_as<binding_t>(); \
2771 } \
2772 \
2773 auto _Getter_last() const \
2774 { \
2775 return _Getter_##_last_as<binding_t>(); \
2776 } \
2777 \
2778 template <typename T> \
2779 bool setCurrent(T const* current) \
2780 { \
2781 if constexpr (o2::soa::is_binding_compatible_v<T, binding_t>()) { \
2782 assert(current != nullptr); \
2783 this->mBinding.bind(current); \
2784 return true; \
2785 } \
2786 return false; \
2787 } \
2788 \
2789 bool setCurrentRaw(o2::soa::Binding current) \
2790 { \
2791 this->mBinding = current; \
2792 return true; \
2793 } \
2794 binding_t const* getCurrent() const { return mBinding.get<binding_t>(); } \
2795 o2::soa::Binding getCurrentRaw() const { return mBinding; } \
2796 o2::soa::Binding mBinding; \
2797 };
2798
2799#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_)
2800#define DECLARE_SOA_ARRAY_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_ARRAY_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, _Name_##s, "")
2801#define DECLARE_SOA_ARRAY_INDEX_COLUMN_CUSTOM(_Name_, _Getter_, _Label_) DECLARE_SOA_ARRAY_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, int32_t, _Name_##s, _Label_, "")
2802
2804#define DECLARE_SOA_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, _Type_, _Table_, _Label_, _Suffix_) \
2805 struct _Name_##Id : o2::soa::Column<_Type_, _Name_##Id> { \
2806 static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
2807 static_assert((*_Suffix_ == '\0') || (*_Suffix_ == '_'), "Suffix has to begin with _"); \
2808 static constexpr const char* mLabel = "fIndex" _Label_ _Suffix_; \
2809 static constexpr const uint32_t hash = compile_time_hash(o2::framework::namespace_prefix<_Name_##Id>(), std::string_view{#_Getter_ "Id"}); \
2810 using base = o2::soa::Column<_Type_, _Name_##Id>; \
2811 using type = _Type_; \
2812 using column_t = _Name_##Id; \
2813 using binding_t = _Table_; \
2814 static constexpr auto index_targets = getIndexTargets<_Table_>(); \
2815 _Name_##Id(arrow::ChunkedArray const* column) \
2816 : o2::soa::Column<_Type_, _Name_##Id>(o2::soa::ColumnIterator<type>(column)) \
2817 { \
2818 } \
2819 \
2820 _Name_##Id() = default; \
2821 _Name_##Id(_Name_##Id const& other) = default; \
2822 _Name_##Id& operator=(_Name_##Id const& other) = default; \
2823 type inline getId() const \
2824 { \
2825 return _Getter_##Id(); \
2826 } \
2827 \
2828 type _Getter_##Id() const \
2829 { \
2830 return *mColumnIterator; \
2831 } \
2832 \
2833 bool has_##_Getter_() const \
2834 { \
2835 return *mColumnIterator >= 0; \
2836 } \
2837 \
2838 template <typename T> \
2839 auto _Getter_##_as() const \
2840 { \
2841 if (O2_BUILTIN_UNLIKELY(mBinding.ptr == nullptr)) { \
2842 o2::soa::notBoundTable(#_Table_); \
2843 } \
2844 if (O2_BUILTIN_UNLIKELY(!has_##_Getter_())) { \
2845 o2::soa::accessingInvalidIndexFor(#_Getter_); \
2846 } \
2847 auto t = mBinding.get<T>(); \
2848 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2849 o2::soa::dereferenceWithWrongType(#_Getter_, #_Table_); \
2850 } \
2851 return t->rawIteratorAt(*mColumnIterator); \
2852 } \
2853 \
2854 auto _Getter_() const \
2855 { \
2856 return _Getter_##_as<binding_t>(); \
2857 } \
2858 \
2859 template <typename T> \
2860 bool setCurrent(T* current) \
2861 { \
2862 if constexpr (o2::soa::is_binding_compatible_v<T, binding_t>()) { \
2863 assert(current != nullptr); \
2864 this->mBinding.bind(current); \
2865 return true; \
2866 } \
2867 return false; \
2868 } \
2869 \
2870 bool setCurrentRaw(o2::soa::Binding current) \
2871 { \
2872 this->mBinding = current; \
2873 return true; \
2874 } \
2875 binding_t const* getCurrent() const { return mBinding.get<binding_t>(); } \
2876 o2::soa::Binding getCurrentRaw() const { return mBinding; } \
2877 o2::soa::Binding mBinding; \
2878 }; \
2879 [[maybe_unused]] static constexpr o2::framework::expressions::BindingNode _Getter_##Id { "fIndex" _Label_ _Suffix_, _Name_##Id::hash, o2::framework::expressions::selectArrowType<_Type_>() }
2880
2881#define DECLARE_SOA_INDEX_COLUMN_FULL(_Name_, _Getter_, _Type_, _Table_, _Suffix_) DECLARE_SOA_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, _Type_, _Table_, #_Table_, _Suffix_)
2882#define DECLARE_SOA_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, _Name_##s, "")
2883#define DECLARE_SOA_INDEX_COLUMN_CUSTOM(_Name_, _Getter_, _Label_) DECLARE_SOA_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, int32_t, _Name_##s, _Label_, "")
2884
2886#define DECLARE_SOA_SELF_INDEX_COLUMN_COMPLETE(_Name_, _Getter_, _Type_, _Label_, _IndexTarget_) \
2887 struct _Name_##Id : o2::soa::Column<_Type_, _Name_##Id> { \
2888 static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
2889 static constexpr const char* mLabel = "fIndex" _Label_; \
2890 static constexpr const uint32_t hash = compile_time_hash(o2::framework::namespace_prefix<_Name_##Id>(), std::string_view{#_Getter_ "Id"}); \
2891 using base = o2::soa::Column<_Type_, _Name_##Id>; \
2892 using type = _Type_; \
2893 using column_t = _Name_##Id; \
2894 using self_index_t = std::true_type; \
2895 using compatible_signature = std::conditional<aod::is_aod_hash<_IndexTarget_>, _IndexTarget_, void>; \
2896 _Name_##Id(arrow::ChunkedArray const* column) \
2897 : o2::soa::Column<_Type_, _Name_##Id>(o2::soa::ColumnIterator<type>(column)) \
2898 { \
2899 } \
2900 \
2901 _Name_##Id() = default; \
2902 _Name_##Id(_Name_##Id const& other) = default; \
2903 _Name_##Id& operator=(_Name_##Id const& other) = default; \
2904 type inline getId() const \
2905 { \
2906 return _Getter_##Id(); \
2907 } \
2908 \
2909 type _Getter_##Id() const \
2910 { \
2911 return *mColumnIterator; \
2912 } \
2913 \
2914 bool has_##_Getter_() const \
2915 { \
2916 return *mColumnIterator >= 0; \
2917 } \
2918 \
2919 template <typename T> \
2920 auto _Getter_##_as() const \
2921 { \
2922 if (O2_BUILTIN_UNLIKELY(!has_##_Getter_())) { \
2923 o2::soa::accessingInvalidIndexFor(#_Getter_); \
2924 } \
2925 auto t = mBinding.get<T>(); \
2926 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2927 o2::soa::dereferenceWithWrongType(#_Getter_, "self"); \
2928 } \
2929 return t->rawIteratorAt(*mColumnIterator); \
2930 } \
2931 \
2932 bool setCurrentRaw(o2::soa::Binding current) \
2933 { \
2934 this->mBinding = current; \
2935 return true; \
2936 } \
2937 o2::soa::Binding getCurrentRaw() const { return mBinding; } \
2938 o2::soa::Binding mBinding; \
2939 }; \
2940 [[maybe_unused]] static constexpr o2::framework::expressions::BindingNode _Getter_##Id { "fIndex" _Label_, _Name_##Id::hash, o2::framework::expressions::selectArrowType<_Type_>() }
2941
2942#define DECLARE_SOA_SELF_INDEX_COLUMN_FULL(_Name_, _Getter_, _Type_, _Label_) DECLARE_SOA_SELF_INDEX_COLUMN_COMPLETE(_Name_, _Getter_, _Type_, _Label_, void)
2943#define DECLARE_SOA_SELF_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_SELF_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, #_Name_)
2945#define DECLARE_SOA_SELF_SLICE_INDEX_COLUMN_COMPLETE(_Name_, _Getter_, _Type_, _Label_, _IndexTarget_) \
2946 struct _Name_##IdSlice : o2::soa::Column<_Type_[2], _Name_##IdSlice> { \
2947 static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
2948 static constexpr const char* mLabel = "fIndexSlice" _Label_; \
2949 static constexpr const uint32_t hash = 0; \
2950 using base = o2::soa::Column<_Type_[2], _Name_##IdSlice>; \
2951 using type = _Type_[2]; \
2952 using column_t = _Name_##IdSlice; \
2953 using self_index_t = std::true_type; \
2954 using compatible_signature = std::conditional<aod::is_aod_hash<_IndexTarget_>, _IndexTarget_, void>; \
2955 _Name_##IdSlice(arrow::ChunkedArray const* column) \
2956 : o2::soa::Column<_Type_[2], _Name_##IdSlice>(o2::soa::ColumnIterator<type>(column)) \
2957 { \
2958 } \
2959 \
2960 _Name_##IdSlice() = default; \
2961 _Name_##IdSlice(_Name_##IdSlice const& other) = default; \
2962 _Name_##IdSlice& operator=(_Name_##IdSlice const& other) = default; \
2963 std::array<_Type_, 2> inline getIds() const \
2964 { \
2965 return _Getter_##Ids(); \
2966 } \
2967 \
2968 bool has_##_Getter_() const \
2969 { \
2970 auto a = *mColumnIterator; \
2971 return a[0] >= 0 && a[1] >= 0; \
2972 } \
2973 \
2974 std::array<_Type_, 2> _Getter_##Ids() const \
2975 { \
2976 auto a = *mColumnIterator; \
2977 return std::array{a[0], a[1]}; \
2978 } \
2979 \
2980 template <typename T> \
2981 auto _Getter_##_as() const \
2982 { \
2983 auto t = mBinding.get<T>(); \
2984 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2985 o2::soa::dereferenceWithWrongType(#_Getter_, "self"); \
2986 } \
2987 if (O2_BUILTIN_UNLIKELY(!has_##_Getter_())) { \
2988 return t->emptySlice(); \
2989 } \
2990 auto a = *mColumnIterator; \
2991 auto r = t->rawSlice(a[0], a[1]); \
2992 t->copyIndexBindings(r); \
2993 r.bindInternalIndicesTo(t); \
2994 return r; \
2995 } \
2996 \
2997 bool setCurrentRaw(o2::soa::Binding current) \
2998 { \
2999 this->mBinding = current; \
3000 return true; \
3001 } \
3002 o2::soa::Binding getCurrentRaw() const { return mBinding; } \
3003 o2::soa::Binding mBinding; \
3004 };
3005
3006#define DECLARE_SOA_SELF_SLICE_INDEX_COLUMN_FULL(_Name_, _Getter_, _Type_, _Label_) DECLARE_SOA_SELF_SLICE_INDEX_COLUMN_COMPLETE(_Name_, _Getter_, _Type_, _Label_, void)
3007#define DECLARE_SOA_SELF_SLICE_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_SELF_SLICE_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, "_" #_Name_)
3009#define DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN_COMPLETE(_Name_, _Getter_, _Type_, _Label_, _IndexTarget_) \
3010 struct _Name_##Ids : o2::soa::Column<std::vector<_Type_>, _Name_##Ids> { \
3011 static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
3012 static constexpr const char* mLabel = "fIndexArray" _Label_; \
3013 static constexpr const uint32_t hash = 0; \
3014 using base = o2::soa::Column<std::vector<_Type_>, _Name_##Ids>; \
3015 using type = std::vector<_Type_>; \
3016 using column_t = _Name_##Ids; \
3017 using self_index_t = std::true_type; \
3018 using compatible_signature = std::conditional<aod::is_aod_hash<_IndexTarget_>, _IndexTarget_, void>; \
3019 _Name_##Ids(arrow::ChunkedArray const* column) \
3020 : o2::soa::Column<std::vector<_Type_>, _Name_##Ids>(o2::soa::ColumnIterator<type>(column)) \
3021 { \
3022 } \
3023 \
3024 _Name_##Ids() = default; \
3025 _Name_##Ids(_Name_##Ids const& other) = default; \
3026 _Name_##Ids& operator=(_Name_##Ids const& other) = default; \
3027 gsl::span<const _Type_> inline getIds() const \
3028 { \
3029 return _Getter_##Ids(); \
3030 } \
3031 \
3032 gsl::span<const _Type_> _Getter_##Ids() const \
3033 { \
3034 return *mColumnIterator; \
3035 } \
3036 \
3037 bool has_##_Getter_() const \
3038 { \
3039 return !(*mColumnIterator).empty(); \
3040 } \
3041 \
3042 template <typename T> \
3043 auto _Getter_##_as() const \
3044 { \
3045 auto t = mBinding.get<T>(); \
3046 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
3047 o2::soa::dereferenceWithWrongType(#_Getter_, "self"); \
3048 } \
3049 auto result = std::vector<typename T::unfiltered_iterator>(); \
3050 for (auto& i : *mColumnIterator) { \
3051 result.push_back(t->rawIteratorAt(i)); \
3052 } \
3053 return result; \
3054 } \
3055 \
3056 template <typename T> \
3057 auto _Getter_##_first_as() const \
3058 { \
3059 return mBinding.get<T>()->rawIteratorAt((*mColumnIterator)[0]); \
3060 } \
3061 \
3062 template <typename T> \
3063 auto _Getter_##_last_as() const \
3064 { \
3065 return mBinding.get<T>()->rawIteratorAt((*mColumnIterator).back()); \
3066 } \
3067 \
3068 bool setCurrentRaw(o2::soa::Binding current) \
3069 { \
3070 this->mBinding = current; \
3071 return true; \
3072 } \
3073 o2::soa::Binding getCurrentRaw() const { return mBinding; } \
3074 o2::soa::Binding mBinding; \
3075 };
3076
3077#define DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN_FULL(_Name_, _Getter_, _Type_, _Label_) DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN_COMPLETE(_Name_, _Getter_, _Type_, _Label_, void)
3078#define DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, "_" #_Name_)
3079
3108#define DECLARE_SOA_DYNAMIC_COLUMN(_Name_, _Getter_, ...) \
3109 struct _Name_##Callback { \
3110 static inline constexpr auto getLambda() { return __VA_ARGS__; } \
3111 }; \
3112 \
3113 struct _Name_##Helper { \
3114 using callable_t = decltype(o2::framework::FunctionMetadata(std::declval<decltype(_Name_##Callback::getLambda())>())); \
3115 using return_type = typename callable_t::return_type; \
3116 }; \
3117 template <typename... Bindings> \
3118 struct _Name_ : o2::soa::DynamicColumn<typename _Name_##Helper::callable_t::type, _Name_<Bindings...>> { \
3119 using base = o2::soa::DynamicColumn<typename _Name_##Helper::callable_t::type, _Name_<Bindings...>>; \
3120 using helper = _Name_##Helper; \
3121 using callback_holder_t = _Name_##Callback; \
3122 using callable_t = helper::callable_t; \
3123 using callback_t = callable_t::type; \
3124 static constexpr const uint32_t hash = 0; \
3125 \
3126 _Name_(arrow::ChunkedArray const*) \
3127 { \
3128 } \
3129 _Name_() = default; \
3130 _Name_(_Name_ const& other) = default; \
3131 _Name_& operator=(_Name_ const& other) = default; \
3132 static constexpr const char* mLabel = #_Name_; \
3133 using type = typename callable_t::return_type; \
3134 \
3135 template <typename... FreeArgs> \
3136 type _Getter_(FreeArgs... freeArgs) const \
3137 { \
3138 return boundGetter(std::make_index_sequence<std::tuple_size_v<decltype(boundIterators)>>{}, freeArgs...); \
3139 } \
3140 template <typename... FreeArgs> \
3141 type getDynamicValue(FreeArgs... freeArgs) const \
3142 { \
3143 return boundGetter(std::make_index_sequence<std::tuple_size_v<decltype(boundIterators)>>{}, freeArgs...); \
3144 } \
3145 \
3146 type get() const \
3147 { \
3148 return _Getter_(); \
3149 } \
3150 \
3151 template <size_t... Is, typename... FreeArgs> \
3152 type boundGetter(std::integer_sequence<size_t, Is...>&&, FreeArgs... freeArgs) const \
3153 { \
3154 return __VA_ARGS__((**std::get<Is>(boundIterators))..., freeArgs...); \
3155 } \
3156 \
3157 using bindings_t = typename o2::framework::pack<Bindings...>; \
3158 std::tuple<o2::soa::ColumnIterator<typename Bindings::type> const*...> boundIterators; \
3159 }
3160
3161#define DECLARE_SOA_TABLE_METADATA(_Name_, _Desc_, _Version_, ...) \
3162 using _Name_##Metadata = TableMetadata<Hash<_Desc_ "/" #_Version_ ""_h>, __VA_ARGS__>;
3163
3164#define DECLARE_SOA_TABLE_METADATA_TRAIT(_Name_, _Desc_, _Version_) \
3165 template <> \
3166 struct MetadataTrait<Hash<_Desc_ "/" #_Version_ ""_h>> { \
3167 static constexpr void isMetadataTrait() {}; \
3168 using metadata = _Name_##Metadata; \
3169 };
3170
3171#define DECLARE_SOA_TABLE_FULL_VERSIONED_(_Name_, _Label_, _Origin_, _Desc_, _Version_) \
3172 O2HASH(_Desc_ "/" #_Version_); \
3173 template <typename O> \
3174 using _Name_##From = o2::soa::Table<Hash<_Label_ ""_h>, Hash<_Desc_ "/" #_Version_ ""_h>, O>; \
3175 using _Name_ = _Name_##From<Hash<_Origin_ ""_h>>; \
3176 template <> \
3177 struct MetadataTrait<Hash<_Desc_ "/" #_Version_ ""_h>> { \
3178 static constexpr void isMetadataTrait() {}; \
3179 using metadata = _Name_##Metadata; \
3180 };
3181
3182#define DECLARE_SOA_STAGE(_Name_, _Origin_, _Desc_, _Version_) \
3183 template <typename O> \
3184 using _Name_##From = o2::soa::Table<Hash<#_Name_ ""_h>, Hash<_Desc_ "/" #_Version_ ""_h>, O>; \
3185 using _Name_ = _Name_##From<Hash<_Origin_ ""_h>>;
3186
3187#define DECLARE_SOA_TABLE_FULL_VERSIONED(_Name_, _Label_, _Origin_, _Desc_, _Version_, ...) \
3188 DECLARE_SOA_TABLE_METADATA(_Name_, _Desc_, _Version_, __VA_ARGS__); \
3189 DECLARE_SOA_TABLE_FULL_VERSIONED_(_Name_, _Label_, _Origin_, _Desc_, _Version_);
3190
3191#define DECLARE_SOA_TABLE_FULL(_Name_, _Label_, _Origin_, _Desc_, ...) \
3192 O2HASH(_Label_); \
3193 DECLARE_SOA_TABLE_METADATA(_Name_, _Desc_, 0, __VA_ARGS__); \
3194 DECLARE_SOA_TABLE_FULL_VERSIONED_(_Name_, _Label_, _Origin_, _Desc_, 0)
3195
3196#define DECLARE_SOA_TABLE(_Name_, _Origin_, _Desc_, ...) \
3197 DECLARE_SOA_TABLE_FULL(_Name_, #_Name_, _Origin_, _Desc_, __VA_ARGS__)
3198
3199#define DECLARE_SOA_TABLE_VERSIONED(_Name_, _Origin_, _Desc_, _Version_, ...) \
3200 O2HASH(#_Name_) \
3201 DECLARE_SOA_TABLE_METADATA(_Name_, _Desc_, _Version_, __VA_ARGS__) \
3202 DECLARE_SOA_TABLE_FULL_VERSIONED_(_Name_, #_Name_, _Origin_, _Desc_, _Version_)
3203
3204#define DECLARE_SOA_TABLE_STAGED_VERSIONED(_BaseName_, _Desc_, _Version_, ...) \
3205 O2HASH(_Desc_ "/" #_Version_); \
3206 O2HASH(#_BaseName_); \
3207 O2HASH("Stored" #_BaseName_); \
3208 DECLARE_SOA_TABLE_METADATA(_BaseName_, _Desc_, _Version_, __VA_ARGS__); \
3209 using Stored##_BaseName_##Metadata = _BaseName_##Metadata; \
3210 DECLARE_SOA_TABLE_METADATA_TRAIT(_BaseName_, _Desc_, _Version_); \
3211 DECLARE_SOA_STAGE(_BaseName_, "AOD", _Desc_, _Version_); \
3212 DECLARE_SOA_STAGE(Stored##_BaseName_, "AOD1", _Desc_, _Version_); \
3213 using StoredEMB##_BaseName_ = Stored##_BaseName_##From<o2::aod::Hash<"EMB"_h>>;
3214
3215#define DECLARE_SOA_TABLE_STAGED(_BaseName_, _Desc_, ...) \
3216 DECLARE_SOA_TABLE_STAGED_VERSIONED(_BaseName_, _Desc_, 0, __VA_ARGS__);
3217
3218#define DECLARE_SOA_EXTENDED_TABLE_NG(_Name_, _OriginalTable_, _Desc_, _Version_, ...) \
3219 O2HASH(_Desc_ "/" #_Version_); \
3220 O2HASH(#_Name_ "Extension"); \
3221 template <typename O> \
3222 using _Name_##ExtensionFrom = soa::Table<o2::aod::Hash<#_Name_ "Extension"_h>, o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, O>; \
3223 using _Name_##Extension = _Name_##ExtensionFrom<o2::aod::Hash<"AOD"_h>>; \
3224 struct _Name_##ExtensionMetadata : TableMetadata<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, __VA_ARGS__> { \
3225 using base_table_t = _OriginalTable_; \
3226 template <o2::aod::is_origin_hash O> \
3227 using extension_table_t_from = _Name_##ExtensionFrom<O>; \
3228 using extension_table_t = _Name_##Extension; \
3229 using expression_pack_t = framework::pack<__VA_ARGS__>; \
3230 static constexpr auto N = _OriginalTable_::originals.size(); \
3231 template <o2::aod::is_origin_hash O = o2::aod::Hash<"AOD"_h>> \
3232 static consteval auto generateSources() \
3233 { \
3234 return _OriginalTable_##From<O>::originals; \
3235 } \
3236 }; \
3237 template <> \
3238 struct MetadataTrait<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>> { \
3239 static constexpr void isMetadataTrait() {}; \
3240 using metadata = _Name_##ExtensionMetadata; \
3241 }; \
3242 template <typename O> \
3243 using _Name_##From = o2::soa::Join<_OriginalTable_##From<O>, _Name_##ExtensionFrom<O>>; \
3244 using _Name_ = _Name_##From<o2::aod::Hash<"AOD"_h>>;
3245
3246#define DECLARE_SOA_EXTENDED_TABLE(_Name_, _Table_, _Description_, _Version_, ...) \
3247 DECLARE_SOA_EXTENDED_TABLE_NG(_Name_, _Table_, _Description_, _Version_, __VA_ARGS__)
3248
3249#define DECLARE_SOA_EXTENDED_TABLE_USER(_Name_, _Table_, _Description_, ...) \
3250 DECLARE_SOA_EXTENDED_TABLE_NG(_Name_, _Table_, "EX" _Description_, 0, __VA_ARGS__)
3251
3252#define DECLARE_SOA_CONFIGURABLE_EXTENDED_TABLE_NG(_Name_, _OriginalTable_, _Desc_, _Version_, ...) \
3253 O2HASH(_Desc_ "/" #_Version_); \
3254 O2HASH(#_Name_ "CfgExtension"); \
3255 template <typename O> \
3256 using _Name_##CfgExtensionFrom = soa::Table<o2::aod::Hash<#_Name_ "CfgExtension"_h>, o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, O>; \
3257 using _Name_##CfgExtension = _Name_##CfgExtensionFrom<o2::aod::Hash<"AOD"_h>>; \
3258 struct _Name_##CfgExtensionMetadata : TableMetadata<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, __VA_ARGS__> { \
3259 using base_table_t = _OriginalTable_; \
3260 template <o2::aod::is_origin_hash O> \
3261 using extension_table_t_from = _Name_##CfgExtensionFrom<O>; \
3262 using extension_table_t = _Name_##CfgExtension; \
3263 using placeholders_pack_t = framework::pack<__VA_ARGS__>; \
3264 using configurable_t = std::true_type; \
3265 static constexpr auto N = _OriginalTable_::originals.size(); \
3266 template <o2::aod::is_origin_hash O = o2::aod::Hash<"AOD"_h>> \
3267 static consteval auto generateSources() \
3268 { \
3269 return _OriginalTable_##From<O>::originals; \
3270 } \
3271 }; \
3272 template <> \
3273 struct MetadataTrait<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>> { \
3274 static constexpr void isMetadataTrait() {}; \
3275 using metadata = _Name_##CfgExtensionMetadata; \
3276 }; \
3277 template <typename O> \
3278 using _Name_##From = o2::soa::Join<_OriginalTable_##From<O>, _Name_##CfgExtensionFrom<O>>; \
3279 using _Name_ = _Name_##From<o2::aod::Hash<"AOD"_h>>;
3280
3281#define DECLARE_SOA_CONFIGURABLE_EXTENDED_TABLE(_Name_, _OriginalTable_, _Description_, ...) \
3282 DECLARE_SOA_CONFIGURABLE_EXTENDED_TABLE_NG(_Name_, _OriginalTable_, "EX" _Description_, 0, __VA_ARGS__)
3283
3284#define DECLARE_SOA_INDEX_TABLE_NG(_Name_, _Key_, _Version_, _Desc_, _Exclusive_, ...) \
3285 O2HASH(#_Name_); \
3286 O2HASH(_Desc_ "/" #_Version_); \
3287 struct _Name_##Metadata : o2::aod::TableMetadata<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, soa::Index<>, __VA_ARGS__> { \
3288 static constexpr bool exclusive = _Exclusive_; \
3289 template <o2::aod::is_origin_hash O> \
3290 using KeyFrom = _Key_##From<O>; \
3291 using Key = _Key_; \
3292 using index_pack_t = framework::pack<__VA_ARGS__>; \
3293 template <o2::aod::is_origin_hash O = o2::aod::Hash<"AOD"_h>> \
3294 static consteval auto generateSources() \
3295 { \
3296 return []<soa::is_index_column... Cs>(framework::pack<Cs...>) consteval { \
3297 constexpr auto first = o2::soa::mergeOriginals<typename Cs::binding_t...>(); \
3298 constexpr auto second = o2::aod::filterForKey<first.size(), first, Key>(); \
3299 return o2::aod::replaceOrigin<second.size(), second, O>(); \
3300 }(framework::pack<__VA_ARGS__>{}); \
3301 } \
3302 static constexpr auto N = []<typename... Cs>(framework::pack<Cs...>) consteval { \
3303 constexpr auto a = o2::soa::mergeOriginals<typename Cs::binding_t...>(); \
3304 return o2::aod::filterForKey<a.size(), a, Key>(); \
3305 }(framework::pack<__VA_ARGS__>{}) \
3306 .size(); \
3307 }; \
3308 template <> \
3309 struct MetadataTrait<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>> { \
3310 static constexpr void isMetadataTrait() {}; \
3311 using metadata = _Name_##Metadata; \
3312 }; \
3313 template <o2::aod::is_origin_hash O> \
3314 using _Name_##From = o2::soa::IndexTable<o2::aod::Hash<#_Name_ ""_h>, o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, O, _Key_##From<O>, __VA_ARGS__>; \
3315 using _Name_ = _Name_##From<o2::aod::Hash<"AOD"_h>>;
3316
3317#define DECLARE_SOA_INDEX_TABLE(_Name_, _Key_, _Description_, ...) \
3318 DECLARE_SOA_INDEX_TABLE_NG(_Name_, _Key_, 0, _Description_, false, __VA_ARGS__)
3319
3320#define DECLARE_SOA_INDEX_TABLE_EXCLUSIVE(_Name_, _Key_, _Description_, ...) \
3321 DECLARE_SOA_INDEX_TABLE_NG(_Name_, _Key_, 0, _Description_, true, __VA_ARGS__)
3322
3323#define DECLARE_SOA_INDEX_TABLE_USER(_Name_, _Key_, _Description_, ...) \
3324 DECLARE_SOA_INDEX_TABLE_NG(_Name_, _Key_, 0, _Description_, false, __VA_ARGS__)
3325
3326#define DECLARE_SOA_INDEX_TABLE_EXCLUSIVE_USER(_Name_, _Key_, _Description_, ...) \
3327 DECLARE_SOA_INDEX_TABLE_NG(_Name_, _Key_, 0, _Description_, true, __VA_ARGS__)
3328
3329// Declare were each row is associated to a timestamp column of an _TimestampSource_
3330// table.
3331//
3332// The columns of this table have to be CCDB_COLUMNS so that for each timestamp, we get a row
3333// which points to the specified CCDB objectes described by those columns.
3334#define DECLARE_SOA_TIMESTAMPED_TABLE_FULL(_Name_, _Label_, _TimestampSource_, _TimestampColumn_, _UniformitySource_, _UniformityColumn_, _Version_, _Desc_, ...) \
3335 O2HASH(_Desc_ "/" #_Version_); \
3336 template <typename O> \
3337 using _Name_##TimestampFrom = soa::Table<o2::aod::Hash<_Label_ ""_h>, o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, O>; \
3338 using _Name_##Timestamp = _Name_##TimestampFrom<o2::aod::Hash< \
3339 "AOD" \
3340 ""_h>>; \
3341 struct _Name_##TimestampMetadata : TableMetadata<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, __VA_ARGS__> { \
3342 template <typename O = o2::aod::Hash<"AOD" \
3343 ""_h>> \
3344 using base_table_t = _TimestampSource_##From<O>; \
3345 template <typename O = o2::aod::Hash<"AOD" \
3346 ""_h>> \
3347 using extension_table_t = _Name_##TimestampFrom<O>; \
3348 static constexpr const auto ccdb_urls = []<typename... Cs>(framework::pack<Cs...>) consteval { \
3349 return std::array<std::string_view, sizeof...(Cs)>{Cs::query...}; \
3350 }(framework::pack<__VA_ARGS__>{}); \
3351 static constexpr const auto ccdb_bindings = []<typename... Cs>(framework::pack<Cs...>) consteval { \
3352 return std::array<std::string_view, sizeof...(Cs)>{o2::framework::with_namespace_prefix<Cs>()...}; \
3353 }(framework::pack<__VA_ARGS__>{}); \
3354 static constexpr const auto ccdb_run_dependent = []<typename... Cs>(framework::pack<Cs...>) consteval { \
3355 return std::array<int, sizeof...(Cs)>{Cs::run_dependent...}; \
3356 }(framework::pack<__VA_ARGS__>{}); \
3357 /* The uniformity column may live in a table other than the timestamp source (the run */ \
3358 /* number is on aod::BCs, the timestamp on aod::Timestamps). Both are handed to the */ \
3359 /* fetcher, which reads them positionally — sound because the two are row-aligned. */ \
3360 /* Row alignment cannot be checked here: ASoA encodes no type-level relation between */ \
3361 /* two tables that happen to have equal row counts (aod::BCs and aod::Timestamps have */ \
3362 /* disjoint originals). The CCDB fetcher verifies the lengths match before reading. */ \
3363 static constexpr auto N = o2::soa::mergeOriginals<_TimestampSource_, _UniformitySource_>().size(); \
3364 template <o2::aod::is_origin_hash O = o2::aod::Hash<"AOD"_h>> \
3365 static consteval auto generateSources() \
3366 { \
3367 return o2::soa::mergeOriginals<_TimestampSource_##From<O>, _UniformitySource_##From<O>>(); \
3368 } \
3369 static constexpr auto timestamp_column_label = _TimestampColumn_::mLabel; \
3370 /* Rows sharing a uniformity value resolve to the same CCDB object, so the fetcher */ \
3371 /* need only query once per distinct value. Defaults to the timestamp column, i.e. */ \
3372 /* every distinct timestamp may yield a different object — the pre-existing behaviour.*/ \
3373 static constexpr auto uniformity_column_label = _UniformityColumn_::mLabel; \
3374 /*static constexpr auto timestampColumn = _TimestampColumn_;*/ \
3375 }; \
3376 template <> \
3377 struct MetadataTrait<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>> { \
3378 static constexpr void isMetadataTrait() {}; \
3379 using metadata = _Name_##TimestampMetadata; \
3380 }; \
3381 template <typename O> \
3382 using _Name_##From = o2::soa::Join<_TimestampSource_, _Name_##TimestampFrom<O>>; \
3383 using _Name_ = _Name_##From<o2::aod::Hash< \
3384 "AOD" \
3385 ""_h>>;
3386
3387/* Uniformity defaults to the timestamp column of the timestamp source: each distinct
3388 timestamp may resolve to a different object, which is the pre-existing behaviour.
3389 Pass an explicit uniformity source + column (e.g. aod::BCs / aod::bc::RunNumber) when
3390 the object is constant across a coarser key: the fetcher then queries once per distinct
3391 value instead of once per row. The uniformity source must be row-aligned with the
3392 timestamp source, which is checked. */
3393#define DECLARE_SOA_TIMESTAMPED_TABLE(_Name_, _TimestampSource_, _TimestampColumn_, _Version_, _Desc_, ...) \
3394 O2HASH(#_Name_ "Timestamped"); \
3395 DECLARE_SOA_TIMESTAMPED_TABLE_FULL(_Name_, #_Name_ "Timestamped", _TimestampSource_, _TimestampColumn_, _TimestampSource_, _TimestampColumn_, _Version_, _Desc_, __VA_ARGS__)
3396
3397/* Short form for a table with a coarser uniformity key; unlike the CCDB column macros the
3398 short form is worth keeping, because going through _FULL would also make every caller
3399 hand-write the O2HASH of the label. */
3400#define DECLARE_SOA_UNIFORM_TABLE(_Name_, _TimestampSource_, _TimestampColumn_, _UniformitySource_, _UniformityColumn_, _Version_, _Desc_, ...) \
3401 O2HASH(#_Name_ "Timestamped"); \
3402 DECLARE_SOA_TIMESTAMPED_TABLE_FULL(_Name_, #_Name_ "Timestamped", _TimestampSource_, _TimestampColumn_, _UniformitySource_, _UniformityColumn_, _Version_, _Desc_, __VA_ARGS__)
3403
3404namespace o2::soa
3405{
3406template <typename... Ts>
3407struct Join : Table<o2::aod::Hash<"JOIN"_h>, o2::aod::Hash<"JOIN/0"_h>, o2::aod::Hash<"JOIN"_h>, Ts...> {
3408 static constexpr void isJoin() {};
3409 using base = Table<o2::aod::Hash<"JOIN"_h>, o2::aod::Hash<"JOIN/0"_h>, o2::aod::Hash<"JOIN"_h>, Ts...>;
3410
3411 Join(std::vector<ArrowTableRef>&& tables)
3412 : base{ArrowHelpers::joinTables(std::move(tables))}
3413 {
3414 if (this->tableSize() != 0) {
3416 }
3417 }
3418
3423
3424 template <typename... TA>
3425 void bindExternalIndices(TA*... current)
3426 {
3427 ([this](TA* cur) {
3428 if constexpr (binding_origin == TA::binding_origin) {
3429 this->bindExternalIndex(cur);
3430 }
3431 }(current),
3432 ...);
3433 }
3434
3435 using self_t = Join<Ts...>;
3436 using table_t = base;
3437 static constexpr const auto originals = base::originals;
3438 static constexpr const auto originalLabels = base::originalLabels;
3441 using iterator = table_t::template iterator_template<DefaultIndexPolicy, self_t, Ts...>;
3447
3449 {
3450 return iterator{this->cached_begin()};
3451 }
3452
3454 {
3455 return const_iterator{this->cached_begin()};
3456 }
3457
3459 {
3460 return doSliceByCached(this, node, value, cache);
3461 }
3462
3467
3468 template <typename T1, typename Policy, bool OPT>
3470 {
3471 return doSliceBy(this, container, value);
3472 }
3473
3475 {
3476 auto it = iterator{this->cached_begin()};
3477 it.setCursor(i);
3478 return it;
3479 }
3480
3482 {
3483 return rawIteratorAt(i);
3484 }
3485
3487 {
3488 return self_t{{this->asArrowTableRef().slice({start, static_cast<int64_t>(end - start + 1)})}};
3489 }
3490
3491 auto emptySlice() const
3492 {
3493 return self_t{{this->asArrowTableRef().slice({0, 0})}};
3494 }
3495
3496 template <typename T>
3497 static consteval bool contains()
3498 {
3499 return []<size_t... Is>(std::index_sequence<Is...>) constexpr {
3500 return (std::ranges::any_of(originals, [](TableRef const& ref) constexpr { return ref.desc_hash == T::originals[Is].desc_hash; }) && ...);
3501 }(std::make_index_sequence<T::originals.size()>());
3502 }
3503};
3504
3505template <typename... Ts>
3506constexpr auto join(Ts const&... t)
3507{
3508 return Join<Ts...>({ArrowHelpers::joinTables({t.asArrowTableRef()...}, std::span{Join<Ts...>::base::originalLabels})});
3509}
3510
3511template <typename T>
3512constexpr bool is_soa_join_v = is_join<T>;
3513
3514template <typename... Ts>
3515struct Concat : Table<o2::aod::Hash<"CONC"_h>, o2::aod::Hash<"CONC/0"_h>, o2::aod::Hash<"CONC"_h>, Ts...> {
3516 using base = Table<o2::aod::Hash<"CONC"_h>, o2::aod::Hash<"CONC/0"_h>, o2::aod::Hash<"CONC"_h>, Ts...>;
3517 using self_t = Concat<Ts...>;
3518
3520 : base{table}
3521 {
3523 }
3524
3525 Concat(std::shared_ptr<arrow::Table> table)
3526 : Concat{ArrowTableRef{table}}
3527 {
3528 }
3529
3530 Concat(std::vector<ArrowTableRef>&& tables)
3531 : Concat{ArrowHelpers::concatTables(std::move(tables))}
3532 {
3533 }
3534
3535 Concat(Ts const&... t)
3536 : Concat{ArrowHelpers::concatTables({t.asArrowTableRef()...})}
3537 {
3538 }
3539
3540 using base::originals;
3541
3542 using base::bindExternalIndices;
3543 using base::bindInternalIndicesTo;
3544
3545 using table_t = base;
3548
3549 using iterator = table_t::template iterator_template<DefaultIndexPolicy, self_t, Ts...>;
3555};
3556
3557template <typename... Ts>
3558constexpr auto concat(Ts const&... t)
3559{
3560 return Concat<Ts...>{t...};
3561}
3562
3563template <typename S>
3564concept is_a_selection = std::same_as<std::decay_t<S>, gandiva::Selection> || std::same_as<std::decay_t<S>, SelectionVector> || std::same_as<std::decay_t<S>, std::span<int64_t const>>;
3565
3566template <soa::is_table T>
3567class FilteredBase : public T
3568{
3569 public:
3570 static constexpr void isFilteredBase() {};
3572 using table_t = typename T::table_t;
3573 using T::originals;
3574 static constexpr const uint32_t binding_origin = T::binding_origin;
3575 static constexpr const header::DataOrigin binding_origin_ = T::binding_origin_;
3576 template <typename... TA>
3577 void bindExternalIndices(TA*... current)
3578 {
3579 ([this](TA* cur) {
3580 if constexpr (binding_origin == TA::binding_origin) {
3581 this->bindExternalIndex(cur);
3582 mFilteredBegin.bindExternalIndex(cur);
3583 }
3584 }(current),
3585 ...);
3586 }
3587 using columns_t = typename T::columns_t;
3588 using persistent_columns_t = typename T::persistent_columns_t;
3589 using external_index_columns_t = typename T::external_index_columns_t;
3590
3591 using iterator = T::template iterator_template_o<FilteredIndexPolicy, self_t>;
3592 using unfiltered_iterator = T::template iterator_template_o<DefaultIndexPolicy, self_t>;
3594
3595 FilteredBase(std::vector<ArrowTableRef>&& tables, is_a_selection auto selection)
3596 : T{std::move(tables)}
3597 {
3598 adoptSelection(selection);
3599 if (this->tableSize() != 0) {
3600 mFilteredBegin = table_t::filtered_begin(mSelectedRows);
3601 }
3602 resetRanges();
3603 mFilteredBegin.bindInternalIndices(this);
3604 }
3605
3607 {
3608 return iterator(mFilteredBegin);
3609 }
3610
3612 {
3613 return const_iterator(mFilteredBegin);
3614 }
3615
3617 {
3618 auto it = unfiltered_iterator{mFilteredBegin};
3619 it.setCursor(i);
3620 return it;
3621 }
3622
3623 [[nodiscard]] RowViewSentinel end() const
3624 {
3625 return RowViewSentinel{*mFilteredEnd};
3626 }
3627
3629 {
3630 return mFilteredBegin;
3631 }
3632
3633 auto const& cached_begin() const
3634 {
3635 return mFilteredBegin;
3636 }
3637
3639 {
3640 return mFilteredBegin + i;
3641 }
3642
3643 [[nodiscard]] int64_t size() const
3644 {
3645 return mSelectedRows.size();
3646 }
3647
3648 [[nodiscard]] int64_t tableSize() const
3649 {
3650 return this->asArrowTableRef().range.size;
3651 }
3652
3653 auto const& getSelectedRows() const
3654 {
3655 return mSelectedRows;
3656 }
3657
3659 {
3660 SelectionVector newSelection;
3661 newSelection.resize(static_cast<int64_t>(end - start + 1));
3662 std::iota(newSelection.begin(), newSelection.end(), start);
3663 return self_t{{this->asArrowTableRef()}, std::move(newSelection)};
3664 }
3665
3666 auto emptySlice() const
3667 {
3668 return self_t{{this->asArrowTableRef()}, SelectionVector{}};
3669 }
3670
3671 static inline auto getSpan(gandiva::Selection const& sel)
3672 {
3673 if (sel == nullptr) {
3674 return std::span<int64_t const>{};
3675 }
3676 auto array = std::static_pointer_cast<arrow::Int64Array>(sel->ToArray());
3677 auto start = array->raw_values();
3678 auto stop = start + array->length();
3679 return std::span{start, stop};
3680 }
3681
3684 void bindExternalIndicesRaw(std::vector<o2::soa::Binding>&& ptrs)
3685 {
3686 mFilteredBegin.bindExternalIndicesRaw(std::forward<std::vector<o2::soa::Binding>>(ptrs));
3687 }
3688
3689 template <typename I>
3691 {
3692 mFilteredBegin.bindInternalIndices(ptr);
3693 }
3694
3695 template <typename T1, typename... Cs>
3697 {
3698 dest.bindExternalIndicesRaw(mFilteredBegin.getIndexBindings());
3699 }
3700
3701 template <typename T1>
3702 void copyIndexBindings(T1& dest) const
3703 {
3704 doCopyIndexBindings(external_index_columns_t{}, dest);
3705 }
3706
3707 template <typename T1>
3708 auto rawSliceBy(o2::framework::Preslice<T1> const& container, int value) const
3709 {
3710 return (table_t)this->sliceBy(container, value);
3711 }
3712
3714 {
3715 return doFilteredSliceByCached(this, node, value, cache);
3716 }
3717
3722
3723 template <typename T1, bool OPT>
3725 {
3726 return doFilteredSliceBy(this, container, value);
3727 }
3728
3729 template <typename T1, bool OPT>
3731 {
3732 return doSliceBy(this, container, value);
3733 }
3734
3736 {
3737 auto t = o2::soa::select(*this, f);
3738 copyIndexBindings(t);
3739 return t;
3740 }
3741
3742 int isInSelectedRows(int i) const
3743 {
3744 auto locate = std::find(mSelectedRows.begin(), mSelectedRows.end(), i);
3745 if (locate == mSelectedRows.end()) {
3746 return -1;
3747 }
3748 return static_cast<int>(std::distance(mSelectedRows.begin(), locate));
3749 }
3750
3752 {
3753 mCached = true;
3754 SelectionVector rowsUnion;
3755 std::ranges::set_union(mSelectedRows, selection, std::back_inserter(rowsUnion));
3756 mSelectedRowsCache.clear();
3757 mSelectedRowsCache = rowsUnion;
3758 resetRanges();
3759 }
3760
3762 {
3763 mCached = true;
3764 SelectionVector intersection;
3765 std::ranges::set_intersection(mSelectedRows, selection, std::back_inserter(intersection));
3766 mSelectedRowsCache.clear();
3767 mSelectedRowsCache = intersection;
3768 resetRanges();
3769 }
3770
3771 bool isCached() const
3772 {
3773 return mCached;
3774 }
3775
3777 {
3778 mFilteredBegin.setPointerReconstructor(pointerReconstructor);
3779 }
3780
3781 private:
3782 void resetRanges()
3783 {
3784 if (mCached) {
3785 mSelectedRows = std::span{mSelectedRowsCache};
3786 }
3787 mFilteredEnd.reset(new RowViewSentinel{static_cast<int64_t>(mSelectedRows.size())});
3788 if (tableSize() == 0) {
3789 mFilteredBegin = *mFilteredEnd;
3790 } else {
3791 mFilteredBegin.resetSelection(mSelectedRows);
3792 }
3793 }
3794
3795 template <typename S>
3796 inline void adoptSelection(S)
3797 {
3798 }
3799
3800 template <typename S>
3801 requires(std::same_as<std::decay_t<S>, gandiva::Selection>)
3802 inline void adoptSelection(S selection)
3803 {
3804 mSelectedRows = getSpan(selection);
3805 mCached = false;
3806 }
3807
3808 template <typename S>
3809 requires(std::same_as<std::decay_t<S>, SelectionVector>)
3810 inline void adoptSelection(S selection)
3811 {
3812 mSelectedRowsCache = std::move(selection);
3813 mSelectedRows = std::span{mSelectedRowsCache};
3814 mCached = true;
3815 }
3816
3817 template <typename S>
3818 requires(std::same_as<std::decay_t<S>, std::span<int64_t const>>)
3819 inline void adoptSelection(S selection)
3820 {
3821 mSelectedRows = selection;
3822 mCached = false;
3823 }
3824
3825 std::span<int64_t const> mSelectedRows;
3826 SelectionVector mSelectedRowsCache;
3827 bool mCached = false;
3828 iterator mFilteredBegin;
3829 std::shared_ptr<RowViewSentinel> mFilteredEnd;
3830};
3831
3832template <typename T>
3833class Filtered : public FilteredBase<T>
3834{
3835 public:
3836 using base_t = T;
3838 using table_t = typename T::table_t;
3839 using columns_t = typename T::columns_t;
3840
3841 using iterator = T::template iterator_template_o<FilteredIndexPolicy, self_t>;
3842 using unfiltered_iterator = T::template iterator_template_o<DefaultIndexPolicy, self_t>;
3844
3846 {
3847 return iterator(this->cached_begin());
3848 }
3849
3851 {
3852 return const_iterator(this->cached_begin());
3853 }
3854
3855 Filtered(std::vector<ArrowTableRef>&& tables, is_a_selection auto selection)
3856 : FilteredBase<T>{std::move(tables), std::forward<decltype(selection)>(selection)} {}
3857
3859 {
3860 Filtered<T> copy(*this);
3861 copy.sumWithSelection(selection);
3862 return copy;
3863 }
3864
3866 {
3867 return operator+(other.getSelectedRows());
3868 }
3869
3871 {
3872 this->sumWithSelection(selection);
3873 return *this;
3874 }
3875
3877 {
3878 return operator+=(other.getSelectedRows());
3879 }
3880
3882 {
3883 Filtered<T> copy(*this);
3884 copy.intersectWithSelection(selection);
3885 return copy;
3886 }
3887
3889 {
3890 return operator*(other.getSelectedRows());
3891 }
3892
3894 {
3895 this->intersectWithSelection(selection);
3896 return *this;
3897 }
3898
3900 {
3901 return operator*=(other.getSelectedRows());
3902 }
3903
3905 {
3906 auto it = unfiltered_iterator{this->cached_begin()};
3907 it.setCursor(i);
3908 return it;
3909 }
3910
3911 using FilteredBase<T>::getSelectedRows;
3912
3914 {
3915 SelectionVector newSelection;
3916 newSelection.resize(static_cast<int64_t>(end - start + 1));
3917 std::iota(newSelection.begin(), newSelection.end(), start);
3918 return self_t{{this->asArrowTableRef()}, std::move(newSelection)};
3919 }
3920
3921 auto emptySlice() const
3922 {
3923 return self_t{{this->asArrowTableRef()}, SelectionVector{}};
3924 }
3925
3926 template <typename T1>
3927 auto rawSliceBy(o2::framework::Preslice<T1> const& container, int value) const
3928 {
3929 return (table_t)this->sliceBy(container, value);
3930 }
3931
3933 {
3934 return doFilteredSliceByCached(this, node, value, cache);
3935 }
3936
3941
3942 template <typename T1, bool OPT>
3944 {
3945 return doFilteredSliceBy(this, container, value);
3946 }
3947
3948 template <typename T1, bool OPT>
3950 {
3951 return doSliceBy(this, container, value);
3952 }
3953
3955 {
3956 auto t = o2::soa::select(*this, f);
3957 copyIndexBindings(t);
3958 return t;
3959 }
3960};
3961
3962template <typename T>
3963class Filtered<Filtered<T>> : public FilteredBase<typename T::table_t>
3964{
3965 public:
3967 using base_t = T;
3969 using columns_t = typename T::columns_t;
3970
3971 using iterator = typename T::template iterator_template_o<FilteredIndexPolicy, self_t>;
3972 using unfiltered_iterator = typename T::template iterator_template_o<DefaultIndexPolicy, self_t>;
3974
3976 {
3977 return iterator(this->cached_begin());
3978 }
3979
3981 {
3982 return const_iterator(this->cached_begin());
3983 }
3984
3985 Filtered(std::vector<Filtered<T>>&& tables, is_a_selection auto selection)
3986 : FilteredBase<typename T::table_t>(std::move(extractTablesFromFiltered(tables)), std::forward<decltype(selection)>(selection))
3987 {
3988 for (auto& table : tables) {
3989 *this *= table;
3990 }
3991 }
3992
3994 {
3995 Filtered<Filtered<T>> copy(*this);
3996 copy.sumWithSelection(selection);
3997 return copy;
3998 }
3999
4001 {
4002 return operator+(other.getSelectedRows());
4003 }
4004
4006 {
4007 this->sumWithSelection(selection);
4008 return *this;
4009 }
4010
4012 {
4013 return operator+=(other.getSelectedRows());
4014 }
4015
4017 {
4018 Filtered<Filtered<T>> copy(*this);
4019 copy.intersectionWithSelection(selection);
4020 return copy;
4021 }
4022
4024 {
4025 return operator*(other.getSelectedRows());
4026 }
4027
4029 {
4030 this->intersectWithSelection(selection);
4031 return *this;
4032 }
4033
4035 {
4036 return operator*=(other.getSelectedRows());
4037 }
4038
4040 {
4041 auto it = unfiltered_iterator{this->cached_begin()};
4042 it.setCursor(i);
4043 return it;
4044 }
4045
4047 {
4048 SelectionVector newSelection;
4049 newSelection.resize(static_cast<int64_t>(end - start + 1));
4050 std::iota(newSelection.begin(), newSelection.end(), start);
4051 return self_t{{this->asArrowTableRef()}, std::move(newSelection)};
4052 }
4053
4054 auto emptySlice() const
4055 {
4056 return self_t{{this->asArrowTableRef()}, SelectionVector{}};
4057 }
4058
4060 {
4061 return doFilteredSliceByCached(this, node, value, cache);
4062 }
4063
4068
4069 template <typename T1, bool OPT>
4071 {
4072 return doFilteredSliceBy(this, container, value);
4073 }
4074
4075 template <typename T1, bool OPT>
4077 {
4078 return doSliceBy(this, container, value);
4079 }
4080
4081 private:
4082 std::vector<ArrowTableRef> extractTablesFromFiltered(std::vector<Filtered<T>>& tables)
4083 {
4084 std::vector<ArrowTableRef> outTables;
4085 for (auto& table : tables) {
4086 outTables.push_back(table.asArrowTableRef());
4087 }
4088 return outTables;
4089 }
4090};
4091
4097template <typename L, typename D, typename O, typename Key, typename H, typename... Ts>
4098struct IndexTable : Table<L, D, O> {
4099 static constexpr void isIndexTable() {};
4100 using self_t = IndexTable<L, D, O, Key, H, Ts...>;
4105 using first_t = typename H::binding_t;
4106 using rest_t = framework::pack<typename Ts::binding_t...>;
4107
4108 static constexpr const uint32_t binding_origin = Key::binding_origin;
4109 static constexpr const header::DataOrigin binding_origin_ = Key::binding_origin_;
4110
4111 template <typename... TA>
4112 void bindExternalIndices(TA*... current)
4113 {
4114 ([this](TA* cur) {
4115 if constexpr (binding_origin == TA::binding_origin) {
4116 this->bindExternalIndex(cur);
4117 }
4118 }(current),
4119 ...);
4120 }
4121
4123 : base_t{table} {}
4124
4127 IndexTable(std::vector<ArrowTableRef>&& tables)
4128 : base_t{tables[0]} {}
4129
4130 IndexTable(IndexTable const&) = default;
4132 IndexTable& operator=(IndexTable const&) = default;
4134
4139};
4140
4141template <typename T, bool APPLY>
4142struct SmallGroupsBase : public Filtered<T> {
4143 static constexpr void isSmallGroups() {};
4144 static constexpr bool applyFilters = APPLY;
4145
4146 SmallGroupsBase(std::vector<ArrowTableRef>&& tables, is_a_selection auto selection)
4147 : Filtered<T>(std::move(tables), selection) {}
4148};
4149
4150template <typename T>
4152
4153template <typename T>
4155} // namespace o2::soa
4156
4157#endif // O2_FRAMEWORK_ASOA_H_
header::DataDescription description
std::string binding
#define O2HASH(_Str_)
Pre-declare Hash specialization for a generic string.
Definition ASoA.h:299
#define O2ORIGIN(_Str_)
Pre-declare Hash specialization for an origin string.
Definition ASoA.h:308
consteval auto getIndexTargets()
SLICE.
Definition ASoA.h:2571
o2::monitoring::tags::Key Key
#define O2_BUILTIN_UNREACHABLE
#define O2_BUILTIN_LIKELY(x)
#define O2_BUILTIN_UNLIKELY(x)
Hit operator+(const Hit &lhs, const Hit &rhs)
Definition Hit.cxx:46
uint32_t hash
std::unique_ptr< expressions::Node > node
unsigned int uint32_t
int32_t i
configStandalone Light OpenGL display display_light Apply smoothing to points Enable Z buffer Highlight links Highlight seeds Highlight sector tracks Highlight final tracks Show individual Show related Highlight grid Show only individual collision Color clusters belonging to track objects Set line Enable drawing TPC data Enable drawing TOF data Enable drawing magnetic field Set field line step count Invert colors configStandalone Heavy OpenGL display display_heavy Show tracks with ITS contribution Show tracks with TOF contribution Enable propagation of loopers Show clusters at nominal x of pad row for early transformed data Split CE tracks when they cross the central Mark clusters Mark adjacent clusters Hide rejected tracks Apply filter on tracks to be displayed Separate increase X h configStandalone Camera window renderer OpenGL display display_camera Orient the camera such that the y axis is always upwards Full Screen MultiSample Anti Downsampling Anti Enable Vertical Sync Target frame or if the backend cannot limit to the refresh Use OpenGL indirect draws to reduce number of draw calls Display h configStandalone Vulkan display display_vulkan Have uniform buffers in host accessible device memory h configStandalone Internal display display_internal Number of updates the Qt GUI may send ahead of the last one the display has before it waits for the display Opacity of the console background Number of console lines the history is shortened to this when it reaches twice the size Time in seconds an info message fades out after setInfoTime h OpenGL display display Font size Do not use Freetype for font auto
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events Show standalone event Run event generator maximum time bin of continuous for triggered for automatic continuous for automatic continuous triggered uint64_t
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char e
configStandalone Reconstruction rec_tpc multiplier for the combined cluster track error during track following area in cm for the search of for z only used if decrease removal by when above this local occupancy rowx Shift of TPC revert cluster flag edge bit distance to edge exceeds this ZOffset for secondary multiple of radius max P of electron K BB bands crossing max P of electron p BB bands crossing max P of electron d BB bands crossing max P of electron t BB bands crossing min accepted dEdxMaxTPC of the track Additive extra cluster error for Y2 if edge flag set Additive extra cluster error for Y2 if single set Additive extra cluster error for Y2 if or single set Additive extra cluster error for Z2 if or single set Extra errors to add to track when crossing depending on addErrorsCECrossing Inner portion of y range in sector that is not used in searching for extrapolated track candidates factor2YS for track merging factor2K for track merging Margin in cm of Y position when rejecting edge clusters based on uncorrected track Y Max fraction of shared clusters for tracklet Except pad from cluster finding if total number of charges in a fragment is above this Except pad from cluster finding if number of consecutive charges in a fragment is above this Threshold where a timebin is considered disabling the noisy pad check for that pad Treat signal above this minimum as saturated Smoothing factor for the exponential Highly Ionising Particle tail filter Number of timebins to use for the averaging Add additional custom track errors when crossing relative as fraction of Do N fit passes in final fit of< 0:reject at max -n hits") AddOptionRTC(rejectIFCLowRadiusCluster, uint8_t, 1, "", 0, "Reject clusters that get the IFC mask error during refit") AddOptionRTC(dEdxTruncLow, uint8_t, 2, "", 0, "Low truncation threshold, fraction of 128") AddOptionRTC(dEdxTruncHigh, uint8_t, 77, "", 0, "High truncation threshold, fraction of 128") AddOptionRTC(extrapolationTracking, int8_t, 1, "", 0, "Enable Extrapolation Tracking(prolong tracks to adjacent sectors to find short segments)") AddOptionRTC(disableRefitAttachment, uint8_t, 0, "", 0, "Bitmask to disable certain attachment steps during refit(1:attachment, 2:propagation, 4:loop following, 8:mirroring)") AddOptionRTC(rejectionStrategy, uint8_t, o2::gpu::GPUSettings::RejectionStrategyA, "", 0, "Enable rejection of TPC clusters for compression(0=no, 1=strategy A, 2=strategy B)") AddOptionRTC(mergeLoopersAfterburner, uint8_t, 1, "", 0, "Run afterburner for additional looper merging") AddOptionRTC(compressionTypeMask, uint8_t, o2::gpu::GPUSettings::CompressionFull, "", 0, "TPC Compression mode bits(1=truncate charge/width LSB, 2=differences, 4=track-model)") AddOptionRTC(compressionSortOrder, uint8_t, o2::gpu::GPUSettings::SortTime, "", 0, "Sort order of TPC compression(0=time, 1=pad, 2=Z-time-pad, 3=Z-pad-time, 4=no sorting(use incoming order))") AddOptionRTC(sigBitsCharge, uint8_t, 4, "", 0, "Number of significant bits for TPC cluster charge in compression mode 1") AddOptionRTC(sigBitsWidth, uint8_t, 3, "", 0, "Number of significant bits for TPC cluster width in compression mode 1") AddOptionRTC(dropLoopers, uint8_t, 0, "", 0, "Drop looping tracks starting from second loop") AddOptionRTC(mergerInterpolateErrors, uint8_t, 1, "", 0, "Use interpolation instead of extrapolation for chi2 based cluster rejection") AddOptionRTC(mergerInterpolateRejectAlsoOnCurrentPosition, uint8_t, 1, "", 0, "When using mergerInterpolateErrors, reject based on chi2 twice computed with interpolated and current track position starting from NDF > mergerNonInterpolateRejectMinNDF Merge tracks accross the central electrode Enable PID response Add sub threshold clusters in TPC dEdx computation OR mask of TPC flags that will reject the cluster in alternative dEdx Reject edge clusters based on uncorrected track Y during track fit Increase decrease removal by when on this number of pads from the edge h configStandalone Reconstruction rec_trd Max chi2 for TRD tracklets to be matched to a track Chi2 cut for strict matching mode Number of sigmas for ITS TPC track time error estimate Addition to search road around track prolongation along Y in cm Optimal tracklet rphi resolution in maximum chi2 per attached tracklet for TRD tracks take into account the full likelihood of the slope including exponential tails Tracks with less attached tracklets are discarded after the tracking Post trigger Pile up integration time in BCs fits all iterations but the last one in projections Use material lookup table for TPC refit Apply workarounds to avoid cyclic merge should not be needed tpc dyn configStandalone Processing proc_rtc Replace constant variables static by constexpr expressions false
configStandalone Reconstruction rec_tpc multiplier for the combined cluster track error during track following area in cm for the search of for z only used if decrease removal by when above this local occupancy rowx Shift of TPC revert cluster flag edge bit distance to edge exceeds this ZOffset for secondary multiple of radius max P of electron K BB bands crossing max P of electron p BB bands crossing max P of electron d BB bands crossing max P of electron t BB bands crossing min accepted dEdxMaxTPC of the track Additive extra cluster error for Y2 if edge flag set Additive extra cluster error for Y2 if single set Additive extra cluster error for Y2 if or single set Additive extra cluster error for Z2 if or single set Extra errors to add to track when crossing depending on addErrorsCECrossing Inner portion of y range in sector that is not used in searching for extrapolated track candidates factor2YS for track merging factor2K for track merging Margin in cm of Y position when rejecting edge clusters based on uncorrected track Y Max fraction of shared clusters for tracklet Except pad from cluster finding if total number of charges in a fragment is above this Except pad from cluster finding if number of consecutive charges in a fragment is above this Threshold where a timebin is considered disabling the noisy pad check for that pad Treat signal above this minimum as saturated Smoothing factor for the exponential Highly Ionising Particle tail filter Number of timebins to use for the averaging Add additional custom track errors when crossing relative as fraction of Do N fit passes in final fit of< 0:reject at max -n hits") AddOptionRTC(rejectIFCLowRadiusCluster, uint8_t, 1, "", 0, "Reject clusters that get the IFC mask error during refit") AddOptionRTC(dEdxTruncLow, uint8_t, 2, "", 0, "Low truncation threshold, fraction of 128") AddOptionRTC(dEdxTruncHigh, uint8_t, 77, "", 0, "High truncation threshold, fraction of 128") AddOptionRTC(extrapolationTracking, int8_t, 1, "", 0, "Enable Extrapolation Tracking(prolong tracks to adjacent sectors to find short segments)") AddOptionRTC(disableRefitAttachment, uint8_t, 0, "", 0, "Bitmask to disable certain attachment steps during refit(1:attachment, 2:propagation, 4:loop following, 8:mirroring)") AddOptionRTC(rejectionStrategy, uint8_t, o2::gpu::GPUSettings::RejectionStrategyA, "", 0, "Enable rejection of TPC clusters for compression(0=no, 1=strategy A, 2=strategy B)") AddOptionRTC(mergeLoopersAfterburner, uint8_t, 1, "", 0, "Run afterburner for additional looper merging") AddOptionRTC(compressionTypeMask, uint8_t, o2::gpu::GPUSettings::CompressionFull, "", 0, "TPC Compression mode bits(1=truncate charge/width LSB, 2=differences, 4=track-model)") AddOptionRTC(compressionSortOrder, uint8_t, o2::gpu::GPUSettings::SortTime, "", 0, "Sort order of TPC compression(0=time, 1=pad, 2=Z-time-pad, 3=Z-pad-time, 4=no sorting(use incoming order))") AddOptionRTC(sigBitsCharge, uint8_t, 4, "", 0, "Number of significant bits for TPC cluster charge in compression mode 1") AddOptionRTC(sigBitsWidth, uint8_t, 3, "", 0, "Number of significant bits for TPC cluster width in compression mode 1") AddOptionRTC(dropLoopers, uint8_t, 0, "", 0, "Drop looping tracks starting from second loop") AddOptionRTC(mergerInterpolateErrors, uint8_t, 1, "", 0, "Use interpolation instead of extrapolation for chi2 based cluster rejection") AddOptionRTC(mergerInterpolateRejectAlsoOnCurrentPosition, uint8_t, 1, "", 0, "When using mergerInterpolateErrors, reject based on chi2 twice computed with interpolated and current track position starting from NDF > mergerNonInterpolateRejectMinNDF Merge tracks accross the central electrode Enable PID response Add sub threshold clusters in TPC dEdx computation OR mask of TPC flags that will reject the cluster in alternative dEdx Reject edge clusters based on uncorrected track Y during track fit Increase decrease removal by when on this number of pads from the edge h configStandalone Reconstruction rec_trd Max chi2 for TRD tracklets to be matched to a track Chi2 cut for strict matching mode Number of sigmas for ITS TPC track time error estimate Addition to search road around track prolongation along Y in cm Optimal tracklet rphi resolution in maximum chi2 per attached tracklet for TRD tracks take into account the full likelihood of the slope including exponential tails Tracks with less attached tracklets are discarded after the tracking Post trigger Pile up integration time in BCs fits all iterations but the last one in projections Use material lookup table for TPC refit Apply workarounds to avoid cyclic merge should not be needed tpc dyn configStandalone Processing proc_rtc Replace constant variables static by constexpr expressions Compile RTC in deterministic with NO_FAST_MATH flags and GPUCA_DETERMINISTIC_MODE define Use RTC to optimize GPU code h configStandalone Processing proc_rtctech Use a file lock to serialize access to the cache folder int32_t
configStandalone Reconstruction rec_tpc multiplier for the combined cluster track error during track following area in cm for the search of for z only used if decrease removal by when above this local occupancy rowx Shift of TPC revert cluster flag edge bit distance to edge exceeds this ZOffset for secondary multiple of radius max P of electron K BB bands crossing max P of electron p BB bands crossing max P of electron d BB bands crossing max P of electron t BB bands crossing min accepted dEdxMaxTPC of the track Additive extra cluster error for Y2 if edge flag set Additive extra cluster error for Y2 if single set Additive extra cluster error for Y2 if or single set Additive extra cluster error for Z2 if or single set Extra errors to add to track when crossing depending on addErrorsCECrossing Inner portion of y range in sector that is not used in searching for extrapolated track candidates factor2YS for track merging factor2K for track merging Margin in cm of Y position when rejecting edge clusters based on uncorrected track Y Max fraction of shared clusters for tracklet Except pad from cluster finding if total number of charges in a fragment is above this Except pad from cluster finding if number of consecutive charges in a fragment is above this Threshold where a timebin is considered disabling the noisy pad check for that pad Treat signal above this minimum as saturated Smoothing factor for the exponential Highly Ionising Particle tail filter Number of timebins to use for the averaging Add additional custom track errors when crossing relative as fraction of Do N fit passes in final fit of< 0:reject at max -n hits") AddOptionRTC(rejectIFCLowRadiusCluster, uint8_t, 1, "", 0, "Reject clusters that get the IFC mask error during refit") AddOptionRTC(dEdxTruncLow, uint8_t, 2, "", 0, "Low truncation threshold, fraction of 128") AddOptionRTC(dEdxTruncHigh, uint8_t, 77, "", 0, "High truncation threshold, fraction of 128") AddOptionRTC(extrapolationTracking, int8_t, 1, "", 0, "Enable Extrapolation Tracking(prolong tracks to adjacent sectors to find short segments)") AddOptionRTC(disableRefitAttachment, uint8_t, 0, "", 0, "Bitmask to disable certain attachment steps during refit(1:attachment, 2:propagation, 4:loop following, 8:mirroring)") AddOptionRTC(rejectionStrategy, uint8_t, o2::gpu::GPUSettings::RejectionStrategyA, "", 0, "Enable rejection of TPC clusters for compression(0=no, 1=strategy A, 2=strategy B)") AddOptionRTC(mergeLoopersAfterburner, uint8_t, 1, "", 0, "Run afterburner for additional looper merging") AddOptionRTC(compressionTypeMask, uint8_t, o2::gpu::GPUSettings::CompressionFull, "", 0, "TPC Compression mode bits(1=truncate charge/width LSB, 2=differences, 4=track-model)") AddOptionRTC(compressionSortOrder, uint8_t, o2::gpu::GPUSettings::SortTime, "", 0, "Sort order of TPC compression(0=time, 1=pad, 2=Z-time-pad, 3=Z-pad-time, 4=no sorting(use incoming order))") AddOptionRTC(sigBitsCharge, uint8_t, 4, "", 0, "Number of significant bits for TPC cluster charge in compression mode 1") AddOptionRTC(sigBitsWidth, uint8_t, 3, "", 0, "Number of significant bits for TPC cluster width in compression mode 1") AddOptionRTC(dropLoopers, uint8_t, 0, "", 0, "Drop looping tracks starting from second loop") AddOptionRTC(mergerInterpolateErrors, uint8_t, 1, "", 0, "Use interpolation instead of extrapolation for chi2 based cluster rejection") AddOptionRTC(mergerInterpolateRejectAlsoOnCurrentPosition, uint8_t, 1, "", 0, "When using mergerInterpolateErrors, reject based on chi2 twice computed with interpolated and current track position starting from NDF > mergerNonInterpolateRejectMinNDF Merge tracks accross the central electrode Enable PID response Add sub threshold clusters in TPC dEdx computation OR mask of TPC flags that will reject the cluster in alternative dEdx Reject edge clusters based on uncorrected track Y during track fit Increase decrease removal by when on this number of pads from the edge h configStandalone Reconstruction rec_trd Max chi2 for TRD tracklets to be matched to a track Chi2 cut for strict matching mode Number of sigmas for ITS TPC track time error estimate Addition to search road around track prolongation along Y in cm Optimal tracklet rphi resolution in maximum chi2 per attached tracklet for TRD tracks take into account the full likelihood of the slope including exponential tails Tracks with less attached tracklets are discarded after the tracking Post trigger Pile up integration time in BCs fits all iterations but the last one in projections Use material lookup table for TPC refit Apply workarounds to avoid cyclic merge should not be needed tpc dyn configStandalone Processing proc_rtc bool
configStandalone Reconstruction rec_tpc multiplier for the combined cluster track error during track following area in cm for the search of for z only used if decrease removal by when above this local occupancy rowx Shift of TPC revert cluster flag edge bit distance to edge exceeds this ZOffset for secondary multiple of radius max P of electron K BB bands crossing max P of electron p BB bands crossing max P of electron d BB bands crossing max P of electron t BB bands crossing min accepted dEdxMaxTPC of the track Additive extra cluster error for Y2 if edge flag set Additive extra cluster error for Y2 if single set Additive extra cluster error for Y2 if or single set Additive extra cluster error for Z2 if or single set Extra errors to add to track when crossing depending on addErrorsCECrossing Inner portion of y range in sector that is not used in searching for extrapolated track candidates factor2YS for track merging factor2K for track merging Margin in cm of Y position when rejecting edge clusters based on uncorrected track Y Max fraction of shared clusters for tracklet Except pad from cluster finding if total number of charges in a fragment is above this Except pad from cluster finding if number of consecutive charges in a fragment is above this Threshold where a timebin is considered disabling the noisy pad check for that pad Treat signal above this minimum as saturated Smoothing factor for the exponential Highly Ionising Particle tail filter Number of timebins to use for the averaging Add additional custom track errors when crossing relative as fraction of Do N fit passes in final fit of< 0:reject at max -n hits") AddOptionRTC(rejectIFCLowRadiusCluster, uint8_t, 1, "", 0, "Reject clusters that get the IFC mask error during refit") AddOptionRTC(dEdxTruncLow, uint8_t, 2, "", 0, "Low truncation threshold, fraction of 128") AddOptionRTC(dEdxTruncHigh, uint8_t, 77, "", 0, "High truncation threshold, fraction of 128") AddOptionRTC(extrapolationTracking, int8_t, 1, "", 0, "Enable Extrapolation Tracking(prolong tracks to adjacent sectors to find short segments)") AddOptionRTC(disableRefitAttachment, uint8_t, 0, "", 0, "Bitmask to disable certain attachment steps during refit(1:attachment, 2:propagation, 4:loop following, 8:mirroring)") AddOptionRTC(rejectionStrategy, uint8_t, o2::gpu::GPUSettings::RejectionStrategyA, "", 0, "Enable rejection of TPC clusters for compression(0=no, 1=strategy A, 2=strategy B)") AddOptionRTC(mergeLoopersAfterburner, uint8_t, 1, "", 0, "Run afterburner for additional looper merging") AddOptionRTC(compressionTypeMask, uint8_t, o2::gpu::GPUSettings::CompressionFull, "", 0, "TPC Compression mode bits(1=truncate charge/width LSB, 2=differences, 4=track-model)") AddOptionRTC(compressionSortOrder, uint8_t, o2::gpu::GPUSettings::SortTime, "", 0, "Sort order of TPC compression(0=time, 1=pad, 2=Z-time-pad, 3=Z-pad-time, 4=no sorting(use incoming order))") AddOptionRTC(sigBitsCharge, uint8_t, 4, "", 0, "Number of significant bits for TPC cluster charge in compression mode 1") AddOptionRTC(sigBitsWidth, uint8_t, 3, "", 0, "Number of significant bits for TPC cluster width in compression mode 1") AddOptionRTC(dropLoopers, uint8_t, 0, "", 0, "Drop looping tracks starting from second loop") AddOptionRTC(mergerInterpolateErrors, uint8_t, 1, "", 0, "Use interpolation instead of extrapolation for chi2 based cluster rejection") AddOptionRTC(mergerInterpolateRejectAlsoOnCurrentPosition, uint8_t, 1, "", 0, "When using mergerInterpolateErrors, reject based on chi2 twice computed with interpolated and current track position starting from NDF > mergerNonInterpolateRejectMinNDF Merge tracks accross the central electrode Enable PID response Add sub threshold clusters in TPC dEdx computation OR mask of TPC flags that will reject the cluster in alternative dEdx Reject edge clusters based on uncorrected track Y during track fit Increase decrease removal by when on this number of pads from the edge h configStandalone Reconstruction rec_trd Max chi2 for TRD tracklets to be matched to a track Chi2 cut for strict matching mode Number of sigmas for ITS TPC track time error estimate Addition to search road around track prolongation along Y in cm Optimal tracklet rphi resolution in maximum chi2 per attached tracklet for TRD tracks take into account the full likelihood of the slope including exponential tails Tracks with less attached tracklets are discarded after the tracking Post trigger Pile up integration time in BCs fits all iterations but the last one in projections Use material lookup table for TPC refit Apply workarounds to avoid cyclic merge should not be needed tpc dyn configStandalone Processing proc_rtc true
std::vector< o2::MCCompLabel > labels
std::string columnLabel
uint16_t pos
Definition RawData.h:3
uint32_t res
Definition RawData.h:0
uint32_t c
Definition RawData.h:2
uint32_t version
Definition RawData.h:8
TBranch * ptr
void merge(Options const &options)
StringRef key
Definition B.h:16
Class for time synchronization of RawReader instances.
int64_t const * mCurrentPos
Definition ASoA.h:613
ColumnIterator(arrow::ChunkedArray const *column)
Definition ASoA.h:508
ColumnIterator(ColumnIterator< T, ChunkingPolicy > const &)=default
uint64_t const * mGlobalOffset
Definition ASoA.h:614
void moveToEnd()
Move the iterator to the end of the column.
Definition ASoA.h:564
ColumnIterator< T > & moveToPos()
Definition ASoA.h:606
auto operator*() const
Definition ASoA.h:580
ColumnIterator< T, ChunkingPolicy > & operator=(ColumnIterator< T, ChunkingPolicy > const &)=default
unwrap_t< T > const * mCurrent
Definition ASoA.h:612
unwrap_t< T > const * mLast
Definition ASoA.h:615
ColumnIterator(ColumnIterator< T, ChunkingPolicy > &&)=default
void prevChunk() const
Definition ASoA.h:540
arrow::ChunkedArray const * mColumn
Definition ASoA.h:616
auto operator*() const
Definition ASoA.h:573
ColumnIterator< T, ChunkingPolicy > & operator=(ColumnIterator< T, ChunkingPolicy > &&)=default
void moveToChunk(int chunk)
Definition ASoA.h:550
void nextChunk() const
Move the iterator to the next chunk.
Definition ASoA.h:530
bool isCached() const
Definition ASoA.h:3771
auto sliceByCachedUnsorted(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
Definition ASoA.h:3718
int64_t tableSize() const
Definition ASoA.h:3648
auto & cached_begin()
Definition ASoA.h:3628
typename T::external_index_columns_t external_index_columns_t
Definition ASoA.h:3589
auto select(framework::expressions::Filter const &f) const
Definition ASoA.h:3735
static auto getSpan(gandiva::Selection const &sel)
Definition ASoA.h:3671
int64_t size() const
Definition ASoA.h:3643
T::template iterator_template_o< FilteredIndexPolicy, self_t > iterator
Definition ASoA.h:3591
auto rawSliceBy(o2::framework::Preslice< T1 > const &container, int value) const
Definition ASoA.h:3708
T::template iterator_template_o< DefaultIndexPolicy, self_t > unfiltered_iterator
Definition ASoA.h:3592
void copyIndexBindings(T1 &dest) const
Definition ASoA.h:3702
auto const & getSelectedRows() const
Definition ASoA.h:3653
void setPointerReconstructor(framework::PointerReconstructor const &pointerReconstructor)
Definition ASoA.h:3776
typename T::columns_t columns_t
Definition ASoA.h:3587
auto emptySlice() const
Definition ASoA.h:3666
void bindExternalIndices(TA *... current)
Definition ASoA.h:3577
void sumWithSelection(is_a_selection auto selection)
Definition ASoA.h:3751
void bindInternalIndicesTo(I const *ptr)
Definition ASoA.h:3690
FilteredBase(std::vector< ArrowTableRef > &&tables, is_a_selection auto selection)
Definition ASoA.h:3595
auto sliceBy(o2::framework::PresliceBase< T1, framework::PreslicePolicyGeneral, OPT > const &container, int value) const
Definition ASoA.h:3730
auto rawSlice(uint64_t start, uint64_t end) const
Definition ASoA.h:3658
auto sliceBy(o2::framework::PresliceBase< T1, framework::PreslicePolicySorted, OPT > const &container, int value) const
Definition ASoA.h:3724
iterator iteratorAt(uint64_t i) const
Definition ASoA.h:3638
iterator const_iterator
Definition ASoA.h:3593
typename T::table_t table_t
Definition ASoA.h:3572
typename T::persistent_columns_t persistent_columns_t
Definition ASoA.h:3588
static constexpr void isFilteredBase()
Definition ASoA.h:3570
RowViewSentinel end() const
Definition ASoA.h:3623
void intersectWithSelection(is_a_selection auto selection)
Definition ASoA.h:3761
void bindExternalIndicesRaw(std::vector< o2::soa::Binding > &&ptrs)
Definition ASoA.h:3684
const_iterator begin() const
Definition ASoA.h:3611
unfiltered_iterator rawIteratorAt(uint64_t i) const
Definition ASoA.h:3616
int isInSelectedRows(int i) const
Definition ASoA.h:3742
auto sliceByCached(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
Definition ASoA.h:3713
void doCopyIndexBindings(framework::pack< Cs... >, T1 &dest) const
Definition ASoA.h:3696
iterator begin()
Definition ASoA.h:3606
auto const & cached_begin() const
Definition ASoA.h:3633
auto sliceBy(o2::framework::PresliceBase< T1, framework::PreslicePolicySorted, OPT > const &container, int value) const
Definition ASoA.h:4070
Filtered(std::vector< Filtered< T > > &&tables, is_a_selection auto selection)
Definition ASoA.h:3985
typename FilteredBase< typename T::table_t >::table_t table_t
Definition ASoA.h:3968
typename T::template iterator_template_o< DefaultIndexPolicy, self_t > unfiltered_iterator
Definition ASoA.h:3972
auto sliceBy(o2::framework::PresliceBase< T1, framework::PreslicePolicyGeneral, OPT > const &container, int value) const
Definition ASoA.h:4076
typename T::template iterator_template_o< FilteredIndexPolicy, self_t > iterator
Definition ASoA.h:3971
typename T::columns_t columns_t
Definition ASoA.h:3969
const_iterator begin() const
Definition ASoA.h:3980
Filtered< Filtered< T > > operator+=(is_a_selection auto selection)
Definition ASoA.h:4005
Filtered< Filtered< T > > operator*(is_a_selection auto selection)
Definition ASoA.h:4016
Filtered< Filtered< T > > operator+(is_a_selection auto selection)
Definition ASoA.h:3993
unfiltered_iterator rawIteratorAt(uint64_t i) const
Definition ASoA.h:4039
Filtered< Filtered< T > > operator*=(is_a_selection auto selection)
Definition ASoA.h:4028
Filtered< Filtered< T > > operator+=(Filtered< T > const &other)
Definition ASoA.h:4011
auto rawSlice(uint64_t start, uint64_t end) const
Definition ASoA.h:4046
Filtered< Filtered< T > > operator+(Filtered< T > const &other)
Definition ASoA.h:4000
Filtered< Filtered< T > > operator*=(Filtered< T > const &other)
Definition ASoA.h:4034
auto sliceByCached(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
Definition ASoA.h:4059
Filtered< Filtered< T > > operator*(Filtered< T > const &other)
Definition ASoA.h:4023
auto sliceByCachedUnsorted(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
Definition ASoA.h:4064
Filtered< T > operator+=(Filtered< T > const &other)
Definition ASoA.h:3876
Filtered(std::vector< ArrowTableRef > &&tables, is_a_selection auto selection)
Definition ASoA.h:3855
auto sliceBy(o2::framework::PresliceBase< T1, framework::PreslicePolicyGeneral, OPT > const &container, int value) const
Definition ASoA.h:3949
iterator const_iterator
Definition ASoA.h:3843
iterator begin()
Definition ASoA.h:3845
auto sliceByCachedUnsorted(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
Definition ASoA.h:3937
Filtered< T > operator+(Filtered< T > const &other)
Definition ASoA.h:3865
auto emptySlice() const
Definition ASoA.h:3921
const_iterator begin() const
Definition ASoA.h:3850
Filtered< T > operator+(is_a_selection auto selection)
Definition ASoA.h:3858
T::template iterator_template_o< FilteredIndexPolicy, self_t > iterator
Definition ASoA.h:3841
auto sliceByCached(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
Definition ASoA.h:3932
auto select(framework::expressions::Filter const &f) const
Definition ASoA.h:3954
Filtered< T > operator*(is_a_selection auto selection)
Definition ASoA.h:3881
T::template iterator_template_o< DefaultIndexPolicy, self_t > unfiltered_iterator
Definition ASoA.h:3842
unfiltered_iterator rawIteratorAt(uint64_t i) const
Definition ASoA.h:3904
Filtered< T > operator*=(Filtered< T > const &other)
Definition ASoA.h:3899
Filtered< T > operator*(Filtered< T > const &other)
Definition ASoA.h:3888
auto rawSliceBy(o2::framework::Preslice< T1 > const &container, int value) const
Definition ASoA.h:3927
auto rawSlice(uint64_t start, uint64_t end) const
Definition ASoA.h:3913
auto sliceBy(o2::framework::PresliceBase< T1, framework::PreslicePolicySorted, OPT > const &container, int value) const
Definition ASoA.h:3943
typename T::table_t table_t
Definition ASoA.h:3838
typename T::columns_t columns_t
Definition ASoA.h:3839
Filtered< T > operator+=(is_a_selection auto selection)
Definition ASoA.h:3870
Filtered< T > operator*=(is_a_selection auto selection)
Definition ASoA.h:3893
void bindInternalIndicesExplicit(o2::soa::Binding binding)
Definition ASoA.h:2126
decltype([]< typename... C >(framework::pack< C... > &&) consteval -> framework::selected_pack< soa::is_persistent_column_t, C... > {}(columns_t{})) persistent_columns_t
Definition ASoA.h:1768
void setPointerReconstructor(framework::PointerReconstructor const &pointerReconstructor)
Definition ASoA.h:2187
auto & cached_begin()
Definition ASoA.h:2019
iterator iteratorAt(uint64_t i) const
Definition ASoA.h:2048
static constexpr const auto ref
Definition ASoA.h:1719
auto offset() const
Return offset.
Definition ASoA.h:2086
static consteval bool hasOriginal()
Definition ASoA.h:1755
unfiltered_iterator begin()
Definition ASoA.h:2029
int64_t tableSize() const
Definition ASoA.h:2096
auto rawSlice(uint64_t start, uint64_t end) const
Definition ASoA.h:2177
Table(std::vector< o2::soa::ArrowTableRef > &&tables)
Definition ASoA.h:1975
void bindExternalIndices(TA *... current)
Definition ASoA.h:2104
auto select(framework::expressions::Filter const &f) const
Definition ASoA.h:2154
decltype([]< typename... C >(framework::pack< C... >) consteval -> framework::pack< typename C::type... > {}(persistent_columns_t{})) column_types
Definition ASoA.h:1769
unfiltered_iterator unfiltered_const_iterator
Definition ASoA.h:1949
decltype([]() { if constexpr(sizeof...(Ts)==0) { return iterator_template< IP, Parent >{} iterator_template_o
Definition ASoA.h:1934
auto const & cached_begin() const
Definition ASoA.h:2024
auto emptySlice() const
Definition ASoA.h:2182
auto sliceByCachedUnsorted(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
Definition ASoA.h:2166
TableIteratorBase< IP, Parent, T... > iterator_template
Definition ASoA.h:1929
static constexpr header::DataOrigin binding_origin_
Definition ASoA.h:1728
void bindExternalIndicesRaw(std::vector< o2::soa::Binding > &&ptrs)
Definition ASoA.h:2137
auto sliceBy(o2::framework::PresliceBase< T1, Policy, OPT > const &container, int value) const
Definition ASoA.h:2172
iterator unfiltered_iterator
Definition ASoA.h:1947
void bindExternalIndex(TA *current)
Definition ASoA.h:2115
std::shared_ptr< arrow::Table > asArrowTable() const
Return a type erased arrow table backing store for / the type safe table.
Definition ASoA.h:2071
filtered_iterator filtered_begin(std::span< int64_t const > selection)
Definition ASoA.h:2039
void doCopyIndexBindings(framework::pack< Cs... >, T &dest) const
Definition ASoA.h:2143
int64_t size() const
Size of the table, in rows.
Definition ASoA.h:2091
static constexpr auto column_hashes
Definition ASoA.h:1762
decltype(getColumns< ref, Ts... >()) columns_t
Definition ASoA.h:1760
arrow::ChunkedArray * getIndexToKey()
Definition ASoA.h:2000
decltype([]< typename... C >(framework::pack< C... > &&) consteval -> framework::selected_pack< soa::is_external_index_t, C... > {}(columns_t{})) external_index_columns_t
Definition ASoA.h:1771
RowViewSentinel end()
Definition ASoA.h:2034
ArrowTableRef asArrowTableRef() const
Definition ASoA.h:2081
static constexpr const uint32_t binding_origin
Definition ASoA.h:1727
static consteval auto isIndexTargetOf()
Definition ASoA.h:1732
std::shared_ptr< arrow::Table > asArrowTableConstrained() const
Definition ASoA.h:2076
iterator_template_o< FilteredIndexPolicy, table_t > filtered_iterator
Definition ASoA.h:1945
unfiltered_const_iterator begin() const
Definition ASoA.h:2060
void copyIndexBindings(T &dest) const
Definition ASoA.h:2149
static constexpr const auto originalLabels
Definition ASoA.h:1724
Table< L, D, O, Ts... > self_t
Definition ASoA.h:1720
static consteval auto isIndexTargetOf()
Definition ASoA.h:1739
void doBindInternalIndicesExplicit(framework::pack< Cs... >, o2::soa::Binding binding)
Definition ASoA.h:2132
static constexpr const auto originals
Definition ASoA.h:1723
Table(std::vector< std::shared_ptr< arrow::Table > > &&tables)
Definition ASoA.h:1987
decltype([]< typename... C >(framework::pack< C... > &&) consteval -> framework::selected_pack< soa::is_self_index_t, C... > {}(columns_t{})) internal_index_columns_t
Definition ASoA.h:1772
Table(std::shared_ptr< arrow::Table > table)
Definition ASoA.h:1970
Table(o2::soa::ArrowTableRef tableRef)
Definition ASoA.h:1951
Table(std::vector< std::shared_ptr< arrow::Table > > &&tables)
Definition ASoA.h:1993
RowViewSentinel end() const
Definition ASoA.h:2065
static constexpr void isSOATable()
Definition ASoA.h:1718
auto sliceByCached(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
Definition ASoA.h:2161
void bindInternalIndicesTo(I const *ptr)
Definition ASoA.h:2121
unfiltered_iterator rawIteratorAt(uint64_t i) const
Definition ASoA.h:2053
Table(std::vector< o2::soa::ArrowTableRef > &&tables)
Definition ASoA.h:1981
iterator_template_o< DefaultIndexPolicy, table_t > iterator
Definition ASoA.h:1944
GLint GLenum GLint x
Definition glcorearb.h:403
GLenum func
Definition glcorearb.h:778
GLint GLsizei count
Definition glcorearb.h:399
GLsizeiptr size
Definition glcorearb.h:659
GLuint GLsizei const GLuint const GLintptr * offsets
Definition glcorearb.h:2595
GLuint GLuint end
Definition glcorearb.h:469
GLdouble f
Definition glcorearb.h:310
GLboolean GLboolean GLboolean b
Definition glcorearb.h:1233
GLenum GLint * range
Definition glcorearb.h:1899
GLsizei const GLfloat * value
Definition glcorearb.h:819
GLint GLint GLsizei GLint GLenum GLenum type
Definition glcorearb.h:275
GLboolean * data
Definition glcorearb.h:298
GLintptr offset
Definition glcorearb.h:660
GLuint GLsizei GLsizei * length
Definition glcorearb.h:790
GLuint GLsizei const GLchar * label
Definition glcorearb.h:2519
GLsizei GLenum const void * indices
Definition glcorearb.h:400
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GLboolean r
Definition glcorearb.h:1233
GLuint start
Definition glcorearb.h:469
GLenum GLenum GLsizei len
Definition glcorearb.h:4232
GLboolean GLboolean GLboolean GLboolean a
Definition glcorearb.h:1233
GLint ref
Definition glcorearb.h:291
std::shared_ptr< gandiva::SelectionVector > Selection
Definition Expressions.h:45
consteval const char * origin_str()
Definition ASoA.h:370
consteval const char * signature()
Definition ASoA.h:382
consteval auto replaceOrigin()
Replace origins in the TableRef array.
Definition ASoA.h:402
constexpr framework::ConcreteDataMatcher matcher()
Definition ASoA.h:388
consteval auto filterForKey()
Filter TableRef array for compatibility with Key table.
Definition ASoA.h:287
consteval const char * label()
Definition ASoA.h:364
consteval header::DataOrigin origin()
Definition ASoA.h:376
gandiva::Selection createSelection(std::shared_ptr< arrow::Table > const &table, Filter const &expression)
Function for creating gandiva selection from our internal filter tree.
Defining ITS Vertex explicitly as messageable.
Definition Cartesian.h:288
std::decay_t< decltype(select_pack< Condition >(pack<>{}, Pack{}, CondPack{}))> selected_pack_multicondition
Definition Pack.h:181
std::decay_t< decltype(prune_voids_pack(pack<>{}, with_condition_pack< Condition, Types... >{}))> selected_pack
Definition Pack.h:179
std::function< std::byte *(fair::mq::shmem::MetaHeader &&)> PointerReconstructor
Definition ASoA.h:52
decltype(intersected_pack(Ps{}...)) full_intersected_pack_t
Definition Pack.h:283
typename pack_element< I, T >::type pack_element_t
Definition Pack.h:56
consteval size_t has_type_at_v(pack< Ts... >)
Definition Pack.h:228
constexpr std::size_t pack_size(pack< Ts... > const &)
template function to determine number of types in a pack
Definition Pack.h:28
decltype(concatenate_pack_unique(Ps{}...)) concatenated_pack_unique_t
Definition Pack.h:319
std::string strToUpper(std::string &&str)
Definition ASoA.cxx:331
typename pack_element< 0, T >::type pack_head_t
Definition Pack.h:59
std::string cutString(std::string &&str)
Definition ASoA.cxx:322
std::vector< std::vector< int64_t > > ListVector
Descriptor< gSizeDataDescriptionString > DataDescription
Definition DataHeader.h:554
const int tableSize
R getColumnValue(const T &rowIterator)
Definition ASoA.h:2223
ColumnGetterFunction< R, typename T::iterator > getColumnGetterByLabel(const std::string_view &targetColumnLabel)
Definition ASoA.h:2290
void * extractCCDBPayload(char *payload, size_t size, TClass const *cl, const char *what)
Definition ASoA.cxx:252
consteval auto computeOriginals()
Definition ASoA.h:1700
auto createFieldsFromColumns(framework::pack< C... >)
Definition ASoA.h:77
SelectionVector selectionToVector(gandiva::Selection const &sel)
Definition ASoA.cxx:48
constexpr bool is_persistent_v
column identification
Definition ASoA.h:209
constexpr bool is_ng_index_equivalent_v
Definition ASoA.h:460
consteval auto remove_if(L l)
Definition ASoA.h:155
constexpr auto join(Ts const &... t)
Definition ASoA.h:3506
auto doSliceBy(T const *table, o2::framework::PresliceBase< C, Policy, OPT > const &container, int value)
Definition ASoA.h:1527
void notBoundTable(const char *tableName)
Definition ASoA.cxx:237
SelectionVector sliceSelection(std::span< int64_t const > const &mSelectedRows, int64_t nrows, uint64_t offset)
Definition ASoA.cxx:58
auto doFilteredSliceBy(T const *table, o2::framework::PresliceBase< C, framework::PreslicePolicySorted, OPT > const &container, int value)
Definition ASoA.h:1602
constexpr auto concat(Ts const &... t)
Definition ASoA.h:3558
consteval auto intersectOriginals()
Definition ASoA.h:190
consteval auto getColumns()
Definition ASoA.h:1672
std::vector< int64_t > SelectionVector
Definition ASoA.h:444
std::conditional_t< is_binding_compatible_v< T, typename B::binding_t >(), std::true_type, std::false_type > is_binding_compatible
Definition ASoA.h:1294
consteval auto mergeOriginals()
Definition ASoA.h:173
constexpr bool is_soa_filtered_v
Definition ASoA.h:1514
typename std::conditional_t< is_index_column< C >, std::true_type, std::false_type > is_external_index_t
Definition ASoA.h:215
void missingFilterDeclaration(int hash, int ai)
Definition ASoA.cxx:33
auto doSliceByCachedUnsorted(T const *table, framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache)
Definition ASoA.h:1638
auto doSliceByCached(T const *table, framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache)
Definition ASoA.h:1616
void accessingInvalidIndexFor(const char *getter)
Definition ASoA.cxx:25
auto select(T const &t, framework::expressions::Filter const &f)
Definition ASoA.h:1659
consteval auto base_iter(framework::pack< C... > &&) -> TableIterator< D, O, IP, C... >
Definition ASoA.h:1667
constexpr bool is_index_equivalent_v
Definition ASoA.h:457
constexpr bool is_soa_join_v
Definition ASoA.h:3512
void dereferenceWithWrongType(const char *getter, const char *target)
Definition ASoA.cxx:29
consteval bool is_binding_compatible_v()
Definition ASoA.h:1288
void emptyColumnLabel()
Definition ASoA.cxx:43
typename unwrap< T >::type unwrap_t
Definition ASoA.h:492
auto prepareFilteredSlice(T const *table, o2::soa::ArrowTableRef slice)
Definition ASoA.h:1583
void getterNotFound(const char *targetColumnLabel)
Definition ASoA.cxx:38
auto doFilteredSliceByCached(T const *table, framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache)
Definition ASoA.h:1629
void missingOptionalPreslice(const char *label, const char *key)
Definition ASoA.cxx:247
constexpr char asciiToLower(char c)
Definition ASoA.h:71
auto doSliceByHelper(T const *table, std::span< const int64_t > const &selection)
Definition ASoA.h:1544
std::function< framework::ConcreteDataMatcher(framework::ConcreteDataMatcher &&)> originReplacement(header::DataOrigin newOrigin)
Definition ASoA.cxx:308
consteval bool is_compatible()
Definition ASoA.h:1275
arrow::ChunkedArray * getIndexFromLabel(arrow::Table *table, std::string_view label)
Definition ASoA.cxx:219
consteval auto merge()
Helpers to manipulate TableRef arrays.
Definition ASoA.h:132
consteval auto merge_if(L l)
Definition ASoA.h:143
std::conditional_t< is_persistent_column< C >, std::true_type, std::false_type > is_persistent_column_t
Definition ASoA.h:212
typename arrow_array_for< T >::type arrow_array_for_t
Definition ArrowTypes.h:166
void notFoundColumn(const char *label, const char *key)
Definition ASoA.cxx:242
std::conditional_t< is_dynamic_column< T >, std::true_type, std::false_type > is_dynamic_t
pack filtering helpers
Definition Concepts.h:95
typename std::conditional_t< is_self_index_column< C >, std::true_type, std::false_type > is_self_index_t
Definition ASoA.h:218
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
FIXME: do not use data model tables.
static constexpr uint32_t hash
Definition ASoA.h:281
static constexpr char const *const str
Definition ASoA.h:282
static constexpr void isHash()
Definition ASoA.h:280
static constexpr void isMetadataTrait()
Definition ASoA.h:272
Base type for table metadata.
Definition ASoA.h:239
static consteval int getIndexPosToKey()
Definition ASoA.h:259
framework::selected_pack< soa::is_self_index_t, Cs... > internal_index_columns_t
Definition ASoA.h:244
framework::selected_pack< soa::is_persistent_column_t, Cs... > persistent_columns_t
Definition ASoA.h:242
static std::shared_ptr< arrow::Schema > getSchema()
Definition ASoA.h:264
framework::selected_pack< soa::is_external_index_t, Cs... > external_index_columns_t
Definition ASoA.h:243
static consteval std::array< bool, sizeof...(PCs)> getMap(framework::pack< PCs... >)
Definition ASoA.h:247
static constexpr void isTableMetadata()
Definition ASoA.h:240
SliceInfoUnsortedPtr getCacheUnsortedFor(Entry const &bindingKey) const
SliceInfoPtr getCacheFor(Entry const &bindingKey) const
static constexpr bool optional
Definition ASoA.h:1448
PresliceBase(expressions::BindingNode index_)
Definition ASoA.h:1453
std::span< const int64_t > getSliceFor(int value) const
Definition ASoA.h:1468
const std::string binding
Definition ASoA.h:1451
o2::soa::ArrowTableRef getSliceFor(int value, o2::soa::ArrowTableRef const &input) const
Definition ASoA.h:1458
static constexpr void isPresliceContainer()
Definition ASoA.h:1447
static constexpr void isPresliceGroup()
Definition ASoA.h:1501
tracks origin in bindingKey matcher to handle the correct arguments
Definition ASoA.h:1422
const std::string binding
Definition ASoA.h:1424
Entry const & getBindingKey() const
Definition ASoA.cxx:342
static constexpr void isPreslicePolicy()
Definition ASoA.h:1423
SliceInfoUnsortedPtr sliceInfo
Definition ASoA.h:1441
std::span< const int64_t > getSliceFor(int value) const
Definition ASoA.cxx:363
void updateSliceInfo(SliceInfoUnsortedPtr &&si)
Definition ASoA.cxx:352
o2::soa::ArrowTableRef getSliceFor(int value, o2::soa::ArrowTableRef const &input) const
Definition ASoA.cxx:357
void updateSliceInfo(SliceInfoPtr &&si)
Definition ASoA.cxx:347
ArrowTableSlicingCache * ptr
Definition SliceCache.h:22
std::pair< int64_t, int64_t > getSliceFor(int value) const
An expression tree node corresponding to a column binding.
A struct, containing the root of the expression tree.
From https://en.cppreference.com/w/cpp/utility/variant/visit.
static o2::soa::ArrowTableRef concatTables(std::vector< std::shared_ptr< arrow::Table > > &&tables)
static o2::soa::ArrowTableRef joinTables(std::vector< std::shared_ptr< arrow::Table > > &&tables)
Definition ASoA.cxx:149
static o2::soa::ArrowTableRef concatTables(std::vector< o2::soa::ArrowTableRef > &&tables)
Definition ASoA.cxx:183
ArrowTableRef makeEmpty() const
Definition ArrowTypes.h:47
std::shared_ptr< arrow::Table > tablePtr
Definition ArrowTypes.h:32
ArrowTableRef slice(ArrowRange newRange) const
Definition ArrowTypes.h:52
Type-checking index column binding.
Definition ASoA.h:421
uint32_t hash
Definition ASoA.h:423
void const * ptr
Definition ASoA.h:422
void bind(T const *table)
Definition ASoA.h:427
T const * get() const
Definition ASoA.h:435
static constexpr bool chunked
Definition ASoA.h:466
arrow::ChunkedArray * second
Definition ASoA.h:1023
Column(ColumnIterator< T > const &it)
Definition ASoA.h:672
Column()=default
static constexpr const char *const & columnLabel()
Definition ASoA.h:685
ColumnIterator< T > const & getIterator() const
Definition ASoA.h:686
Column & operator=(Column const &)=default
INHERIT inherited_t
Definition ASoA.h:671
Column(Column &&)=default
static auto asArrowField()
Definition ASoA.h:691
Column & operator=(Column &&)=default
Column(Column const &)=default
static constexpr void isIteratableColumn()
Definition ASoA.h:669
ColumnIterator< T > mColumnIterator
Definition ASoA.h:698
Concat(std::shared_ptr< arrow::Table > table)
Definition ASoA.h:3525
table_t::template iterator_template< DefaultIndexPolicy, self_t, Ts... > iterator
Definition ASoA.h:3549
typename table_t::persistent_columns_t persistent_columns_t
Definition ASoA.h:3547
typename table_t::columns_t columns_t
Definition ASoA.h:3546
Concat(std::vector< ArrowTableRef > &&tables)
Definition ASoA.h:3530
iterator const_iterator
Definition ASoA.h:3550
const_iterator unfiltered_const_iterator
Definition ASoA.h:3552
Concat(Ts const &... t)
Definition ASoA.h:3535
iterator unfiltered_iterator
Definition ASoA.h:3551
table_t::template iterator_template< FilteredIndexPolicy, self_t, Ts... > filtered_iterator
Definition ASoA.h:3553
Concat(ArrowTableRef table)
Definition ASoA.h:3519
filtered_iterator filtered_const_iterator
Definition ASoA.h:3554
DefaultIndexPolicy(int64_t nRows, uint64_t offset)
Definition ASoA.h:954
friend bool operator==(DefaultIndexPolicy const &lh, DefaultIndexPolicy const &rh)
Definition ASoA.h:1000
bool operator==(RowViewSentinel const &sentinel) const
Definition ASoA.h:1005
static constexpr void isDefaultIndexPolicy()
Definition ASoA.h:943
DefaultIndexPolicy(FilteredIndexPolicy const &other)
Definition ASoA.h:960
std::tuple< uint64_t const * > getOffsets() const
Definition ASoA.h:981
DefaultIndexPolicy & operator=(DefaultIndexPolicy &&)=default
void setCursor(int64_t i)
Definition ASoA.h:986
void limitRange(int64_t start, int64_t end)
Definition ASoA.h:966
DefaultIndexPolicy(DefaultIndexPolicy &&)=default
DefaultIndexPolicy(DefaultIndexPolicy const &)=default
DefaultIndexPolicy & operator=(DefaultIndexPolicy const &)=default
std::tuple< int64_t const *, int64_t const * > getIndices() const
Definition ASoA.h:975
DefaultIndexPolicy()=default
Needed to be able to copy the policy.
void moveByIndex(int64_t i)
Definition ASoA.h:990
static constexpr const char *const & columnLabel()
Definition ASoA.h:708
INHERIT inherited_t
Definition ASoA.h:706
static constexpr void isDynamicColumn()
Definition ASoA.h:705
FilteredIndexPolicy & operator=(FilteredIndexPolicy &&)=default
std::tuple< int64_t const *, int64_t const * > getIndices() const
Definition ASoA.h:866
FilteredIndexPolicy & operator=(FilteredIndexPolicy const &)=default
auto getSelectionRow() const
Definition ASoA.h:916
FilteredIndexPolicy(std::span< int64_t const > selection, int64_t rows, uint64_t offset=0)
Definition ASoA.h:843
friend bool operator==(FilteredIndexPolicy const &lh, FilteredIndexPolicy const &rh)
Definition ASoA.h:897
void resetSelection(std::span< int64_t const > selection)
Definition ASoA.h:852
void setCursor(int64_t i)
Definition ASoA.h:885
static constexpr void isFilteredIndexPolicy()
FilteredIndexPolicy(FilteredIndexPolicy const &)=default
auto raw_size() const
Definition ASoA.h:926
bool operator==(RowViewSentinel const &sentinel) const
Definition ASoA.h:902
std::tuple< uint64_t const * > getOffsets() const
Definition ASoA.h:872
void limitRange(int64_t start, int64_t end)
Definition ASoA.h:877
FilteredIndexPolicy(FilteredIndexPolicy &&)=default
void moveByIndex(int64_t i)
Definition ASoA.h:891
static constexpr bool chunked
Definition ASoA.h:472
static constexpr const char *const & columnLabel()
Definition ASoA.h:717
static constexpr void isEnumeratingColumn()
Definition ASoA.h:713
INHERIT inherited_t
Definition ASoA.h:714
static constexpr const uint32_t hash
Definition ASoA.h:715
uint64_t mOffset
Offset within a larger table.
Definition ASoA.h:828
int64_t mRowIndex
Position inside the current table.
Definition ASoA.h:826
static constexpr void isIndexTable()
Definition ASoA.h:4099
void bindExternalIndices(TA *... current)
Definition ASoA.h:4112
IndexTable(ArrowTableRef table)
Definition ASoA.h:4122
typename base_t::template iterator_template_o< DefaultIndexPolicy, self_t > iterator
Definition ASoA.h:4135
filtered_iterator const_filtered_iterator
Definition ASoA.h:4138
IndexTable(IndexTable &&)=default
IndexTable(std::vector< ArrowTableRef > &&tables)
Definition ASoA.h:4127
IndexTable & operator=(IndexTable const &)=default
iterator const_iterator
Definition ASoA.h:4136
IndexTable & operator=(IndexTable &&)=default
typename H::binding_t first_t
Definition ASoA.h:4105
typename base_t::template iterator_template_o< FilteredIndexPolicy, self_t > filtered_iterator
Definition ASoA.h:4137
IndexTable(IndexTable const &)=default
Index(Index const &)=default
void setIndices(std::tuple< int64_t const *, int64_t const * > indices)
Definition ASoA.h:805
Index & operator=(Index &&)=default
int64_t index() const
Definition ASoA.h:778
Index()=default
Index(arrow::ChunkedArray const *)
Definition ASoA.h:764
int64_t filteredIndex() const
Definition ASoA.h:783
constexpr int64_t rangeEnd()
Definition ASoA.h:773
constexpr int64_t rangeStart()
Definition ASoA.h:768
Index(Index &&)=default
Index & operator=(Index const &)=default
int64_t index() const
Definition ASoA.h:794
int64_t globalIndex() const
Definition ASoA.h:788
std::tuple< int64_t const *, int64_t const * > rowIndices
Definition ASoA.h:818
int64_t offsets() const
Definition ASoA.h:800
void setOffsets(std::tuple< uint64_t const * > offsets)
Definition ASoA.h:810
static constexpr const char * mLabel
Definition ASoA.h:815
std::tuple< uint64_t const * > rowOffsets
Definition ASoA.h:821
auto sliceBy(o2::framework::PresliceBase< T1, Policy, OPT > const &container, int value) const
Definition ASoA.h:3469
static constexpr const auto originalLabels
Definition ASoA.h:3438
iterator const_iterator
Definition ASoA.h:3442
static constexpr const auto originals
Definition ASoA.h:3437
iterator rawIteratorAt(uint64_t i) const
Definition ASoA.h:3474
static constexpr const uint32_t binding_origin
Definition ASoA.h:3421
auto sliceByCached(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
Definition ASoA.h:3458
const_iterator unfiltered_const_iterator
Definition ASoA.h:3444
typename table_t::columns_t columns_t
Definition ASoA.h:3439
auto emptySlice() const
Definition ASoA.h:3491
Table< o2::aod::Hash<"JOIN"_h >, o2::aod::Hash<"JOIN/0"_h >, o2::aod::Hash<"JOIN"_h >, Ts... > base
Definition ASoA.h:3409
iterator iteratorAt(uint64_t i) const
Definition ASoA.h:3481
typename table_t::persistent_columns_t persistent_columns_t
Definition ASoA.h:3440
Join< Ts... > self_t
Definition ASoA.h:3435
const_iterator begin() const
Definition ASoA.h:3453
void bindExternalIndices(TA *... current)
Definition ASoA.h:3425
table_t::template iterator_template< DefaultIndexPolicy, self_t, Ts... > iterator
Definition ASoA.h:3441
static consteval bool contains()
Definition ASoA.h:3497
static constexpr void isJoin()
Definition ASoA.h:3408
Join(std::vector< ArrowTableRef > &&tables)
Definition ASoA.h:3411
iterator begin()
Definition ASoA.h:3448
table_t::template iterator_template< FilteredIndexPolicy, self_t, Ts... > filtered_iterator
Definition ASoA.h:3445
auto sliceByCachedUnsorted(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
Definition ASoA.h:3463
auto rawSlice(uint64_t start, uint64_t end) const
Definition ASoA.h:3486
static constexpr const header::DataOrigin binding_origin_
Definition ASoA.h:3422
iterator unfiltered_iterator
Definition ASoA.h:3443
filtered_iterator filtered_const_iterator
Definition ASoA.h:3446
static constexpr const uint32_t hash
Definition ASoA.h:724
static constexpr const char *const & columnLabel()
Definition ASoA.h:726
static constexpr void isMarkingColumn()
Definition ASoA.h:722
INHERIT inherited_t
Definition ASoA.h:723
constexpr auto mark()
Definition ASoA.h:743
Marker & operator=(Marker const &)=default
size_t type
Definition ASoA.h:731
static constexpr auto value
Definition ASoA.h:733
static constexpr const char * mLabel
Definition ASoA.h:748
Marker(arrow::ChunkedArray const *)
Definition ASoA.h:742
Marker()=default
Marker(Marker const &)=default
Marker & operator=(Marker &&)=default
Marker(Marker &&)=default
int64_t const index
Definition ASoA.h:833
static constexpr void isRowViewSentinel()
Definition ASoA.h:832
SmallGroupsBase(std::vector< ArrowTableRef > &&tables, is_a_selection auto selection)
Definition ASoA.h:4146
static constexpr void isSmallGroups()
Definition ASoA.h:4143
framework::selected_pack< soa::is_persistent_column_t, C... > persistent_columns_t
Definition ASoA.h:1036
void doSetCurrentIndexRaw(framework::pack< Cs... > p, std::vector< o2::soa::Binding > &&ptrs)
Definition ASoA.h:1174
void bindInternalIndices(I const *table)
Definition ASoA.h:1193
TableIterator(TableIterator< D, O, FilteredIndexPolicy, C... > const &other)
Definition ASoA.h:1085
TableIterator(self_t const &other)
Definition ASoA.h:1066
TableIterator operator-(int64_t dec) const
Definition ASoA.h:1129
TableIterator(arrow::ChunkedArray *columnData[sizeof...(C)], IP &&policy)
Definition ASoA.h:1050
TableIterator & operator=(TableIterator other)
Definition ASoA.h:1075
TableIterator & operator++()
Definition ASoA.h:1095
void bindExternalIndex(TA *current)
Definition ASoA.h:1166
void doSetCurrentInternal(framework::pack< Cs... >, I const *ptr)
Definition ASoA.h:1180
decltype([]< typename... Cs >(framework::pack< Cs... >) consteval -> framework::pack< typename Cs::binding_t... > {}(external_index_columns_t{})) bindings_pack_t
Definition ASoA.h:1039
auto getIndexBindingsImpl(framework::pack< Cs... >) const
Definition ASoA.h:1146
TableIterator operator--(int)
Definition ASoA.h:1114
void bindExternalIndicesRaw(std::vector< o2::soa::Binding > &&ptrs)
Definition ASoA.h:1187
TableIterator(arrow::ChunkedArray *columnData[sizeof...(C)], IP &&policy)
Definition ASoA.h:1041
void bindExternalIndices(TA *... current)
Definition ASoA.h:1157
auto getCurrent() const
Definition ASoA.h:1140
TableIterator & operator--()
Definition ASoA.h:1108
framework::selected_pack< soa::is_external_index_t, C... > external_index_columns_t
Definition ASoA.h:1037
TableIterator const & operator*() const
Definition ASoA.h:1134
static constexpr void isTableIterator()
Definition ASoA.h:1032
TableIterator operator++(int)
Definition ASoA.h:1101
framework::selected_pack< soa::is_self_index_t, C... > internal_index_columns_t
Definition ASoA.h:1038
auto getIndexBindings() const
Definition ASoA.h:1151
void setPointerReconstructor(framework::PointerReconstructor const &pointerReconstructor)
Definition ASoA.h:1198
TableIterator operator+(int64_t inc) const
Allow incrementing by more than one the iterator.
Definition ASoA.h:1122
Generic identifier for a table type.
Definition ASoA.h:86
constexpr TableRef & operator=(TableRef const &)=default
consteval TableRef()
Definition ASoA.h:87
uint32_t label_hash
Definition ASoA.h:101
constexpr bool descriptionCompatible(uint32_t _desc_hash) const noexcept
Definition ASoA.h:119
constexpr bool operator==(TableRef const &other) const noexcept
Definition ASoA.h:106
constexpr TableRef(TableRef &&)=default
uint32_t version
Definition ASoA.h:104
constexpr TableRef(TableRef const &)=default
consteval TableRef(uint32_t _label, uint32_t _desc, uint32_t _origin, uint32_t _version)
Definition ASoA.h:94
constexpr bool descriptionCompatible(TableRef const &other) const noexcept
Definition ASoA.h:114
uint32_t desc_hash
Definition ASoA.h:102
uint32_t origin_hash
Definition ASoA.h:103
constexpr TableRef & operator=(TableRef &&)=default
TableIteratorBase const & operator*() const
Definition ASoA.h:1922
TableIteratorBase(TableIteratorBase< IP, P, T... > const &other)
Definition ASoA.h:1830
typename Parent::columns_t columns_t
Definition ASoA.h:1778
TableIteratorBase(TableIteratorBase< IP, P, O1, Os... > const &other)
Definition ASoA.h:1816
typename Parent::external_index_columns_t external_index_columns_t
Definition ASoA.h:1779
TableIteratorBase operator-(int64_t dec) const
Definition ASoA.h:1917
void matchTo(TableIteratorBase< IP, P, T... > const &other)
Definition ASoA.h:1854
void matchTo(TableIteratorBase< IP, P, Os... > const &other)
Definition ASoA.h:1860
TableIteratorBase(TableIteratorBase< FilteredIndexPolicy, P, T... > other)
Definition ASoA.h:1842
std::array< B, sizeof...(CCs)> getValues() const
Definition ASoA.h:1899
static constexpr auto originals
Definition ASoA.h:1781
TableIteratorBase(TableIteratorBase< IP, P, T... > &&other) noexcept
Definition ASoA.h:1836
TableIteratorBase & operator=(TableIteratorBase< IP, P, Os... > other)
Definition ASoA.h:1793
TableIteratorBase(TableIteratorBase< IP, P, O1, Os... > &&other) noexcept
Definition ASoA.h:1823
TableIteratorBase & operator=(RowViewSentinel const &other)
Definition ASoA.h:1848
decltype([]< typename... C >(framework::pack< C... >) consteval -> framework::pack< typename C::binding_t... > {}(external_index_columns_t{})) bindings_pack_t
Definition ASoA.h:1780
TableIteratorBase(arrow::ChunkedArray *columnData[framework::pack_size(columns_t{})], IP &&policy)
Definition ASoA.h:1787
TableIteratorBase & operator=(TableIteratorBase< IP, P, T... > other)
Definition ASoA.h:1801
TableIteratorBase operator+(int64_t inc) const
Allow incrementing by more than one the iterator.
Definition ASoA.h:1910
TableIteratorBase & operator=(TableIteratorBase< FilteredIndexPolicy, P, T... > other)
Definition ASoA.h:1808
unwrapper
Definition ASoA.h:477
VectorOfTObjectPtrs other
std::vector< ReadoutWindowData > rows
const std::string str