Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP/TODO] RelNode/RexNode (PlanNode/PredNode) separation + more refactors #193

Closed
wants to merge 53 commits into from

Conversation

jurplel
Copy link
Member

@jurplel jurplel commented Oct 27, 2024

No description provided.

@jurplel jurplel changed the title [WIP/TODO] RexNode/RelNode (PlanNode/PredNode) separation + more refactors [WIP/TODO] RelNode/RexNode (PlanNode/PredNode) separation + more refactors Oct 28, 2024
@skyzh skyzh changed the base branch from bowad/core-hacking to main November 4, 2024 02:26
@skyzh skyzh changed the base branch from main to bowad/core-hacking November 4, 2024 02:27
@skyzh skyzh changed the base branch from bowad/core-hacking to main November 4, 2024 23:24
skyzh added a commit that referenced this pull request Nov 5, 2024
Extracted from #193, this patch adds
predicate to the relnode and refactors the memo table to store the
predicates. Minimum changes are done to the df-repr to ensure it still
works.

Follow-ups:
* Rename RelNode -> PlanNode
* Rename RelNodeTyp -> PlanNodeTyp
* Refactor RelNode to store RelNodeOrGroup
* Remove `data` from RelNode

Signed-off-by: Alex Chi <[email protected]>
Co-authored-by: Benjamin O <[email protected]>
jurplel and others added 13 commits November 5, 2024 10:47
Seeking design feedback.

Implemented on `eliminate_limit`, not tested with anything yet.

Example expansion:
```rs
define_rule!(
    EliminateLimitRule,
    apply_eliminate_limit,
    (Limit, [child], [skip, fetch])
);
```
->
```rs
// Recursive expansion of define_rule! macro
// ==========================================

pub struct EliminateLimitRule {
    matcher:RuleMatcher<DfNodeType>,
}
impl EliminateLimitRule {
    pub fn new() -> Self {
        #[allow(unused_imports)]
        use DfNodeType::*;
        let mut pick_num = 0;
        let matcher = RuleMatcher::MatchNode {
            typ:Limit,children:(<[_]>::into_vec(#[rustc_box]
            alloc::boxed::Box::new([(RuleMatcher::PickOne {
                pick_to:{
                    let x = pick_num;
                    pick_num+=1;
                    x
                },
            })]))),predicates:(<[_]>::into_vec(#[rustc_box]
            alloc::boxed::Box::new([(RuleMatcher::PickPred),(RuleMatcher::PickPred)]))),
        };
        let _ = pick_num;
        Self {
            matcher
        }
    }

    }
pub struct EliminateLimitRulePicks {
    pub child:PlanNodeOrGroup<DfNodeType>,pub skip:ArcPredNode<DfNodeType>,pub fetch:ArcPredNode<DfNodeType>,
}
impl <O:Optimizer<DfNodeType>>Rule<DfNodeType,O>for EliminateLimitRule {
    fn matcher(&self) ->  &RuleMatcher<DfNodeType>{
        &self.matcher
    }
    fn apply(&self,optimizer: &O,mut input:HashMap<usize,PlanNodeOrGroup<DfNodeType>>,mut pred_input:HashMap<usize,ArcPredNode<DfNodeType>>,) -> Vec<PlanNode<DfNodeType>>{
        let child:PlanNodeOrGroup<DfNodeType>;
        ;
        let skip:ArcPredNode<DfNodeType>;
        ;
        let fetch:ArcPredNode<DfNodeType>;
        ;
        ;
        let mut pick_num = 0;
        let mut pred_pick_num = 0;
        {
            child = input.remove(&pick_num).unwrap();
            pick_num+=1;
        };
        {
            skip = pred_input.remove(&pred_pick_num).unwrap();
            pred_pick_num+=1;
        };
        {
            fetch = pred_input.remove(&pred_pick_num).unwrap();
            pred_pick_num+=1;
        };
        ;
        let res;
        res = pub struct EliminateLimitRulePicks {
            child,skip,fetch,
        };
        let _ = pick_num;
        apply_eliminate_limit(optimizer,res)
    }
    fn name(&self) ->  &'static str {
        "eliminate_limit_rule"
    }
    fn is_impl_rule(&self) -> bool {
        false
    }

    }
 ```
@skyzh skyzh closed this Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants