Project
Loading...
Searching...
No Matches
Expressions.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_EXPRESSIONS_H_
12#define O2_FRAMEWORK_EXPRESSIONS_H_
13
14#include "Framework/BasicOps.h"
15#include "Framework/Pack.h"
17#include "Framework/Variant.h"
21#include <arrow/type_fwd.h>
22#include <gandiva/gandiva_aliases.h>
23#include <arrow/type.h>
24#include <gandiva/arrow.h>
25#if !defined(__CLING__) && !defined(__ROOTCLING__)
26#include <arrow/table.h>
27#include <gandiva/selection_vector.h>
28#include <gandiva/node.h>
29#include <gandiva/filter.h>
30#include <gandiva/projector.h>
31#else
32namespace gandiva
33{
34class SelectionVector;
35class Filter;
36class Projector;
37} // namespace gandiva
38#endif
39#include <variant>
40#include <string>
41#include <memory>
42#include <set>
43#include <stack>
44namespace gandiva
45{
46using Selection = std::shared_ptr<gandiva::SelectionVector>;
47using FilterPtr = std::shared_ptr<gandiva::Filter>;
48} // namespace gandiva
49
50using atype = arrow::Type;
52 ExpressionInfo(int ai, size_t hash, std::set<uint32_t>&& hs, gandiva::SchemaPtr sc)
53 : argumentIndex(ai),
54 processHash(hash),
55 hashes(hs),
56 schema(sc)
57 {
58 }
61 std::set<uint32_t> hashes;
62 gandiva::SchemaPtr schema;
63 gandiva::NodePtr tree = nullptr;
66 bool resetSelection = false;
67};
68
70{
71void unknownParameterUsed(const char* name);
72const char* stringType(atype::type t);
73
74template <typename... T>
76 using stored_type = std::variant<T...>;
78};
79
81
82template <typename T>
83constexpr auto selectArrowType()
84{
85 return atype::NA;
86}
87
88#define SELECT_ARROW_TYPE(_Ctype_, _Atype_) \
89 template <typename T> \
90 requires std::same_as<T, _Ctype_> \
91 constexpr auto selectArrowType() \
92 { \
93 return atype::_Atype_; \
94 }
95
97SELECT_ARROW_TYPE(float, FLOAT);
98SELECT_ARROW_TYPE(double, DOUBLE);
99SELECT_ARROW_TYPE(uint8_t, UINT8);
100SELECT_ARROW_TYPE(int8_t, INT8);
101SELECT_ARROW_TYPE(uint16_t, UINT16);
102SELECT_ARROW_TYPE(int16_t, INT16);
103SELECT_ARROW_TYPE(uint32_t, UINT32);
104SELECT_ARROW_TYPE(int32_t, INT32);
105SELECT_ARROW_TYPE(uint64_t, UINT64);
106SELECT_ARROW_TYPE(int64_t, INT64);
107
108std::shared_ptr<arrow::DataType> concreteArrowType(atype::type type);
109std::string upcastTo(atype::type f);
110
113 template <typename T>
115 {
116 }
117
118 LiteralNode(LiteralNode const& other) = default;
119
122 atype::type type = atype::NA;
123};
124
127 BindingNode(BindingNode const&) = default;
129 constexpr BindingNode(const char* name_, uint32_t hash_, atype::type type_) : name{name_}, hash{hash_}, type{type_} {}
130 const char* name;
131 uint32_t hash;
132 atype::type type;
133};
134
136struct OpNode {
137 OpNode(BasicOp op_) : op{op_} {}
138 OpNode(OpNode const& other) = default;
140};
141
144 template <typename T>
145 requires(variant_trait_v<typename std::decay<T>::type> != VariantType::Unknown)
147 {
148 retrieve = [](InitContext& context, char const* name) { return LiteralNode::var_t{context.options().get<T>(name)}; };
149 }
150
151 template <typename T, typename AT>
152 requires((std::convertible_to<T, AT>) && (variant_trait_v<typename std::decay<T>::type> != VariantType::Unknown))
153 PlaceholderNode(Configurable<T> const& v, AT*) : LiteralNode{static_cast<AT>(v.value)}, name{v.name}
154 {
155 retrieve = [](InitContext& context, char const* name) { return LiteralNode::var_t{static_cast<AT>(context.options().get<T>(name))}; };
156 }
157
159
160 void reset(InitContext& context)
161 {
162 value = retrieve(context, name.data());
163 }
164
165 std::string const& name;
167};
168
169template <typename AT, typename T>
171{
172 return PlaceholderNode(v, (AT*)nullptr);
173}
174
177 ParameterNode(int index_ = -1)
178 : LiteralNode((float)0),
179 index{index_}
180 {
181 }
182
183 ParameterNode(ParameterNode const&) = default;
184
185 template <typename T>
186 void reset(T value_, int index_ = -1)
187 {
188 (*static_cast<LiteralNode*>(this)) = LiteralNode(value_);
189 if (index_ > 0) {
190 index = index_;
191 }
192 }
193
194 int index;
195};
196
199};
200
202template <typename T>
203concept is_literal_like = std::same_as<T, LiteralNode> || std::same_as<T, PlaceholderNode> || std::same_as<T, ParameterNode>;
204
205template <typename T>
206concept is_binding = std::same_as<T, BindingNode>;
207
208template <typename T>
209concept is_operation = std::same_as<T, OpNode>;
210
211template <typename T>
212concept is_conditional = std::same_as<T, ConditionalNode>;
213
215struct Node {
216 Node(LiteralNode&& v) : self{std::forward<LiteralNode>(v)}, left{nullptr}, right{nullptr}, condition{nullptr}
217 {
218 }
219
220 Node(PlaceholderNode&& v) : self{std::forward<PlaceholderNode>(v)}, left{nullptr}, right{nullptr}, condition{nullptr}
221 {
222 }
223
224 Node(Node&& n) : self{std::forward<self_t>(n.self)}, left{std::forward<std::unique_ptr<Node>>(n.left)}, right{std::forward<std::unique_ptr<Node>>(n.right)}, condition{std::forward<std::unique_ptr<Node>>(n.condition)}
225 {
226 }
227
228 Node(BindingNode const& n) : self{n}, left{nullptr}, right{nullptr}, condition{nullptr}
229 {
230 }
231
232 Node(ParameterNode&& p) : self{std::forward<ParameterNode>(p)}, left{nullptr}, right{nullptr}, condition{nullptr}
233 {
234 }
235
236 Node(ConditionalNode op, Node&& then_, Node&& else_, Node&& condition_)
237 : self{op},
238 left{std::make_unique<Node>(std::forward<Node>(then_))},
239 right{std::make_unique<Node>(std::forward<Node>(else_))},
240 condition{std::make_unique<Node>(std::forward<Node>(condition_))} {}
241
243 : self{op},
244 left{std::make_unique<Node>(std::forward<Node>(l))},
245 right{std::make_unique<Node>(std::forward<Node>(r))},
246 condition{nullptr} {}
247
249 : self{op},
250 left{std::make_unique<Node>(std::forward<Node>(l))},
251 right{nullptr},
252 condition{nullptr} {}
253
255 : self{other.self},
257 {
258 if (other.left != nullptr) {
259 left = std::make_unique<Node>(*other.left);
260 }
261 if (other.right != nullptr) {
262 right = std::make_unique<Node>(*other.right);
263 }
264 if (other.condition != nullptr) {
265 condition = std::make_unique<Node>(*other.condition);
266 }
267 }
268
270 using self_t = std::variant<LiteralNode, BindingNode, OpNode, PlaceholderNode, ConditionalNode, ParameterNode>;
272 size_t index = 0;
274 std::unique_ptr<Node> left = nullptr;
275 std::unique_ptr<Node> right = nullptr;
276 std::unique_ptr<Node> condition = nullptr;
277};
278
282 Node* node_ptr = nullptr;
283 size_t index = 0;
284 explicit NodeRecord(Node* node_, size_t index_) : node_ptr(node_), index{index_} {}
285 bool operator!=(NodeRecord const& rhs)
286 {
287 return this->node_ptr != rhs.node_ptr;
288 }
289};
290
292template <typename L>
293void walk(Node* head, L&& pred)
294{
295 std::stack<NodeRecord> path;
296 path.emplace(head, 0);
297 while (!path.empty()) {
298 auto& top = path.top();
299 pred(top.node_ptr);
300
301 auto* leftp = top.node_ptr->left.get();
302 auto* rightp = top.node_ptr->right.get();
303 auto* condp = top.node_ptr->condition.get();
304 path.pop();
305
306 if (leftp != nullptr) {
307 path.emplace(leftp, 0);
308 }
309 if (rightp != nullptr) {
310 path.emplace(rightp, 0);
311 }
312 if (condp != nullptr) {
313 path.emplace(condp, 0);
314 }
315 }
316}
317
319
320#define BINARY_OP_NODES(_operator_, _operation_) \
321 inline Node operator _operator_(Node&& left, Node&& right) \
322 { \
323 return Node{OpNode{BasicOp::_operation_}, std::forward<Node>(left), std::forward<Node>(right)}; \
324 } \
325 template <typename T> \
326 inline Node operator _operator_(Node&& left, T right) requires(std::is_arithmetic_v<std::decay_t<T>>) \
327 { \
328 return Node{OpNode{BasicOp::_operation_}, std::forward<Node>(left), LiteralNode{right}}; \
329 } \
330 template <typename T> \
331 inline Node operator _operator_(T left, Node&& right) requires(std::is_arithmetic_v<std::decay_t<T>>) \
332 { \
333 return Node{OpNode{BasicOp::_operation_}, LiteralNode{left}, std::forward<Node>(right)}; \
334 } \
335 template <typename T> \
336 inline Node operator _operator_(Node&& left, Configurable<T> const& right) \
337 { \
338 return Node{OpNode{BasicOp::_operation_}, std::forward<Node>(left), PlaceholderNode{right}}; \
339 } \
340 template <typename T> \
341 inline Node operator _operator_(Configurable<T> const& left, Node&& right) \
342 { \
343 return Node{OpNode{BasicOp::_operation_}, PlaceholderNode{left}, std::forward<Node>(right)}; \
344 } \
345 inline Node operator _operator_(BindingNode const& left, BindingNode const& right) \
346 { \
347 return Node{OpNode{BasicOp::_operation_}, left, right}; \
348 } \
349 inline Node operator _operator_(BindingNode const& left, Node&& right) \
350 { \
351 return Node{OpNode{BasicOp::_operation_}, left, std::forward<Node>(right)}; \
352 } \
353 inline Node operator _operator_(Node&& left, BindingNode const& right) \
354 { \
355 return Node{OpNode{BasicOp::_operation_}, std::forward<Node>(left), right}; \
356 } \
357 template <typename T> \
358 inline Node operator _operator_(Configurable<T> const& left, BindingNode const& right) \
359 { \
360 return Node{OpNode{BasicOp::_operation_}, PlaceholderNode{left}, right}; \
361 } \
362 template <typename T> \
363 inline Node operator _operator_(BindingNode const& left, Configurable<T> const& right) \
364 { \
365 return Node{OpNode{BasicOp::_operation_}, left, PlaceholderNode{right}}; \
366 }
367
383
385template <typename T>
386inline Node npow(Node&& left, T right) requires(std::is_arithmetic_v<T>)
387{
388 return Node{OpNode{BasicOp::Power}, std::forward<Node>(left), LiteralNode{right}};
389}
390
391#define BINARY_FUNC_NODES(_func_, _node_) \
392 template <typename L, typename R> \
393 inline Node _node_(L left, R right) requires(std::is_arithmetic_v<L> && std::is_arithmetic_v<R>) \
394 { \
395 return Node{OpNode{BasicOp::_func_}, LiteralNode{left}, LiteralNode{right}}; \
396 } \
397 \
398 inline Node _node_(Node&& left, Node&& right) \
399 { \
400 return Node{OpNode{BasicOp::_func_}, std::forward<Node>(left), std::forward<Node>(right)}; \
401 } \
402 \
403 inline Node _node_(Node&& left, BindingNode const& right) \
404 { \
405 return Node{OpNode{BasicOp::_func_}, std::forward<Node>(left), right}; \
406 } \
407 \
408 inline Node _node_(BindingNode const& left, BindingNode const& right) \
409 { \
410 return Node{OpNode{BasicOp::_func_}, left, right}; \
411 } \
412 \
413 inline Node _node_(BindingNode const& left, Node&& right) \
414 { \
415 return Node{OpNode{BasicOp::_func_}, left, std::forward<Node>(right)}; \
416 } \
417 \
418 template <typename T> \
419 inline Node _node_(Node&& left, Configurable<T> const& right) \
420 { \
421 return Node{OpNode{BasicOp::_func_}, std::forward<Node>(left), PlaceholderNode{right}}; \
422 } \
423 \
424 template <typename T> \
425 inline Node _node_(Configurable<T> const& left, Node&& right) \
426 { \
427 return Node{OpNode{BasicOp::_func_}, PlaceholderNode{left}, std::forward<Node>(right)}; \
428 } \
429 \
430 template <typename T> \
431 inline Node _node_(BindingNode const& left, Configurable<T> const& right) \
432 { \
433 return Node{OpNode{BasicOp::_func_}, left, PlaceholderNode{right}}; \
434 } \
435 \
436 template <typename T> \
437 inline Node _node_(Configurable<T> const& left, BindingNode const& right) \
438 { \
439 return Node{OpNode{BasicOp::_func_}, PlaceholderNode{left}, right}; \
440 }
441
443#define ncheckbit(_node_, _bit_) ((_node_ & _bit_) == _bit_)
444
446#define UNARY_FUNC_NODES(_func_, _node_) \
447 inline Node _node_(Node&& arg) \
448 { \
449 return Node{OpNode{BasicOp::_func_}, std::forward<Node>(arg)}; \
450 }
451
465
467inline Node ifnode(Node&& condition_, Node&& then_, Node&& else_)
468{
469 return Node{ConditionalNode{}, std::forward<Node>(then_), std::forward<Node>(else_), std::forward<Node>(condition_)};
470}
471
472template <typename L>
473inline Node ifnode(Node&& condition_, Node&& then_, L else_) requires(std::is_arithmetic_v<L>)
474{
475 return Node{ConditionalNode{}, std::forward<Node>(then_), LiteralNode{else_}, std::forward<Node>(condition_)};
476}
477
478template <typename L>
479inline Node ifnode(Node&& condition_, L then_, Node&& else_) requires(std::is_arithmetic_v<L>)
480{
481 return Node{ConditionalNode{}, LiteralNode{then_}, std::forward<Node>(else_), std::forward<Node>(condition_)};
482}
483
484template <typename L1, typename L2>
485inline Node ifnode(Node&& condition_, L1 then_, L2 else_) requires(std::is_arithmetic_v<L1>&& std::is_arithmetic_v<L2>)
486{
487 return Node{ConditionalNode{}, LiteralNode{then_}, LiteralNode{else_}, std::forward<Node>(condition_)};
488}
489
490template <typename T>
491inline Node ifnode(Configurable<T> const& condition_, Node&& then_, Node&& else_)
492{
493 return Node{ConditionalNode{}, std::forward<Node>(then_), std::forward<Node>(else_), PlaceholderNode{condition_}};
494}
495
496template <typename L>
497inline Node ifnode(Node&& condition_, Node&& then_, Configurable<L> const& else_)
498{
499 return Node{ConditionalNode{}, std::forward<Node>(then_), PlaceholderNode{else_}, std::forward<Node>(condition_)};
500}
501
502template <typename L>
503inline Node ifnode(Node&& condition_, Configurable<L> const& then_, Node&& else_)
504{
505 return Node{ConditionalNode{}, PlaceholderNode{then_}, std::forward<Node>(else_), std::forward<Node>(condition_)};
506}
507
508template <typename L1, typename L2>
509inline Node ifnode(Node&& condition_, Configurable<L1> const& then_, Configurable<L2> const& else_)
510{
511 return Node{ConditionalNode{}, PlaceholderNode{then_}, PlaceholderNode{else_}, std::forward<Node>(condition_)};
512}
513
515inline Node par(int index)
516{
517 return Node{ParameterNode{index}};
518}
519
521template <typename T>
522inline Node binned(std::vector<T> const& binning, std::vector<T> const& parameters, Node&& binned, Node&& pexp, Node&& out)
523{
524 int bins = binning.size() - 1;
525 const auto binned_copy = binned;
526 const auto out_copy = out;
527 auto root = ifnode(Node{binned_copy} < binning[0], Node{out_copy}, LiteralNode{-1});
528 auto* current = &root;
529 for (auto i = 0; i < bins; ++i) {
530 current->right = std::make_unique<Node>(ifnode(Node{binned_copy} < binning[i + 1], updateParameters(pexp, bins, parameters, i), LiteralNode{-1}));
531 current = current->right.get();
532 }
533 current->right = std::make_unique<Node>(out);
534 return root;
535}
536
537template <typename T>
538inline Node updateParameters(Node const& pexp, int bins, std::vector<T> const& parameters, int bin)
539{
540 Node result{pexp};
541 walk(&result, [&bins, &parameters, &bin](Node* node) {
542 if (node->self.index() == 5) {
543 auto* n = std::get_if<5>(&node->self);
544 n->reset(parameters[n->index * bins + bin]);
545 }
546 });
547 return result;
548}
549
551template <typename T>
552inline Node clamp(Node&& expr, T low, T hi)
553{
554 auto copy = expr;
555 return ifnode(Node{copy} < LiteralNode{low}, LiteralNode{low}, ifnode(Node{copy} > LiteralNode{hi}, LiteralNode{hi}, Node{copy}));
556}
557
559inline Node protect0(Node&& expr)
560{
561 auto copy = expr;
563}
564
566struct Filter {
567 Filter() = default;
568
569 Filter(Node&& node_) : node{std::make_unique<Node>(std::forward<Node>(node_))}
570 {
572 }
573
574 Filter(Filter&& other) : node{std::forward<std::unique_ptr<Node>>(other.node)}
575 {
577 }
578
580 {
581 node = std::move(other.node);
582 return *this;
583 }
584
585 std::unique_ptr<Node> node = nullptr;
586
587 size_t designateSubtrees(Node* node, size_t index = 0);
588};
589
590template <typename T>
591concept is_filter = std::same_as<T, Filter>;
592
594
596gandiva::Selection createSelection(std::shared_ptr<arrow::Table> const& table, Filter const& expression);
598gandiva::Selection createSelection(std::shared_ptr<arrow::Table> const& table, std::shared_ptr<gandiva::Filter> const& gfilter);
599
601using Operations = std::vector<ColumnOperationSpec>;
602
604Operations createOperations(Filter const& expression);
605
607bool isTableCompatible(std::set<uint32_t> const& hashes, Operations const& specs);
609gandiva::NodePtr createExpressionTree(Operations const& opSpecs,
610 gandiva::SchemaPtr const& Schema);
612std::shared_ptr<gandiva::Filter> createFilter(gandiva::SchemaPtr const& Schema,
613 gandiva::ConditionPtr condition);
615std::shared_ptr<gandiva::Filter> createFilter(gandiva::SchemaPtr const& Schema,
616 Operations const& opSpecs);
618std::shared_ptr<gandiva::Projector> createProjector(gandiva::SchemaPtr const& Schema,
619 Operations const& opSpecs,
620 gandiva::FieldPtr result);
622std::shared_ptr<gandiva::Projector> createProjector(gandiva::SchemaPtr const& Schema,
623 Projector&& p,
624 gandiva::FieldPtr result);
626void updateExpressionInfos(expressions::Filter const& filter, std::vector<ExpressionInfo>& eInfos);
628gandiva::ConditionPtr makeCondition(gandiva::NodePtr node);
630gandiva::ExpressionPtr makeExpression(gandiva::NodePtr node, gandiva::FieldPtr result);
633
634std::shared_ptr<gandiva::Projector> createProjectorHelper(size_t nColumns, expressions::Projector* projectors,
635 std::shared_ptr<arrow::Schema> schema,
636 std::vector<std::shared_ptr<arrow::Field>> const& fields);
637
638template <typename... C>
639std::shared_ptr<gandiva::Projector> createProjectors(framework::pack<C...>, std::vector<std::shared_ptr<arrow::Field>> const& fields, gandiva::SchemaPtr schema)
640{
641 std::array<expressions::Projector, sizeof...(C)> projectors{{std::move(C::Projector())...}};
642
643 return createProjectorHelper(sizeof...(C), projectors.data(), schema, fields);
644}
645
646void updateFilterInfo(ExpressionInfo& info, std::shared_ptr<arrow::Table>& table);
647} // namespace o2::framework::expressions
648
649#endif // O2_FRAMEWORK_EXPRESSIONS_H_
const auto bins
Definition PID.cxx:49
#define SELECT_ARROW_TYPE(_Ctype_, _Atype_)
Definition Expressions.h:88
#define BINARY_FUNC_NODES(_func_, _node_)
arrow::Type atype
Definition Expressions.h:50
#define UNARY_FUNC_NODES(_func_, _node_)
unary functions on nodes
int32_t i
uint32_t op
useful math constants
uint32_t gfilter
Definition RawData.h:6
ConfigParamRegistry const & options()
Definition InitContext.h:33
GLdouble n
Definition glcorearb.h:1982
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
GLsizei const GLfloat * value
Definition glcorearb.h:819
GLint GLint GLsizei GLint GLenum GLenum type
Definition glcorearb.h:275
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition glcorearb.h:1308
GLsizei const GLchar *const * path
Definition glcorearb.h:3591
GLenum clamp
Definition glcorearb.h:1245
GLboolean r
Definition glcorearb.h:1233
std::shared_ptr< gandiva::Filter > FilterPtr
Definition Expressions.h:47
std::shared_ptr< gandiva::SelectionVector > Selection
Definition Expressions.h:46
constexpr float Almost0
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.
BINARY_OP_NODES && LogicalAnd
BINARY_OP_NODES & BitwiseAnd
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.
PlaceholderNode as(Configurable< T > const &v)
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.
constexpr auto selectArrowType()
Definition Expressions.h:83
Node par(int index)
Parameters.
Operations createOperations(Filter const &expression)
Function to create an internal operation sequence from a filter tree.
Node updateParameters(Node const &pexp, int bins, std::vector< T > const &parameters, int bin)
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.
void unknownParameterUsed(const char *name)
void walk(Node *head, L &&pred)
Tree-walker helper.
Node ifnode(Node &&condition_, Node &&then_, Node &&else_)
conditionals
gandiva::NodePtr createExpressionTree(Operations const &opSpecs, gandiva::SchemaPtr const &Schema)
Function to create gandiva expression tree from operation sequence.
Node binned(std::vector< T > const &binning, std::vector< T > const &parameters, Node &&binned, Node &&pexp, Node &&out)
binned functional
void updatePlaceholders(Filter &filter, InitContext &context)
Update placeholder nodes from context.
BINARY_OP_NODES^ BitwiseXor
BINARY_OP_NODES * Multiplication
Node protect0(Node &&expr)
division by 0 protector
Node npow(Node &&left, T right)
functions
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.
std::shared_ptr< gandiva::Projector > createProjectors(framework::pack< C... >, std::vector< std::shared_ptr< arrow::Field > > const &fields, gandiva::SchemaPtr schema)
void updateFilterInfo(ExpressionInfo &info, std::shared_ptr< arrow::Table > &table)
@ GreaterThanOrEqual
Definition BasicOps.h:29
constexpr VariantType variant_trait_v
Definition Variant.h:190
std::vector< int64_t > SelectionVector
Definition ASoA.h:411
Defining DataPointCompositeObject explicitly as copiable.
gandiva::Selection selection
Definition Expressions.h:65
gandiva::SchemaPtr schema
Definition Expressions.h:62
ExpressionInfo(int ai, size_t hash, std::set< uint32_t > &&hs, gandiva::SchemaPtr sc)
Definition Expressions.h:52
std::set< uint32_t > hashes
Definition Expressions.h:61
gandiva::NodePtr tree
Definition Expressions.h:63
size_t processHash
Definition Expressions.h:60
An expression tree node corresponding to a column binding.
constexpr BindingNode(const char *name_, uint32_t hash_, atype::type type_)
BindingNode(BindingNode const &)=default
A struct, containing the root of the expression tree.
Filter & operator=(Filter &&other) noexcept
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
LiteralNode(LiteralNode const &other)=default
helper struct used to parse trees
bool operator!=(NodeRecord const &rhs)
Node * node_ptr
pointer to the actual tree node
NodeRecord(Node *node_, size_t index_)
std::unique_ptr< Node > condition
std::unique_ptr< Node > right
std::variant< LiteralNode, BindingNode, OpNode, PlaceholderNode, ConditionalNode, ParameterNode > self_t
variant with possible nodes
Node(BindingNode const &n)
Node(OpNode op, Node &&l, Node &&r)
Node(ConditionalNode op, Node &&then_, Node &&else_, Node &&condition_)
An expression tree node corresponding to binary or unary operation.
OpNode(OpNode const &other)=default
A placeholder node for parameters taken from an array.
ParameterNode(ParameterNode const &)=default
void reset(T value_, int index_=-1)
A placeholder node for simple type configurable.
LiteralNode::var_t(* retrieve)(InitContext &, char const *)
PlaceholderNode(Configurable< T > const &v)
PlaceholderNode(PlaceholderNode const &other)=default
PlaceholderNode(Configurable< T > const &v, AT *)
VectorOfTObjectPtrs other