5#include <unordered_map>
6#include <unordered_set>
20using expression_pair = std::pair<std::shared_ptr<Expression>, std::shared_ptr<Expression>>;
31 friend class ExpressionChildrenCollector;
36 : expressionType{expressionType}, dataType{std::move(dataType)},
37 uniqueName{std::move(uniqueName)}, children{std::move(children)} {}
40 const std::shared_ptr<Expression>& left,
const std::shared_ptr<Expression>& right,
41 std::string uniqueName)
43 std::move(uniqueName)} {}
46 const std::shared_ptr<Expression>& child, std::string uniqueName)
48 std::move(uniqueName)} {}
51 std::string uniqueName)
53 std::move(uniqueName)} {}
66 void setAlias(
const std::string& newAlias) { alias = newAlias; }
67 bool hasAlias()
const {
return !alias.empty(); }
78 children[idx] = std::move(child);
85 std::string
toString()
const {
return hasAlias() ? alias : toStringInternal(); }
87 virtual std::unique_ptr<Expression>
copy()
const {
91 template<
class TARGET>
93 return common::ku_dynamic_cast<TARGET&>(*
this);
95 template<
class TARGET>
97 return common::ku_dynamic_cast<TARGET*>(
this);
99 template<
class TARGET>
101 return common::ku_dynamic_cast<const TARGET&>(*
this);
103 template<
class TARGET>
105 return common::ku_dynamic_cast<const TARGET*>(
this);
123 std::size_t
operator()(
const std::shared_ptr<Expression>& expression)
const {
124 return std::hash<std::string>{}(expression->getUniqueName());
130 const std::shared_ptr<Expression>& right)
const {
131 return left->getUniqueName() == right->getUniqueName();
#define KUZU_API
Definition api.h:25
#define KU_ASSERT(condition)
Definition assert.h:19
Definition expression.h:30
const TARGET * constPtrCast() const
Definition expression.h:104
bool operator==(const Expression &rhs) const
Definition expression.h:83
std::string uniqueName
Definition expression.h:117
std::string toString() const
Definition expression.h:85
expression_vector splitOnAND()
const common::LogicalType & getDataType() const
Definition expression.h:64
void setAlias(const std::string &newAlias)
Definition expression.h:66
std::shared_ptr< Expression > getChild(common::idx_t idx) const
Definition expression.h:71
common::ExpressionType expressionType
Definition expression.h:112
const TARGET & constCast() const
Definition expression.h:100
std::string getUniqueName() const
Definition expression.h:58
expression_vector children
Definition expression.h:119
virtual std::unique_ptr< Expression > copy() const
Definition expression.h:87
TARGET * ptrCast()
Definition expression.h:96
void setChild(common::idx_t idx, std::shared_ptr< Expression > child)
Definition expression.h:76
virtual ~Expression()=default
bool hasAlias() const
Definition expression.h:67
std::string getAlias() const
Definition expression.h:68
virtual std::string toStringInternal() const =0
common::idx_t getNumChildren() const
Definition expression.h:70
expression_vector getChildren() const
Definition expression.h:75
DELETE_COPY_DEFAULT_MOVE(Expression)
Expression(common::ExpressionType expressionType, common::LogicalType dataType, expression_vector children, std::string uniqueName)
Definition expression.h:34
void setUniqueName(const std::string &name)
Definition expression.h:57
virtual void cast(const common::LogicalType &type)
common::LogicalType dataType
Definition expression.h:113
std::string alias
Definition expression.h:118
TARGET & cast()
Definition expression.h:92
Expression(common::ExpressionType expressionType, common::LogicalType dataType, const std::shared_ptr< Expression > &left, const std::shared_ptr< Expression > &right, std::string uniqueName)
Definition expression.h:39
Expression(common::ExpressionType expressionType, common::LogicalType dataType, std::string uniqueName)
Definition expression.h:50
Expression(common::ExpressionType expressionType, common::LogicalType dataType, const std::shared_ptr< Expression > &child, std::string uniqueName)
Definition expression.h:45
std::unordered_map< std::shared_ptr< Expression >, T, ExpressionHasher, ExpressionEquality > expression_map
Definition expression.h:27
std::unordered_set< std::shared_ptr< Expression >, ExpressionHasher, ExpressionEquality > expression_set
Definition expression.h:24
std::pair< std::shared_ptr< Expression >, std::shared_ptr< Expression > > expression_pair
Definition expression.h:20
std::vector< std::shared_ptr< Expression > > expression_vector
Definition expression.h:19
uint32_t idx_t
Definition types.h:44
ExpressionType
Definition expression_type.h:9
Definition array_utils.h:7
Definition expression.h:128
bool operator()(const std::shared_ptr< Expression > &left, const std::shared_ptr< Expression > &right) const
Definition expression.h:129
Definition expression.h:122
std::size_t operator()(const std::shared_ptr< Expression > &expression) const
Definition expression.h:123