Project
Loading...
Searching...
No Matches
AnalysisTask.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
12#ifndef FRAMEWORK_ANALYSIS_TASK_H_
13#define FRAMEWORK_ANALYSIS_TASK_H_
14
25#include "Framework/Traits.h"
29
30#include <arrow/compute/kernel.h>
31#include <arrow/table.h>
32#include <gandiva/node.h>
33#include <type_traits>
34#include <utility>
35#include <memory>
36#include <tuple> // IWYU pragma: export
37
38namespace o2::framework
39{
48};
49
50template <int64_t BEGIN, int64_t END, int64_t STEP = 1>
52 static constexpr int64_t begin = BEGIN;
53 static constexpr int64_t end = END;
54 static constexpr int64_t step = STEP;
55};
56
57template <typename T>
58static constexpr bool is_enumeration_v = false;
59
60template <int64_t BEGIN, int64_t END, int64_t STEP>
61static constexpr bool is_enumeration_v<Enumeration<BEGIN, END, STEP>> = true;
62
63template <typename T>
64concept is_enumeration = is_enumeration_v<std::decay_t<T>>;
65
66// Helper struct which builds a DataProcessorSpec from
67// the contents of an AnalysisTask...
68namespace
69{
70struct AnalysisDataProcessorBuilder {
71 template <soa::is_iterator G, typename... Args>
72 static void addGroupingCandidates(Cache& bk, Cache& bku, bool enabled)
73 {
74 [&bk, &bku, enabled]<typename... As>(framework::pack<As...>) mutable {
75 auto key = std::string{"fIndex"} + o2::framework::cutString(soa::getLabelFromType<std::decay_t<G>>());
76 ([&bk, &bku, &key, enabled]() mutable {
77 if constexpr (soa::relatedByIndex<std::decay_t<G>, std::decay_t<As>>()) {
78 auto binding = soa::getLabelFromTypeForKey<std::decay_t<As>>(key);
81 } else {
83 }
84 }
85 }(),
86 ...);
87 }(framework::pack<Args...>{});
88 }
89
90 template <soa::TableRef R>
91 static void addOriginalRef(const char* name, bool value, std::vector<InputSpec>& inputs)
92 {
93 auto spec = soa::tableRef2InputSpec<R>();
94 spec.metadata.emplace_back(ConfigParamSpec{std::string{"control:"} + name, VariantType::Bool, value, {"\"\""}});
95 DataSpecUtils::updateInputList(inputs, std::move(spec));
96 }
97
99 template <soa::is_table A>
101 static void addExpression(int, uint32_t, std::vector<ExpressionInfo>&)
102 {
103 }
104
105 template <soa::is_filtered_table A>
106 static void addExpression(int ai, uint32_t hash, std::vector<ExpressionInfo>& eInfos)
107 {
108 auto fields = soa::createFieldsFromColumns(typename std::decay_t<A>::persistent_columns_t{});
109 eInfos.emplace_back(ai, hash, std::decay_t<A>::hashes(), std::make_shared<arrow::Schema>(fields));
110 }
111
112 template <soa::is_iterator A>
113 static void addExpression(int ai, uint32_t hash, std::vector<ExpressionInfo>& eInfos)
114 {
115 addExpression<typename std::decay_t<A>::parent_t>(ai, hash, eInfos);
116 }
117
119 template <soa::is_table A>
120 static void addInput(const char* name, bool value, std::vector<InputSpec>& inputs)
121 {
122 [&name, &value, &inputs]<size_t N, std::array<soa::TableRef, N> refs, size_t... Is>(std::index_sequence<Is...>) mutable {
123 (addOriginalRef<refs[Is]>(name, value, inputs), ...);
124 }.template operator()<A::originals.size(), std::decay_t<A>::originals>(std::make_index_sequence<std::decay_t<A>::originals.size()>());
125 }
126
127 template <soa::is_iterator A>
128 static void addInput(const char* name, bool value, std::vector<InputSpec>& inputs)
129 {
130 addInput<typename std::decay_t<A>::parent_t>(name, value, inputs);
131 }
132
134 template <soa::is_table... As>
135 static void addInputsAndExpressions(uint32_t hash, const char* name, bool value, std::vector<InputSpec>& inputs, std::vector<ExpressionInfo>& eInfos)
136 {
137 int ai = -1;
138 ([&ai, &hash, &eInfos, &name, &value, &inputs]() mutable {
139 ++ai;
140 using T = std::decay_t<As>;
141 addExpression<T>(ai, hash, eInfos);
142 addInput<T>(name, value, inputs);
143 }(),
144 ...);
145 }
146
148 template <typename T>
149 inline static bool requestInputsFromArgs(T&, std::string const&, std::vector<InputSpec>&, std::vector<ExpressionInfo>&)
150 {
151 return false;
152 }
153 template <is_process_configurable T>
154 inline static bool requestInputsFromArgs(T& pc, std::string const& name, std::vector<InputSpec>& inputs, std::vector<ExpressionInfo>& eis)
155 {
156 AnalysisDataProcessorBuilder::inputsFromArgs(pc.process, (name + "/" + pc.name).c_str(), pc.value, inputs, eis);
157 return true;
158 }
159 template <typename T>
160 inline static bool requestCacheFromArgs(T&, Cache&, Cache&)
161 {
162 return false;
163 }
164 template <is_process_configurable T>
165 inline static bool requestCacheFromArgs(T& pc, Cache& bk, Cache& bku)
166 {
167 AnalysisDataProcessorBuilder::cacheFromArgs(pc.process, pc.value, bk, bku);
168 return true;
169 }
171 template <typename R, typename C, is_enumeration A>
172 static void inputsFromArgs(R (C::*)(A), const char* /*name*/, bool /*value*/, std::vector<InputSpec>& inputs, std::vector<ExpressionInfo>&) //, Cache&, Cache&)
173 {
174 std::vector<ConfigParamSpec> inputMetadata;
175 // FIXME: for the moment we do not support begin, end and step.
176 DataSpecUtils::updateInputList(inputs, InputSpec{"enumeration", "DPL", "ENUM", 0, Lifetime::Enumeration, inputMetadata});
177 }
178
180 template <typename R, typename C, soa::is_iterator A, soa::is_table... Args>
181 static void inputsFromArgs(R (C::*)(A, Args...), const char* name, bool value, std::vector<InputSpec>& inputs, std::vector<ExpressionInfo>& eInfos) //, Cache& bk, Cache& bku)
182 requires(std::is_lvalue_reference_v<A> && (std::is_lvalue_reference_v<Args> && ...))
183 {
184 constexpr auto hash = o2::framework::TypeIdHelpers::uniqueId<R (C::*)(A, Args...)>();
185 addInputsAndExpressions<typename std::decay_t<A>::parent_t, Args...>(hash, name, value, inputs, eInfos);
186 }
187
189 template <typename R, typename C, soa::is_table... Args>
190 static void inputsFromArgs(R (C::*)(Args...), const char* name, bool value, std::vector<InputSpec>& inputs, std::vector<ExpressionInfo>& eInfos) //, Cache&, Cache&)
191 requires(std::is_lvalue_reference_v<Args> && ...)
192 {
193 constexpr auto hash = o2::framework::TypeIdHelpers::uniqueId<R (C::*)(Args...)>();
194 addInputsAndExpressions<Args...>(hash, name, value, inputs, eInfos);
195 }
196
198 template <typename R, typename C, is_enumeration A>
199 static void cacheFromArgs(R (C::*)(A), bool, Cache&, Cache&)
200 {
201 }
203 template <typename R, typename C, soa::is_iterator A, soa::is_table... Args>
204 static void cacheFromArgs(R (C::*)(A, Args...), bool value, Cache& bk, Cache& bku)
205 {
206 addGroupingCandidates<A, Args...>(bk, bku, value);
207 }
209 template <typename R, typename C, soa::is_table A, soa::is_table... Args>
210 static void cacheFromArgs(R (C::*)(A, Args...), bool, Cache&, Cache&)
211 {
212 }
213
214 template <soa::TableRef R>
215 static auto extractTableFromRecord(InputRecord& record)
216 {
217 auto table = record.get<TableConsumer>(o2::aod::label<R>())->asArrowTable();
218 if (table->num_rows() == 0) {
219 table = makeEmptyTable<R>();
220 }
221 return table;
222 }
223
224 template <soa::is_table T>
225 static auto extractFromRecord(InputRecord& record)
226 {
227 return T { [&record]<size_t N, std::array<soa::TableRef, N> refs, size_t... Is>(std::index_sequence<Is...>) { return std::vector{extractTableFromRecord<refs[Is]>(record)...}; }.template operator()<T::originals.size(), T::originals>(std::make_index_sequence<T::originals.size()>()) };
228 }
229
230 template <soa::is_iterator T>
231 static auto extractFromRecord(InputRecord& record)
232 {
233 return typename T::parent_t { [&record]<size_t N, std::array<soa::TableRef, N> refs, size_t... Is>(std::index_sequence<Is...>) { return std::vector{extractTableFromRecord<refs[Is]>(record)...}; }.template operator()<T::parent_t::originals.size(), T::parent_t::originals>(std::make_index_sequence<T::parent_t::originals.size()>()) };
234 }
235
236 template <soa::is_filtered T>
237 static auto extractFilteredFromRecord(InputRecord& record, ExpressionInfo& info)
238 {
239 std::shared_ptr<arrow::Table> table = nullptr;
240 auto joiner = [&record]<size_t N, std::array<soa::TableRef, N> refs, size_t... Is>(std::index_sequence<Is...>) { return std::vector{extractTableFromRecord<refs[Is]>(record)...}; };
241 if constexpr (soa::is_iterator<T>) {
242 table = o2::soa::ArrowHelpers::joinTables(joiner.template operator()<T::parent_t::originals.size(), T::parent_t::originals>(std::make_index_sequence<T::parent_t::originals.size()>()), std::span{T::parent_t::originalLabels});
243 } else {
244 table = o2::soa::ArrowHelpers::joinTables(joiner.template operator()<T::originals.size(), T::originals>(std::make_index_sequence<T::originals.size()>()), std::span{T::originalLabels});
245 }
248 if (info.selection == nullptr) {
250 }
251 }
252 if constexpr (soa::is_iterator<T>) {
253 return typename T::parent_t({table}, info.selection);
254 } else {
255 return T({table}, info.selection);
256 }
257 }
258
259 template <is_enumeration T, int AI>
260 static auto extract(InputRecord&, std::vector<ExpressionInfo>&, size_t)
261 {
262 return T{};
263 }
264
265 template <soa::is_iterator T, int AI>
266 static auto extract(InputRecord& record, std::vector<ExpressionInfo>& infos, size_t phash)
267 {
268 if constexpr (std::same_as<typename T::policy_t, soa::FilteredIndexPolicy>) {
269 return extractFilteredFromRecord<T>(record, *std::find_if(infos.begin(), infos.end(), [&phash](ExpressionInfo const& i) { return (i.processHash == phash && i.argumentIndex == AI); }));
270 } else {
271 return extractFromRecord<T>(record);
272 }
273 }
274
275 template <soa::is_table T, int AI>
276 static auto extract(InputRecord& record, std::vector<ExpressionInfo>& infos, size_t phash)
277 {
278 if constexpr (soa::is_filtered_table<T>) {
279 return extractFilteredFromRecord<T>(record, *std::find_if(infos.begin(), infos.end(), [&phash](ExpressionInfo const& i) { return (i.processHash == phash && i.argumentIndex == AI); }));
280 } else {
281 return extractFromRecord<T>(record);
282 }
283 }
284
285 template <typename R, typename C, typename Grouping, typename... Args>
286 static auto bindGroupingTable(InputRecord& record, R (C::*)(Grouping, Args...), std::vector<ExpressionInfo>& infos)
287 requires(!std::same_as<Grouping, void>)
288 {
289 constexpr auto hash = o2::framework::TypeIdHelpers::uniqueId<R (C::*)(Grouping, Args...)>();
290 return extract<std::decay_t<Grouping>, 0>(record, infos, hash);
291 }
292
293 template <typename R, typename C, typename Grouping, typename... Args>
294 static auto bindAssociatedTables(InputRecord& record, R (C::*)(Grouping, Args...), std::vector<ExpressionInfo>& infos)
295 requires(!std::same_as<Grouping, void> && sizeof...(Args) > 0)
296 {
297 constexpr auto p = pack<Args...>{};
298 constexpr auto hash = o2::framework::TypeIdHelpers::uniqueId<R (C::*)(Grouping, Args...)>();
299 return std::make_tuple(extract<std::decay_t<Args>, has_type_at_v<Args>(p) + 1>(record, infos, hash)...);
300 }
301
302 template <typename... As>
303 static void overwriteInternalIndices(std::tuple<As...>& dest, std::tuple<As...> const& src)
304 {
305 (std::get<As>(dest).bindInternalIndicesTo(&std::get<As>(src)), ...);
306 }
307
308 template <typename Task, typename R, typename C, typename Grouping, typename... Associated>
309 static void invokeProcess(Task& task, InputRecord& inputs, R (C::*processingFunction)(Grouping, Associated...), std::vector<ExpressionInfo>& infos, ArrowTableSlicingCache& slices)
310 {
311 using G = std::decay_t<Grouping>;
312 auto groupingTable = AnalysisDataProcessorBuilder::bindGroupingTable(inputs, processingFunction, infos);
313
314 // set filtered tables for partitions with grouping
315 homogeneous_apply_refs([&groupingTable](auto& element) {
316 analysis_task_parsers::setPartition(element, groupingTable);
318 return true;
319 },
320 task);
321
322 if constexpr (sizeof...(Associated) == 0) {
323 // single argument to process
324 homogeneous_apply_refs([&groupingTable](auto& element) {
326 analysis_task_parsers::setGroupedCombination(element, groupingTable);
327 return true;
328 },
329 task);
330 if constexpr (soa::is_iterator<G>) {
331 for (auto& element : groupingTable) {
332 std::invoke(processingFunction, task, *element);
333 }
334 } else {
335 static_assert(soa::is_table<G> || is_enumeration<G>,
336 "Single argument of process() should be a table-like or an iterator");
337 std::invoke(processingFunction, task, groupingTable);
338 }
339 } else {
340 // multiple arguments to process
341 static_assert(((soa::is_iterator<std::decay_t<Associated>> == false) && ...),
342 "Associated arguments of process() should not be iterators");
343 auto associatedTables = AnalysisDataProcessorBuilder::bindAssociatedTables(inputs, processingFunction, infos);
344 // pre-bind self indices
345 std::apply(
346 [&task](auto&... t) mutable {
348 [&t](auto& p) {
350 return true;
351 },
352 task),
353 ...);
354 },
355 associatedTables);
356
357 auto binder = [&task, &groupingTable, &associatedTables](auto& x) mutable {
358 x.bindExternalIndices(&groupingTable, &std::get<std::decay_t<Associated>>(associatedTables)...);
359 homogeneous_apply_refs([&x](auto& t) mutable {
362 return true;
363 },
364 task);
365 };
366 groupingTable.bindExternalIndices(&std::get<std::decay_t<Associated>>(associatedTables)...);
367
368 // always pre-bind full tables to support index hierarchy
369 std::apply(
370 [&binder](auto&... x) mutable {
371 (binder(x), ...);
372 },
373 associatedTables);
374
375 // GroupedCombinations bound separately, as they should be set once for all associated tables
376 homogeneous_apply_refs([&groupingTable, &associatedTables](auto& t) {
377 analysis_task_parsers::setGroupedCombination(t, groupingTable, associatedTables);
378 return true;
379 },
380 task);
381 overwriteInternalIndices(associatedTables, associatedTables);
382 if constexpr (soa::is_iterator<std::decay_t<G>>) {
383 auto slicer = GroupSlicer(groupingTable, associatedTables, slices);
384 for (auto& slice : slicer) {
385 auto associatedSlices = slice.associatedTables();
386 overwriteInternalIndices(associatedSlices, associatedTables);
387 std::apply(
388 [&binder](auto&... x) mutable {
389 (binder(x), ...);
390 },
391 associatedSlices);
392
393 // bind partitions and grouping table
394 homogeneous_apply_refs([&groupingTable](auto& x) {
396 return true;
397 },
398 task);
399
400 invokeProcessWithArgs(task, processingFunction, slice.groupingElement(), associatedSlices);
401 }
402 } else {
403 // bind partitions and grouping table
404 homogeneous_apply_refs([&groupingTable](auto& x) {
406 return true;
407 },
408 task);
409
410 invokeProcessWithArgs(task, processingFunction, groupingTable, associatedTables);
411 }
412 }
413 }
414
415 template <typename C, typename T, typename G, typename... A>
416 static void invokeProcessWithArgs(C& task, T processingFunction, G g, std::tuple<A...>& at)
417 {
418 std::invoke(processingFunction, task, g, std::get<A>(at)...);
419 }
420};
421} // namespace
422
424 std::vector<std::pair<std::string, bool>> map;
425};
426
428struct TaskName {
429 TaskName(std::string name) : value{std::move(name)} {}
430 std::string value;
431};
432
433namespace
434{
435template <typename T, typename... A>
436auto getTaskNameSetProcesses(std::string& outputName, TaskName first, SetDefaultProcesses second, A... args)
437{
438 auto task = std::make_shared<T>(std::forward<A>(args)...);
439 for (auto& setting : second.map) {
441 [&](auto& element) {
442 return analysis_task_parsers::setProcessSwitch(setting, element);
443 },
444 *task.get());
445 }
446 outputName = first.value;
447 return task;
448}
449
450template <typename T, typename... A>
451auto getTaskNameSetProcesses(std::string& outputName, SetDefaultProcesses first, TaskName second, A... args)
452{
453 auto task = std::make_shared<T>(std::forward<A>(args)...);
454 for (auto& setting : first.map) {
456 [&](auto& element) {
457 return analysis_task_parsers::setProcessSwitch(setting, element);
458 },
459 *task.get());
460 }
461 outputName = second.value;
462 return task;
463}
464
465template <typename T, typename... A>
466auto getTaskNameSetProcesses(std::string& outputName, SetDefaultProcesses first, A... args)
467{
468 auto task = std::make_shared<T>(std::forward<A>(args)...);
469 for (auto& setting : first.map) {
471 [&](auto& element) {
472 return analysis_task_parsers::setProcessSwitch(setting, element);
473 },
474 *task.get());
475 }
476 auto type_name_str = type_name<T>();
477 outputName = type_to_task_name(type_name_str);
478 return task;
479}
480
481template <typename T, typename... A>
482auto getTaskNameSetProcesses(std::string& outputName, TaskName first, A... args)
483{
484 auto task = std::make_shared<T>(std::forward<A>(args)...);
485 outputName = first.value;
486 return task;
487}
488
489template <typename T, typename... A>
490auto getTaskNameSetProcesses(std::string& outputName, A... args)
491{
492 auto task = std::make_shared<T>(std::forward<A>(args)...);
493 auto type_name_str = type_name<T>();
494 outputName = type_to_task_name(type_name_str);
495 return task;
496}
497
498} // namespace
499
502template <typename T, typename... Args>
504{
505 TH1::AddDirectory(false);
506
507 std::string name_str;
508 auto task = getTaskNameSetProcesses<T>(name_str, args...);
509
510 auto suffix = ctx.options().get<std::string>("workflow-suffix");
511 if (!suffix.empty()) {
512 name_str += suffix;
513 }
514 const char* name = name_str.c_str();
515
516 auto hash = runtime_hash(name);
517
518 std::vector<OutputSpec> outputs;
519 std::vector<InputSpec> inputs;
520 std::vector<ConfigParamSpec> options;
521 std::vector<ExpressionInfo> expressionInfos;
522
524 homogeneous_apply_refs([&options, &hash](auto& element) { return analysis_task_parsers::appendOption(options, element); }, *task.get());
526 homogeneous_apply_refs([&inputs](auto& element) { return analysis_task_parsers::appendCondition(inputs, element); }, *task.get());
527
529 if constexpr (requires { &T::process; }) {
530 AnalysisDataProcessorBuilder::inputsFromArgs(&T::process, "default", true, inputs, expressionInfos);
531 }
533 [name = name_str, &expressionInfos, &inputs](auto& x) mutable {
534 // this pushes (argumentIndex, processHash, schemaPtr, nullptr) into expressionInfos for arguments that are Filtered/filtered_iterators
535 return AnalysisDataProcessorBuilder::requestInputsFromArgs(x, name, inputs, expressionInfos);
536 },
537 *task.get());
538
539 // request base tables for spawnable extended tables and indices to be built
540 // this checks for duplications
541 homogeneous_apply_refs([&inputs](auto& element) {
542 return analysis_task_parsers::requestInputs(inputs, element);
543 },
544 *task.get());
545
546 // no static way to check if the task defines any processing, we can only make sure it subscribes to at least something
547 if (inputs.empty() == true) {
548 LOG(warn) << "Task " << name_str << " has no inputs";
549 }
550
551 homogeneous_apply_refs([&outputs, &hash](auto& element) { return analysis_task_parsers::appendOutput(outputs, element, hash); }, *task.get());
552
553 auto requiredServices = CommonServices::defaultServices();
554 auto arrowServices = CommonServices::arrowServices();
555 requiredServices.insert(requiredServices.end(), arrowServices.begin(), arrowServices.end());
556 homogeneous_apply_refs([&requiredServices](auto& element) { return analysis_task_parsers::addService(requiredServices, element); }, *task.get());
557
558 auto algo = AlgorithmSpec::InitCallback{[task = task, expressionInfos](InitContext& ic) mutable {
559 Cache bindingsKeys;
560 Cache bindingsKeysUnsorted;
561 // add preslice declarations to slicing cache definition
562 homogeneous_apply_refs([&bindingsKeys, &bindingsKeysUnsorted](auto& element) { return analysis_task_parsers::registerCache(element, bindingsKeys, bindingsKeysUnsorted); }, *task.get());
563
564 homogeneous_apply_refs([&ic](auto&& element) { return analysis_task_parsers::prepareOption(ic, element); }, *task.get());
565 homogeneous_apply_refs([&ic](auto&& element) { return analysis_task_parsers::prepareService(ic, element); }, *task.get());
566
567 auto& callbacks = ic.services().get<CallbackService>();
568 auto eoscb = [task](EndOfStreamContext& eosContext) {
569 homogeneous_apply_refs([&eosContext](auto& element) {
570 analysis_task_parsers::postRunService(eosContext, element);
571 analysis_task_parsers::postRunOutput(eosContext, element);
572 return true; },
573 *task.get());
574 eosContext.services().get<ControlService>().readyToQuit(QuitRequest::Me);
575 };
576
577 callbacks.set<CallbackService::Id::EndOfStream>(eoscb);
578
580 if constexpr (requires { task->init(ic); }) {
581 task->init(ic);
582 }
583
586 [&ic](auto& element) -> bool { return analysis_task_parsers::updatePlaceholders(ic, element); },
587 *task.get());
589 homogeneous_apply_refs([&expressionInfos](auto& element) {
590 return analysis_task_parsers::createExpressionTrees(expressionInfos, element);
591 },
592 *task.get());
593
595 if constexpr (requires { &T::process; }) {
596 AnalysisDataProcessorBuilder::cacheFromArgs(&T::process, true, bindingsKeys, bindingsKeysUnsorted);
597 }
599 [&bindingsKeys, &bindingsKeysUnsorted](auto& x) mutable {
600 return AnalysisDataProcessorBuilder::requestCacheFromArgs(x, bindingsKeys, bindingsKeysUnsorted);
601 },
602 *task.get());
603
604 ic.services().get<ArrowTableSlicingCacheDef>().setCaches(std::move(bindingsKeys));
605 ic.services().get<ArrowTableSlicingCacheDef>().setCachesUnsorted(std::move(bindingsKeysUnsorted));
606 // initialize global caches
607 homogeneous_apply_refs([&ic](auto& element) {
609 },
610 *(task.get()));
611
612 return [task, expressionInfos](ProcessingContext& pc) mutable {
613 // load the ccdb object from their cache
614 homogeneous_apply_refs([&pc](auto& element) { return analysis_task_parsers::newDataframeCondition(pc.inputs(), element); }, *task.get());
615 // reset partitions once per dataframe
616 homogeneous_apply_refs([](auto& element) { return analysis_task_parsers::newDataframePartition(element); }, *task.get());
617 // reset selections for the next dataframe
618 for (auto& info : expressionInfos) {
619 info.resetSelection = true;
620 }
621 // reset pre-slice for the next dataframe
622 auto slices = pc.services().get<ArrowTableSlicingCache>();
623 homogeneous_apply_refs([&pc, &slices](auto& element) {
624 return analysis_task_parsers::updateSliceInfo(element, slices);
625 },
626 *(task.get()));
627 // initialize local caches
628 homogeneous_apply_refs([&pc](auto& element) { return analysis_task_parsers::initializeCache(pc, element); }, *(task.get()));
629 // prepare outputs
630 homogeneous_apply_refs([&pc](auto& element) { return analysis_task_parsers::prepareOutput(pc, element); }, *task.get());
631 // execute run()
632 if constexpr (requires { task->run(pc); }) {
633 task->run(pc);
634 }
635 // execute process()
636 if constexpr (requires { AnalysisDataProcessorBuilder::invokeProcess(*(task.get()), pc.inputs(), &T::process, expressionInfos, slices); }) {
637 AnalysisDataProcessorBuilder::invokeProcess(*(task.get()), pc.inputs(), &T::process, expressionInfos, slices);
638 }
639 // execute optional process()
641 [&pc, &expressionInfos, &task, &slices](auto& x) mutable {
642 if constexpr (base_of_template<ProcessConfigurable, std::decay_t<decltype(x)>>) {
643 if (x.value == true) {
644 AnalysisDataProcessorBuilder::invokeProcess(*task.get(), pc.inputs(), x.process, expressionInfos, slices);
645 return true;
646 }
647 }
648 return false;
649 },
650 *task.get());
651 // prepare delayed outputs
652 homogeneous_apply_refs([&pc](auto& element) { return analysis_task_parsers::prepareDelayedOutput(pc, element); }, *task.get());
653 // finalize outputs
654 homogeneous_apply_refs([&pc](auto& element) { return analysis_task_parsers::finalizeOutput(pc, element); }, *task.get());
655 };
656 }};
657
658 return {
659 name,
660 // FIXME: For the moment we hardcode this. We could build
661 // this list from the list of methods actually implemented in the
662 // task itself.
663 inputs,
664 outputs,
665 algo,
666 options,
667 requiredServices};
668}
669
670} // namespace o2::framework
671#endif // FRAMEWORK_ANALYSISTASK_H_
int32_t i
constexpr uint32_t runtime_hash(char const *str)
StringRef key
Definition A.h:16
ConfigParamRegistry & options() const
Helper to check if a type T is an iterator.
Definition ASoA.h:1278
GLint GLenum GLint x
Definition glcorearb.h:403
GLenum src
Definition glcorearb.h:1767
GLuint GLuint end
Definition glcorearb.h:469
GLuint const GLchar * name
Definition glcorearb.h:781
GLenum GLenum GLsizei const GLuint GLboolean enabled
Definition glcorearb.h:2513
GLsizei const GLfloat * value
Definition glcorearb.h:819
GLboolean GLboolean g
Definition glcorearb.h:1233
bool prepareService(InitContext &, T &)
bool requestInputs(std::vector< InputSpec > &, T const &)
Table auto-creation handling.
void setGroupedCombination(C &, TG &, Ts &...)
Combinations handling.
bool initializeCache(ProcessingContext &, T &)
bool preInitializeCache(InitContext &, T &)
Cache handling.
bool prepareDelayedOutput(ProcessingContext &, T &)
bool prepareOption(InitContext &, O &)
bool appendOutput(std::vector< OutputSpec > &, T &, uint32_t)
Outputs handling.
bool finalizeOutput(ProcessingContext &, T &)
bool registerCache(T &, Cache &, Cache &)
Preslice handling.
bool postRunOutput(EndOfStreamContext &, T &)
bool createExpressionTrees(std::vector< ExpressionInfo > &, T &)
bool prepareOutput(ProcessingContext &, T &)
bool appendOption(std::vector< ConfigParamSpec > &, O &)
Options handling.
bool updateSliceInfo(T &, ArrowTableSlicingCache &)
bool appendCondition(std::vector< InputSpec > &, C &)
Conditions handling.
bool postRunService(EndOfStreamContext &, T &)
bool addService(std::vector< ServiceSpec > &, T &)
Service handling.
bool updatePlaceholders(InitContext &, T &)
Filter handling.
bool newDataframeCondition(InputRecord &, C &)
void updateFilterInfo(ExpressionInfo &info, std::shared_ptr< arrow::Table > &table)
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
auto homogeneous_apply_refs(L l, T &&object)
DataProcessorSpec adaptAnalysisTask(ConfigContext const &ctx, Args &&... args)
std::vector< Entry > Cache
void updatePairList(Cache &list, std::string const &binding, std::string const &key, bool enabled)
@ Me
Only quit this data processor.
std::string cutString(std::string &&str)
Definition ASoA.cxx:238
auto createFieldsFromColumns(framework::pack< C... >)
Definition ASoA.h:410
void missingFilterDeclaration(int hash, int ai)
Definition ASoA.cxx:33
Defining DataPointCompositeObject explicitly as copiable.
gandiva::Selection selection
Definition Expressions.h:65
size_t processHash
Definition Expressions.h:60
std::function< ProcessCallback(InitContext &)> InitCallback
static std::vector< ServiceSpec > defaultServices(std::string extraPlugins="", int numWorkers=0)
Split a string into a vector of strings using : as a separator.
static std::vector< ServiceSpec > arrowServices()
static void updateInputList(std::vector< InputSpec > &list, InputSpec &&input)
Updates list of InputSpecs by merging metadata.
static constexpr int64_t step
static constexpr int64_t begin
std::vector< std::pair< std::string, bool > > map
Struct to differentiate task names from possible task string arguments.
TaskName(std::string name)
static constexpr uint32_t uniqueId()
static std::shared_ptr< arrow::Table > joinTables(std::vector< std::shared_ptr< arrow::Table > > &&tables, std::span< const char *const > labels)
Definition ASoA.cxx:72
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"