Project
Loading...
Searching...
No Matches
AnalysisHelpers.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11#ifndef o2_framework_AnalysisHelpers_H_DEFINED
12#define o2_framework_AnalysisHelpers_H_DEFINED
13
14#include "Framework/ASoA.h"
17#include "Framework/InputSpec.h"
18#include "Framework/Output.h"
20#include "Framework/OutputRef.h"
22#include "Framework/Plugins.h"
25#include "Framework/Traits.h"
26
27#include <string>
28namespace o2::soa
29{
30template <TableRef R>
32{
34 std::string{"input:"} + o2::aod::label<R>(),
36 aod::sourceSpec<R>(),
37 {"\"\""}};
38}
39
40namespace
41{
42template <soa::with_sources T>
43inline constexpr auto getSources()
44{
45 return []<size_t N, std::array<soa::TableRef, N> refs>() {
46 return []<size_t... Is>(std::index_sequence<Is...>) {
47 return std::vector{soa::tableRef2ConfigParamSpec<refs[Is]>()...};
48 }(std::make_index_sequence<N>());
49 }.template operator()<T::sources.size(), T::sources>();
50}
51
52template <soa::with_sources T>
53constexpr auto getInputMetadata() -> std::vector<framework::ConfigParamSpec>
54{
55 std::vector<framework::ConfigParamSpec> inputMetadata;
56 auto inputSources = getSources<T>();
57 std::sort(inputSources.begin(), inputSources.end(), [](framework::ConfigParamSpec const& a, framework::ConfigParamSpec const& b) { return a.name < b.name; });
58 auto last = std::unique(inputSources.begin(), inputSources.end(), [](framework::ConfigParamSpec const& a, framework::ConfigParamSpec const& b) { return a.name == b.name; });
59 inputSources.erase(last, inputSources.end());
60 inputMetadata.insert(inputMetadata.end(), inputSources.begin(), inputSources.end());
61 return inputMetadata;
62}
63
64template <typename T>
65 requires(!soa::with_sources<T>)
66constexpr auto getInputMetadata() -> std::vector<framework::ConfigParamSpec>
67{
68 return {};
69}
70} // namespace
71
72template <TableRef R>
73constexpr auto tableRef2InputSpec()
74{
76 o2::aod::label<R>(),
77 o2::aod::origin<R>(),
78 o2::aod::description(o2::aod::signature<R>()),
79 R.version,
80 framework::Lifetime::Timeframe,
81 getInputMetadata<typename o2::aod::MetadataTrait<o2::aod::Hash<R.desc_hash>>::metadata>()};
82}
83
84template <TableRef R>
85constexpr auto tableRef2OutputSpec()
86{
88 framework::OutputLabel{o2::aod::label<R>()},
89 o2::aod::origin<R>(),
90 o2::aod::description(o2::aod::signature<R>()),
91 R.version};
92}
93
94template <TableRef R>
95constexpr auto tableRef2Output()
96{
97 return framework::Output{
98 o2::aod::origin<R>(),
99 o2::aod::description(o2::aod::signature<R>()),
100 R.version};
101}
102
103template <TableRef R>
104constexpr auto tableRef2OutputRef()
105{
107 o2::aod::label<R>(),
108 R.version};
109}
110} // namespace o2::soa
111
112namespace o2::framework
113{
114class TableConsumer;
115
119template <typename T>
121
122template <is_producable T>
124 public:
125 using persistent_table_t = decltype([]() { if constexpr (soa::is_iterator<T>) { return typename T::parent_t{nullptr}; } else { return T{nullptr}; } }());
126 using cursor_t = decltype(std::declval<TableBuilder>().cursor<persistent_table_t>());
127
128 template <typename... Ts>
129 void operator()(Ts... args)
130 {
131 static_assert(sizeof...(Ts) == framework::pack_size(typename persistent_table_t::persistent_columns_t{}), "Argument number mismatch");
132 ++mCount;
133 cursor(0, extract(args)...);
134 }
135
137 int64_t lastIndex()
138 {
139 return mCount;
140 }
141
143 {
144 mBuilder = std::move(builder);
145 cursor = std::move(FFL(mBuilder->cursor<persistent_table_t>()));
146 mCount = -1;
147 return true;
148 }
149
150 void setLabel(const char* label)
151 {
152 mBuilder->setLabel(label);
153 }
154
157 void reserve(int64_t size)
158 {
159 mBuilder->reserve(typename persistent_table_t::column_types{}, size);
160 }
161
162 void release()
163 {
164 mBuilder.release();
165 }
166
167 decltype(FFL(std::declval<cursor_t>())) cursor;
168
169 private:
170 template <typename A>
171 requires requires { &A::globalIndex; }
172 static decltype(auto) extract(A const& arg)
173 {
174 return arg.globalIndex();
175 }
176
177 template <typename A>
178 static decltype(auto) extract(A const& arg)
179 {
180 return arg;
181 }
182
186 LifetimeHolder<TableBuilder> mBuilder = nullptr;
187 int64_t mCount = -1;
188};
189
191template <soa::is_table T>
192consteval auto typeWithRef() -> T
193{
194}
195
196template <soa::is_iterator T>
197consteval auto typeWithRef() -> typename T::parent_t
198{
199}
200
201template <typename T>
202 requires soa::is_table<T> || soa::is_iterator<T>
204 using table_t = decltype(typeWithRef<T>());
205 using metadata = aod::MetadataTrait<o2::aod::Hash<table_t::ref.desc_hash>>::metadata;
206
207 static OutputSpec const spec()
208 {
209 return OutputSpec{OutputLabel{aod::label<table_t::ref>()}, o2::aod::origin<table_t::ref>(), o2::aod::description(o2::aod::signature<table_t::ref>()), table_t::ref.version};
210 }
211
212 static OutputRef ref()
213 {
214 return OutputRef{aod::label<table_t::ref>(), table_t::ref.version};
215 }
216};
217
222template <is_producable T>
224};
225
226template <typename T>
227concept is_produces = requires(T t) { typename T::cursor_t; typename T::persistent_table_t; &T::cursor; };
228
238};
239
240template <typename T>
241concept is_produces_group = std::derived_from<T, ProducesGroup>;
242
244template <soa::is_metadata M, soa::TableRef Ref>
246 using metadata = M;
247 constexpr static auto sources = M::sources;
248
249 template <soa::TableRef R>
250 static constexpr auto base_spec()
251 {
252 return soa::tableRef2InputSpec<R>();
253 }
254
255 static auto base_specs()
256 {
257 return []<size_t... Is>(std::index_sequence<Is...>) -> std::vector<InputSpec> {
258 return {base_spec<sources[Is]>()...};
259 }(std::make_index_sequence<sources.size()>{});
260 }
261
262 constexpr auto spec() const
263 {
264 return soa::tableRef2OutputSpec<Ref>();
265 }
266
267 constexpr auto output() const
268 {
269 return soa::tableRef2Output<Ref>();
270 }
271
272 constexpr auto ref() const
273 {
274 return soa::tableRef2OutputRef<Ref>();
275 }
276};
277
280template <typename T>
281concept is_spawnable = soa::has_metadata<aod::MetadataTrait<o2::aod::Hash<T::ref.desc_hash>>> && soa::has_extension<typename aod::MetadataTrait<o2::aod::Hash<T::ref.desc_hash>>::metadata>;
282
283template <typename T>
284concept is_dynamically_spawnable = soa::has_metadata<aod::MetadataTrait<o2::aod::Hash<T::ref.desc_hash>>> && soa::has_configurable_extension<typename aod::MetadataTrait<o2::aod::Hash<T::ref.desc_hash>>::metadata>;
285
286template <is_spawnable T>
287constexpr auto transformBase()
288{
289 using metadata = typename aod::MetadataTrait<o2::aod::Hash<T::ref.desc_hash>>::metadata;
291}
292
293template <is_spawnable T>
294struct Spawns : decltype(transformBase<T>()) {
295 using spawnable_t = T;
296 using metadata = decltype(transformBase<T>())::metadata;
297 using extension_t = typename metadata::extension_table_t;
298 using base_table_t = typename metadata::base_table_t;
299 using expression_pack_t = typename metadata::expression_pack_t;
300
301 constexpr auto pack()
302 {
303 return expression_pack_t{};
304 }
305
306 typename T::table_t* operator->()
307 {
308 return table.get();
309 }
310 typename T::table_t const& operator*() const
311 {
312 return *table;
313 }
314
316 {
317 return extension->asArrowTable();
318 }
319 std::shared_ptr<typename T::table_t> table = nullptr;
320 std::shared_ptr<extension_t> extension = nullptr;
321 std::shared_ptr<gandiva::Projector> projector = nullptr;
322};
323
324template <typename T>
325concept is_spawns = requires(T t) {
326 typename T::metadata;
327 requires std::same_as<decltype(t.pack()), typename T::expression_pack_t>;
328 requires std::same_as<decltype(t.projector), std::shared_ptr<gandiva::Projector>>;
329};
330
335
336template <is_dynamically_spawnable T>
337struct Defines : decltype(transformBase<T>()) {
338 using spawnable_t = T;
339 using metadata = decltype(transformBase<T>())::metadata;
340 using extension_t = typename metadata::extension_table_t;
341 using base_table_t = typename metadata::base_table_t;
342 using placeholders_pack_t = typename metadata::placeholders_pack_t;
343 static constexpr size_t N = framework::pack_size(placeholders_pack_t{});
344
345 constexpr auto pack()
346 {
347 return placeholders_pack_t{};
348 }
349
350 typename T::table_t* operator->()
351 {
352 return table.get();
353 }
354 typename T::table_t const& operator*() const
355 {
356 return *table;
357 }
358
360 {
361 return extension->asArrowTable();
362 }
363 std::shared_ptr<typename T::table_t> table = nullptr;
364 std::shared_ptr<extension_t> extension = nullptr;
365
366 std::array<o2::framework::expressions::Projector, N> projectors;
367 std::shared_ptr<gandiva::Projector> projector = nullptr;
368};
369
370template <typename T>
371concept is_defines = requires(T t) {
372 typename T::metadata;
373 requires std::same_as<decltype(t.pack()), typename T::placeholders_pack_t>;
374 requires std::same_as<decltype(t.projector), std::shared_ptr<gandiva::Projector>>;
375};
376
381struct Exclusive {
382};
383struct Sparse {
384};
385
386namespace
387{
388template <typename T, typename Key>
389inline std::shared_ptr<arrow::ChunkedArray> getIndexToKey(arrow::Table* table)
390{
391 using IC = framework::pack_element_t<framework::has_type_at_conditional_v<soa::is_binding_compatible, Key>(typename T::external_index_columns_t{}), typename T::external_index_columns_t>;
392 return table->column(framework::has_type_at_v<IC>(typename T::persistent_columns_t{}));
393}
394
395template <soa::is_column C>
396struct ColumnTrait {
397 using column_t = C;
398
399 static consteval auto listSize()
400 {
401 if constexpr (std::same_as<typename C::type, std::vector<int>>) {
402 return -1;
403 } else if constexpr (std::same_as<int[2], typename C::type>) {
404 return 2;
405 } else {
406 return 1;
407 }
408 }
409
410 template <typename T, typename Key>
411 static std::shared_ptr<SelfIndexColumnBuilder> makeColumnBuilder(arrow::Table* table, arrow::MemoryPool* pool)
412 {
413 if constexpr (!std::same_as<T, Key>) {
414 return std::make_shared<IndexColumnBuilder>(getIndexToKey<T, Key>(table), C::columnLabel(), listSize(), pool);
415 } else {
416 return std::make_shared<SelfIndexColumnBuilder>(C::columnLabel(), pool);
417 }
418 }
419};
420
421template <typename Key, typename C>
422struct Reduction {
423 using type = typename std::conditional<soa::is_binding_compatible_v<Key, typename C::binding_t>(), SelfIndexColumnBuilder, IndexColumnBuilder>::type;
424};
425
426template <typename Key, typename C>
427using reduced_t = Reduction<Key, C>::type;
428} // namespace
429
430template <typename Kind>
432 template <typename Key, size_t N, std::array<soa::TableRef, N> refs, typename C1, typename... Cs>
433 static auto indexBuilder(const char* label, std::vector<std::shared_ptr<arrow::Table>>&& tables, framework::pack<C1, Cs...>)
434 {
435 auto pool = arrow::default_memory_pool();
436 SelfIndexColumnBuilder self{C1::columnLabel(), pool};
437 std::unique_ptr<ChunkedArrayIterator> keyIndex = nullptr;
438 if constexpr (!Key::template hasOriginal<refs[0]>()) {
439 keyIndex = std::make_unique<ChunkedArrayIterator>(tables[0]->column(o2::aod::MetadataTrait<o2::aod::Hash<refs[0].desc_hash>>::metadata::template getIndexPosToKey<Key>()));
440 }
441
442 auto sq = std::make_index_sequence<sizeof...(Cs)>();
443
444 auto columnBuilders = [&tables, &pool ]<size_t... Is>(std::index_sequence<Is...>) -> std::array<std::shared_ptr<framework::SelfIndexColumnBuilder>, sizeof...(Cs)>
445 {
446 return {[](arrow::Table* table, arrow::MemoryPool* pool) {
447 using T = framework::pack_element_t<Is, framework::pack<Cs...>>;
448 if constexpr (!Key::template hasOriginal<refs[Is + 1]>()) {
449 constexpr auto pos = o2::aod::MetadataTrait<o2::aod::Hash<refs[Is + 1].desc_hash>>::metadata::template getIndexPosToKey<Key>();
450 return std::make_shared<IndexColumnBuilder>(table->column(pos), T::columnLabel(), ColumnTrait<T>::listSize(), pool);
451 } else {
452 return std::make_shared<SelfIndexColumnBuilder>(T::columnLabel(), pool);
453 }
454 }(tables[Is + 1].get(), pool)...};
455 }
456 (sq);
457
458 std::array<bool, sizeof...(Cs)> finds;
459
460 for (int64_t counter = 0; counter < tables[0]->num_rows(); ++counter) {
461 int64_t idx = -1;
462 if constexpr (Key::template hasOriginal<refs[0]>()) {
463 idx = counter;
464 } else {
465 idx = keyIndex->valueAt(counter);
466 }
467 finds = [&idx, &columnBuilders]<size_t... Is>(std::index_sequence<Is...>) {
468 return std::array{
469 [&idx, &columnBuilders]() {
470 using T = typename framework::pack_element_t<Is, framework::pack<Cs...>>;
471 return std::static_pointer_cast<reduced_t<Key, T>>(columnBuilders[Is])->template find<T>(idx);
472 }()...};
473 }(sq);
474 if constexpr (std::same_as<Kind, Sparse>) {
475 [&idx, &columnBuilders]<size_t... Is>(std::index_sequence<Is...>) {
476 ([&idx, &columnBuilders]() {
477 using T = typename framework::pack_element_t<Is, framework::pack<Cs...>>;
478 return std::static_pointer_cast<reduced_t<Key, T>>(columnBuilders[Is])->template fill<T>(idx); }(), ...);
479 }(sq);
480 self.fill<C1>(counter);
481 } else if constexpr (std::same_as<Kind, Exclusive>) {
482 if (std::none_of(finds.begin(), finds.end(), [](bool const x) { return x == false; })) {
483 [&idx, &columnBuilders]<size_t... Is>(std::index_sequence<Is...>) {
484 ([&idx, &columnBuilders]() {
485 using T = typename framework::pack_element_t<Is, framework::pack<Cs...>>;
486 return std::static_pointer_cast<reduced_t<Key, T>>(columnBuilders[Is])->template fill<T>(idx);
487 }(),
488 ...);
489 }(sq);
490 self.fill<C1>(counter);
491 }
492 }
493 }
494
495 return [&label, &columnBuilders, &self]<size_t... Is>(std::index_sequence<Is...>) {
496 return makeArrowTable(label,
497 {self.template result<C1>(), [&columnBuilders]() {
498 using T = typename framework::pack_element_t<Is, framework::pack<Cs...>>;
499 return std::static_pointer_cast<reduced_t<Key, T>>(columnBuilders[Is])->template result<T>();
500 }()...},
501 {self.field(), [&columnBuilders]() {
502 using T = typename framework::pack_element_t<Is, framework::pack<Cs...>>;
503 return std::static_pointer_cast<reduced_t<Key, T>>(columnBuilders[Is])->field();
504 }()...});
505 }(sq);
506 }
507};
508
510
511template <soa::is_index_table T>
512constexpr auto transformBase()
513{
514 using metadata = typename aod::MetadataTrait<o2::aod::Hash<T::ref.desc_hash>>::metadata;
516}
517
518template <soa::is_index_table T>
519struct Builds : decltype(transformBase<T>()) {
520 using buildable_t = T;
521 using metadata = decltype(transformBase<T>())::metadata;
522 using IP = std::conditional_t<metadata::exclusive, IndexBuilder<Exclusive>, IndexBuilder<Sparse>>;
523 using Key = metadata::Key;
524 using H = typename T::first_t;
525 using Ts = typename T::rest_t;
526 using index_pack_t = metadata::index_pack_t;
527
529 {
530 return table.get();
531 }
532 T const& operator*() const
533 {
534 return *table;
535 }
536
538 {
539 return table->asArrowTable();
540 }
541 std::shared_ptr<T> table = nullptr;
542
543 constexpr auto pack()
544 {
545 return index_pack_t{};
546 }
547
548 template <typename Key, typename... Cs>
549 auto build(framework::pack<Cs...>, std::vector<std::shared_ptr<arrow::Table>>&& tables)
550 {
551 this->table = std::make_shared<T>(IP::template indexBuilder<Key, metadata::sources.size(), metadata::sources>(o2::aod::label<T::ref>(), std::forward<std::vector<std::shared_ptr<arrow::Table>>>(tables), framework::pack<Cs...>{}));
552 return (this->table != nullptr);
553 }
554};
555
556template <typename T>
557concept is_builds = requires(T t) {
558 typename T::metadata;
559 typename T::Key;
560 requires std::same_as<decltype(t.pack()), typename T::index_pack_t>;
561};
562
570template <typename T>
571struct OutputObj {
572 using obj_t = T;
573
575 : object(std::make_shared<T>(t)),
576 label(t.GetName()),
577 policy{policy_},
578 sourceType{sourceType_},
579 mTaskHash{0}
580 {
581 }
582
584 : object(nullptr),
585 label(label_),
586 policy{policy_},
587 sourceType{sourceType_},
588 mTaskHash{0}
589 {
590 }
591
592 void setObject(T const& t)
593 {
594 object = std::make_shared<T>(t);
595 object->SetName(label.c_str());
596 }
597
598 void setObject(T&& t)
599 {
600 object = std::make_shared<T>(t);
601 object->SetName(label.c_str());
602 }
603
604 void setObject(T* t)
605 {
606 object.reset(t);
607 object->SetName(label.c_str());
608 }
609
610 void setObject(std::shared_ptr<T> t)
611 {
612 object = t;
613 object->SetName(label.c_str());
614 }
615
616 void setHash(uint32_t hash)
617 {
618 mTaskHash = hash;
619 }
620
623 {
625 auto lhash = runtime_hash(label.c_str());
626 std::memset(desc.str, '_', 16);
627 std::stringstream s;
628 s << std::hex << lhash;
629 s << std::hex << mTaskHash;
630 s << std::hex << reinterpret_cast<uint64_t>(this);
631 std::memcpy(desc.str, s.str().c_str(), 12);
632 return OutputSpec{OutputLabel{label}, "ATSK", desc, 0, Lifetime::QA};
633 }
634
636 {
637 return object.get();
638 }
639
641 {
642 return *object.get();
643 }
644
645 OutputRef ref(uint16_t index, uint16_t max)
646 {
647 return OutputRef{std::string{label}, 0,
649 }
650
651 std::shared_ptr<T> object;
652 std::string label;
655 uint32_t mTaskHash;
656};
657
658template <typename T>
659concept is_outputobj = requires(T t) {
660 &T::setHash;
661 &T::spec;
662 &T::ref;
663 requires std::same_as<decltype(t.operator->()), typename T::obj_t*>;
664 requires std::same_as<decltype(t.object), std::shared_ptr<typename T::obj_t>>;
665};
666
670template <typename T>
671struct Service {
672 using service_t = T;
674
675 decltype(auto) operator->() const
676 {
678 return service->get();
679 } else {
680 return service;
681 }
682 }
683};
684
685template <typename T>
686concept is_service = requires(T t) {
687 requires std::same_as<decltype(t.service), typename T::service_t*>;
688 &T::operator->;
689};
690
692{
693 return std::make_unique<o2::soa::Filtered<std::decay_t<decltype(table)>>>(std::vector{table}, std::forward<soa::SelectionVector>(selection));
694}
695
697{
698 return std::make_unique<o2::soa::Filtered<std::decay_t<decltype(table)>>>(std::vector{table.asArrowTable()}, std::forward<soa::SelectionVector>(selection));
699}
700
701void initializePartitionCaches(std::set<uint32_t> const& hashes, std::shared_ptr<arrow::Schema> const& schema, expressions::Filter const& filter, gandiva::NodePtr& tree, gandiva::FilterPtr& gfilter);
702
703template <typename T>
704struct Partition {
705 using content_t = T;
706 Partition(expressions::Node&& filter_) : filter{std::forward<expressions::Node>(filter_)}
707 {
708 }
709
710 Partition(expressions::Node&& filter_, T const& table)
711 : filter{std::forward<expressions::Node>(filter_)}
712 {
713 setTable(table);
714 }
715
716 void intializeCaches(std::set<uint32_t> const& hashes, std::shared_ptr<arrow::Schema> const& schema)
717 {
718 initializePartitionCaches(hashes, schema, filter, tree, gfilter);
719 }
720
721 void bindTable(T const& table)
722 {
723 intializeCaches(T::table_t::hashes(), table.asArrowTable()->schema());
724 if (dataframeChanged) {
726 dataframeChanged = false;
727 }
728 }
729
730 template <typename... Ts>
731 void bindExternalIndices(Ts*... tables)
732 {
733 if (mFiltered != nullptr) {
734 mFiltered->bindExternalIndices(tables...);
735 }
736 }
737
738 template <typename E>
740 {
741 if (mFiltered != nullptr) {
742 mFiltered->bindInternalIndicesTo(ptr);
743 }
744 }
745
747 {
749 }
750
751 [[nodiscard]] std::shared_ptr<arrow::Table> asArrowTable() const
752 {
753 return mFiltered->asArrowTable();
754 }
755
757 {
758 return mFiltered.get();
759 }
760
761 template <typename T1>
762 [[nodiscard]] auto rawSliceBy(o2::framework::Preslice<T1> const& container, int value) const
763 {
764 return mFiltered->rawSliceBy(container, value);
765 }
766
767 [[nodiscard]] auto sliceByCached(framework::expressions::BindingNode const& node, int value, o2::framework::SliceCache& cache) const
768 {
769 return mFiltered->sliceByCached(node, value, cache);
770 }
771
773 {
774 return mFiltered->sliceByCachedUnsorted(node, value, cache);
775 }
776
777 template <typename T1, typename Policy, bool OPT>
778 [[nodiscard]] auto sliceBy(o2::framework::PresliceBase<T1, Policy, OPT> const& container, int value) const
779 {
780 return mFiltered->sliceBy(container, value);
781 }
782
784 std::unique_ptr<o2::soa::Filtered<T>> mFiltered = nullptr;
785 gandiva::NodePtr tree = nullptr;
787 bool dataframeChanged = true;
788
794 {
795 return mFiltered->begin();
796 }
798 {
799 return mFiltered->end();
800 }
802 {
803 return mFiltered->begin();
804 }
806 {
807 return mFiltered->end();
808 }
809
810 int64_t size() const
811 {
812 return mFiltered->size();
813 }
814};
815
816template <typename T>
817concept is_partition = requires(T t) {
818 &T::updatePlaceholders;
819 requires std::same_as<decltype(t.filter), expressions::Filter>;
820 requires std::same_as<decltype(t.mFiltered), std::unique_ptr<o2::soa::Filtered<typename T::content_t>>>;
821};
822} // namespace o2::framework
823
824namespace o2::soa
825{
827template <soa::is_table T, soa::is_spawnable_column... Cs>
828auto Extend(T const& table)
829{
830 using output_t = Join<T, soa::Table<o2::aod::Hash<"JOIN"_h>, o2::aod::Hash<"JOIN/0"_h>, o2::aod::Hash<"JOIN"_h>, Cs...>>;
831 static std::shared_ptr<gandiva::Projector> projector = nullptr;
832 return output_t{{o2::framework::spawner(framework::pack<Cs...>{}, {table.asArrowTable()}, "dynamicExtension", projector), table.asArrowTable()}, 0};
833}
834
837template <soa::is_table T, soa::is_dynamic_column... Cs>
838auto Attach(T const& table)
839{
840 using output_t = Join<T, o2::soa::Table<o2::aod::Hash<"JOIN"_h>, o2::aod::Hash<"JOIN/0"_h>, o2::aod::Hash<"JOIN"_h>, Cs...>>;
841 return output_t{{table.asArrowTable()}, table.offset()};
842}
843} // namespace o2::soa
844
845#endif // o2_framework_AnalysisHelpers_H_DEFINED
uint16_t pos
Definition RawData.h:3
uint32_t gfilter
Definition RawData.h:6
constexpr uint32_t runtime_hash(char const *str)
TBranch * ptr
Definition A.h:16
iterator const_iterator
Definition ASoA.h:3622
T::template iterator_template_o< FilteredIndexPolicy, self_t > iterator
Definition ASoA.h:3620
Helper to check if a type T is an iterator.
Definition ASoA.h:1254
GLint GLenum GLint x
Definition glcorearb.h:403
GLuint64EXT * result
Definition glcorearb.h:5662
GLsizeiptr size
Definition glcorearb.h:659
GLuint index
Definition glcorearb.h:781
GLboolean GLboolean GLboolean b
Definition glcorearb.h:1233
GLsizei const GLfloat * value
Definition glcorearb.h:819
GLint GLint GLsizei GLint GLenum GLenum type
Definition glcorearb.h:275
GLuint GLsizei const GLchar * label
Definition glcorearb.h:2519
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition glcorearb.h:1308
GLuint object
Definition glcorearb.h:4041
GLboolean GLboolean GLboolean GLboolean a
Definition glcorearb.h:1233
GLsizei GLenum * sources
Definition glcorearb.h:2516
GLuint counter
Definition glcorearb.h:3987
std::shared_ptr< gandiva::Filter > FilterPtr
Definition Expressions.h:48
std::variant< OriginValueMatcher, DescriptionValueMatcher, SubSpecificationTypeValueMatcher, std::unique_ptr< DataDescriptorMatcher >, ConstantValueMatcher, StartTimeValueMatcher > Node
gandiva::Selection createSelection(std::shared_ptr< arrow::Table > const &table, Filter const &expression)
Function for creating gandiva selection from our internal filter tree.
void updatePlaceholders(Filter &filter, InitContext &context)
Update placeholder nodes from context.
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
auto spawner(std::vector< std::shared_ptr< arrow::Table > > &&tables, const char *name, o2::framework::expressions::Projector *projectors, std::shared_ptr< gandiva::Projector > &projector)
Expression-based column generator to materialize columns.
typename pack_element< I, T >::type pack_element_t
Definition Pack.h:56
constexpr std::size_t pack_size(pack< Ts... > const &)
template function to determine number of types in a pack
Definition Pack.h:28
constexpr auto transformBase()
This helper struct allows you to declare index tables to be created in a task.
memfun_type< decltype(&F::operator())>::type FFL(F const &func)
auto getTableFromFilter(soa::is_filtered_table auto const &table, soa::SelectionVector &&selection)
consteval auto typeWithRef() -> T
Helper to define output for a Table.
OutputObjHandlingPolicy
Policy enum to determine OutputObj handling when writing.
void initializePartitionCaches(std::set< uint32_t > const &hashes, std::shared_ptr< arrow::Schema > const &schema, expressions::Filter const &filter, gandiva::NodePtr &tree, gandiva::FilterPtr &gfilter)
std::shared_ptr< arrow::Table > makeArrowTable(const char *label, std::vector< std::shared_ptr< arrow::ChunkedArray > > &&columns, std::vector< std::shared_ptr< arrow::Field > > &&fields)
SelectionVector selectionToVector(gandiva::Selection const &sel)
Definition ASoA.cxx:43
constexpr auto tableRef2InputSpec()
constexpr auto tableRef2Output()
std::vector< int64_t > SelectionVector
Definition ASoA.h:411
auto Attach(T const &table)
constexpr auto tableRef2ConfigParamSpec()
auto Extend(T const &table)
On-the-fly adding of expression columns.
constexpr auto tableRef2OutputSpec()
constexpr auto tableRef2OutputRef()
@ C
Definition Defs.h:36
Defining DataPointCompositeObject explicitly as copiable.
std::shared_ptr< T > table
constexpr auto pack()
typename T::first_t H
T const & operator*() const
auto build(framework::pack< Cs... >, std::vector< std::shared_ptr< arrow::Table > > &&tables)
metadata::index_pack_t index_pack_t
typename T::rest_t Ts
decltype(transformBase< T >())::metadata metadata
std::array< o2::framework::expressions::Projector, N > projectors
std::shared_ptr< extension_t > extension
typename metadata::extension_table_t extension_t
T::table_t const & operator*() const
typename metadata::placeholders_pack_t placeholders_pack_t
static constexpr size_t N
std::shared_ptr< gandiva::Projector > projector
typename metadata::base_table_t base_table_t
std::shared_ptr< typename T::table_t > table
decltype(transformBase< T >())::metadata metadata
static auto indexBuilder(const char *label, std::vector< std::shared_ptr< arrow::Table > > &&tables, framework::pack< C1, Cs... >)
static OutputSpec const spec()
aod::MetadataTrait< o2::aod::Hash< table_t::ref.desc_hash > >::metadata metadata
decltype(typeWithRef< T >()) table_t
O2 header for OutputObj metadata.
OutputObj(T &&t, OutputObjHandlingPolicy policy_=OutputObjHandlingPolicy::AnalysisObject, OutputObjSourceType sourceType_=OutputObjSourceType::OutputObjSource)
void setObject(std::shared_ptr< T > t)
OutputObjSourceType sourceType
OutputRef ref(uint16_t index, uint16_t max)
std::shared_ptr< T > object
OutputObj(std::string const &label_, OutputObjHandlingPolicy policy_=OutputObjHandlingPolicy::AnalysisObject, OutputObjSourceType sourceType_=OutputObjSourceType::OutputObjSource)
OutputSpec const spec()
OutputObjHandlingPolicy policy
void setHash(uint32_t hash)
Partition(expressions::Node &&filter_, T const &table)
typename o2::soa::Filtered< T >::const_iterator filtered_const_iterator
void bindTable(T const &table)
filtered_const_iterator begin() const
auto rawSliceBy(o2::framework::Preslice< T1 > const &container, int value) const
auto sliceByCached(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
void intializeCaches(std::set< uint32_t > const &hashes, std::shared_ptr< arrow::Schema > const &schema)
Partition(expressions::Node &&filter_)
typename o2::soa::Filtered< T >::iterator filtered_iterator
o2::soa::Filtered< T > * operator->()
typename o2::soa::Filtered< T >::iterator iterator
auto sliceBy(o2::framework::PresliceBase< T1, Policy, OPT > const &container, int value) const
std::shared_ptr< arrow::Table > asArrowTable() const
o2::soa::RowViewSentinel end() const
void updatePlaceholders(InitContext &context)
std::unique_ptr< o2::soa::Filtered< T > > mFiltered
expressions::Filter filter
o2::soa::RowViewSentinel end()
auto sliceByCachedUnsorted(framework::expressions::BindingNode const &node, int value, o2::framework::SliceCache &cache) const
typename o2::soa::Filtered< T >::const_iterator const_iterator
gandiva::FilterPtr gfilter
void bindExternalIndices(Ts *... tables)
filtered_iterator begin()
T::table_t * operator->()
std::shared_ptr< gandiva::Projector > projector
std::shared_ptr< extension_t > extension
T::table_t const & operator*() const
typename metadata::base_table_t base_table_t
typename metadata::expression_pack_t expression_pack_t
constexpr auto pack()
decltype(transformBase< T >())::metadata metadata
std::shared_ptr< typename T::table_t > table
typename metadata::extension_table_t extension_t
Helper template for table transformations.
constexpr auto spec() const
constexpr auto output() const
static constexpr auto base_spec()
constexpr auto ref() const
int64_t lastIndex()
Last index inserted in the table.
decltype(FFL(std::declval< cursor_t >())) cursor
bool resetCursor(LifetimeHolder< TableBuilder > builder)
void setLabel(const char *label)
decltype([]() { if constexpr(soa::is_iterator< T >) { return typename T::parent_t{nullptr} persistent_table_t
decltype(std::declval< TableBuilder >().cursor< persistent_table_t >()) cursor_t
An expression tree node corresponding to a column binding.
A struct, containing the root of the expression tree.
a move-only header stack with serialized headers This is the flat buffer where all the headers in a m...
Definition Stack.h:36
constexpr size_t max
std::unique_ptr< TTree > tree((TTree *) flIn.Get(std::string(o2::base::NameConf::CTFTREENAME).c_str()))