12#ifndef O2_FRAMEWORK_ASOA_H_
13#define O2_FRAMEWORK_ASOA_H_
26#include <arrow/array/array_binary.h>
27#include <arrow/table.h>
28#include <arrow/array.h>
29#include <arrow/util/config.h>
30#include <gandiva/selection_vector.h>
33#include <fmt/format.h>
41using ListVector = std::vector<std::vector<int64_t>>;
69 consteval TableRef(uint32_t _label, uint32_t _desc, uint32_t _origin, uint32_t _version)
83 return (this->label_hash ==
other.label_hash) &&
84 (this->desc_hash ==
other.desc_hash) &&
85 (this->origin_hash ==
other.origin_hash) &&
86 (this->version ==
other.version);
91 return this->desc_hash ==
other.desc_hash;
96 return this->desc_hash == _desc_hash;
106template <
size_t N1,
size_t N2, std::array<TableRef, N1> ar1, std::array<TableRef, N2> ar2>
109 constexpr const int duplicates = std::ranges::count_if(ar2.begin(), ar2.end(), [&](
TableRef const&
a) { return std::any_of(ar1.begin(), ar1.end(), [&](TableRef const& e) { return e == a; }); });
110 std::array<TableRef, N1 + N2 - duplicates> out;
112 auto pos = std::copy(ar1.begin(), ar1.end(), out.begin());
113 std::copy_if(ar2.begin(), ar2.end(),
pos, [&](TableRef
const&
a) { return std::none_of(ar1.begin(), ar1.end(), [&](TableRef const& e) { return e == a; }); });
117template <
size_t N1,
size_t N2, std::array<TableRef, N1> ar1, std::array<TableRef, N2> ar2,
typename L>
120 constexpr const int to_remove = std::ranges::count_if(ar1.begin(), ar1.end(), [&](
TableRef const&
a) { return !l(a); });
121 constexpr const int duplicates = std::ranges::count_if(ar2.begin(), ar2.end(), [&](
TableRef const&
a) { return std::any_of(ar1.begin(), ar1.end(), [&](TableRef const& e) { return e == a; }) || !l(
a); });
122 std::array<TableRef, N1 + N2 - duplicates - to_remove> out;
124 auto pos = std::copy_if(ar1.begin(), ar1.end(), out.begin(), [&](TableRef
const&
a) { return l(a); });
125 std::copy_if(ar2.begin(), ar2.end(),
pos, [&](TableRef
const&
a) { return std::none_of(ar1.begin(), ar1.end(), [&](TableRef const& e) { return e == a; }) && l(
a); });
129template <
size_t N, std::array<TableRef, N> ar,
typename L>
132 constexpr const int to_remove = std::ranges::count_if(ar.begin(), ar.end(), [&l](
TableRef const& e) { return l(e); });
133 std::array<
TableRef, N - to_remove> out;
134 std::copy_if(ar.begin(), ar.end(), out.begin(), [&l](
TableRef const& e) { return !l(e); });
138template <
size_t N1,
size_t N2, std::array<TableRef, N1> ar1, std::array<TableRef, N2> ar2>
139consteval auto intersect()
141 constexpr const int duplicates = std::ranges::count_if(ar2.begin(), ar2.end(), [&](
TableRef const&
a) { return std::any_of(ar1.begin(), ar1.end(), [&](TableRef const& e) { return e == a; }); });
142 std::array<TableRef, duplicates> out;
143 std::copy_if(ar1.begin(), ar1.end(), out.begin(), [](TableRef
const&
a) { return std::find(ar2.begin(), ar2.end(), a) != ar2.end(); });
147template <
typename T,
typename... Ts>
149 requires(
sizeof...(Ts) == 1)
152 return merge<T::originals.size(), T1::originals.size(), T::originals, T1::originals>();
155template <
typename T,
typename...
Ts>
157 requires(
sizeof...(Ts) > 1)
160 return merge<T::originals.size(), tail.size(), T::originals, tail>();
163template <
typename T,
typename...
Ts>
164 requires(
sizeof...(Ts) == 1)
165consteval auto intersectOriginals()
168 return intersect<T::originals.size(), T1::originals.size(), T::originals, T1::originals>();
171template <
typename T,
typename...
Ts>
172 requires(
sizeof...(Ts) > 1)
173consteval auto intersectOriginals()
176 return intersect<T::originals.size(), tail.size(), T::originals, tail>();
185concept not_void =
requires { !std::same_as<T, void>; };
202 {
c.setCurrentRaw(
b) } -> std::same_as<bool>;
207using is_external_index_t =
typename std::conditional_t<is_index_column<C>, std::true_type, std::false_type>;
210using is_self_index_t =
typename std::conditional_t<is_self_index_column<C>, std::true_type, std::false_type>;
216template <
typename D,
typename... Cs>
223 template <
typename Key,
typename... PCs>
226 return std::array<bool,
sizeof...(PCs)>{[]() {
227 if constexpr (
requires { PCs::index_targets.size(); }) {
228 return Key::template isIndexTargetOf<PCs::index_targets.size(), PCs::index_targets>();
235 template <
typename Key>
241 template <
typename Key,
size_t N, std::array<
bool, N> map>
244 constexpr const auto pos = std::find(map.begin(), map.end(),
true);
245 if constexpr (
pos != map.end()) {
246 return std::distance(map.begin(),
pos);
262 static constexpr uint32_t
hash = H;
263 static constexpr char const*
const str{
""};
267template <
size_t N, std::array<soa::TableRef, N> ar,
typename Key>
270 constexpr std::array<bool, N>
test = []<
size_t... Is>(std::index_sequence<Is...>) {
271 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))...};
272 }(std::make_index_sequence<N>());
273 constexpr int correct = std::ranges::count(
test.begin(),
test.end(),
true);
274 std::array<soa::TableRef, correct> out;
275 std::ranges::copy_if(ar.begin(), ar.end(), out.begin(), [&
test](
soa::TableRef const&
r) { return test[std::distance(ar.begin(), std::find(ar.begin(), ar.end(), r))]; });
280#define O2HASH(_Str_) \
282 struct Hash<_Str_ ""_h> { \
283 static constexpr uint32_t hash = _Str_ ""_h; \
284 static constexpr char const* const str{_Str_}; \
288#define O2ORIGIN(_Str_) \
290 struct Hash<_Str_ ""_h> { \
291 static constexpr header::DataOrigin origin{_Str_}; \
292 static constexpr uint32_t hash = _Str_ ""_h; \
293 static constexpr char const* const str{_Str_}; \
297static inline constexpr uint32_t
version(
const char*
const str)
299 if (
str[0] ==
'\0') {
307 if (
str[
len - 1] ==
'\0') {
310 for (
auto i =
len + 1;
str[
i] !=
'\0'; ++
i) {
317static inline constexpr std::string_view description_str(
const char*
const str)
323 return std::string_view{
str,
len};
333 for (
auto i = 0;
i < 16; ++
i) {
336 std::memcpy(out,
str,
len);
341template <soa::TableRef R>
347template <soa::TableRef R>
353template <soa::TableRef R>
359template <soa::TableRef R>
373template <soa::TableRef R>
374static constexpr auto sourceSpec()
376 return fmt::format(
"{}/{}/{}/{}",
label<R>(), origin_str<R>(), description_str(signature<R>()),
R.version);
382template <aod::is_aod_hash L, aod::is_aod_hash D, aod::is_origin_hash O,
typename... Ts>
387 void const*
ptr =
nullptr;
389 std::span<TableRef const>
refs;
391 template <
typename T>
395 hash = o2::framework::TypeIdHelpers::uniqueId<T>();
396 refs = std::span{T::originals};
399 template <
typename T>
402 if (
hash == o2::framework::TypeIdHelpers::uniqueId<T>()) {
403 return static_cast<T const*
>(
ptr);
409template <
typename... C>
412 return std::vector<std::shared_ptr<arrow::Field>>{C::asArrowField()...};
438template <
typename B,
typename E>
440 constexpr static bool value =
false;
443template <aod::is_aod_hash A, aod::is_aod_hash B>
445 constexpr static bool value =
false;
448template <
typename B,
typename E>
451template <aod::is_aod_hash A, aod::is_aod_hash B>
490template <
typename T,
typename ChunkingPolicy = Chunked>
493 static constexpr char SCALE_FACTOR = std::same_as<std::decay_t<T>,
bool> ? 3 : 0;
509 auto array = getCurrentArray();
524 auto previousArray = getCurrentArray();
528 auto array = getCurrentArray();
535 auto previousArray = getCurrentArray();
539 auto array = getCurrentArray();
561 auto array = getCurrentArray();
568 requires
std::same_as<
bool,
std::decay_t<T>>
584 decltype(
auto)
operator*()
const
585 requires((!std::same_as<bool, std::decay_t<T>>) && std::same_as<
arrow_array_for_t<T>, arrow::BinaryViewArray>)
592 decltype(
auto)
operator*()
const
615 void checkSkipChunk() const
624 void checkSkipChunk() const
632 void checkSkipChunk() const
633 requires(ChunkingPolicy::
chunked == false)
637 auto getCurrentArray() const
641 mOffset = chunkToUse->offset();
642 chunkToUse = std::dynamic_pointer_cast<arrow::FixedSizeListArray>(chunkToUse)->values();
643 return std::static_pointer_cast<arrow_array_for_t<value_for_t<T>>>(chunkToUse);
646 auto getCurrentArray() const
650 mOffset = chunkToUse->offset();
651 chunkToUse = std::dynamic_pointer_cast<arrow::ListArray>(chunkToUse)->values();
652 mOffset = chunkToUse->offset();
653 return std::static_pointer_cast<arrow_array_for_t<value_for_t<T>>>(chunkToUse);
656 auto getCurrentArray() const
660 mOffset = chunkToUse->offset();
661 return std::static_pointer_cast<arrow_array_for_t<T>>(chunkToUse);
665template <
typename T,
typename INHERIT>
681 static constexpr const char*
const&
columnLabel() {
return INHERIT::mLabel; }
699template <
typename F,
typename INHERIT>
703 static constexpr const char*
const&
columnLabel() {
return INHERIT::mLabel; }
706template <
typename INHERIT>
709 static constexpr const uint32_t
hash = 0;
711 static constexpr const char*
const&
columnLabel() {
return INHERIT::mLabel; }
714template <
typename INHERIT>
717 static constexpr const uint32_t
hash = 0;
719 static constexpr const char*
const&
columnLabel() {
return INHERIT::mLabel; }
722template <
size_t M = 0>
726 constexpr inline static auto value = M;
741 static constexpr const char*
mLabel =
"Marker";
744template <int64_t START = 0, int64_t
END = -1>
747 constexpr inline static int64_t
start = START;
748 constexpr inline static int64_t
end =
END;
808 static constexpr const char*
mLabel =
"Index";
832using is_dynamic_t = std::conditional_t<is_dynamic_column<T>, std::true_type, std::false_type>;
838using is_indexing_t = std::conditional_t<is_indexing_column<T>, std::true_type, std::false_type>;
859 mSelectedRows(selection),
860 mMaxSelection(selection.
size()),
868 mSelectedRows = selection;
869 mMaxSelection = selection.size();
879 [[nodiscard]] std::tuple<int64_t const*, int64_t const*>
882 return std::make_tuple(&
mRowIndex, &mSelectionRow);
885 [[nodiscard]] std::tuple<uint64_t const*>
888 return std::make_tuple(&
mOffset);
895 mMaxSelection = std::min(
end, mMaxSelection);
913 return lh.mSelectionRow == rh.mSelectionRow;
926 this->mSelectionRow = this->mMaxSelection;
932 return mSelectionRow;
935 [[nodiscard]]
auto size()
const
937 return mMaxSelection;
946 inline void updateRow()
950 std::span<int64_t const> mSelectedRows;
951 int64_t mSelectionRow = 0;
952 int64_t mMaxSelection = 0;
987 [[nodiscard]] std::tuple<int64_t const*, int64_t const*>
993 [[nodiscard]] std::tuple<uint64_t const*>
996 return std::make_tuple(&
mOffset);
1037template <
typename T>
1042template <
typename C>
1048template <
typename T,
typename B>
1050 { t.B::mColumnIterator };
1053template <
typename...
C>
1056template <
typename D,
typename O,
typename IP,
typename... C>
1071 if (this->
size() != 0) {
1081 if (this->
size() != 0) {
1088 this->limitRange(this->rangeStart(), this->rangeEnd());
1094 C(static_cast<
C const&>(
other))...
1096 if (this->
size() != 0) {
1103 IP::operator=(
static_cast<IP const&
>(
other));
1104 (
void(
static_cast<C&
>(*
this) =
static_cast<C>(
other)), ...);
1105 if (this->
size() != 0) {
1112 requires std::same_as<IP, DefaultIndexPolicy>
1114 C(
static_cast<C const&
>(
other))...
1116 if (this->
size() != 0) {
1123 this->moveByIndex(1);
1136 this->moveByIndex(-1);
1151 copy.moveByIndex(inc);
1165 template <
typename... CL,
typename TA>
1168 (CL::setCurrent(current), ...);
1171 template <
typename CL>
1174 return CL::getCurrentRaw();
1177 template <
typename... Cs>
1180 return std::vector<o2::soa::Binding>{
static_cast<Cs const&
>(*this).getCurrentRaw()...};
1188 template <
typename... TA>
1194 template <
typename... Cs>
1197 (Cs::setCurrentRaw(ptrs[framework::has_type_at_v<Cs>(p)]), ...);
1200 template <
typename... Cs,
typename I>
1205 (Cs::setCurrentRaw(
b), ...);
1213 template <
typename I>
1221 template <
typename... PC>
1224 (PC::mColumnIterator.moveToEnd(), ...);
1234 [
this]<soa::is_dynamic_column T>(T*) ->
void { bindDynamicColumn<T>(
typename T::bindings_t{}); },
1235 [
this]<
typename T>(
T*) ->
void {},
1237 (
f(
static_cast<C*
>(
nullptr)), ...);
1238 if constexpr (has_index<
C...>) {
1239 this->setIndices(this->getIndices());
1240 this->setOffsets(this->getOffsets());
1244 template <
typename DC,
typename...
B>
1247 DC::boundIterators = std::make_tuple(getDynamicBinding<B>()...);
1255 template <
typename B>
1256 requires(can_bind<self_t, B>)
1257 decltype(
auto) getDynamicBinding()
1259 static_assert(std::same_as<decltype(&(static_cast<B*>(
this)->mColumnIterator)), std::decay_t<
decltype(B::mColumnIterator)>*>,
"foo");
1260 return &(
static_cast<B*
>(
this)->mColumnIterator);
1264 template <
typename B>
1265 decltype(
auto) getDynamicBinding()
1267 return static_cast<std::decay_t<decltype(B::mColumnIterator)
>*>(
nullptr);
1272 static std::shared_ptr<arrow::Table>
joinTables(std::vector<std::shared_ptr<arrow::Table>>&& tables, std::span<const char* const> labels);
1273 static std::shared_ptr<arrow::Table>
concatTables(std::vector<std::shared_ptr<arrow::Table>>&& tables);
1277template <
typename T>
1280template <
typename T>
1282 T::originals.size();
1285template <
typename T>
1290template <
typename T>
1292 T::ccdb_urls.size();
1295template <
typename T>
1298template <
size_t N1, std::array<TableRef, N1> os1,
size_t N2, std::array<TableRef, N2> os2>
1301 return []<
size_t... Is>(std::index_sequence<Is...>) {
1302 return ([]<
size_t... Ks>(std::index_sequence<Ks...>) {
1303 constexpr auto h = os1[Is].desc_hash;
1306 }(std::make_index_sequence<N2>()) ||
1308 }(std::make_index_sequence<N1>());
1311template <with_originals T, with_originals B>
1314 return is_compatible<T::originals.size(), T::originals, B::originals.size(), B::originals>();
1317template <
typename T,
typename B>
1318using is_binding_compatible = std::conditional_t<is_binding_compatible_v<T, typename B::binding_t>(), std::true_type, std::false_type>;
1320template <
typename L,
typename D,
typename O,
typename Key,
typename H,
typename...
Ts>
1323template <
typename T>
1326template <soa::is_table T>
1327static constexpr std::string getLabelForTable()
1329 return std::string{aod::label<std::decay_t<T>::originals[0]>()};
1332template <soa::is_table T>
1334static constexpr std::string getLabelFromType()
1336 return getLabelForTable<T>();
1339template <soa::is_iterator T>
1340static constexpr std::string getLabelFromType()
1342 return getLabelForTable<typename std::decay_t<T>::parent_t>();
1345template <soa::is_index_table T>
1346static constexpr std::string getLabelFromType()
1348 return getLabelForTable<typename std::decay_t<T>::first_t>();
1350template <soa::with_base_table T>
1351static constexpr std::string getLabelFromType()
1356template <
typename...
C>
1359 return ((C::inherited_t::mLabel ==
key) || ...);
1362template <TableRef ref>
1363static constexpr std::pair<bool, std::string> hasKey(std::string
const&
key)
1368template <
typename...
C>
1371 return std::vector{hasKey<C>(
key)...};
1377template <with_originals T,
bool OPT = false>
1378static constexpr std::string getLabelFromTypeForKey(std::string
const&
key)
1380 if constexpr (T::originals.size() == 1) {
1381 auto locate = hasKey<T::originals[0]>(
key);
1383 return locate.second;
1386 auto locate = [&]<
size_t... Is>(std::index_sequence<Is...>) {
1387 return std::vector{hasKey<T::originals[Is]>(
key)...};
1388 }(std::make_index_sequence<T::originals.size()>{});
1389 auto it = std::find_if(locate.begin(), locate.end(), [](
auto const&
x) { return x.first; });
1390 if (it != locate.end()) {
1394 if constexpr (!OPT) {
1402template <
typename B,
typename...
C>
1405 return (o2::soa::is_binding_compatible_v<B, typename C::binding_t>() || ...);
1408template <
typename B,
typename...
C>
1411 return ((C::sorted && o2::soa::is_binding_compatible_v<B, typename C::binding_t>()) || ...);
1414template <
typename B,
typename Z>
1415consteval static bool relatedByIndex()
1417 return hasIndexTo<B>(
typename Z::table_t::external_index_columns_t{});
1420template <
typename B,
typename Z>
1421consteval static bool relatedBySortedIndex()
1423 return hasSortedIndexTo<B>(
typename Z::table_t::external_index_columns_t{});
1442 std::shared_ptr<arrow::Table>
getSliceFor(
int value, std::shared_ptr<arrow::Table>
const& input, uint64_t&
offset)
const;
1452template <
typename T,
typename Policy,
bool OPT = false>
1460 : Policy{
PreslicePolicyBase{{o2::soa::getLabelFromTypeForKey<T, OPT>(std::string{index_.
name})},
Entry(o2::soa::getLabelFromTypeForKey<T, OPT>(std::string{index_.name}), std::string{index_.name})}, {}}
1466 if constexpr (OPT) {
1467 if (Policy::isMissing()) {
1476 if constexpr (OPT) {
1477 if (Policy::isMissing()) {
1481 return Policy::getSliceFor(
value);
1485template <
typename T>
1487template <
typename T>
1489template <
typename T>
1491template <
typename T>
1494template <
typename T>
1512template <
typename T>
1519template <soa::is_table T>
1521template <
typename T>
1524template <
typename T>
1527template <
typename T>
1530template <
typename T>
1534template <
typename T>
1537template <
typename T>
1540template <
typename T>
1544template <
typename... Is>
1552template <
typename T,
typename C,
typename Policy,
bool OPT>
1553 requires std::same_as<Policy, framework::PreslicePolicySorted> && (o2::soa::is_binding_compatible_v<C, T>())
1556 if constexpr (OPT) {
1557 if (container.isMissing()) {
1563 auto t =
typename T::self_t({out},
offset);
1564 if (t.tableSize() != 0) {
1565 table->copyIndexBindings(t);
1566 t.bindInternalIndicesTo(table);
1571template <soa::is_filtered_table T>
1575 if (t.tableSize() != 0) {
1577 t.bindInternalIndicesTo(table);
1578 t.intersectWithSelection(table->getSelectedRows());
1583template <soa::is_table T>
1588 if (t.tableSize() != 0) {
1590 t.bindInternalIndicesTo(table);
1595template <
typename T,
typename C,
typename Policy,
bool OPT>
1596 requires std::same_as<Policy, framework::PreslicePolicyGeneral> && (o2::soa::is_binding_compatible_v<C, T>())
1599 if constexpr (OPT) {
1600 if (container.isMissing()) {
1610template <soa::is_filtered_table T>
1613 if (
offset >=
static_cast<uint64_t
>(table->tableSize())) {
1615 if (fresult.tableSize() != 0) {
1622 if (fresult.tableSize() != 0) {
1628template <soa::is_filtered_table T,
typename C,
bool OPT>
1629 requires(o2::soa::is_binding_compatible_v<C, T>())
1632 if constexpr (OPT) {
1633 if (container.isMissing()) {
1642template <
typename T>
1647 auto t =
typename T::self_t({table->asArrowTable()->Slice(
static_cast<uint64_t
>(
offset),
count)},
static_cast<uint64_t
>(
offset));
1648 if (t.tableSize() != 0) {
1649 table->copyIndexBindings(t);
1654template <
typename T>
1659 auto slice = table->asArrowTable()->Slice(
static_cast<uint64_t
>(
offset),
count);
1663template <
typename T>
1668 auto t =
typename T::self_t({table->asArrowTable()}, localCache.getSliceFor(
value));
1669 if (t.tableSize() != 0) {
1670 t.intersectWithSelection(table->getSelectedRows());
1671 table->copyIndexBindings(t);
1675 auto t =
Filtered<T>({table->asArrowTable()}, localCache.getSliceFor(
value));
1676 if (t.tableSize() != 0) {
1677 table->copyIndexBindings(t);
1683template <with_originals T>
1691template <
typename D,
typename O,
typename IP,
typename...
C>
1728 return std::array<TableRef, 1>{
ref};
1744 static constexpr const auto ref =
TableRef{L::hash, D::hash, O::hash, o2::aod::version(D::str)};
1749 static constexpr const auto originalLabels = []<
size_t N, std::array<TableRef, N> refs,
size_t... Is>(std::index_sequence<Is...>) {
return std::array<const char*, N>{o2::aod::label<refs[Is]>()...}; }.template operator()<
originals.size(),
originals>(std::make_index_sequence<
originals.size()>());
1751 template <
size_t N, std::array<TableRef, N> bindings>
1752 requires(
ref.origin_hash ==
"CONC"_h)
1758 template <
size_t N, std::array<TableRef, N> bindings>
1759 requires(
ref.origin_hash ==
"JOIN"_h)
1764 return std::find(bindings.begin(), bindings.end(),
r) != bindings.end();
1768 template <
size_t N, std::array<TableRef, N> bindings>
1769 requires(!(
ref.origin_hash ==
"CONC"_h ||
ref.origin_hash ==
"JOIN"_h))
1772 return std::find(bindings.begin(), bindings.end(),
self_t::ref) != bindings.end();
1775 template <TableRef r>
1788 template <
typename IP>
1791 template <
typename IP,
typename Parent,
typename... T>
1808 template <
typename P,
typename... Os>
1810 requires(P::ref.desc_hash == Parent::ref.desc_hash)
1816 template <
typename P>
1823 template <
typename P>
1825 requires std::same_as<IP, DefaultIndexPolicy>
1831 template <
typename P,
typename O1,
typename... Os>
1833 requires(P::ref.desc_hash == Parent::ref.desc_hash)
1838 template <
typename P,
typename O1,
typename... Os>
1840 requires(P::ref.desc_hash == Parent::ref.desc_hash)
1845 template <
typename P>
1851 template <
typename P>
1857 template <
typename P>
1859 requires std::same_as<IP, DefaultIndexPolicy>
1866 this->mRowIndex =
other.index;
1869 template <
typename P>
1872 this->mRowIndex =
other.mRowIndex;
1875 template <
typename P,
typename... Os>
1877 requires std::same_as<typename P::table_t, typename Parent::table_t>
1879 this->mRowIndex =
other.mRowIndex;
1882 template <
typename TI>
1885 using decayed = std::decay_t<TI>;
1887 constexpr auto idx = framework::has_type_at_v<decayed>(
bindings_pack_t{});
1889 }
else if constexpr (std::same_as<decayed, Parent>) {
1890 return this->globalIndex();
1892 return this->globalIndex();
1894 return static_cast<int32_t
>(-1);
1898 template <
typename CD,
typename... CDArgs>
1901 using decayed = std::decay_t<CD>;
1903 return static_cast<decayed
>(*this).template getDynamicValue<CDArgs...>();
1906 template <
typename B,
typename CC>
1909 using COL = std::decay_t<CC>;
1911 return static_cast<B>(
static_cast<COL
>(*this).get());
1914 template <
typename B,
typename... CCs>
1917 static_assert(std::same_as<B, float> || std::same_as<B, double>,
"The common return type should be float or double");
1918 return {getValue<B, CCs>()...};
1929 copy.moveByIndex(inc);
1944 template <
typename IP,
typename Parent,
typename... T>
1947 template <
typename IP,
typename Parent>
1950 if constexpr (
sizeof...(Ts) == 0) {
1961 template <
typename IP,
typename Parent>
1978 mEnd{table->num_rows()},
1981 if (mTable->num_rows() == 0) {
1983 mColumnChunks[ci] =
nullptr;
1989 mColumnChunks[ci] = lookups[ci];
1992 mBegin.bindInternalIndices(
this);
1996 Table(std::vector<std::shared_ptr<arrow::Table>>&& tables, uint64_t
offset = 0)
1997 requires(
ref.origin_hash !=
"CONC"_h)
2002 Table(std::vector<std::shared_ptr<arrow::Table>>&& tables, uint64_t
offset = 0)
2003 requires(
ref.origin_hash ==
"CONC"_h)
2008 template <
typename Key>
2012 return std::array<bool,
sizeof...(Cs)>{[]() {
2013 if constexpr (
requires { Cs::index_targets.size(); }) {
2014 return Key::template
isIndexTargetOf<Cs::index_targets.size(), Cs::index_targets>();
2020 constexpr auto pos = std::find(map.begin(), map.end(),
true);
2021 if constexpr (
pos != map.end()) {
2022 return mColumnChunks[std::distance(map.begin(),
pos)];
2024 static_assert(framework::always_static_assert_v<Key>,
"This table does not have an index to given Key");
2054 return filtered_iterator(mColumnChunks, {selection, mTable->num_rows(), mOffset});
2092 return mTable->num_rows();
2102 template <
typename... TA>
2105 mBegin.bindExternalIndices(current...);
2108 template <
typename I>
2111 mBegin.bindInternalIndices(
ptr);
2119 template <
typename... Cs>
2122 (
static_cast<Cs
>(mBegin).setCurrentRaw(binding), ...);
2127 mBegin.bindExternalIndicesRaw(std::forward<std::vector<o2::soa::Binding>>(ptrs));
2130 template <
typename T,
typename... Cs>
2133 dest.bindExternalIndicesRaw(mBegin.getIndexBindings());
2136 template <
typename T>
2159 template <
typename T1,
typename Policy,
bool OPT>
2172 return self_t{mTable->Slice(0, 0), 0};
2176 template <
typename T>
2177 arrow::ChunkedArray* lookupColumn()
2180 auto label = T::columnLabel();
2186 std::shared_ptr<arrow::Table> mTable =
nullptr;
2187 uint64_t mOffset = 0;
2194template <uint32_t
D, soa::is_column...
C>
2200namespace row_helpers
2202template <
typename R,
typename T,
typename C>
2205 return static_cast<R>(
static_cast<C>(rowIterator).get());
2210template <
typename R,
typename T>
2211using ColumnGetterFunction =
R (*)(
const T&);
2213template <
typename T,
typename R>
2218 { t.get() } -> std::convertible_to<R>;
2221template <
typename T,
typename R>
2223 { t.get() } -> std::convertible_to<R>;
2226template <
typename R,
typename T, persistent_with_common_getter<R> C>
2227ColumnGetterFunction<R, T> createGetterPtr(
const std::string_view& targetColumnLabel)
2229 return targetColumnLabel == C::columnLabel() ? &getColumnValue<R, T, C> :
nullptr;
2232template <
typename R,
typename T, dynamic_with_common_getter<R> C>
2233ColumnGetterFunction<R, T> createGetterPtr(
const std::string_view& targetColumnLabel)
2235 std::string_view columnLabel(C::columnLabel());
2239 if (targetColumnLabel.starts_with(
"f") && targetColumnLabel.substr(1) == columnLabel) {
2240 return &getColumnValue<R, T, C>;
2244 if (targetColumnLabel == columnLabel) {
2245 return &getColumnValue<R, T, C>;
2251template <
typename R,
typename T,
typename... Cs>
2254 ColumnGetterFunction<R, T>
func;
2256 (
void)((
func = createGetterPtr<R, T, Cs>(targetColumnLabel),
func) || ...);
2265template <
typename T,
typename R>
2266using 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;
2269template <
typename R,
typename T>
2274 if (targetColumnLabel.size() == 0) {
2278 return getColumnGetterByLabel<R, typename T::iterator>(TypesWithCommonGetter{}, targetColumnLabel);
2303template <
typename T>
2304consteval static std::string_view namespace_prefix()
2306 constexpr auto name = o2::framework::type_name<T>();
2307 const auto pos =
name.rfind(std::string_view{
":"});
2308 return name.substr(0,
pos + 1);
2312#define DECLARE_EQUIVALENT_FOR_INDEX(_Base_, _Equiv_) \
2314 struct EquivalentIndexNG<o2::aod::Hash<_Base_::ref.desc_hash>, o2::aod::Hash<_Equiv_::ref.desc_hash>> { \
2315 constexpr static bool value = true; \
2318#define DECLARE_EQUIVALENT_FOR_INDEX_NG(_Base_, _Equiv_) \
2320 struct EquivalentIndexNG<o2::aod::Hash<_Base_ ""_h>, o2::aod::Hash<_Equiv_ ""_h>> { \
2321 constexpr static bool value = true; \
2324#define DECLARE_SOA_COLUMN_FULL(_Name_, _Getter_, _Type_, _Label_) \
2325 struct _Name_ : o2::soa::Column<_Type_, _Name_> { \
2326 static constexpr const char* mLabel = _Label_; \
2327 static constexpr const uint32_t hash = compile_time_hash(namespace_prefix<_Name_>(), std::string_view{#_Getter_}); \
2328 static_assert(!((*(mLabel + 1) == 'I' && *(mLabel + 2) == 'n' && *(mLabel + 3) == 'd' && *(mLabel + 4) == 'e' && *(mLabel + 5) == 'x')), "Index is not a valid column name"); \
2329 using base = o2::soa::Column<_Type_, _Name_>; \
2330 using type = _Type_; \
2331 using column_t = _Name_; \
2332 _Name_(arrow::ChunkedArray const* column) \
2333 : o2::soa::Column<_Type_, _Name_>(o2::soa::ColumnIterator<type>(column)) \
2337 _Name_() = default; \
2338 _Name_(_Name_ const& other) = default; \
2339 _Name_& operator=(_Name_ const& other) = default; \
2341 decltype(auto) _Getter_() const \
2343 return *mColumnIterator; \
2346 decltype(auto) get() const \
2348 return _Getter_(); \
2351 [[maybe_unused]] static constexpr o2::framework::expressions::BindingNode _Getter_ { _Label_, _Name_::hash, o2::framework::expressions::selectArrowType<_Type_>() }
2353#define DECLARE_SOA_CCDB_COLUMN_FULL(_Name_, _Label_, _Getter_, _ConcreteType_, _CCDBQuery_) \
2354 struct _Name_ : o2::soa::Column<std::span<std::byte>, _Name_> { \
2355 static constexpr const char* mLabel = _Label_; \
2356 static constexpr const char* query = _CCDBQuery_; \
2357 static constexpr const uint32_t hash = crc32(namespace_prefix<_Name_>(), std::string_view{#_Getter_}); \
2358 using base = o2::soa::Column<std::span<std::byte>, _Name_>; \
2359 using type = std::span<std::byte>; \
2360 using column_t = _Name_; \
2361 _Name_(arrow::ChunkedArray const* column) \
2362 : o2::soa::Column<std::span<std::byte>, _Name_>(o2::soa::ColumnIterator<std::span<std::byte>>(column)) \
2366 _Name_() = default; \
2367 _Name_(_Name_ const& other) = default; \
2368 _Name_& operator=(_Name_ const& other) = default; \
2370 decltype(auto) _Getter_() const \
2372 static std::byte* payload = nullptr; \
2373 static _ConcreteType_* deserialised = nullptr; \
2374 static TClass* c = TClass::GetClass(#_ConcreteType_); \
2375 auto span = *mColumnIterator; \
2376 if (payload != (std::byte*)span.data()) { \
2377 payload = (std::byte*)span.data(); \
2378 delete deserialised; \
2379 TBufferFile f(TBufferFile::EMode::kRead, span.size(), (char*)span.data(), kFALSE); \
2380 deserialised = (_ConcreteType_*)soa::extractCCDBPayload((char*)payload, span.size(), c, "ccdb_object"); \
2382 return *deserialised; \
2388 return _Getter_(); \
2392#define DECLARE_SOA_CCDB_COLUMN(_Name_, _Getter_, _ConcreteType_, _CCDBQuery_) \
2393 DECLARE_SOA_CCDB_COLUMN_FULL(_Name_, "f" #_Name_, _Getter_, _ConcreteType_, _CCDBQuery_)
2395#define DECLARE_SOA_COLUMN(_Name_, _Getter_, _Type_) \
2396 DECLARE_SOA_COLUMN_FULL(_Name_, _Getter_, _Type_, "f" #_Name_)
2400#define MAKEINT(_Size_) uint##_Size_##_t
2402#define DECLARE_SOA_BITMAP_COLUMN_FULL(_Name_, _Getter_, _Size_, _Label_) \
2403 struct _Name_ : o2::soa::Column<MAKEINT(_Size_), _Name_> { \
2404 static constexpr const char* mLabel = _Label_; \
2405 static constexpr const uint32_t hash = compile_time_hash(namespace_prefix<_Name_>(), std::string_view{#_Getter_}); \
2406 static_assert(!((*(mLabel + 1) == 'I' && *(mLabel + 2) == 'n' && *(mLabel + 3) == 'd' && *(mLabel + 4) == 'e' && *(mLabel + 5) == 'x')), "Index is not a valid column name"); \
2407 using base = o2::soa::Column<MAKEINT(_Size_), _Name_>; \
2408 using type = MAKEINT(_Size_); \
2409 _Name_(arrow::ChunkedArray const* column) \
2410 : o2::soa::Column<type, _Name_>(o2::soa::ColumnIterator<type>(column)) \
2414 _Name_() = default; \
2415 _Name_(_Name_ const& other) = default; \
2416 _Name_& operator=(_Name_ const& other) = default; \
2418 decltype(auto) _Getter_##_raw() const \
2420 return *mColumnIterator; \
2423 bool _Getter_##_bit(int bit) const \
2425 return (*mColumnIterator & (static_cast<type>(1) << bit)) >> bit; \
2428 [[maybe_unused]] static constexpr o2::framework::expressions::BindingNode _Getter_ { _Label_, _Name_::hash, o2::framework::expressions::selectArrowType<MAKEINT(_Size_)>() }
2430#define DECLARE_SOA_BITMAP_COLUMN(_Name_, _Getter_, _Size_) \
2431 DECLARE_SOA_BITMAP_COLUMN_FULL(_Name_, _Getter_, _Size_, "f" #_Name_)
2435#define DECLARE_SOA_EXPRESSION_COLUMN_FULL(_Name_, _Getter_, _Type_, _Label_, _Expression_) \
2436 struct _Name_ : o2::soa::Column<_Type_, _Name_> { \
2437 static constexpr const char* mLabel = _Label_; \
2438 static constexpr const uint32_t hash = compile_time_hash(namespace_prefix<_Name_>(), std::string_view{#_Getter_}); \
2439 using base = o2::soa::Column<_Type_, _Name_>; \
2440 using type = _Type_; \
2441 using column_t = _Name_; \
2442 using spawnable_t = std::true_type; \
2443 _Name_(arrow::ChunkedArray const* column) \
2444 : o2::soa::Column<_Type_, _Name_>(o2::soa::ColumnIterator<type>(column)) \
2448 _Name_() = default; \
2449 _Name_(_Name_ const& other) = default; \
2450 _Name_& operator=(_Name_ const& other) = default; \
2452 decltype(auto) _Getter_() const \
2454 return *mColumnIterator; \
2457 decltype(auto) get() const \
2459 return _Getter_(); \
2462 static o2::framework::expressions::Projector Projector() \
2464 return _Expression_; \
2467 [[maybe_unused]] static constexpr o2::framework::expressions::BindingNode _Getter_ { _Label_, _Name_::hash, o2::framework::expressions::selectArrowType<_Type_>() }
2469#define DECLARE_SOA_EXPRESSION_COLUMN(_Name_, _Getter_, _Type_, _Expression_) \
2470 DECLARE_SOA_EXPRESSION_COLUMN_FULL(_Name_, _Getter_, _Type_, "f" #_Name_, _Expression_);
2474#define DECLARE_SOA_CONFIGURABLE_EXPRESSION_COLUMN(_Name_, _Getter_, _Type_, _Label_) \
2475 struct _Name_ : o2::soa::Column<_Type_, _Name_> { \
2476 static constexpr const char* mLabel = _Label_; \
2477 static constexpr const uint32_t hash = compile_time_hash(namespace_prefix<_Name_>(), std::string_view{#_Getter_}); \
2478 static constexpr const int32_t mHash = _Label_ ""_h; \
2479 using base = o2::soa::Column<_Type_, _Name_>; \
2480 using type = _Type_; \
2481 using column_t = _Name_; \
2482 using spawnable_t = std::true_type; \
2483 _Name_(arrow::ChunkedArray const* column) \
2484 : o2::soa::Column<_Type_, _Name_>(o2::soa::ColumnIterator<type>(column)) \
2488 _Name_() = default; \
2489 _Name_(_Name_ const& other) = default; \
2490 _Name_& operator=(_Name_ const& other) = default; \
2492 decltype(auto) _Getter_() const \
2494 return *mColumnIterator; \
2497 decltype(auto) get() const \
2499 return _Getter_(); \
2502 [[maybe_unused]] static constexpr o2::framework::expressions::BindingNode _Getter_ { _Label_, _Name_::hash, o2::framework::expressions::selectArrowType<_Type_>() }
2525template <o2::soa::is_table T>
2528 return T::originals;
2531#define DECLARE_SOA_SLICE_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, _Type_, _Table_, _Label_, _Suffix_) \
2532 struct _Name_##IdSlice : o2::soa::Column<_Type_[2], _Name_##IdSlice> { \
2533 static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
2534 static_assert((*_Suffix_ == '\0') || (*_Suffix_ == '_'), "Suffix has to begin with _"); \
2535 static constexpr const char* mLabel = "fIndexSlice" _Label_ _Suffix_; \
2536 static constexpr const uint32_t hash = 0; \
2537 using base = o2::soa::Column<_Type_[2], _Name_##IdSlice>; \
2538 using type = _Type_[2]; \
2539 using column_t = _Name_##IdSlice; \
2540 using binding_t = _Table_; \
2541 static constexpr auto index_targets = getIndexTargets<_Table_>(); \
2542 _Name_##IdSlice(arrow::ChunkedArray const* column) \
2543 : o2::soa::Column<_Type_[2], _Name_##IdSlice>(o2::soa::ColumnIterator<type>(column)) \
2547 _Name_##IdSlice() = default; \
2548 _Name_##IdSlice(_Name_##IdSlice const& other) = default; \
2549 _Name_##IdSlice& operator=(_Name_##IdSlice const& other) = default; \
2550 std::array<_Type_, 2> inline getIds() const \
2552 return _Getter_##Ids(); \
2555 bool has_##_Getter_() const \
2557 auto a = *mColumnIterator; \
2558 return a[0] >= 0 && a[1] >= 0; \
2561 std::array<_Type_, 2> _Getter_##Ids() const \
2563 auto a = *mColumnIterator; \
2564 return std::array{a[0], a[1]}; \
2567 template <typename T> \
2568 auto _Getter_##_as() const \
2570 if (O2_BUILTIN_UNLIKELY(mBinding.ptr == nullptr)) { \
2571 o2::soa::notBoundTable(#_Table_); \
2573 auto t = mBinding.get<T>(); \
2574 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2575 o2::soa::dereferenceWithWrongType(#_Getter_, #_Table_); \
2577 if (O2_BUILTIN_UNLIKELY(!has_##_Getter_())) { \
2578 return t->emptySlice(); \
2580 auto a = *mColumnIterator; \
2581 auto r = t->rawSlice(a[0], a[1]); \
2582 t->copyIndexBindings(r); \
2583 r.bindInternalIndicesTo(t); \
2587 auto _Getter_() const \
2589 return _Getter_##_as<binding_t>(); \
2592 template <typename T> \
2593 bool setCurrent(T const* current) \
2595 if constexpr (o2::soa::is_binding_compatible_v<T, binding_t>()) { \
2596 assert(current != nullptr); \
2597 this->mBinding.bind(current); \
2603 bool setCurrentRaw(o2::soa::Binding current) \
2605 this->mBinding = current; \
2608 binding_t const* getCurrent() const { return mBinding.get<binding_t>(); } \
2609 o2::soa::Binding getCurrentRaw() const { return mBinding; } \
2610 o2::soa::Binding mBinding; \
2613#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_)
2614#define DECLARE_SOA_SLICE_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_SLICE_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, _Name_##s, "")
2615#define DECLARE_SOA_SLICE_INDEX_COLUMN_CUSTOM(_Name_, _Getter_, _Label_) DECLARE_SOA_SLICE_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, int32_t, _Name_##s, _Label_, "")
2618#define DECLARE_SOA_ARRAY_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, _Type_, _Table_, _Label_, _Suffix_) \
2619 struct _Name_##Ids : o2::soa::Column<std::vector<_Type_>, _Name_##Ids> { \
2620 static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
2621 static_assert((*_Suffix_ == '\0') || (*_Suffix_ == '_'), "Suffix has to begin with _"); \
2622 static constexpr const char* mLabel = "fIndexArray" _Label_ _Suffix_; \
2623 static constexpr const uint32_t hash = 0; \
2624 using base = o2::soa::Column<std::vector<_Type_>, _Name_##Ids>; \
2625 using type = std::vector<_Type_>; \
2626 using column_t = _Name_##Ids; \
2627 using binding_t = _Table_; \
2628 static constexpr auto index_targets = getIndexTargets<_Table_>(); \
2629 _Name_##Ids(arrow::ChunkedArray const* column) \
2630 : o2::soa::Column<std::vector<_Type_>, _Name_##Ids>(o2::soa::ColumnIterator<type>(column)) \
2634 _Name_##Ids() = default; \
2635 _Name_##Ids(_Name_##Ids const& other) = default; \
2636 _Name_##Ids& operator=(_Name_##Ids const& other) = default; \
2638 gsl::span<const _Type_> inline getIds() const \
2640 return _Getter_##Ids(); \
2643 gsl::span<const _Type_> _Getter_##Ids() const \
2645 return *mColumnIterator; \
2648 bool has_##_Getter_() const \
2650 return !(*mColumnIterator).empty(); \
2653 template <typename T> \
2654 auto _Getter_##_as() const \
2656 if (O2_BUILTIN_UNLIKELY(mBinding.ptr == nullptr)) { \
2657 o2::soa::notBoundTable(#_Table_); \
2659 auto t = mBinding.get<T>(); \
2660 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2661 o2::soa::dereferenceWithWrongType(#_Getter_, #_Table_); \
2663 return getIterators<T>(); \
2666 template <typename T> \
2667 auto filtered_##_Getter_##_as() const \
2669 if (O2_BUILTIN_UNLIKELY(mBinding.ptr == nullptr)) { \
2670 o2::soa::notBoundTable(#_Table_); \
2672 auto t = mBinding.get<T>(); \
2673 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2674 o2::soa::dereferenceWithWrongType(#_Getter_, #_Table_); \
2676 return getFilteredIterators<T>(); \
2679 template <typename T> \
2680 auto getIterators() const \
2682 auto result = std::vector<typename T::unfiltered_iterator>(); \
2683 for (auto& i : *mColumnIterator) { \
2684 result.push_back(mBinding.get<T>()->rawIteratorAt(i)); \
2689 template <typename T> \
2690 std::vector<typename T::iterator> getFilteredIterators() const \
2692 if constexpr (o2::soa::is_filtered_table<T>) { \
2693 auto result = std::vector<typename T::iterator>(); \
2694 for (auto const& i : *mColumnIterator) { \
2695 auto pos = mBinding.get<T>()->isInSelectedRows(i); \
2697 result.emplace_back(mBinding.get<T>()->iteratorAt(pos)); \
2702 static_assert(o2::framework::always_static_assert_v<T>, "T is not a Filtered type"); \
2707 auto _Getter_() const \
2709 return _Getter_##_as<binding_t>(); \
2712 template <typename T> \
2713 auto _Getter_##_first_as() const \
2715 if (O2_BUILTIN_UNLIKELY(mBinding.ptr == nullptr)) { \
2716 o2::soa::notBoundTable(#_Table_); \
2718 auto t = mBinding.get<T>(); \
2719 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2720 o2::soa::dereferenceWithWrongType(#_Getter_, #_Table_); \
2722 return t->rawIteratorAt((*mColumnIterator)[0]); \
2725 template <typename T> \
2726 auto _Getter_##_last_as() const \
2728 if (O2_BUILTIN_UNLIKELY(mBinding.ptr == nullptr)) { \
2729 o2::soa::notBoundTable(#_Table_); \
2731 auto t = mBinding.get<T>(); \
2732 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2733 o2::soa::dereferenceWithWrongType(#_Getter_, #_Table_); \
2735 return t->rawIteratorAt((*mColumnIterator).back()); \
2738 auto _Getter_first() const \
2740 return _Getter_##_first_as<binding_t>(); \
2743 auto _Getter_last() const \
2745 return _Getter_##_last_as<binding_t>(); \
2748 template <typename T> \
2749 bool setCurrent(T const* current) \
2751 if constexpr (o2::soa::is_binding_compatible_v<T, binding_t>()) { \
2752 assert(current != nullptr); \
2753 this->mBinding.bind(current); \
2759 bool setCurrentRaw(o2::soa::Binding current) \
2761 this->mBinding = current; \
2764 binding_t const* getCurrent() const { return mBinding.get<binding_t>(); } \
2765 o2::soa::Binding getCurrentRaw() const { return mBinding; } \
2766 o2::soa::Binding mBinding; \
2769#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_)
2770#define DECLARE_SOA_ARRAY_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_ARRAY_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, _Name_##s, "")
2771#define DECLARE_SOA_ARRAY_INDEX_COLUMN_CUSTOM(_Name_, _Getter_, _Label_) DECLARE_SOA_ARRAY_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, int32_t, _Name_##s, _Label_, "")
2774#define DECLARE_SOA_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, _Type_, _Table_, _Label_, _Suffix_) \
2775 struct _Name_##Id : o2::soa::Column<_Type_, _Name_##Id> { \
2776 static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
2777 static_assert((*_Suffix_ == '\0') || (*_Suffix_ == '_'), "Suffix has to begin with _"); \
2778 static constexpr const char* mLabel = "fIndex" _Label_ _Suffix_; \
2779 static constexpr const uint32_t hash = compile_time_hash(namespace_prefix<_Name_##Id>(), std::string_view{#_Getter_ "Id"}); \
2780 using base = o2::soa::Column<_Type_, _Name_##Id>; \
2781 using type = _Type_; \
2782 using column_t = _Name_##Id; \
2783 using binding_t = _Table_; \
2784 static constexpr auto index_targets = getIndexTargets<_Table_>(); \
2785 _Name_##Id(arrow::ChunkedArray const* column) \
2786 : o2::soa::Column<_Type_, _Name_##Id>(o2::soa::ColumnIterator<type>(column)) \
2790 _Name_##Id() = default; \
2791 _Name_##Id(_Name_##Id const& other) = default; \
2792 _Name_##Id& operator=(_Name_##Id const& other) = default; \
2793 type inline getId() const \
2795 return _Getter_##Id(); \
2798 type _Getter_##Id() const \
2800 return *mColumnIterator; \
2803 bool has_##_Getter_() const \
2805 return *mColumnIterator >= 0; \
2808 template <typename T> \
2809 auto _Getter_##_as() const \
2811 if (O2_BUILTIN_UNLIKELY(mBinding.ptr == nullptr)) { \
2812 o2::soa::notBoundTable(#_Table_); \
2814 if (O2_BUILTIN_UNLIKELY(!has_##_Getter_())) { \
2815 o2::soa::accessingInvalidIndexFor(#_Getter_); \
2817 auto t = mBinding.get<T>(); \
2818 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2819 o2::soa::dereferenceWithWrongType(#_Getter_, #_Table_); \
2821 return t->rawIteratorAt(*mColumnIterator); \
2824 auto _Getter_() const \
2826 return _Getter_##_as<binding_t>(); \
2829 template <typename T> \
2830 bool setCurrent(T* current) \
2832 if constexpr (o2::soa::is_binding_compatible_v<T, binding_t>()) { \
2833 assert(current != nullptr); \
2834 this->mBinding.bind(current); \
2840 bool setCurrentRaw(o2::soa::Binding current) \
2842 this->mBinding = current; \
2845 binding_t const* getCurrent() const { return mBinding.get<binding_t>(); } \
2846 o2::soa::Binding getCurrentRaw() const { return mBinding; } \
2847 o2::soa::Binding mBinding; \
2849 [[maybe_unused]] static constexpr o2::framework::expressions::BindingNode _Getter_##Id { "fIndex" #_Table_ _Suffix_, _Name_##Id::hash, o2::framework::expressions::selectArrowType<_Type_>() }
2851#define DECLARE_SOA_INDEX_COLUMN_FULL(_Name_, _Getter_, _Type_, _Table_, _Suffix_) DECLARE_SOA_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, _Type_, _Table_, #_Table_, _Suffix_)
2852#define DECLARE_SOA_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, _Name_##s, "")
2853#define DECLARE_SOA_INDEX_COLUMN_CUSTOM(_Name_, _Getter_, _Label_) DECLARE_SOA_INDEX_COLUMN_FULL_CUSTOM(_Name_, _Getter_, int32_t, _Name_##s, _Label_, "")
2856#define DECLARE_SOA_SELF_INDEX_COLUMN_COMPLETE(_Name_, _Getter_, _Type_, _Label_, _IndexTarget_) \
2857 struct _Name_##Id : o2::soa::Column<_Type_, _Name_##Id> { \
2858 static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
2859 static constexpr const char* mLabel = "fIndex" _Label_; \
2860 static constexpr const uint32_t hash = compile_time_hash(namespace_prefix<_Name_##Id>(), std::string_view{#_Getter_ "Id"}); \
2861 using base = o2::soa::Column<_Type_, _Name_##Id>; \
2862 using type = _Type_; \
2863 using column_t = _Name_##Id; \
2864 using self_index_t = std::true_type; \
2865 using compatible_signature = std::conditional<aod::is_aod_hash<_IndexTarget_>, _IndexTarget_, void>; \
2866 _Name_##Id(arrow::ChunkedArray const* column) \
2867 : o2::soa::Column<_Type_, _Name_##Id>(o2::soa::ColumnIterator<type>(column)) \
2871 _Name_##Id() = default; \
2872 _Name_##Id(_Name_##Id const& other) = default; \
2873 _Name_##Id& operator=(_Name_##Id const& other) = default; \
2874 type inline getId() const \
2876 return _Getter_##Id(); \
2879 type _Getter_##Id() const \
2881 return *mColumnIterator; \
2884 bool has_##_Getter_() const \
2886 return *mColumnIterator >= 0; \
2889 template <typename T> \
2890 auto _Getter_##_as() const \
2892 if (O2_BUILTIN_UNLIKELY(!has_##_Getter_())) { \
2893 o2::soa::accessingInvalidIndexFor(#_Getter_); \
2895 auto t = mBinding.get<T>(); \
2896 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2897 o2::soa::dereferenceWithWrongType(#_Getter_, "self"); \
2899 return t->rawIteratorAt(*mColumnIterator); \
2902 bool setCurrentRaw(o2::soa::Binding current) \
2904 this->mBinding = current; \
2907 o2::soa::Binding getCurrentRaw() const { return mBinding; } \
2908 o2::soa::Binding mBinding; \
2910 [[maybe_unused]] static constexpr o2::framework::expressions::BindingNode _Getter_##Id { "fIndex" _Label_, _Name_##Id::hash, o2::framework::expressions::selectArrowType<_Type_>() }
2912#define DECLARE_SOA_SELF_INDEX_COLUMN_FULL(_Name_, _Getter_, _Type_, _Label_) DECLARE_SOA_SELF_INDEX_COLUMN_COMPLETE(_Name_, _Getter_, _Type_, _Label_, void)
2913#define DECLARE_SOA_SELF_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_SELF_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, #_Name_)
2915#define DECLARE_SOA_SELF_SLICE_INDEX_COLUMN_COMPLETE(_Name_, _Getter_, _Type_, _Label_, _IndexTarget_) \
2916 struct _Name_##IdSlice : o2::soa::Column<_Type_[2], _Name_##IdSlice> { \
2917 static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
2918 static constexpr const char* mLabel = "fIndexSlice" _Label_; \
2919 static constexpr const uint32_t hash = 0; \
2920 using base = o2::soa::Column<_Type_[2], _Name_##IdSlice>; \
2921 using type = _Type_[2]; \
2922 using column_t = _Name_##IdSlice; \
2923 using self_index_t = std::true_type; \
2924 using compatible_signature = std::conditional<aod::is_aod_hash<_IndexTarget_>, _IndexTarget_, void>; \
2925 _Name_##IdSlice(arrow::ChunkedArray const* column) \
2926 : o2::soa::Column<_Type_[2], _Name_##IdSlice>(o2::soa::ColumnIterator<type>(column)) \
2930 _Name_##IdSlice() = default; \
2931 _Name_##IdSlice(_Name_##IdSlice const& other) = default; \
2932 _Name_##IdSlice& operator=(_Name_##IdSlice const& other) = default; \
2933 std::array<_Type_, 2> inline getIds() const \
2935 return _Getter_##Ids(); \
2938 bool has_##_Getter_() const \
2940 auto a = *mColumnIterator; \
2941 return a[0] >= 0 && a[1] >= 0; \
2944 std::array<_Type_, 2> _Getter_##Ids() const \
2946 auto a = *mColumnIterator; \
2947 return std::array{a[0], a[1]}; \
2950 template <typename T> \
2951 auto _Getter_##_as() const \
2953 auto t = mBinding.get<T>(); \
2954 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
2955 o2::soa::dereferenceWithWrongType(#_Getter_, "self"); \
2957 if (O2_BUILTIN_UNLIKELY(!has_##_Getter_())) { \
2958 return t->emptySlice(); \
2960 auto a = *mColumnIterator; \
2961 auto r = t->rawSlice(a[0], a[1]); \
2962 t->copyIndexBindings(r); \
2963 r.bindInternalIndicesTo(t); \
2967 bool setCurrentRaw(o2::soa::Binding current) \
2969 this->mBinding = current; \
2972 o2::soa::Binding getCurrentRaw() const { return mBinding; } \
2973 o2::soa::Binding mBinding; \
2976#define DECLARE_SOA_SELF_SLICE_INDEX_COLUMN_FULL(_Name_, _Getter_, _Type_, _Label_) DECLARE_SOA_SELF_SLICE_INDEX_COLUMN_COMPLETE(_Name_, _Getter_, _Type_, _Label_, void)
2977#define DECLARE_SOA_SELF_SLICE_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_SELF_SLICE_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, "_" #_Name_)
2979#define DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN_COMPLETE(_Name_, _Getter_, _Type_, _Label_, _IndexTarget_) \
2980 struct _Name_##Ids : o2::soa::Column<std::vector<_Type_>, _Name_##Ids> { \
2981 static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \
2982 static constexpr const char* mLabel = "fIndexArray" _Label_; \
2983 static constexpr const uint32_t hash = 0; \
2984 using base = o2::soa::Column<std::vector<_Type_>, _Name_##Ids>; \
2985 using type = std::vector<_Type_>; \
2986 using column_t = _Name_##Ids; \
2987 using self_index_t = std::true_type; \
2988 using compatible_signature = std::conditional<aod::is_aod_hash<_IndexTarget_>, _IndexTarget_, void>; \
2989 _Name_##Ids(arrow::ChunkedArray const* column) \
2990 : o2::soa::Column<std::vector<_Type_>, _Name_##Ids>(o2::soa::ColumnIterator<type>(column)) \
2994 _Name_##Ids() = default; \
2995 _Name_##Ids(_Name_##Ids const& other) = default; \
2996 _Name_##Ids& operator=(_Name_##Ids const& other) = default; \
2997 gsl::span<const _Type_> inline getIds() const \
2999 return _Getter_##Ids(); \
3002 gsl::span<const _Type_> _Getter_##Ids() const \
3004 return *mColumnIterator; \
3007 bool has_##_Getter_() const \
3009 return !(*mColumnIterator).empty(); \
3012 template <typename T> \
3013 auto _Getter_##_as() const \
3015 auto t = mBinding.get<T>(); \
3016 if (O2_BUILTIN_UNLIKELY(t == nullptr)) { \
3017 o2::soa::dereferenceWithWrongType(#_Getter_, "self"); \
3019 return getIterators<T>(); \
3022 template <typename T> \
3023 auto getIterators() const \
3025 auto result = std::vector<typename T::unfiltered_iterator>(); \
3026 for (auto& i : *mColumnIterator) { \
3027 result.push_back(mBinding.get<T>()->rawIteratorAt(i)); \
3032 template <typename T> \
3033 auto _Getter_##_first_as() const \
3035 return mBinding.get<T>()->rawIteratorAt((*mColumnIterator)[0]); \
3038 template <typename T> \
3039 auto _Getter_##_last_as() const \
3041 return mBinding.get<T>()->rawIteratorAt((*mColumnIterator).back()); \
3044 bool setCurrentRaw(o2::soa::Binding current) \
3046 this->mBinding = current; \
3049 o2::soa::Binding getCurrentRaw() const { return mBinding; } \
3050 o2::soa::Binding mBinding; \
3053#define DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN_FULL(_Name_, _Getter_, _Type_, _Label_) DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN_COMPLETE(_Name_, _Getter_, _Type_, _Label_, void)
3054#define DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, "_" #_Name_)
3084#define DECLARE_SOA_DYNAMIC_COLUMN(_Name_, _Getter_, ...) \
3085 struct _Name_##Callback { \
3086 static inline constexpr auto getLambda() { return __VA_ARGS__; } \
3089 struct _Name_##Helper { \
3090 using callable_t = decltype(o2::framework::FunctionMetadata(std::declval<decltype(_Name_##Callback::getLambda())>())); \
3091 using return_type = typename callable_t::return_type; \
3093 template <typename... Bindings> \
3094 struct _Name_ : o2::soa::DynamicColumn<typename _Name_##Helper::callable_t::type, _Name_<Bindings...>> { \
3095 using base = o2::soa::DynamicColumn<typename _Name_##Helper::callable_t::type, _Name_<Bindings...>>; \
3096 using helper = _Name_##Helper; \
3097 using callback_holder_t = _Name_##Callback; \
3098 using callable_t = helper::callable_t; \
3099 using callback_t = callable_t::type; \
3100 static constexpr const uint32_t hash = 0; \
3102 _Name_(arrow::ChunkedArray const*) \
3105 _Name_() = default; \
3106 _Name_(_Name_ const& other) = default; \
3107 _Name_& operator=(_Name_ const& other) = default; \
3108 static constexpr const char* mLabel = #_Name_; \
3109 using type = typename callable_t::return_type; \
3111 template <typename... FreeArgs> \
3112 type _Getter_(FreeArgs... freeArgs) const \
3114 return boundGetter(std::make_index_sequence<std::tuple_size_v<decltype(boundIterators)>>{}, freeArgs...); \
3116 template <typename... FreeArgs> \
3117 type getDynamicValue(FreeArgs... freeArgs) const \
3119 return boundGetter(std::make_index_sequence<std::tuple_size_v<decltype(boundIterators)>>{}, freeArgs...); \
3124 return _Getter_(); \
3127 template <size_t... Is, typename... FreeArgs> \
3128 type boundGetter(std::integer_sequence<size_t, Is...>&&, FreeArgs... freeArgs) const \
3130 return __VA_ARGS__((**std::get<Is>(boundIterators))..., freeArgs...); \
3133 using bindings_t = typename o2::framework::pack<Bindings...>; \
3134 std::tuple<o2::soa::ColumnIterator<typename Bindings::type> const*...> boundIterators; \
3137#define DECLARE_SOA_TABLE_METADATA(_Name_, _Desc_, _Version_, ...) \
3138 using _Name_##Metadata = TableMetadata<Hash<_Desc_ "/" #_Version_ ""_h>, __VA_ARGS__>;
3140#define DECLARE_SOA_TABLE_METADATA_TRAIT(_Name_, _Desc_, _Version_) \
3142 struct MetadataTrait<Hash<_Desc_ "/" #_Version_ ""_h>> { \
3143 using metadata = _Name_##Metadata; \
3146#define DECLARE_SOA_TABLE_FULL_VERSIONED_(_Name_, _Label_, _Origin_, _Desc_, _Version_) \
3147 O2HASH(_Desc_ "/" #_Version_); \
3148 template <typename O> \
3149 using _Name_##From = o2::soa::Table<Hash<_Label_ ""_h>, Hash<_Desc_ "/" #_Version_ ""_h>, O>; \
3150 using _Name_ = _Name_##From<Hash<_Origin_ ""_h>>; \
3152 struct MetadataTrait<Hash<_Desc_ "/" #_Version_ ""_h>> { \
3153 using metadata = _Name_##Metadata; \
3156#define DECLARE_SOA_STAGE(_Name_, _Origin_, _Desc_, _Version_) \
3157 template <typename O> \
3158 using _Name_##From = o2::soa::Table<Hash<#_Name_ ""_h>, Hash<_Desc_ "/" #_Version_ ""_h>, O>; \
3159 using _Name_ = _Name_##From<Hash<_Origin_ ""_h>>;
3161#define DECLARE_SOA_TABLE_FULL_VERSIONED(_Name_, _Label_, _Origin_, _Desc_, _Version_, ...) \
3162 DECLARE_SOA_TABLE_METADATA(_Name_, _Desc_, _Version_, __VA_ARGS__); \
3163 DECLARE_SOA_TABLE_FULL_VERSIONED_(_Name_, _Label_, _Origin_, _Desc_, _Version_);
3165#define DECLARE_SOA_TABLE_FULL(_Name_, _Label_, _Origin_, _Desc_, ...) \
3167 DECLARE_SOA_TABLE_METADATA(_Name_, _Desc_, 0, __VA_ARGS__); \
3168 DECLARE_SOA_TABLE_FULL_VERSIONED_(_Name_, _Label_, _Origin_, _Desc_, 0)
3170#define DECLARE_SOA_TABLE(_Name_, _Origin_, _Desc_, ...) \
3171 DECLARE_SOA_TABLE_FULL(_Name_, #_Name_, _Origin_, _Desc_, __VA_ARGS__)
3173#define DECLARE_SOA_TABLE_VERSIONED(_Name_, _Origin_, _Desc_, _Version_, ...) \
3175 DECLARE_SOA_TABLE_METADATA(_Name_, _Desc_, _Version_, __VA_ARGS__); \
3176 DECLARE_SOA_TABLE_FULL_VERSIONED_(_Name_, #_Name_, _Origin_, _Desc_, _Version_)
3178#define DECLARE_SOA_TABLE_STAGED_VERSIONED(_BaseName_, _Desc_, _Version_, ...) \
3179 O2HASH(_Desc_ "/" #_Version_); \
3180 O2HASH(#_BaseName_); \
3181 O2HASH("Stored" #_BaseName_); \
3182 DECLARE_SOA_TABLE_METADATA(_BaseName_, _Desc_, _Version_, __VA_ARGS__); \
3183 using Stored##_BaseName_##Metadata = _BaseName_##Metadata; \
3184 DECLARE_SOA_TABLE_METADATA_TRAIT(_BaseName_, _Desc_, _Version_); \
3185 DECLARE_SOA_STAGE(_BaseName_, "AOD", _Desc_, _Version_); \
3186 DECLARE_SOA_STAGE(Stored##_BaseName_, "AOD1", _Desc_, _Version_);
3188#define DECLARE_SOA_TABLE_STAGED(_BaseName_, _Desc_, ...) \
3189 DECLARE_SOA_TABLE_STAGED_VERSIONED(_BaseName_, _Desc_, 0, __VA_ARGS__);
3191#define DECLARE_SOA_EXTENDED_TABLE_FULL(_Name_, _Label_, _OriginalTable_, _Origin_, _Desc_, _Version_, ...) \
3192 O2HASH(_Desc_ "/" #_Version_); \
3193 template <typename O> \
3194 using _Name_##ExtensionFrom = soa::Table<o2::aod::Hash<_Label_ ""_h>, o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, O>; \
3195 using _Name_##Extension = _Name_##ExtensionFrom<o2::aod::Hash<_Origin_ ""_h>>; \
3196 template <typename O = o2::aod::Hash<_Origin_ ""_h>> \
3197 struct _Name_##ExtensionMetadataFrom : TableMetadata<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, __VA_ARGS__> { \
3198 using base_table_t = _OriginalTable_; \
3199 using extension_table_t = _Name_##ExtensionFrom<O>; \
3200 using expression_pack_t = framework::pack<__VA_ARGS__>; \
3201 static constexpr auto sources = _OriginalTable_::originals; \
3203 using _Name_##ExtensionMetadata = _Name_##ExtensionMetadataFrom<o2::aod::Hash<_Origin_ ""_h>>; \
3205 struct MetadataTrait<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>> { \
3206 using metadata = _Name_##ExtensionMetadata; \
3208 template <typename O> \
3209 using _Name_##From = o2::soa::JoinFull<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, _OriginalTable_, _Name_##ExtensionFrom<O>>; \
3210 using _Name_ = _Name_##From<o2::aod::Hash<_Origin_ ""_h>>;
3212#define DECLARE_SOA_EXTENDED_TABLE(_Name_, _Table_, _Description_, _Version_, ...) \
3213 O2HASH(#_Name_ "Extension"); \
3214 DECLARE_SOA_EXTENDED_TABLE_FULL(_Name_, #_Name_ "Extension", _Table_, "DYN", _Description_, _Version_, __VA_ARGS__)
3216#define DECLARE_SOA_EXTENDED_TABLE_USER(_Name_, _Table_, _Description_, ...) \
3217 O2HASH(#_Name_ "Extension"); \
3218 DECLARE_SOA_EXTENDED_TABLE_FULL(_Name_, #_Name_ "Extension", _Table_, "AOD", "EX" _Description_, 0, __VA_ARGS__)
3220#define DECLARE_SOA_CONFIGURABLE_EXTENDED_TABLE_FULL(_Name_, _Label_, _OriginalTable_, _Origin_, _Desc_, _Version_, ...) \
3221 O2HASH(_Desc_ "/" #_Version_); \
3222 template <typename O> \
3223 using _Name_##CfgExtensionFrom = soa::Table<o2::aod::Hash<_Label_ ""_h>, o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, O>; \
3224 using _Name_##CfgExtension = _Name_##CfgExtensionFrom<o2::aod::Hash<_Origin_ ""_h>>; \
3225 template <typename O = o2::aod::Hash<_Origin_ ""_h>> \
3226 struct _Name_##CfgExtensionMetadataFrom : TableMetadata<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, __VA_ARGS__> { \
3227 using base_table_t = _OriginalTable_; \
3228 using extension_table_t = _Name_##CfgExtensionFrom<O>; \
3229 using placeholders_pack_t = framework::pack<__VA_ARGS__>; \
3230 using configurable_t = std::true_type; \
3231 static constexpr auto sources = _OriginalTable_::originals; \
3233 using _Name_##CfgExtensionMetadata = _Name_##CfgExtensionMetadataFrom<o2::aod::Hash<_Origin_ ""_h>>; \
3235 struct MetadataTrait<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>> { \
3236 using metadata = _Name_##CfgExtensionMetadata; \
3238 template <typename O> \
3239 using _Name_##From = o2::soa::JoinFull<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, _OriginalTable_, _Name_##CfgExtensionFrom<O>>; \
3240 using _Name_ = _Name_##From<o2::aod::Hash<_Origin_ ""_h>>;
3242#define DECLARE_SOA_CONFIGURABLE_EXTENDED_TABLE(_Name_, _Table_, _Description_, ...) \
3243 O2HASH(#_Name_ "CfgExtension"); \
3244 DECLARE_SOA_CONFIGURABLE_EXTENDED_TABLE_FULL(_Name_, #_Name_ "CfgExtension", _Table_, "AOD", "EX" _Description_, 0, __VA_ARGS__)
3246#define DECLARE_SOA_INDEX_TABLE_FULL(_Name_, _Key_, _Origin_, _Version_, _Desc_, _Exclusive_, ...) \
3248 O2HASH(_Desc_ "/" #_Version_); \
3249 template <typename O = o2::aod::Hash<_Origin_ ""_h>> \
3250 struct _Name_##MetadataFrom : o2::aod::TableMetadata<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, soa::Index<>, __VA_ARGS__> { \
3251 static constexpr bool exclusive = _Exclusive_; \
3252 using Key = _Key_; \
3253 using index_pack_t = framework::pack<__VA_ARGS__>; \
3254 static constexpr const auto sources = []<typename... Cs>(framework::pack<Cs...>) { \
3255 constexpr auto a = o2::soa::mergeOriginals<typename Cs::binding_t...>(); \
3256 return o2::aod::filterForKey<a.size(), a, Key>(); \
3257 }(framework::pack<__VA_ARGS__>{}); \
3259 using _Name_##Metadata = _Name_##MetadataFrom<o2::aod::Hash<_Origin_ ""_h>>; \
3261 template <typename O = o2::aod::Hash<_Origin_ ""_h>> \
3262 using _Name_##From = o2::soa::IndexTable<o2::aod::Hash<#_Name_ ""_h>, o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, O, _Key_, __VA_ARGS__>; \
3263 using _Name_ = _Name_##From<o2::aod::Hash<_Origin_ ""_h>>; \
3266 struct MetadataTrait<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>> { \
3267 using metadata = _Name_##Metadata; \
3275#define DECLARE_SOA_TIMESTAMPED_TABLE_FULL(_Name_, _Label_, _TimestampSource_, _TimestampColumn_, _Origin_, _Version_, _Desc_, ...) \
3276 O2HASH(_Desc_ "/" #_Version_); \
3277 template <typename O> \
3278 using _Name_##TimestampFrom = soa::Table<o2::aod::Hash<_Label_ ""_h>, o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, O>; \
3279 using _Name_##Timestamp = _Name_##TimestampFrom<o2::aod::Hash<_Origin_ ""_h>>; \
3280 template <typename O = o2::aod::Hash<_Origin_ ""_h>> \
3281 struct _Name_##TimestampMetadataFrom : TableMetadata<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, __VA_ARGS__> { \
3282 using base_table_t = _TimestampSource_; \
3283 using extension_table_t = _Name_##TimestampFrom<O>; \
3284 static constexpr const auto ccdb_urls = []<typename... Cs>(framework::pack<Cs...>) { \
3285 return std::array<std::string_view, sizeof...(Cs)>{Cs::query...}; \
3286 }(framework::pack<__VA_ARGS__>{}); \
3287 static constexpr const auto ccdb_bindings = []<typename... Cs>(framework::pack<Cs...>) { \
3288 return std::array<std::string_view, sizeof...(Cs)>{Cs::mLabel...}; \
3289 }(framework::pack<__VA_ARGS__>{}); \
3290 static constexpr auto sources = _TimestampSource_::originals; \
3291 static constexpr auto timestamp_column_label = _TimestampColumn_::mLabel; \
3294 using _Name_##TimestampMetadata = _Name_##TimestampMetadataFrom<o2::aod::Hash<_Origin_ ""_h>>; \
3296 struct MetadataTrait<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>> { \
3297 using metadata = _Name_##TimestampMetadata; \
3299 template <typename O> \
3300 using _Name_##From = o2::soa::JoinFull<o2::aod::Hash<_Desc_ "/" #_Version_ ""_h>, _TimestampSource_, _Name_##TimestampFrom<O>>; \
3301 using _Name_ = _Name_##From<o2::aod::Hash<_Origin_ ""_h>>;
3303#define DECLARE_SOA_TIMESTAMPED_TABLE(_Name_, _TimestampSource_, _TimestampColumn_, _Version_, _Desc_, ...) \
3304 O2HASH(#_Name_ "Timestamped"); \
3305 DECLARE_SOA_TIMESTAMPED_TABLE_FULL(_Name_, #_Name_ "Timestamped", _TimestampSource_, _TimestampColumn_, "ATIM", _Version_, _Desc_, __VA_ARGS__)
3307#define DECLARE_SOA_INDEX_TABLE(_Name_, _Key_, _Description_, ...) \
3308 DECLARE_SOA_INDEX_TABLE_FULL(_Name_, _Key_, "IDX", 0, _Description_, false, __VA_ARGS__)
3310#define DECLARE_SOA_INDEX_TABLE_EXCLUSIVE(_Name_, _Key_, _Description_, ...) \
3311 DECLARE_SOA_INDEX_TABLE_FULL(_Name_, _Key_, "IDX", 0, _Description_, true, __VA_ARGS__)
3313#define DECLARE_SOA_INDEX_TABLE_USER(_Name_, _Key_, _Description_, ...) \
3314 DECLARE_SOA_INDEX_TABLE_FULL(_Name_, _Key_, "AOD", 0, _Description_, false, __VA_ARGS__)
3316#define DECLARE_SOA_INDEX_TABLE_EXCLUSIVE_USER(_Name_, _Key_, _Description_, ...) \
3317 DECLARE_SOA_INDEX_TABLE_FULL(_Name_, _Key_, "AOD", 0, _Description_, true, __VA_ARGS__)
3321template <
typename D,
typename...
Ts>
3322struct JoinFull :
Table<o2::aod::Hash<"JOIN"_h>, D, o2::aod::Hash<"JOIN"_h>, Ts...> {
3375 template <
typename T1,
typename Policy,
bool OPT>
3403 template <
typename T>
3410template <
typename...
Ts>
3413template <
typename...
Ts>
3419template <
typename T>
3422template <
typename T>
3425template <
typename...
Ts>
3426struct Concat :
Table<o2::aod::Hash<"CONC"_h>, o2::aod::Hash<"CONC/0"_h>, o2::aod::Hash<"CONC"_h>, Ts...> {
3429 Concat(std::vector<std::shared_ptr<arrow::Table>>&& tables, uint64_t
offset = 0)
3437 bindInternalIndicesTo(
this);
3440 using base::originals;
3442 using base::bindExternalIndices;
3443 using base::bindInternalIndicesTo;
3457template <
typename...
Ts>
3463template <soa::is_table T>
3474 using iterator = T::template iterator_template_o<FilteredIndexPolicy, self_t>;
3480 mSelectedRows{getSpan(selection)}
3482 if (this->tableSize() != 0) {
3483 mFilteredBegin = table_t::filtered_begin(mSelectedRows);
3486 mFilteredBegin.bindInternalIndices(
this);
3491 mSelectedRowsCache{
std::move(selection)},
3494 mSelectedRows = std::span{mSelectedRowsCache};
3495 if (this->tableSize() != 0) {
3496 mFilteredBegin = table_t::filtered_begin(mSelectedRows);
3499 mFilteredBegin.bindInternalIndices(
this);
3502 FilteredBase(std::vector<std::shared_ptr<arrow::Table>>&& tables, std::span<int64_t const>
const& selection, uint64_t
offset = 0)
3504 mSelectedRows{selection}
3506 if (this->tableSize() != 0) {
3507 mFilteredBegin = table_t::filtered_begin(mSelectedRows);
3510 mFilteredBegin.bindInternalIndices(
this);
3537 return mFilteredBegin;
3542 return mFilteredBegin;
3547 return mFilteredBegin +
i;
3552 return mSelectedRows.size();
3557 return table_t::asArrowTable()->num_rows();
3562 return mSelectedRows;
3568 newSelection.resize(
static_cast<int64_t
>(
end -
start + 1));
3569 std::iota(newSelection.begin(), newSelection.end(),
start);
3570 return self_t{{this->asArrowTable()}, std::move(newSelection), 0};
3580 if (sel ==
nullptr) {
3581 return std::span<int64_t const>{};
3583 auto array = std::static_pointer_cast<arrow::Int64Array>(sel->ToArray());
3586 return std::span{
start, stop};
3591 template <
typename... TA>
3594 table_t::bindExternalIndices(current...);
3595 mFilteredBegin.bindExternalIndices(current...);
3600 mFilteredBegin.bindExternalIndicesRaw(std::forward<std::vector<o2::soa::Binding>>(ptrs));
3603 template <
typename I>
3606 mFilteredBegin.bindInternalIndices(
ptr);
3609 template <
typename T1,
typename... Cs>
3612 dest.bindExternalIndicesRaw(mFilteredBegin.getIndexBindings());
3615 template <
typename T1>
3621 template <
typename T1>
3637 template <
typename T1,
bool OPT>
3643 template <
typename T1,
bool OPT>
3652 copyIndexBindings(t);
3658 auto locate = std::find(mSelectedRows.begin(), mSelectedRows.end(),
i);
3659 if (locate == mSelectedRows.end()) {
3662 return static_cast<int>(std::distance(mSelectedRows.begin(), locate));
3669 std::set_union(mSelectedRows.begin(), mSelectedRows.end(), selection.begin(), selection.end(), std::back_inserter(rowsUnion));
3670 mSelectedRowsCache.clear();
3671 mSelectedRowsCache = rowsUnion;
3679 std::set_intersection(mSelectedRows.begin(), mSelectedRows.end(), selection.begin(), selection.end(), std::back_inserter(intersection));
3680 mSelectedRowsCache.clear();
3681 mSelectedRowsCache = intersection;
3689 std::set_union(mSelectedRows.begin(), mSelectedRows.end(), selection.begin(), selection.end(), std::back_inserter(rowsUnion));
3690 mSelectedRowsCache.clear();
3691 mSelectedRowsCache = rowsUnion;
3699 std::set_intersection(mSelectedRows.begin(), mSelectedRows.end(), selection.begin(), selection.end(), std::back_inserter(intersection));
3700 mSelectedRowsCache.clear();
3701 mSelectedRowsCache = intersection;
3714 mSelectedRows = std::span{mSelectedRowsCache};
3716 mFilteredEnd.reset(
new RowViewSentinel{
static_cast<int64_t
>(mSelectedRows.size())});
3717 if (tableSize() == 0) {
3718 mFilteredBegin = *mFilteredEnd;
3720 mFilteredBegin.resetSelection(mSelectedRows);
3724 std::span<int64_t const> mSelectedRows;
3726 bool mCached =
false;
3727 iterator mFilteredBegin;
3728 std::shared_ptr<RowViewSentinel> mFilteredEnd;
3731template <
typename T>
3740 using iterator = T::template iterator_template_o<FilteredIndexPolicy, self_t>;
3746 return iterator(this->cached_begin());
3760 Filtered(std::vector<std::shared_ptr<arrow::Table>>&& tables, std::span<int64_t const>
const& selection, uint64_t
offset = 0)
3784 this->sumWithSelection(selection);
3790 this->sumWithSelection(selection);
3796 return operator+=(
other.getSelectedRows());
3815 return operator*(
other.getSelectedRows());
3820 this->intersectWithSelection(selection);
3826 this->intersectWithSelection(selection);
3832 return operator*=(
other.getSelectedRows());
3847 newSelection.resize(
static_cast<int64_t
>(
end -
start + 1));
3848 std::iota(newSelection.begin(), newSelection.end(),
start);
3849 return self_t{{this->asArrowTable()}, std::move(newSelection), 0};
3857 template <
typename T1>
3873 template <
typename T1,
bool OPT>
3879 template <
typename T1,
bool OPT>
3888 copyIndexBindings(t);
3893template <
typename T>
3902 using iterator =
typename T::template iterator_template_o<FilteredIndexPolicy, self_t>;
3908 return iterator(this->cached_begin());
3919 for (
auto& table : tables) {
3927 for (
auto& table : tables) {
3935 for (
auto& table : tables) {
3961 this->sumWithSelection(selection);
3967 this->sumWithSelection(selection);
3973 return operator+=(
other.getSelectedRows());
3979 copy.intersectionWithSelection(selection);
3986 copy.intersectionWithSelection(selection);
3992 return operator*(
other.getSelectedRows());
3997 this->intersectWithSelection(selection);
4003 this->intersectWithSelection(selection);
4009 return operator*=(
other.getSelectedRows());
4022 newSelection.resize(
static_cast<int64_t
>(
end -
start + 1));
4023 std::iota(newSelection.begin(), newSelection.end(),
start);
4024 return self_t{{this->asArrowTable()}, std::move(newSelection), 0};
4042 template <
typename T1,
bool OPT>
4048 template <
typename T1,
bool OPT>
4055 std::vector<std::shared_ptr<arrow::Table>> extractTablesFromFiltered(std::vector<
Filtered<T>>& tables)
4057 std::vector<std::shared_ptr<arrow::Table>> outTables;
4058 for (
auto& table : tables) {
4059 outTables.push_back(table.asArrowTable());
4070template <
typename L,
typename D,
typename O,
typename Key,
typename H,
typename...
Ts>
4101template <
typename T,
bool APPLY>
4103 static constexpr bool applyFilters = APPLY;
4110 SmallGroupsBase(std::vector<std::shared_ptr<arrow::Table>>&& tables, std::span<int64_t const>
const& selection, uint64_t
offset = 0)
4114template <
typename T>
4117template <
typename T>
4120template <
typename T>
#define O2HASH(_Str_)
Pre-declare Hash specialization for a generic string.
#define O2ORIGIN(_Str_)
Pre-declare Hash specialization for an origin string.
consteval auto getIndexTargets()
SLICE.
o2::monitoring::tags::Key Key
#define O2_BUILTIN_UNREACHABLE
#define O2_BUILTIN_LIKELY(x)
#define O2_BUILTIN_UNLIKELY(x)
Class for time synchronization of RawReader instances.
int64_t const * mCurrentPos
ColumnIterator(arrow::ChunkedArray const *column)
ColumnIterator(ColumnIterator< T, ChunkingPolicy > const &)=default
void moveToEnd()
Move the iterator to the end of the column.
ColumnIterator< T > & moveToPos()
ColumnIterator< T, ChunkingPolicy > & operator=(ColumnIterator< T, ChunkingPolicy > const &)=default
unwrap_t< T > const * mCurrent
unwrap_t< T > const * mLast
ColumnIterator(ColumnIterator< T, ChunkingPolicy > &&)=default
arrow::ChunkedArray const * mColumn
ColumnIterator< T, ChunkingPolicy > & operator=(ColumnIterator< T, ChunkingPolicy > &&)=default
void moveToChunk(int chunk)
void nextChunk() const
Move the iterator to the next chunk.
auto sliceByCachedUnsorted(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
int64_t tableSize() const
FilteredBase(std::vector< std::shared_ptr< arrow::Table > > &&tables, gandiva::Selection const &selection, uint64_t offset=0)
typename T::external_index_columns_t external_index_columns_t
auto select(framework::expressions::Filter const &f) const
static auto getSpan(gandiva::Selection const &sel)
T::template iterator_template_o< FilteredIndexPolicy, self_t > iterator
auto rawSliceBy(o2::framework::Preslice< T1 > const &container, int value) const
T::template iterator_template_o< DefaultIndexPolicy, self_t > unfiltered_iterator
void copyIndexBindings(T1 &dest) const
auto const & getSelectedRows() const
void sumWithSelection(std::span< int64_t const > const &selection)
void intersectWithSelection(std::span< int64_t const > const &selection)
typename T::columns_t columns_t
void bindExternalIndices(TA *... current)
void sumWithSelection(SelectionVector const &selection)
void bindInternalIndicesTo(I const *ptr)
void intersectWithSelection(SelectionVector const &selection)
auto sliceBy(o2::framework::PresliceBase< T1, framework::PreslicePolicyGeneral, OPT > const &container, int value) const
FilteredBase(std::vector< std::shared_ptr< arrow::Table > > &&tables, std::span< int64_t const > const &selection, uint64_t offset=0)
auto rawSlice(uint64_t start, uint64_t end) const
auto sliceBy(o2::framework::PresliceBase< T1, framework::PreslicePolicySorted, OPT > const &container, int value) const
iterator iteratorAt(uint64_t i) const
typename T::table_t table_t
typename T::persistent_columns_t persistent_columns_t
RowViewSentinel end() const
FilteredBase(std::vector< std::shared_ptr< arrow::Table > > &&tables, SelectionVector &&selection, uint64_t offset=0)
void bindExternalIndicesRaw(std::vector< o2::soa::Binding > &&ptrs)
const_iterator begin() const
unfiltered_iterator rawIteratorAt(uint64_t i) const
int isInSelectedRows(int i) const
auto sliceByCached(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
void doCopyIndexBindings(framework::pack< Cs... >, T1 &dest) const
auto const & cached_begin() const
auto sliceBy(o2::framework::PresliceBase< T1, framework::PreslicePolicySorted, OPT > const &container, int value) const
Filtered< Filtered< T > > operator*(std::span< int64_t const > const &selection)
typename FilteredBase< typename T::table_t >::table_t table_t
typename T::template iterator_template_o< DefaultIndexPolicy, self_t > unfiltered_iterator
Filtered< Filtered< T > > operator+(SelectionVector const &selection)
auto sliceBy(o2::framework::PresliceBase< T1, framework::PreslicePolicyGeneral, OPT > const &container, int value) const
Filtered< Filtered< T > > operator+=(std::span< int64_t const > const &selection)
typename T::template iterator_template_o< FilteredIndexPolicy, self_t > iterator
typename T::columns_t columns_t
const_iterator begin() const
Filtered(std::vector< Filtered< T > > &&tables, std::span< int64_t const > const &selection, uint64_t offset=0)
Filtered< Filtered< T > > operator+(std::span< int64_t const > const &selection)
Filtered(std::vector< Filtered< T > > &&tables, SelectionVector &&selection, uint64_t offset=0)
unfiltered_iterator rawIteratorAt(uint64_t i) const
Filtered< Filtered< T > > operator*=(std::span< int64_t const > const &selection)
Filtered< Filtered< T > > operator+=(Filtered< T > const &other)
Filtered< Filtered< T > > operator+=(SelectionVector const &selection)
Filtered< Filtered< T > > operator*=(SelectionVector const &selection)
auto rawSlice(uint64_t start, uint64_t end) const
Filtered< Filtered< T > > operator+(Filtered< T > const &other)
Filtered(std::vector< Filtered< T > > &&tables, gandiva::Selection const &selection, uint64_t offset=0)
Filtered< Filtered< T > > operator*=(Filtered< T > const &other)
auto sliceByCached(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
Filtered< Filtered< T > > operator*(Filtered< T > const &other)
Filtered< Filtered< T > > operator*(SelectionVector const &selection)
auto sliceByCachedUnsorted(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
Filtered< T > operator*(std::span< int64_t const > const &selection)
Filtered< T > operator+=(Filtered< T > const &other)
auto sliceBy(o2::framework::PresliceBase< T1, framework::PreslicePolicyGeneral, OPT > const &container, int value) const
Filtered(std::vector< std::shared_ptr< arrow::Table > > &&tables, SelectionVector &&selection, uint64_t offset=0)
Filtered< T > operator+(std::span< int64_t const > const &selection)
auto sliceByCachedUnsorted(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
Filtered< T > operator+(Filtered< T > const &other)
Filtered< T > operator*=(SelectionVector const &selection)
Filtered(std::vector< std::shared_ptr< arrow::Table > > &&tables, std::span< int64_t const > const &selection, uint64_t offset=0)
const_iterator begin() const
T::template iterator_template_o< FilteredIndexPolicy, self_t > iterator
auto sliceByCached(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
auto select(framework::expressions::Filter const &f) const
Filtered< T > operator+(SelectionVector const &selection)
T::template iterator_template_o< DefaultIndexPolicy, self_t > unfiltered_iterator
unfiltered_iterator rawIteratorAt(uint64_t i) const
Filtered< T > operator*(SelectionVector const &selection)
Filtered< T > operator*=(Filtered< T > const &other)
Filtered< T > operator*(Filtered< T > const &other)
auto rawSliceBy(o2::framework::Preslice< T1 > const &container, int value) const
Filtered< T > operator+=(SelectionVector const &selection)
auto rawSlice(uint64_t start, uint64_t end) const
Filtered(std::vector< std::shared_ptr< arrow::Table > > &&tables, gandiva::Selection const &selection, uint64_t offset=0)
auto sliceBy(o2::framework::PresliceBase< T1, framework::PreslicePolicySorted, OPT > const &container, int value) const
Filtered< T > operator*=(std::span< int64_t const > const &selection)
Filtered< T > operator+=(std::span< int64_t const > const &selection)
typename T::table_t table_t
typename T::columns_t columns_t
decltype([]< typename... C >(framework::pack< C... > &&) -> framework::selected_pack< soa::is_self_index_t, C... > {}(columns_t{})) internal_index_columns_t
void bindInternalIndicesExplicit(o2::soa::Binding binding)
iterator iteratorAt(uint64_t i) const
decltype([]< typename... C >(framework::pack< C... > &&) -> framework::selected_pack< soa::is_persistent_column_t, C... > {}(columns_t{})) persistent_columns_t
static constexpr const auto ref
auto offset() const
Return offset.
static consteval bool hasOriginal()
unfiltered_iterator begin()
int64_t tableSize() const
auto rawSlice(uint64_t start, uint64_t end) const
void bindExternalIndices(TA *... current)
auto select(framework::expressions::Filter const &f) const
unfiltered_iterator unfiltered_const_iterator
static consteval auto full_iter()
auto const & cached_begin() const
auto sliceByCachedUnsorted(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
TableIteratorBase< IP, Parent, T... > iterator_template
void bindExternalIndicesRaw(std::vector< o2::soa::Binding > &&ptrs)
auto sliceBy(o2::framework::PresliceBase< T1, Policy, OPT > const &container, int value) const
static constexpr auto hashes()
iterator unfiltered_iterator
std::shared_ptr< arrow::Table > asArrowTable() const
Return a type erased arrow table backing store for / the type safe table.
filtered_iterator filtered_begin(std::span< int64_t const > selection)
void doCopyIndexBindings(framework::pack< Cs... >, T &dest) const
int64_t size() const
Size of the table, in rows.
Table(std::vector< std::shared_ptr< arrow::Table > > &&tables, uint64_t offset=0)
decltype(getColumns< ref, Ts... >()) columns_t
arrow::ChunkedArray * getIndexToKey()
decltype([]< typename... C >(framework::pack< C... >) -> framework::pack< typename C::type... > {}(persistent_columns_t{})) column_types
static consteval auto isIndexTargetOf()
iterator_template_o< FilteredIndexPolicy, table_t > filtered_iterator
unfiltered_const_iterator begin() const
void copyIndexBindings(T &dest) const
static constexpr const auto originalLabels
Table(std::vector< std::shared_ptr< arrow::Table > > &&tables, uint64_t offset=0)
Table< L, D, O, Ts... > self_t
static consteval auto isIndexTargetOf()
decltype(full_iter< IP, Parent >()) iterator_template_o
void doBindInternalIndicesExplicit(framework::pack< Cs... >, o2::soa::Binding binding)
static constexpr const auto originals
decltype([]< typename... C >(framework::pack< C... > &&) -> framework::selected_pack< soa::is_external_index_t, C... > {}(columns_t{})) external_index_columns_t
Table(std::shared_ptr< arrow::Table > table, uint64_t offset=0)
RowViewSentinel end() const
auto sliceByCached(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
void bindInternalIndicesTo(I const *ptr)
unfiltered_iterator rawIteratorAt(uint64_t i) const
iterator_template_o< DefaultIndexPolicy, table_t > iterator
hash identification concepts
Helper to check if a type T is an iterator.
column identification concepts
GLuint GLsizei const GLuint const GLintptr * offsets
GLuint const GLchar * name
GLboolean GLboolean GLboolean b
GLsizei const GLfloat * value
GLint GLint GLsizei GLint GLenum GLenum type
GLuint GLsizei GLsizei * length
GLuint GLsizei const GLchar * label
GLsizei GLenum const void * indices
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GLenum GLenum GLsizei len
GLboolean GLboolean GLboolean GLboolean a
std::shared_ptr< gandiva::SelectionVector > Selection
consteval const char * origin_str()
consteval const char * signature()
consteval auto filterForKey()
Filter TableRef array for compatibility with Key table.
consteval const char * label()
consteval header::DataOrigin origin()
std::shared_ptr< arrow::DataType > concreteArrowType(atype::type type)
gandiva::Selection createSelection(std::shared_ptr< arrow::Table > const &table, Filter const &expression)
Function for creating gandiva selection from our internal filter tree.
Defining PrimaryVertex explicitly as messageable.
std::decay_t< decltype(select_pack< Condition >(pack<>{}, Pack{}, CondPack{}))> selected_pack_multicondition
std::decay_t< decltype(prune_voids_pack(pack<>{}, with_condition_pack< Condition, Types... >{}))> selected_pack
decltype(intersected_pack(Ps{}...)) full_intersected_pack_t
typename pack_element< I, T >::type pack_element_t
consteval size_t has_type_at_v(pack< Ts... >)
constexpr std::size_t pack_size(pack< Ts... > const &)
template function to determine number of types in a pack
decltype(concatenate_pack_unique(Ps{}...)) concatenated_pack_unique_t
std::string strToUpper(std::string &&str)
typename pack_element< 0, T >::type pack_head_t
std::string cutString(std::string &&str)
std::vector< std::vector< int64_t > > ListVector
R getColumnValue(const T &rowIterator)
ColumnGetterFunction< R, typename T::iterator > getColumnGetterByLabel(const std::string_view &targetColumnLabel)
void * extractCCDBPayload(char *payload, size_t size, TClass const *cl, const char *what)
consteval auto computeOriginals()
auto createFieldsFromColumns(framework::pack< C... >)
SelectionVector selectionToVector(gandiva::Selection const &sel)
constexpr bool is_persistent_v
constexpr bool is_ng_index_equivalent_v
consteval auto remove_if(L l)
constexpr auto join(Ts const &... t)
auto doSliceBy(T const *table, o2::framework::PresliceBase< C, Policy, OPT > const &container, int value)
void notBoundTable(const char *tableName)
SelectionVector sliceSelection(std::span< int64_t const > const &mSelectedRows, int64_t nrows, uint64_t offset)
auto doFilteredSliceBy(T const *table, o2::framework::PresliceBase< C, framework::PreslicePolicySorted, OPT > const &container, int value)
constexpr auto concat(Ts const &... t)
consteval auto intersectOriginals()
consteval auto getColumns()
std::vector< int64_t > SelectionVector
std::conditional_t< is_binding_compatible_v< T, typename B::binding_t >(), std::true_type, std::false_type > is_binding_compatible
consteval auto mergeOriginals()
constexpr bool is_soa_filtered_v
typename std::conditional_t< is_index_column< C >, std::true_type, std::false_type > is_external_index_t
void missingFilterDeclaration(int hash, int ai)
auto doSliceByCachedUnsorted(T const *table, framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache)
auto doSliceByCached(T const *table, framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache)
void accessingInvalidIndexFor(const char *getter)
auto select(T const &t, framework::expressions::Filter const &f)
consteval auto base_iter(framework::pack< C... > &&) -> TableIterator< D, O, IP, C... >
constexpr bool is_index_equivalent_v
constexpr bool is_soa_join_v
void dereferenceWithWrongType(const char *getter, const char *target)
std::conditional_t< is_indexing_column< T >, std::true_type, std::false_type > is_indexing_t
consteval bool is_binding_compatible_v()
auto prepareFilteredSlice(T const *table, std::shared_ptr< arrow::Table > slice, uint64_t offset)
typename unwrap< T >::type unwrap_t
void getterNotFound(const char *targetColumnLabel)
auto doFilteredSliceByCached(T const *table, framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache)
void missingOptionalPreslice(const char *label, const char *key)
auto doSliceByHelper(T const *table, std::span< const int64_t > const &selection)
consteval bool is_compatible()
arrow::ChunkedArray * getIndexFromLabel(arrow::Table *table, std::string_view label)
consteval auto merge()
Helpers to manipulate TableRef arrays.
consteval auto merge_if(L l)
std::conditional_t< is_persistent_column< C >, std::true_type, std::false_type > is_persistent_column_t
typename arrow_array_for< T >::type arrow_array_for_t
void notFoundColumn(const char *label, const char *key)
std::conditional_t< is_dynamic_column< T >, std::true_type, std::false_type > is_dynamic_t
typename std::conditional_t< is_self_index_column< C >, std::true_type, std::false_type > is_self_index_t
Defining DataPointCompositeObject explicitly as copiable.
FIXME: do not use data model tables.
static constexpr uint32_t hash
static constexpr char const *const str
SliceInfoUnsortedPtr getCacheUnsortedFor(Entry const &bindingKey) const
SliceInfoPtr getCacheFor(Entry const &bindingKey) const
std::shared_ptr< arrow::Table > getSliceFor(int value, std::shared_ptr< arrow::Table > const &input, uint64_t &offset) const
static constexpr bool optional
PresliceBase(expressions::BindingNode index_)
std::span< const int64_t > getSliceFor(int value) const
const std::string binding
const std::string binding
Entry const & getBindingKey() const
SliceInfoUnsortedPtr sliceInfo
std::span< const int64_t > getSliceFor(int value) const
void updateSliceInfo(SliceInfoUnsortedPtr &&si)
void updateSliceInfo(SliceInfoPtr &&si)
std::shared_ptr< arrow::Table > getSliceFor(int value, std::shared_ptr< arrow::Table > const &input, uint64_t &offset) const
ArrowTableSlicingCache * ptr
std::pair< int64_t, int64_t > getSliceFor(int value) const
An expression tree node corresponding to a column binding.
A struct, containing the root of the expression tree.
From https://en.cppreference.com/w/cpp/utility/variant/visit.
static std::shared_ptr< arrow::Table > joinTables(std::vector< std::shared_ptr< arrow::Table > > &&tables, std::span< const char *const > labels)
static std::shared_ptr< arrow::Table > concatTables(std::vector< std::shared_ptr< arrow::Table > > &&tables)
Type-checking index column binding.
std::span< TableRef const > refs
void bind(T const *table)
static constexpr bool chunked
arrow::ChunkedArray * second
Column(ColumnIterator< T > const &it)
static constexpr const char *const & columnLabel()
ColumnIterator< T > const & getIterator() const
Column & operator=(Column const &)=default
Column(Column &&)=default
static auto asArrowField()
Column & operator=(Column &&)=default
Column(Column const &)=default
ColumnIterator< T > mColumnIterator
table_t::template iterator_template< DefaultIndexPolicy, self_t, Ts... > iterator
Concat(Ts const &... t, uint64_t offset=0)
typename table_t::persistent_columns_t persistent_columns_t
typename table_t::columns_t columns_t
const_iterator unfiltered_const_iterator
iterator unfiltered_iterator
table_t::template iterator_template< FilteredIndexPolicy, self_t, Ts... > filtered_iterator
Concat(std::vector< std::shared_ptr< arrow::Table > > &&tables, uint64_t offset=0)
filtered_iterator filtered_const_iterator
DefaultIndexPolicy(int64_t nRows, uint64_t offset)
friend bool operator==(DefaultIndexPolicy const &lh, DefaultIndexPolicy const &rh)
bool operator==(RowViewSentinel const &sentinel) const
DefaultIndexPolicy(FilteredIndexPolicy const &other)
std::tuple< uint64_t const * > getOffsets() const
DefaultIndexPolicy & operator=(DefaultIndexPolicy &&)=default
void setCursor(int64_t i)
void limitRange(int64_t start, int64_t end)
DefaultIndexPolicy(DefaultIndexPolicy &&)=default
DefaultIndexPolicy(DefaultIndexPolicy const &)=default
DefaultIndexPolicy & operator=(DefaultIndexPolicy const &)=default
std::tuple< int64_t const *, int64_t const * > getIndices() const
DefaultIndexPolicy()=default
Needed to be able to copy the policy.
void moveByIndex(int64_t i)
static constexpr const char *const & columnLabel()
FilteredIndexPolicy & operator=(FilteredIndexPolicy &&)=default
std::tuple< int64_t const *, int64_t const * > getIndices() const
FilteredIndexPolicy & operator=(FilteredIndexPolicy const &)=default
auto getSelectionRow() const
FilteredIndexPolicy()=default
FilteredIndexPolicy(std::span< int64_t const > selection, int64_t rows, uint64_t offset=0)
friend bool operator==(FilteredIndexPolicy const &lh, FilteredIndexPolicy const &rh)
void resetSelection(std::span< int64_t const > selection)
void setCursor(int64_t i)
FilteredIndexPolicy(FilteredIndexPolicy const &)=default
bool operator==(RowViewSentinel const &sentinel) const
std::tuple< uint64_t const * > getOffsets() const
void limitRange(int64_t start, int64_t end)
FilteredIndexPolicy(FilteredIndexPolicy &&)=default
void moveByIndex(int64_t i)
static constexpr bool chunked
static constexpr const char *const & columnLabel()
static constexpr const uint32_t hash
uint64_t mOffset
Offset within a larger table.
int64_t mRowIndex
Position inside the current table.
IndexTable(std::vector< std::shared_ptr< arrow::Table > > tables, uint64_t offset=0)
IndexTable(std::shared_ptr< arrow::Table > table, uint64_t offset=0)
typename base_t::template iterator_template_o< DefaultIndexPolicy, self_t > iterator
filtered_iterator const_filtered_iterator
IndexTable(IndexTable &&)=default
IndexTable & operator=(IndexTable const &)=default
IndexTable & operator=(IndexTable &&)=default
typename H::binding_t first_t
typename base_t::template iterator_template_o< FilteredIndexPolicy, self_t > filtered_iterator
IndexTable(IndexTable const &)=default
Index(Index const &)=default
void setIndices(std::tuple< int64_t const *, int64_t const * > indices)
Index & operator=(Index &&)=default
Index(arrow::ChunkedArray const *)
int64_t filteredIndex() const
constexpr int64_t rangeEnd()
constexpr int64_t rangeStart()
Index & operator=(Index const &)=default
int64_t globalIndex() const
std::tuple< int64_t const *, int64_t const * > rowIndices
void setOffsets(std::tuple< uint64_t const * > offsets)
static constexpr const char * mLabel
std::tuple< uint64_t const * > rowOffsets
iterator unfiltered_iterator
auto sliceBy(o2::framework::PresliceBase< T1, Policy, OPT > const &container, int value) const
auto rawSlice(uint64_t start, uint64_t end) const
auto sliceByCachedUnsorted(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
JoinFull(std::vector< std::shared_ptr< arrow::Table > > &&tables, uint64_t offset=0)
static constexpr const auto originalLabels
const_iterator unfiltered_const_iterator
filtered_iterator filtered_const_iterator
static consteval bool contains()
iterator iteratorAt(uint64_t i) const
typename table_t::columns_t columns_t
table_t::template iterator_template< DefaultIndexPolicy, self_t, Ts... > iterator
table_t::template iterator_template< FilteredIndexPolicy, self_t, Ts... > filtered_iterator
static constexpr const auto originals
JoinFull< D, Ts... > self_t
const_iterator begin() const
typename table_t::persistent_columns_t persistent_columns_t
iterator rawIteratorAt(uint64_t i) const
Table< o2::aod::Hash<"JOIN"_h >, D, o2::aod::Hash<"JOIN"_h >, Ts... > base
JoinFull(std::shared_ptr< arrow::Table > &&table, uint64_t offset=0)
auto sliceByCached(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
static constexpr const uint32_t hash
static constexpr const char *const & columnLabel()
Marker & operator=(Marker const &)=default
static constexpr auto value
static constexpr const char * mLabel
Marker(arrow::ChunkedArray const *)
Marker(Marker const &)=default
Marker & operator=(Marker &&)=default
Marker(Marker &&)=default
SmallGroupsBase(std::vector< std::shared_ptr< arrow::Table > > &&tables, SelectionVector &&selection, uint64_t offset=0)
SmallGroupsBase(std::vector< std::shared_ptr< arrow::Table > > &&tables, std::span< int64_t const > const &selection, uint64_t offset=0)
SmallGroupsBase(std::vector< std::shared_ptr< arrow::Table > > &&tables, gandiva::Selection const &selection, uint64_t offset=0)
framework::selected_pack< soa::is_persistent_column_t, C... > persistent_columns_t
void doSetCurrentIndexRaw(framework::pack< Cs... > p, std::vector< o2::soa::Binding > &&ptrs)
void bindInternalIndices(I const *table)
TableIterator(TableIterator< D, O, FilteredIndexPolicy, C... > const &other)
TableIterator(self_t const &other)
TableIterator operator-(int64_t dec) const
TableIterator(arrow::ChunkedArray *columnData[sizeof...(C)], IP &&policy)
TableIterator & operator=(TableIterator other)
TableIterator & operator++()
void doSetCurrentInternal(framework::pack< Cs... >, I const *ptr)
auto getIndexBindingsImpl(framework::pack< Cs... >) const
TableIterator operator--(int)
void bindExternalIndicesRaw(std::vector< o2::soa::Binding > &&ptrs)
TableIterator(arrow::ChunkedArray *columnData[sizeof...(C)], IP &&policy)
decltype([]< typename... Cs >(framework::pack< Cs... >) -> framework::pack< typename Cs::binding_t... > {}(external_index_columns_t{})) bindings_pack_t
void bindExternalIndices(TA *... current)
TableIterator & operator--()
framework::selected_pack< soa::is_external_index_t, C... > external_index_columns_t
TableIterator const & operator*() const
TableIterator operator++(int)
framework::selected_pack< soa::is_self_index_t, C... > internal_index_columns_t
auto getIndexBindings() const
void doSetCurrentIndex(framework::pack< CL... >, TA *current)
TableIterator operator+(int64_t inc) const
Allow incrementing by more than one the iterator.
Generic identifier for a table type.
constexpr TableRef & operator=(TableRef const &)=default
constexpr bool descriptionCompatible(uint32_t _desc_hash) const noexcept
constexpr bool operator==(TableRef const &other) const noexcept
constexpr TableRef(TableRef &&)=default
constexpr TableRef(TableRef const &)=default
consteval TableRef(uint32_t _label, uint32_t _desc, uint32_t _origin, uint32_t _version)
constexpr bool descriptionCompatible(TableRef const &other) const noexcept
constexpr TableRef & operator=(TableRef &&)=default
TableIteratorBase const & operator*() const
TableIteratorBase(TableIteratorBase< IP, P, T... > const &other)
typename Parent::columns_t columns_t
TableIteratorBase(TableIteratorBase< IP, P, O1, Os... > const &other)
typename Parent::external_index_columns_t external_index_columns_t
TableIteratorBase operator-(int64_t dec) const
void matchTo(TableIteratorBase< IP, P, T... > const &other)
auto getDynamicColumn() const
TableIteratorBase()=default
void matchTo(TableIteratorBase< IP, P, Os... > const &other)
TableIteratorBase(TableIteratorBase< FilteredIndexPolicy, P, T... > other)
std::array< B, sizeof...(CCs)> getValues() const
static constexpr auto originals
TableIteratorBase(TableIteratorBase< IP, P, T... > &&other) noexcept
decltype([]< typename... C >(framework::pack< C... >) -> framework::pack< typename C::binding_t... > {}(external_index_columns_t{})) bindings_pack_t
TableIteratorBase & operator=(TableIteratorBase< IP, P, Os... > other)
TableIteratorBase(TableIteratorBase< IP, P, O1, Os... > &&other) noexcept
TableIteratorBase & operator=(RowViewSentinel const &other)
TableIteratorBase(arrow::ChunkedArray *columnData[framework::pack_size(columns_t{})], IP &&policy)
TableIteratorBase & operator=(TableIteratorBase< IP, P, T... > other)
TableIteratorBase operator+(int64_t inc) const
Allow incrementing by more than one the iterator.
TableIteratorBase & operator=(TableIteratorBase< FilteredIndexPolicy, P, T... > other)
VectorOfTObjectPtrs other
std::vector< ReadoutWindowData > rows