Project
Loading...
Searching...
No Matches
ExpressionHelpers.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_HELPERS_H_
12#define O2_FRAMEWORK_EXPRESSIONS_HELPERS_H_
14
15#include <iosfwd>
16#include <fmt/format.h>
17
19{
20
21struct DatumSpec {
23 using datum_t = std::variant<std::monostate, size_t, LiteralNode::var_t, std::string>;
24 datum_t datum = std::monostate{};
25 size_t hash = 0;
26 atype::type type = atype::NA;
27
28 explicit constexpr DatumSpec(size_t index, atype::type type_) : datum{index}, type{type_} {}
29 explicit constexpr DatumSpec(LiteralNode::var_t literal, atype::type type_) : datum{literal}, type{type_} {}
30 explicit constexpr DatumSpec(std::string binding, size_t hash_, atype::type type_) : datum{binding}, hash{hash_}, type{type_} {}
31 DatumSpec() = default;
32 DatumSpec(DatumSpec const&) = default;
33 DatumSpec(DatumSpec&&) = default;
34 DatumSpec& operator=(DatumSpec const&) = default;
36
37 bool operator==(DatumSpec const& rhs) const
38 {
39 bool eqValue = this->datum == rhs.datum;
40 bool eqHash = true;
41 if (this->datum.index() == 3 && eqValue) {
42 eqHash = this->hash == rhs.hash;
43 }
44 bool eqType = this->type == rhs.type;
45 return eqValue && eqHash && eqType;
46 }
47};
48
49std::ostream& operator<<(std::ostream& os, DatumSpec const& spec);
50
52 size_t index = 0;
58 atype::type type = atype::NA;
60 explicit ColumnOperationSpec(BasicOp op_, size_t index_ = 0)
61 : index{index_},
62 op{op_},
63 left{},
64 right{},
65 condition{},
66 result{}
67 {
68 switch (op) {
75 case BasicOp::Equal:
77 type = atype::BOOL;
78 break;
80 type = atype::FLOAT;
81 default:
82 type = atype::NA;
83 }
85 }
86};
87} // namespace o2::framework::expressions
88
89#endif // O2_FRAMEWORK_EXPRESSIONS_HELPERS_H_
GLuint64EXT * result
Definition glcorearb.h:5662
GLuint index
Definition glcorearb.h:781
GLdouble GLdouble right
Definition glcorearb.h:4077
GLint GLint GLsizei GLint GLenum GLenum type
Definition glcorearb.h:275
std::ostream & operator<<(std::ostream &os, DatumSpec const &spec)
@ GreaterThanOrEqual
Definition BasicOps.h:29
ColumnOperationSpec(BasicOp op_, size_t index_=0)
DatumSpec & operator=(DatumSpec &&)=default
bool operator==(DatumSpec const &rhs) const
constexpr DatumSpec(std::string binding, size_t hash_, atype::type type_)
std::variant< std::monostate, size_t, LiteralNode::var_t, std::string > datum_t
datum spec either contains an index, a value of a literal or a binding label
DatumSpec & operator=(DatumSpec const &)=default
DatumSpec(DatumSpec const &)=default
constexpr DatumSpec(size_t index, atype::type type_)
constexpr DatumSpec(LiteralNode::var_t literal, atype::type type_)
LiteralValue::stored_type var_t