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
122struct ParameterNodeHelper {
123 DatumSpec operator()(ParameterNode const& node) const
124 {
125 return DatumSpec{node.value, node.type};
126 }
127};
128} // namespace
129
130std::shared_ptr<arrow::DataType> concreteArrowType(atype::type type)
131{
132 switch (type) {
133 case atype::UINT8:
134 return arrow::uint8();
135 case atype::INT8:
136 return arrow::int8();
137 case atype::INT16:
138 return arrow::int16();
139 case atype::UINT16:
140 return arrow::uint16();
141 case atype::INT32:
142 return arrow::int32();
143 case atype::UINT32:
144 return arrow::uint32();
145 case atype::INT64:
146 return arrow::int64();
147 case atype::UINT64:
148 return arrow::uint64();
149 case atype::FLOAT:
150 return arrow::float32();
151 case atype::DOUBLE:
152 return arrow::float64();
153 case atype::BOOL:
154 return arrow::boolean();
155 default:
156 return nullptr;
157 }
158}
159
160std::string upcastTo(atype::type f)
161{
162 switch (f) {
163 case atype::INT32:
164 return "castINT";
165 case atype::INT64:
166 return "castBIGINT";
167 case atype::FLOAT:
168 return "castFLOAT4";
169 case atype::DOUBLE:
170 return "castFLOAT8";
171 default:
172 throw runtime_error_f("Do not know how to cast to %d", f);
173 }
174}
175
176bool operator==(DatumSpec const& lhs, DatumSpec const& rhs)
177{
178 return (lhs.datum == rhs.datum) && (lhs.type == rhs.type);
179}
180
181std::ostream& operator<<(std::ostream& os, DatumSpec const& spec)
182{
183 std::visit(
185 [&os](LiteralNode::var_t&& arg) {
186 std::visit(
187 [&os](auto&& arg) { os << arg; },
188 arg);
189 },
190 [&os](size_t&& arg) { os << arg; },
191 [&os](std::string&& arg) { os << arg; },
192 [](auto&&) {}},
193 spec.datum);
194 return os;
195}
196
198{
199 auto updateNode = [&](Node* node) {
200 if (node->self.index() == 3) {
201 std::get_if<3>(&node->self)->reset(context);
202 }
203 };
204
205 expressions::walk(filter.node.get(), updateNode);
206}
207
208const char* stringType(atype::type t)
209{
210 switch (t) {
211 case atype::BOOL:
212 return "bool";
213 case atype::DOUBLE:
214 return "double";
215 case atype::FLOAT:
216 return "float";
217 case atype::INT8:
218 return "int8";
219 case atype::INT16:
220 return "int16";
221 case atype::INT32:
222 return "int32";
223 case atype::INT64:
224 return "int64";
225 case atype::UINT8:
226 return "uint8";
227 case atype::UINT16:
228 return "uint16";
229 case atype::UINT32:
230 return "uint32";
231 case atype::UINT64:
232 return "uint64";
233 default:
234 return "unsupported";
235 }
237}
238
240{
241 Operations OperationSpecs;
242 std::stack<NodeRecord> path;
243 auto isLeaf = [](Node const* const node) {
244 return ((node->left == nullptr) && (node->right == nullptr));
245 };
246
247 auto processLeaf = [](Node const* const node) {
248 return std::visit(
250 [lh = LiteralNodeHelper{}](LiteralNode const& node) { return lh(node); },
251 [bh = BindingNodeHelper{}](BindingNode const& node) { return bh(node); },
252 [ph = PlaceholderNodeHelper{}](PlaceholderNode const& node) { return ph(node); },
253 [pr = ParameterNodeHelper{}](ParameterNode const& node) { return pr(node); },
254 [](auto&&) { return DatumSpec{}; }},
255 node->self);
256 };
257
258 size_t index = 0;
259 // insert the top node into stack
260 path.emplace(expression.node.get(), index++);
261
262 // while the stack is not empty
263 while (!path.empty()) {
264 auto top = path.top();
265
266 // create operation spec, pop the node and add its children
267 auto operationSpec =
268 std::visit(
270 [&](OpNode node) { return ColumnOperationSpec{node.op, top.node_ptr->index}; },
272 [](auto&&) { return ColumnOperationSpec{}; }},
273 top.node_ptr->self);
274
275 operationSpec.result = DatumSpec{top.index, operationSpec.type};
276 path.pop();
277
278 auto* left = top.node_ptr->left.get();
279 bool leftLeaf = isLeaf(left);
280 size_t li = 0;
281 if (leftLeaf) {
282 operationSpec.left = processLeaf(left);
283 } else {
284 li = index;
285 operationSpec.left = DatumSpec{index++, atype::NA};
286 }
287
288 decltype(left) right = nullptr;
289 if (top.node_ptr->right != nullptr) {
290 right = top.node_ptr->right.get();
291 }
292 bool rightLeaf = true;
293 if (right != nullptr) {
294 rightLeaf = isLeaf(right);
295 }
296 size_t ri = 0;
297 auto isUnary = false;
298 if (top.node_ptr->right == nullptr) {
299 operationSpec.right = DatumSpec{};
300 isUnary = true;
301 } else {
302 if (rightLeaf) {
303 operationSpec.right = processLeaf(right);
304 } else {
305 ri = index;
306 operationSpec.right = DatumSpec{index++, atype::NA};
307 }
308 }
309
310 decltype(left) condition = nullptr;
311 if (top.node_ptr->condition != nullptr) {
312 condition = top.node_ptr->condition.get();
313 }
314 bool condleaf = condition != nullptr ? isLeaf(condition) : true;
315 size_t ci = 0;
316 if (condition != nullptr) {
317 if (condleaf) {
318 operationSpec.condition = processLeaf(condition);
319 } else {
320 ci = index;
321 operationSpec.condition = DatumSpec{index++, atype::BOOL};
322 }
323 } else {
324 operationSpec.condition = DatumSpec{};
325 }
326
327 OperationSpecs.push_back(std::move(operationSpec));
328 if (!leftLeaf) {
329 path.emplace(left, li);
330 }
331 if (!isUnary && !rightLeaf) {
332 path.emplace(right, ri);
333 }
334 if (!condleaf) {
335 path.emplace(condition, ci);
336 }
337 }
338 // at this stage the operations vector is created, but the field types are
339 // only set for the logical operations and leaf nodes
340 std::vector<atype::type> resultTypes;
341 resultTypes.resize(OperationSpecs.size());
342
343 auto inferResultType = [&resultTypes](DatumSpec& left, DatumSpec& right) {
344 // if the left datum is monostate (error)
345 if (left.datum.index() == 0) {
346 throw runtime_error("Malformed operation spec: empty left datum");
347 }
348
349 // check if the datums are references
350 if (left.datum.index() == 1) {
351 left.type = resultTypes[std::get<size_t>(left.datum)];
352 }
353
354 if (right.datum.index() == 1) {
355 right.type = resultTypes[std::get<size_t>(right.datum)];
356 }
357
358 auto t1 = left.type;
359 auto t2 = right.type;
360 // if the right datum is monostate (unary op)
361 if (right.datum.index() == 0) {
362 if (t1 == atype::DOUBLE) {
363 return atype::DOUBLE;
364 }
365 return atype::FLOAT;
366 }
367
368 if (t1 == t2) {
369 return t1;
370 }
371
372 auto isIntType = [](auto t) {
373 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);
374 };
375
376 if (isIntType(t1)) {
377 if (t2 == atype::FLOAT) {
378 return atype::FLOAT;
379 }
380 if (t2 == atype::DOUBLE) {
381 return atype::DOUBLE;
382 }
383 if (isIntType(t2)) {
384 if (t1 > t2) {
385 return t1;
386 }
387 return t2;
388 }
389 }
390 if (t1 == atype::FLOAT) {
391 if (isIntType(t2)) {
392 return atype::FLOAT;
393 }
394 if (t2 == atype::DOUBLE) {
395 return atype::DOUBLE;
396 }
397 }
398 if (t1 == atype::DOUBLE) {
399 return atype::DOUBLE;
400 }
401 throw runtime_error_f("Invalid combination of argument types %s and %s", stringType(t1), stringType(t2));
402 };
403
404 for (auto it = OperationSpecs.rbegin(); it != OperationSpecs.rend(); ++it) {
405 auto type = inferResultType(it->left, it->right);
406 if (it->type == atype::NA) {
407 it->type = type;
408 }
409
410 it->result.type = it->type;
411 resultTypes[std::get<size_t>(it->result.datum)] = it->type;
412 }
413
414 return OperationSpecs;
415}
416
417gandiva::ConditionPtr makeCondition(gandiva::NodePtr node)
418{
419 return gandiva::TreeExprBuilder::MakeCondition(std::move(node));
420}
421
422gandiva::ExpressionPtr makeExpression(gandiva::NodePtr node, gandiva::FieldPtr result)
423{
424 return gandiva::TreeExprBuilder::MakeExpression(std::move(node), std::move(result));
425}
426
427std::shared_ptr<gandiva::Filter>
428 createFilter(gandiva::SchemaPtr const& Schema, Operations const& opSpecs)
429{
430 std::shared_ptr<gandiva::Filter> filter;
431 auto s = gandiva::Filter::Make(Schema,
432 makeCondition(createExpressionTree(opSpecs, Schema)),
433 &filter);
434 if (!s.ok()) {
435 throw runtime_error_f("Failed to create filter: %s", s.ToString().c_str());
436 }
437 return filter;
438}
439
440std::shared_ptr<gandiva::Filter>
441 createFilter(gandiva::SchemaPtr const& Schema, gandiva::ConditionPtr condition)
442{
443 std::shared_ptr<gandiva::Filter> filter;
444 auto s = gandiva::Filter::Make(Schema,
445 condition,
446 &filter);
447 if (!s.ok()) {
448 throw runtime_error_f("Failed to create filter: %s", s.ToString().c_str());
449 }
450 return filter;
451}
452
453std::shared_ptr<gandiva::Projector>
454 createProjector(gandiva::SchemaPtr const& Schema, Operations const& opSpecs, gandiva::FieldPtr result)
455{
456 std::shared_ptr<gandiva::Projector> projector;
457 auto s = gandiva::Projector::Make(Schema,
458 {makeExpression(createExpressionTree(opSpecs, Schema), std::move(result))},
459 &projector);
460 if (!s.ok()) {
461 throw runtime_error_f("Failed to create projector: %s", s.ToString().c_str());
462 }
463 return projector;
464}
465
466std::shared_ptr<gandiva::Projector>
467 createProjector(gandiva::SchemaPtr const& Schema, Projector&& p, gandiva::FieldPtr result)
468{
469 return createProjector(Schema, createOperations(p), std::move(result));
470}
471
472std::shared_ptr<gandiva::Projector> createProjectorHelper(size_t nColumns, expressions::Projector* projectors,
473 std::shared_ptr<arrow::Schema> schema,
474 std::vector<std::shared_ptr<arrow::Field>> const& fields)
475{
476 std::vector<gandiva::ExpressionPtr> expressions;
477
478 for (size_t ci = 0; ci < nColumns; ++ci) {
479 expressions.push_back(
483 schema),
484 fields[ci]));
485 }
486
487 std::shared_ptr<gandiva::Projector> projector;
488 auto s = gandiva::Projector::Make(
489 schema,
490 expressions,
491 &projector);
492 if (s.ok()) {
493 return projector;
494 }
495 throw o2::framework::runtime_error_f("Failed to create projector: %s", s.ToString().c_str());
496}
497
498gandiva::Selection createSelection(std::shared_ptr<arrow::Table> const& table, std::shared_ptr<gandiva::Filter> const& gfilter)
499{
500 gandiva::Selection selection;
501 auto s = gandiva::SelectionVector::MakeInt64(table->num_rows(),
502 arrow::default_memory_pool(),
503 &selection);
504 if (!s.ok()) {
505 throw runtime_error_f("Cannot allocate selection vector %s", s.ToString().c_str());
506 }
507 if (table->num_rows() == 0) {
508 return selection;
509 }
510 arrow::TableBatchReader reader(*table);
511 std::shared_ptr<arrow::RecordBatch> batch;
512 while (true) {
513 s = reader.ReadNext(&batch);
514 if (!s.ok()) {
515 throw runtime_error_f("Cannot read batches from table %s", s.ToString().c_str());
516 }
517 if (batch == nullptr) {
518 break;
519 }
520 s = gfilter->Evaluate(*batch, selection);
521 if (!s.ok()) {
522 throw runtime_error_f("Cannot apply filter %s", s.ToString().c_str());
523 }
524 }
525
526 return selection;
527}
528
529gandiva::Selection createSelection(std::shared_ptr<arrow::Table> const& table,
530 Filter const& expression)
531{
532 return createSelection(table, createFilter(table->schema(), createOperations(std::move(expression))));
533}
534
535auto createProjection(std::shared_ptr<arrow::Table> const& table, std::shared_ptr<gandiva::Projector> const& gprojector)
536{
537 arrow::TableBatchReader reader(*table);
538 std::shared_ptr<arrow::RecordBatch> batch;
539 std::shared_ptr<arrow::ArrayVector> v;
540 while (true) {
541 auto s = reader.ReadNext(&batch);
542 if (!s.ok()) {
543 throw runtime_error_f("Cannot read batches from table %s", s.ToString().c_str());
544 }
545 if (batch == nullptr) {
546 break;
547 }
548 s = gprojector->Evaluate(*batch, arrow::default_memory_pool(), v.get());
549 if (!s.ok()) {
550 throw runtime_error_f("Cannot apply projector %s", s.ToString().c_str());
551 }
552 }
553 return v;
554}
555
556gandiva::NodePtr createExpressionTree(Operations const& opSpecs,
557 gandiva::SchemaPtr const& Schema)
558{
559 std::vector<gandiva::NodePtr> opNodes;
560 opNodes.resize(opSpecs.size());
561 std::fill(opNodes.begin(), opNodes.end(), nullptr);
562 std::unordered_map<std::string, gandiva::NodePtr> fieldNodes;
563 std::unordered_map<size_t, gandiva::NodePtr> subtrees;
564
565 auto datumNode = [Schema, &opNodes, &fieldNodes](DatumSpec const& spec) {
566 if (spec.datum.index() == 0) {
567 return gandiva::NodePtr(nullptr);
568 }
569 if (spec.datum.index() == 1) {
570 return opNodes[std::get<size_t>(spec.datum)];
571 }
572
573 if (spec.datum.index() == 2) {
574 auto content = std::get<LiteralNode::var_t>(spec.datum);
575 switch (content.index()) {
576 case 0: // int
577 return gandiva::TreeExprBuilder::MakeLiteral(static_cast<int32_t>(std::get<int>(content)));
578 case 1: // bool
579 return gandiva::TreeExprBuilder::MakeLiteral(std::get<bool>(content));
580 case 2: // float
581 return gandiva::TreeExprBuilder::MakeLiteral(std::get<float>(content));
582 case 3: // double
583 return gandiva::TreeExprBuilder::MakeLiteral(std::get<double>(content));
584 case 4: // uint8
585 return gandiva::TreeExprBuilder::MakeLiteral(std::get<uint8_t>(content));
586 case 5: // int64
587 return gandiva::TreeExprBuilder::MakeLiteral(std::get<int64_t>(content));
588 case 6: // int16
589 return gandiva::TreeExprBuilder::MakeLiteral(std::get<int16_t>(content));
590 case 7: // uint16
591 return gandiva::TreeExprBuilder::MakeLiteral(std::get<uint16_t>(content));
592 case 8: // int8
593 return gandiva::TreeExprBuilder::MakeLiteral(std::get<int8_t>(content));
594 case 9: // uint32
595 return gandiva::TreeExprBuilder::MakeLiteral(std::get<uint32_t>(content));
596 case 10: // uint64
597 return gandiva::TreeExprBuilder::MakeLiteral(std::get<uint64_t>(content));
598 default:
599 throw runtime_error("Malformed LiteralNode");
600 }
601 }
602
603 if (spec.datum.index() == 3) {
604 auto name = std::get<std::string>(spec.datum);
605 auto lookup = fieldNodes.find(name);
606 if (lookup != fieldNodes.end()) {
607 return lookup->second;
608 }
609 auto field = Schema->GetFieldByName(name);
610 if (field == nullptr) {
611 throw runtime_error_f("Cannot find field \"%s\"", name.c_str());
612 }
613 auto node = gandiva::TreeExprBuilder::MakeField(field);
614 fieldNodes.insert({name, node});
615 return node;
616 }
617 throw runtime_error("Malformed DatumSpec");
618 };
619
620 gandiva::NodePtr tree = nullptr;
621 for (auto it = opSpecs.rbegin(); it != opSpecs.rend(); ++it) {
622 auto leftNode = datumNode(it->left);
623 auto rightNode = datumNode(it->right);
624 auto condNode = datumNode(it->condition);
625
626 auto insertUpcastNode = [&](gandiva::NodePtr node, atype::type t) {
627 if (t != it->type) {
628 auto upcast = gandiva::TreeExprBuilder::MakeFunction(upcastTo(it->type), {node}, concreteArrowType(it->type));
629 node = upcast;
630 }
631 return node;
632 };
633
634 auto insertEqualizeUpcastNode = [&](gandiva::NodePtr& node1, gandiva::NodePtr& node2, atype::type t1, atype::type t2) {
635 if (t2 > t1) {
636 auto upcast = gandiva::TreeExprBuilder::MakeFunction(upcastTo(t2), {node1}, concreteArrowType(t2));
637 node1 = upcast;
638 } else if (t1 > t2) {
639 auto upcast = gandiva::TreeExprBuilder::MakeFunction(upcastTo(t1), {node2}, concreteArrowType(t1));
640 node2 = upcast;
641 }
642 };
643
644 gandiva::NodePtr temp_node;
645
646 switch (it->op) {
648 temp_node = gandiva::TreeExprBuilder::MakeOr({leftNode, rightNode});
649 break;
651 temp_node = gandiva::TreeExprBuilder::MakeAnd({leftNode, rightNode});
652 break;
654 temp_node = gandiva::TreeExprBuilder::MakeIf(condNode, leftNode, rightNode, concreteArrowType(it->type));
655 break;
656 default:
657 if (it->op < BasicOp::Sqrt) {
658 if (it->type != atype::BOOL) {
659 leftNode = insertUpcastNode(leftNode, it->left.type);
660 rightNode = insertUpcastNode(rightNode, it->right.type);
661 } else if (it->op == BasicOp::Equal || it->op == BasicOp::NotEqual) {
662 insertEqualizeUpcastNode(leftNode, rightNode, it->left.type, it->right.type);
663 }
664 temp_node = gandiva::TreeExprBuilder::MakeFunction(basicOperationsMap[it->op], {leftNode, rightNode}, concreteArrowType(it->type));
665 } else {
666 leftNode = insertUpcastNode(leftNode, it->left.type);
667 temp_node = gandiva::TreeExprBuilder::MakeFunction(basicOperationsMap[it->op], {leftNode}, concreteArrowType(it->type));
668 }
669 break;
670 }
671 if (it->index == 0) {
672 tree = temp_node;
673 } else {
674 auto subtree = subtrees.find(it->index);
675 if (subtree == subtrees.end()) {
676 subtrees.insert({it->index, temp_node});
677 } else {
678 subtree->second = temp_node;
679 }
680 }
681 opNodes[std::get<size_t>(it->result.datum)] = temp_node;
682 }
683
684 return tree;
685}
686
687bool isTableCompatible(std::set<uint32_t> const& hashes, Operations const& specs)
688{
689 std::set<uint32_t> opHashes;
690 for (auto const& spec : specs) {
691 if (spec.left.datum.index() == 3) {
692 opHashes.insert(spec.left.hash);
693 }
694 if (spec.right.datum.index() == 3) {
695 opHashes.insert(spec.right.hash);
696 }
697 }
698
699 return std::includes(hashes.begin(), hashes.end(),
700 opHashes.begin(), opHashes.end());
701}
702
703void updateExpressionInfos(expressions::Filter const& filter, std::vector<ExpressionInfo>& eInfos)
704{
705 if (eInfos.empty()) {
706 throw runtime_error("Empty expression info vector.");
707 }
709 for (auto& info : eInfos) {
710 if (isTableCompatible(info.hashes, ops)) {
711 auto tree = createExpressionTree(ops, info.schema);
713 if (info.tree != nullptr) {
714 info.tree = gandiva::TreeExprBuilder::MakeAnd({info.tree, tree});
715 } else {
716 info.tree = tree;
717 }
718 }
719 }
720}
721
722void updateFilterInfo(ExpressionInfo& info, std::shared_ptr<arrow::Table>& table)
723{
724 if (info.tree != nullptr && info.filter == nullptr) {
726 }
727 if (info.tree != nullptr && info.filter != nullptr && info.resetSelection == true) {
729 info.resetSelection = false;
730 }
731}
732
733} // 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:47
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)
void walk(Node *head, L const &pred)
Tree-walker helper.
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:66
gandiva::FilterPtr filter
Definition Expressions.h:65
gandiva::NodePtr tree
Definition Expressions.h:64
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 parameters taken from an array.
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()))