Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
duckdb::ConstantFoldingRule Class Reference
Inheritance diagram for duckdb::ConstantFoldingRule:
Collaboration diagram for duckdb::ConstantFoldingRule:

Public Member Functions

 ConstantFoldingRule (ExpressionRewriter &rewriter)
unique_ptr< Expression > Apply (LogicalOperator &op, vector< reference< Expression > > &bindings, bool &changes_made, bool is_root) override
Public Member Functions inherited from duckdb::Rule
 Rule (ExpressionRewriter &rewriter)
ClientContext & GetContext () const

Additional Inherited Members

Public Attributes inherited from duckdb::Rule
ExpressionRewriter & rewriter
 The expression rewriter this rule belongs to.
unique_ptr< ExpressionMatcher > root
 The expression matcher of the rule.

Constructor & Destructor Documentation

◆ ConstantFoldingRule()

duckdb::ConstantFoldingRule::ConstantFoldingRule ( ExpressionRewriter & rewriter)
explicit
319977 : Rule(rewriter) {
319978 auto op = make_uniq<ConstantFoldingExpressionMatcher>();
319979 root = std::move(op);
319980}
ExpressionRewriter & rewriter
The expression rewriter this rule belongs to.
Definition duckdb.cpp:69564
unique_ptr< ExpressionMatcher > root
The expression matcher of the rule.
Definition duckdb.cpp:69566

Member Function Documentation

◆ Apply()

unique_ptr< Expression > duckdb::ConstantFoldingRule::Apply ( LogicalOperator & op,
vector< reference< Expression > > & bindings,
bool & changes_made,
bool is_root )
overridevirtual

Implements duckdb::Rule.

319983 {
319984 auto &root = bindings[0].get();
319985 // the root is a scalar expression that we have to fold
319986 D_ASSERT(root.IsFoldable() && root.GetExpressionType() != ExpressionType::VALUE_CONSTANT);
319987
319988 // use an ExpressionExecutor to execute the expression
319989 Value result_value;
319990 if (!ExpressionExecutor::TryEvaluateScalar(GetContext(), root, result_value)) {
319991 return nullptr;
319992 }
319993 D_ASSERT(result_value.type().InternalType() == root.return_type.InternalType());
319994 // now get the value from the result vector and insert it back into the plan as a constant expression
319995 return make_uniq<BoundConstantExpression>(result_value);
319996}
static DUCKDB_API bool TryEvaluateScalar(ClientContext &context, const Expression &expr, Value &result)
Try to evaluate a scalar expression and fold it into a single value, returns false if an exception is...
Definition duckdb.cpp:150008

The documentation for this class was generated from the following file: