Project
Loading...
Searching...
No Matches
Expressions.cxx
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
15#include "arrow/table.h"
16#include "gandiva/tree_expr_builder.h"
17#include <algorithm>
18#include <iostream>
19#include <set>
20#include <stack>
21#include <unordered_map>
22
23using namespace o2::framework;
24
26{
27
30static const std::array<std::string, BasicOp::Conditional + 1> basicOperationsMap = {
31 "and",
32 "or",
33 "add",
34 "subtract",
35 "divide",
36 "multiply",
37 "bitwise_and",
38 "bitwise_or",
39 "bitwise_xor",
40 "less_than",
41 "less_than_or_equal_to",
42 "greater_than",
43 "greater_than_or_equal_to",
44 "equal",
45 "not_equal",
46 "atan2f",
47 "powerf",
48 "sqrtf",
49 "expf",
50 "logf",
51 "log10f",
52 "sinf",
53 "cosf",
54 "tanf",
55 "asinf",
56 "acosf",
57 "atanf",
58 "absf",
59 "round",
60 "bitwise_not",
61 "if"};
62
64{
65 std::stack<NodeRecord> path;
66 auto local_index = index;
67 path.emplace(node, 0);
68
69 while (!path.empty()) {
70 auto top = path.top();
71 top.node_ptr->index = local_index;
72 path.pop();
73 if (top.node_ptr->condition != nullptr) {
74 // start new subtrees
75 index = designateSubtrees(top.node_ptr->left.get(), local_index + 1);
76 index = designateSubtrees(top.node_ptr->condition.get(), index + 1);
77 index = designateSubtrees(top.node_ptr->right.get(), index + 1);
78 } else {
79 // continue current subtree
80 if (top.node_ptr->left != nullptr) {
81 path.emplace(top.node_ptr->left.get(), 0);
82 }
83 if (top.node_ptr->right != nullptr) {
84 path.emplace(top.node_ptr->right.get(), 0);
85 }
86 }
87 }
88
89 return index;
90}
91
92namespace
93{
94struct LiteralNodeHelper {
95 DatumSpec operator()(LiteralNode const& node) const
96 {
97 return DatumSpec{node.value, node.type};
98 }
99};
100
101struct BindingNodeHelper {
102 DatumSpec operator()(BindingNode const& node) const
103 {
104 return DatumSpec{node.name, node.hash, node.type};
105 }
106};
107
108struct OpNodeHelper {
109 ColumnOperationSpec operator()(OpNode const& node) const
110 {
111 return ColumnOperationSpec{node.op};
112 }
113};
114
115struct PlaceholderNodeHelper {
116 DatumSpec operator()(PlaceholderNode const& node) const
117 {
118 return DatumSpec{node.value, node.type};
119 }
120};
121} // namespace
122
123std::shared_ptr<arrow::DataType> concreteArrowType(atype::type type)
124{
125 switch (type) {
126 case atype::UINT8:
127 return arrow::uint8();
128 case atype::INT8:
129 return arrow::int8();
130 case atype::INT16:
131 return arrow::int16();
132 case atype::UINT16:
133 return arrow::uint16();
134 case atype::INT32:
135 return arrow::int32();
136 case atype::UINT32:
137 return arrow::uint32();
138 case atype::INT64:
139 return arrow::int64();
140 case atype::UINT64:
141 return arrow::uint64();
142 case atype::FLOAT:
143 return arrow::float32();
144 case atype::DOUBLE:
145 return arrow::float64();
146 case atype::BOOL:
147 return arrow::boolean();
148 default:
149 return nullptr;
150 }
151}
152
153std::string upcastTo(atype::type f)
154{
155 switch (f) {
156 case atype::INT32:
157 return "castINT";
158 case atype::INT64:
159 return "castBIGINT";
160 case atype::FLOAT:
161 return "castFLOAT4";
162 case atype::DOUBLE:
163 return "castFLOAT8";
164 default:
165 throw runtime_error_f("Do not know how to cast to %d", f);
166 }
167}
168
169bool operator==(DatumSpec const& lhs, DatumSpec const& rhs)
170{
171 return (lhs.datum == rhs.datum) && (lhs.type == rhs.type);
172}
173
174std::ostream& operator<<(std::ostream& os, DatumSpec const& spec)
175{
176 std::visit(
178 [&os](LiteralNode::var_t&& arg) {
179 std::visit(
180 [&os](auto&& arg) { os << arg; },
181 arg);
182 },
183 [&os](size_t&& arg) { os << arg; },
184 [&os](std::string&& arg) { os << arg; },
185 [](auto&&) {}},
186 spec.datum);
187 return os;
188}
189
191{
192 std::stack<NodeRecord> path;
193
194 // insert the top node into stack
195 path.emplace(filter.node.get(), 0);
196
197 auto updateNode = [&](Node* node) {
198 if (node->self.index() == 3) {
199 std::get_if<3>(&node->self)->reset(context);
200 }
201 };
202
203 // while the stack is not empty
204 while (!path.empty()) {
205 auto& top = path.top();
206 updateNode(top.node_ptr);
207
208 auto* leftp = top.node_ptr->left.get();
209 auto* rightp = top.node_ptr->right.get();
210 auto* condp = top.node_ptr->condition.get();
211 path.pop();
212
213 if (leftp != nullptr) {
214 path.emplace(leftp, 0);
215 }
216 if (rightp != nullptr) {
217 path.emplace(rightp, 0);
218 }
219 if (condp != nullptr) {
220 path.emplace(condp, 0);
221 }
222 }
223}
224
225const char* stringType(atype::type t)
226{
227 switch (t) {
228 case atype::BOOL:
229 return "bool";
230 case atype::DOUBLE:
231 return "double";
232 case atype::FLOAT:
233 return "float";
234 case atype::INT8:
235 return "int8";
236 case atype::INT16:
237 return "int16";
238 case atype::INT32:
239 return "int32";
240 case atype::INT64:
241 return "int64";
242 case atype::UINT8:
243 return "uint8";
244 case atype::UINT16:
245 return "uint16";
246 case atype::UINT32:
247 return "uint32";
248 case atype::UINT64:
249 return "uint64";
250 default:
251 return "unsupported";
252 }
254}
255
257{
258 Operations OperationSpecs;
259 std::stack<NodeRecord> path;
260 auto isLeaf = [](Node const* const node) {
261 return ((node->left == nullptr) && (node->right == nullptr));
262 };
263
264 auto processLeaf = [](Node const* const node) {
265 return std::visit(
267 [lh = LiteralNodeHelper{}](LiteralNode const& node) { return lh(node); },
268 [bh = BindingNodeHelper{}](BindingNode const& node) { return bh(node); },
269 [ph = PlaceholderNodeHelper{}](PlaceholderNode const& node) { return ph(node); },
270 [](auto&&) { return DatumSpec{}; }},
271 node->self);
272 };
273
274 size_t index = 0;
275 // insert the top node into stack
276 path.emplace(expression.node.get(), index++);
277
278 // while the stack is not empty
279 while (!path.empty()) {
280 auto top = path.top();
281
282 // create operation spec, pop the node and add its children
283 auto operationSpec =
284 std::visit(
286 [&](OpNode node) { return ColumnOperationSpec{node.op, top.node_ptr->index}; },
288 [](auto&&) { return ColumnOperationSpec{}; }},
289 top.node_ptr->self);
290
291 operationSpec.result = DatumSpec{top.index, operationSpec.type};
292 path.pop();
293
294 auto* left = top.node_ptr->left.get();
295 bool leftLeaf = isLeaf(left);
296 size_t li = 0;
297 if (leftLeaf) {
298 operationSpec.left = processLeaf(left);
299 } else {
300 li = index;
301 operationSpec.left = DatumSpec{index++, atype::NA};
302 }
303
304 decltype(left) right = nullptr;
305 if (top.node_ptr->right != nullptr) {
306 right = top.node_ptr->right.get();
307 }
308 bool rightLeaf = true;
309 if (right != nullptr) {
310 rightLeaf = isLeaf(right);
311 }
312 size_t ri = 0;
313 auto isUnary = false;
314 if (top.node_ptr->right == nullptr) {
315 operationSpec.right = DatumSpec{};
316 isUnary = true;
317 } else {
318 if (rightLeaf) {
319 operationSpec.right = processLeaf(right);
320 } else {
321 ri = index;
322 operationSpec.right = DatumSpec{index++, atype::NA};
323 }
324 }
325
326 decltype(left) condition = nullptr;
327 if (top.node_ptr->condition != nullptr) {
328 condition = top.node_ptr->condition.get();
329 }
330 bool condleaf = condition != nullptr ? isLeaf(condition) : true;
331 size_t ci = 0;
332 if (condition != nullptr) {
333 if (condleaf) {
334 operationSpec.condition = processLeaf(condition);
335 } else {
336 ci = index;
337 operationSpec.condition = DatumSpec{index++, atype::BOOL};
338 }
339 } else {
340 operationSpec.condition = DatumSpec{};
341 }
342
343 OperationSpecs.push_back(std::move(operationSpec));
344 if (!leftLeaf) {
345 path.emplace(left, li);
346 }
347 if (!isUnary && !rightLeaf) {
348 path.emplace(right, ri);
349 }
350 if (!condleaf) {
351 path.emplace(condition, ci);
352 }
353 }
354 // at this stage the operations vector is created, but the field types are
355 // only set for the logical operations and leaf nodes
356 std::vector<atype::type> resultTypes;
357 resultTypes.resize(OperationSpecs.size());
358
359 auto inferResultType = [&resultTypes](DatumSpec& left, DatumSpec& right) {
360 // if the left datum is monostate (error)
361 if (left.datum.index() == 0) {
362 throw runtime_error("Malformed operation spec: empty left datum");
363 }
364
365 // check if the datums are references
366 if (left.datum.index() == 1) {
367 left.type = resultTypes[std::get<size_t>(left.datum)];
368 }
369
370 if (right.datum.index() == 1) {
371 right.type = resultTypes[std::get<size_t>(right.datum)];
372 }
373
374 auto t1 = left.type;
375 auto t2 = right.type;
376 // if the right datum is monostate (unary op)
377 if (right.datum.index() == 0) {
378 if (t1 == atype::DOUBLE) {
379 return atype::DOUBLE;
380 }
381 return atype::FLOAT;
382 }
383
384 if (t1 == t2) {
385 return t1;
386 }
387
388 auto isIntType = [](auto t) {
389 return (t == atype::UINT8) || (t == atype::INT8) || (t == atype::UINT16) || (t == atype::INT16) || (t == atype::UINT32) || (t == atype::INT32) || (t == atype::UINT64) || (t == atype::INT64);
390 };
391
392 if (isIntType(t1)) {
393 if (t2 == atype::FLOAT) {
394 return atype::FLOAT;
395 }
396 if (t2 == atype::DOUBLE) {
397 return atype::DOUBLE;
398 }
399 if (isIntType(t2)) {
400 if (t1 > t2) {
401 return t1;
402 }
403 return t2;
404 }
405 }
406 if (t1 == atype::FLOAT) {
407 if (isIntType(t2)) {
408 return atype::FLOAT;
409 }
410 if (t2 == atype::DOUBLE) {
411 return atype::DOUBLE;
412 }
413 }
414 if (t1 == atype::DOUBLE) {
415 return atype::DOUBLE;
416 }
417 throw runtime_error_f("Invalid combination of argument types %s and %s", stringType(t1), stringType(t2));
418 };
419
420 for (auto it = OperationSpecs.rbegin(); it != OperationSpecs.rend(); ++it) {
421 auto type = inferResultType(it->left, it->right);
422 if (it->type == atype::NA) {
423 it->type = type;
424 }
425
426 it->result.type = it->type;
427 resultTypes[std::get<size_t>(it->result.datum)] = it->type;
428 }
429
430 return OperationSpecs;
431}
432
433gandiva::ConditionPtr makeCondition(gandiva::NodePtr node)
434{
435 return gandiva::TreeExprBuilder::MakeCondition(std::move(node));
436}
437
438gandiva::ExpressionPtr makeExpression(gandiva::NodePtr node, gandiva::FieldPtr result)
439{
440 return gandiva::TreeExprBuilder::MakeExpression(std::move(node), std::move(result));
441}
442
443std::shared_ptr<gandiva::Filter>
444 createFilter(gandiva::SchemaPtr const& Schema, Operations const& opSpecs)
445{
446 std::shared_ptr<gandiva::Filter> filter;
447 auto s = gandiva::Filter::Make(Schema,
448 makeCondition(createExpressionTree(opSpecs, Schema)),
449 &filter);
450 if (!s.ok()) {
451 throw runtime_error_f("Failed to create filter: %s", s.ToString().c_str());
452 }
453 return filter;
454}
455
456std::shared_ptr<gandiva::Filter>
457 createFilter(gandiva::SchemaPtr const& Schema, gandiva::ConditionPtr condition)
458{
459 std::shared_ptr<gandiva::Filter> filter;
460 auto s = gandiva::Filter::Make(Schema,
461 condition,
462 &filter);
463 if (!s.ok()) {
464 throw runtime_error_f("Failed to create filter: %s", s.ToString().c_str());
465 }
466 return filter;
467}
468
469std::shared_ptr<gandiva::Projector>
470 createProjector(gandiva::SchemaPtr const& Schema, Operations const& opSpecs, gandiva::FieldPtr result)
471{
472 std::shared_ptr<gandiva::Projector> projector;
473 auto s = gandiva::Projector::Make(Schema,
474 {makeExpression(createExpressionTree(opSpecs, Schema), std::move(result))},
475 &projector);
476 if (!s.ok()) {
477 throw runtime_error_f("Failed to create projector: %s", s.ToString().c_str());
478 }
479 return projector;
480}
481
482std::shared_ptr<gandiva::Projector>
483 createProjector(gandiva::SchemaPtr const& Schema, Projector&& p, gandiva::FieldPtr result)
484{
485 return createProjector(Schema, createOperations(p), std::move(result));
486}
487
488std::shared_ptr<gandiva::Projector> createProjectorHelper(size_t nColumns, expressions::Projector* projectors,
489 std::shared_ptr<arrow::Schema> schema,
490 std::vector<std::shared_ptr<arrow::Field>> const& fields)
491{
492 std::vector<gandiva::ExpressionPtr> expressions;
493
494 for (size_t ci = 0; ci < nColumns; ++ci) {
495 expressions.push_back(
499 schema),
500 fields[ci]));
501 }
502
503 std::shared_ptr<gandiva::Projector> projector;
504 auto s = gandiva::Projector::Make(
505 schema,
506 expressions,
507 &projector);
508 if (s.ok()) {
509 return projector;
510 }
511 throw o2::framework::runtime_error_f("Failed to create projector: %s", s.ToString().c_str());
512}
513
514gandiva::Selection createSelection(std::shared_ptr<arrow::Table> const& table, std::shared_ptr<gandiva::Filter> const& gfilter)
515{
516 gandiva::Selection selection;
517 auto s = gandiva::SelectionVector::MakeInt64(table->num_rows(),
518 arrow::default_memory_pool(),
519 &selection);
520 if (!s.ok()) {
521 throw runtime_error_f("Cannot allocate selection vector %s", s.ToString().c_str());
522 }
523 if (table->num_rows() == 0) {
524 return selection;
525 }
526 arrow::TableBatchReader reader(*table);
527 std::shared_ptr<arrow::RecordBatch> batch;
528 while (true) {
529 s = reader.ReadNext(&batch);
530 if (!s.ok()) {
531 throw runtime_error_f("Cannot read batches from table %s", s.ToString().c_str());
532 }
533 if (batch == nullptr) {
534 break;
535 }
536 s = gfilter->Evaluate(*batch, selection);
537 if (!s.ok()) {
538 throw runtime_error_f("Cannot apply filter %s", s.ToString().c_str());
539 }
540 }
541
542 return selection;
543}
544
545gandiva::Selection createSelection(std::shared_ptr<arrow::Table> const& table,
546 Filter const& expression)
547{
548 return createSelection(table, createFilter(table->schema(), createOperations(std::move(expression))));
549}
550
551auto createProjection(std::shared_ptr<arrow::Table> const& table, std::shared_ptr<gandiva::Projector> const& gprojector)
552{
553 arrow::TableBatchReader reader(*table);
554 std::shared_ptr<arrow::RecordBatch> batch;
555 std::shared_ptr<arrow::ArrayVector> v;
556 while (true) {
557 auto s = reader.ReadNext(&batch);
558 if (!s.ok()) {
559 throw runtime_error_f("Cannot read batches from table %s", s.ToString().c_str());
560 }
561 if (batch == nullptr) {
562 break;
563 }
564 s = gprojector->Evaluate(*batch, arrow::default_memory_pool(), v.get());
565 if (!s.ok()) {
566 throw runtime_error_f("Cannot apply projector %s", s.ToString().c_str());
567 }
568 }
569 return v;
570}
571
572gandiva::NodePtr createExpressionTree(Operations const& opSpecs,
573 gandiva::SchemaPtr const& Schema)
574{
575 std::vector<gandiva::NodePtr> opNodes;
576 opNodes.resize(opSpecs.size());
577 std::fill(opNodes.begin(), opNodes.end(), nullptr);
578 std::unordered_map<std::string, gandiva::NodePtr> fieldNodes;
579 std::unordered_map<size_t, gandiva::NodePtr> subtrees;
580
581 auto datumNode = [Schema, &opNodes, &fieldNodes](DatumSpec const& spec) {
582 if (spec.datum.index() == 0) {
583 return gandiva::NodePtr(nullptr);
584 }
585 if (spec.datum.index() == 1) {
586 return opNodes[std::get<size_t>(spec.datum)];
587 }
588
589 if (spec.datum.index() == 2) {
590 auto content = std::get<LiteralNode::var_t>(spec.datum);
591 switch (content.index()) {
592 case 0: // int
593 return gandiva::TreeExprBuilder::MakeLiteral(static_cast<int32_t>(std::get<int>(content)));
594 case 1: // bool
595 return gandiva::TreeExprBuilder::MakeLiteral(std::get<bool>(content));
596 case 2: // float
597 return gandiva::TreeExprBuilder::MakeLiteral(std::get<float>(content));
598 case 3: // double
599 return gandiva::TreeExprBuilder::MakeLiteral(std::get<double>(content));
600 case 4: // uint8
601 return gandiva::TreeExprBuilder::MakeLiteral(std::get<uint8_t>(content));
602 case 5: // int64
603 return gandiva::TreeExprBuilder::MakeLiteral(std::get<int64_t>(content));
604 case 6: // int16
605 return gandiva::TreeExprBuilder::MakeLiteral(std::get<int16_t>(content));
606 case 7: // uint16
607 return gandiva::TreeExprBuilder::MakeLiteral(std::get<uint16_t>(content));
608 case 8: // int8
609 return gandiva::TreeExprBuilder::MakeLiteral(std::get<int8_t>(content));
610 case 9: // uint32
611 return gandiva::TreeExprBuilder::MakeLiteral(std::get<uint32_t>(content));
612 case 10: // uint64
613 return gandiva::TreeExprBuilder::MakeLiteral(std::get<uint64_t>(content));
614 default:
615 throw runtime_error("Malformed LiteralNode");
616 }
617 }
618
619 if (spec.datum.index() == 3) {
620 auto name = std::get<std::string>(spec.datum);
621 auto lookup = fieldNodes.find(name);
622 if (lookup != fieldNodes.end()) {
623 return lookup->second;
624 }
625 auto field = Schema->GetFieldByName(name);
626 if (field == nullptr) {
627 throw runtime_error_f("Cannot find field \"%s\"", name.c_str());
628 }
629 auto node = gandiva::TreeExprBuilder::MakeField(field);
630 fieldNodes.insert({name, node});
631 return node;
632 }
633 throw runtime_error("Malformed DatumSpec");
634 };
635
636 gandiva::NodePtr tree = nullptr;
637 for (auto it = opSpecs.rbegin(); it != opSpecs.rend(); ++it) {
638 auto leftNode = datumNode(it->left);
639 auto rightNode = datumNode(it->right);
640 auto condNode = datumNode(it->condition);
641
642 auto insertUpcastNode = [&](gandiva::NodePtr node, atype::type t) {
643 if (t != it->type) {
644 auto upcast = gandiva::TreeExprBuilder::MakeFunction(upcastTo(it->type), {node}, concreteArrowType(it->type));
645 node = upcast;
646 }
647 return node;
648 };
649
650 auto insertEqualizeUpcastNode = [&](gandiva::NodePtr& node1, gandiva::NodePtr& node2, atype::type t1, atype::type t2) {
651 if (t2 > t1) {
652 auto upcast = gandiva::TreeExprBuilder::MakeFunction(upcastTo(t2), {node1}, concreteArrowType(t2));
653 node1 = upcast;
654 } else if (t1 > t2) {
655 auto upcast = gandiva::TreeExprBuilder::MakeFunction(upcastTo(t1), {node2}, concreteArrowType(t1));
656 node2 = upcast;
657 }
658 };
659
660 gandiva::NodePtr temp_node;
661
662 switch (it->op) {
664 temp_node = gandiva::TreeExprBuilder::MakeOr({leftNode, rightNode});
665 break;
667 temp_node = gandiva::TreeExprBuilder::MakeAnd({leftNode, rightNode});
668 break;
670 temp_node = gandiva::TreeExprBuilder::MakeIf(condNode, leftNode, rightNode, concreteArrowType(it->type));
671 break;
672 default:
673 if (it->op < BasicOp::Sqrt) {
674 if (it->type != atype::BOOL) {
675 leftNode = insertUpcastNode(leftNode, it->left.type);
676 rightNode = insertUpcastNode(rightNode, it->right.type);
677 } else if (it->op == BasicOp::Equal || it->op == BasicOp::NotEqual) {
678 insertEqualizeUpcastNode(leftNode, rightNode, it->left.type, it->right.type);
679 }
680 temp_node = gandiva::TreeExprBuilder::MakeFunction(basicOperationsMap[it->op], {leftNode, rightNode}, concreteArrowType(it->type));
681 } else {
682 leftNode = insertUpcastNode(leftNode, it->left.type);
683 temp_node = gandiva::TreeExprBuilder::MakeFunction(basicOperationsMap[it->op], {leftNode}, concreteArrowType(it->type));
684 }
685 break;
686 }
687 if (it->index == 0) {
688 tree = temp_node;
689 } else {
690 auto subtree = subtrees.find(it->index);
691 if (subtree == subtrees.end()) {
692 subtrees.insert({it->index, temp_node});
693 } else {
694 subtree->second = temp_node;
695 }
696 }
697 opNodes[std::get<size_t>(it->result.datum)] = temp_node;
698 }
699
700 return tree;
701}
702
703bool isTableCompatible(std::set<uint32_t> const& hashes, Operations const& specs)
704{
705 std::set<uint32_t> opHashes;
706 for (auto const& spec : specs) {
707 if (spec.left.datum.index() == 3) {
708 opHashes.insert(spec.left.hash);
709 }
710 if (spec.right.datum.index() == 3) {
711 opHashes.insert(spec.right.hash);
712 }
713 }
714
715 return std::includes(hashes.begin(), hashes.end(),
716 opHashes.begin(), opHashes.end());
717}
718
719void updateExpressionInfos(expressions::Filter const& filter, std::vector<ExpressionInfo>& eInfos)
720{
721 if (eInfos.empty()) {
722 throw runtime_error("Empty expression info vector.");
723 }
725 for (auto& info : eInfos) {
726 if (isTableCompatible(info.hashes, ops)) {
727 auto tree = createExpressionTree(ops, info.schema);
729 if (info.tree != nullptr) {
730 info.tree = gandiva::TreeExprBuilder::MakeAnd({info.tree, tree});
731 } else {
732 info.tree = tree;
733 }
734 }
735 }
736}
737
738void updateFilterInfo(ExpressionInfo& info, std::shared_ptr<arrow::Table>& table)
739{
740 if (info.tree != nullptr && info.filter == nullptr) {
742 }
743 if (info.tree != nullptr && info.filter != nullptr && info.resetSelection == true) {
745 info.resetSelection = false;
746 }
747}
748
749} // namespace o2::framework::expressions
#define O2_BUILTIN_UNREACHABLE
uint8_t lookup(const char input) noexcept
uint32_t gfilter
Definition RawData.h:6
GLuint64EXT * result
Definition glcorearb.h:5662
const GLdouble * v
Definition glcorearb.h:832
GLuint index
Definition glcorearb.h:781
GLdouble GLdouble GLdouble GLdouble top
Definition glcorearb.h:4077
GLuint const GLchar * name
Definition glcorearb.h:781
GLdouble GLdouble right
Definition glcorearb.h:4077
GLdouble f
Definition glcorearb.h:310
GLint GLint GLsizei GLint GLenum GLenum type
Definition glcorearb.h:275
GLint left
Definition glcorearb.h:1979
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition glcorearb.h:1308
GLsizei const GLchar *const * path
Definition glcorearb.h:3591
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t1
Definition glcorearb.h:5034
std::shared_ptr< gandiva::SelectionVector > Selection
Definition Expressions.h:46
std::shared_ptr< arrow::DataType > concreteArrowType(atype::type type)
std::shared_ptr< gandiva::Filter > createFilter(gandiva::SchemaPtr const &Schema, gandiva::ConditionPtr condition)
Function to create gandiva filter from gandiva condition.
gandiva::ExpressionPtr makeExpression(gandiva::NodePtr node, gandiva::FieldPtr result)
Function to create gandiva projecting expression from generic gandiva expression tree.
std::shared_ptr< gandiva::Projector > createProjectorHelper(size_t nColumns, expressions::Projector *projectors, std::shared_ptr< arrow::Schema > schema, std::vector< std::shared_ptr< arrow::Field > > const &fields)
gandiva::Selection createSelection(std::shared_ptr< arrow::Table > const &table, Filter const &expression)
Function for creating gandiva selection from our internal filter tree.
bool operator==(DatumSpec const &lhs, DatumSpec const &rhs)
auto createProjection(std::shared_ptr< arrow::Table > const &table, std::shared_ptr< gandiva::Projector > const &gprojector)
const char * stringType(atype::type t)
std::vector< ColumnOperationSpec > Operations
void updateExpressionInfos(expressions::Filter const &filter, std::vector< ExpressionInfo > &eInfos)
Function for attaching gandiva filters to to compatible task inputs.
Operations createOperations(Filter const &expression)
Function to create an internal operation sequence from a filter tree.
std::ostream & operator<<(std::ostream &os, DatumSpec const &spec)
gandiva::ConditionPtr makeCondition(gandiva::NodePtr node)
Function to create gandiva condition expression from generic gandiva expression tree.
bool isTableCompatible(std::set< uint32_t > const &hashes, Operations const &specs)
Function to check compatibility of a given arrow schema with operation sequence.
gandiva::NodePtr createExpressionTree(Operations const &opSpecs, gandiva::SchemaPtr const &Schema)
Function to create gandiva expression tree from operation sequence.
void updatePlaceholders(Filter &filter, InitContext &context)
Update placeholder nodes from context.
std::string upcastTo(atype::type f)
std::shared_ptr< gandiva::Projector > createProjector(gandiva::SchemaPtr const &Schema, Operations const &opSpecs, gandiva::FieldPtr result)
Function to create gandiva projector from operation sequence.
void updateFilterInfo(ExpressionInfo &info, std::shared_ptr< arrow::Table > &table)
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
RuntimeErrorRef runtime_error(const char *)
RuntimeErrorRef runtime_error_f(const char *,...)
gandiva::Selection selection
Definition Expressions.h:65
gandiva::FilterPtr filter
Definition Expressions.h:64
gandiva::NodePtr tree
Definition Expressions.h:63
An expression tree node corresponding to a column binding.
A struct, containing the root of the expression tree.
size_t designateSubtrees(Node *node, size_t index=0)
std::unique_ptr< Node > node
An expression tree node corresponding to a literal value.
LiteralValue::stored_type var_t
An expression tree node corresponding to binary or unary operation.
A placeholder node for simple type configurable.
From https://en.cppreference.com/w/cpp/utility/variant/visit.
std::unique_ptr< TTree > tree((TTree *) flIn.Get(std::string(o2::base::NameConf::CTFTREENAME).c_str()))