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::PredicateFactoringRule Class Reference

The Predicate Factoring rule extracts predicates on a common column from disjunctive or conjunctive clauses. More...

Inheritance diagram for duckdb::PredicateFactoringRule:
Collaboration diagram for duckdb::PredicateFactoringRule:

Public Member Functions

 PredicateFactoringRule (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.

Detailed Description

The Predicate Factoring rule extracts predicates on a common column from disjunctive or conjunctive clauses.

Constructor & Destructor Documentation

◆ PredicateFactoringRule()

duckdb::PredicateFactoringRule::PredicateFactoringRule ( ExpressionRewriter & rewriter)
explicit
321785 : Rule(rewriter) {
321786 // Match on a ConjunctionExpression that has at least one ConjunctionExpression as a child
321787 auto op = make_uniq<ConjunctionExpressionMatcher>();
321788 op->matchers.push_back(make_uniq<ConjunctionExpressionMatcher>());
321789 op->policy = SetMatcher::Policy::SOME;
321790 root = std::move(op);
321791}
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
@ SOME
Only some entries have to be matched, the order of the matches does not matter.
Definition duckdb.cpp:69125

Member Function Documentation

◆ Apply()

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

Implements duckdb::Rule.

321907 {
321908 // Only applies to top-level FILTER expressions
321909 if ((op.type != LogicalOperatorType::LOGICAL_FILTER && op.type != LogicalOperatorType::LOGICAL_ANY_JOIN) ||
321910 !is_root) {
321911 return nullptr;
321912 }
321913
321914 // The expression must be an OR TODO: could also implement some common expression extraction for AND
321915 if (!ExpressionIsDisjunction(bindings[0])) {
321916 return nullptr;
321917 }
321918
321919 ColumnBinding column_binding;
321920 if (GetSingleColumnBinding(bindings[0], column_binding)) {
321921 return nullptr; // If it only applies to one column binding it can be pushed down already
321922 }
321923
321924 // Extract map from single column binding to expression it is contained in
321925 const auto binding_map = GetDisjunctedPredicateMap(bindings[0].get());
321926 if (binding_map.empty()) {
321927 return nullptr; // None qualify
321928 }
321929
321930 unique_ptr<Expression> derived_filter;
321931 for (auto &entry : binding_map) {
321932 D_ASSERT(!entry.second.empty());
321933
321934 // Create disjunction on single-column predicates
321935 unique_ptr<Expression> column_filter;
321936 for (auto &expr : entry.second) {
321937 if (!column_filter) {
321938 column_filter = expr.get().Copy();
321939 } else {
321940 auto new_disjunction = make_uniq<BoundConjunctionExpression>(ExpressionType::CONJUNCTION_OR);
321941 new_disjunction->children.push_back(std::move(column_filter));
321942 new_disjunction->children.push_back(expr.get().Copy());
321943 column_filter = std::move(new_disjunction);
321944 }
321945 }
321946
321947 // Conjunct each single-column predicate together
321948 if (!derived_filter) {
321949 derived_filter = std::move(column_filter);
321950 } else {
321951 auto new_conjunction = make_uniq<BoundConjunctionExpression>(ExpressionType::CONJUNCTION_AND);
321952 new_conjunction->children.push_back(std::move(column_filter));
321953 new_conjunction->children.push_back(std::move(derived_filter));
321954 derived_filter = std::move(new_conjunction);
321955 }
321956 }
321957
321958 // Now add the derived filter as an AND to the original expression
321959 auto result = make_uniq<BoundConjunctionExpression>(ExpressionType::CONJUNCTION_AND);
321960 result->children.push_back(bindings[0].get().Copy());
321961 result->children.push_back(std::move(derived_filter));
321962 return std::move(result);
321963}
__host__ cudaTextureObject_t get() const noexcept

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