Removes unused Rc in PlanNode

pull/171/head
Tpt 3 years ago
parent 57123ed42c
commit 4453235b90
  1. 40
      lib/src/sparql/plan.rs
  2. 52
      lib/src/sparql/plan_builder.rs

@ -14,7 +14,7 @@ pub enum PlanNode {
Service {
service_name: PatternValue,
variables: Rc<Vec<Variable>>,
child: Rc<Self>,
child: Box<Self>,
graph_pattern: Rc<GraphPattern>,
silent: bool,
},
@ -32,59 +32,59 @@ pub enum PlanNode {
},
/// Streams left and materializes right join
HashJoin {
left: Rc<Self>,
right: Rc<Self>,
left: Box<Self>,
right: Box<Self>,
},
/// Right nested in left loop
ForLoopJoin {
left: Rc<Self>,
right: Rc<Self>,
left: Box<Self>,
right: Box<Self>,
},
/// Streams left and materializes right anti join
AntiJoin {
left: Rc<Self>,
right: Rc<Self>,
left: Box<Self>,
right: Box<Self>,
},
Filter {
child: Rc<Self>,
expression: Rc<PlanExpression>,
child: Box<Self>,
expression: Box<PlanExpression>,
},
Union {
children: Vec<Rc<Self>>,
children: Vec<Self>,
},
/// right nested in left loop
LeftJoin {
left: Rc<Self>,
right: Rc<Self>,
left: Box<Self>,
right: Box<Self>,
possible_problem_vars: Rc<Vec<usize>>, //Variables that should not be part of the entry of the left join
},
Extend {
child: Rc<Self>,
child: Box<Self>,
position: usize,
expression: Rc<PlanExpression>,
expression: Box<PlanExpression>,
},
Sort {
child: Rc<Self>,
child: Box<Self>,
by: Vec<Comparator>,
},
HashDeduplicate {
child: Rc<Self>,
child: Box<Self>,
},
Skip {
child: Rc<Self>,
child: Box<Self>,
count: usize,
},
Limit {
child: Rc<Self>,
child: Box<Self>,
count: usize,
},
Project {
child: Rc<Self>,
child: Box<Self>,
mapping: Rc<Vec<(usize, usize)>>, // pairs of (variable key in child, variable key in output)
},
Aggregate {
// By definition the group by key are the range 0..key_mapping.len()
child: Rc<Self>,
child: Box<Self>,
key_mapping: Rc<Vec<(usize, usize)>>, // aggregate key pairs of (variable key in child, variable key in output)
aggregates: Rc<Vec<(PlanAggregation, usize)>>,
},

@ -53,8 +53,8 @@ impl<'a> PlanBuilder<'a> {
graph_name: graph_name.clone(),
})
.reduce(|left, right| PlanNode::ForLoopJoin {
left: Rc::new(left),
right: Rc::new(right),
left: Box::new(left),
right: Box::new(right),
})
.unwrap_or_else(|| PlanNode::StaticBindings {
tuples: vec![EncodedTuple::with_capacity(variables.len())],
@ -81,13 +81,13 @@ impl<'a> PlanBuilder<'a> {
.is_some()
{
PlanNode::ForLoopJoin {
left: Rc::new(left),
right: Rc::new(right),
left: Box::new(left),
right: Box::new(right),
}
} else {
PlanNode::HashJoin {
left: Rc::new(left),
right: Rc::new(right),
left: Box::new(left),
right: Box::new(right),
}
}
}
@ -105,8 +105,8 @@ impl<'a> PlanBuilder<'a> {
//We add the extra filter if needed
let right = if let Some(expr) = expression {
PlanNode::Filter {
child: Rc::new(right),
expression: Rc::new(
child: Box::new(right),
expression: Box::new(
self.build_for_expression(expr, variables, graph_name)?,
),
}
@ -115,14 +115,14 @@ impl<'a> PlanBuilder<'a> {
};
PlanNode::LeftJoin {
left: Rc::new(left),
right: Rc::new(right),
left: Box::new(left),
right: Box::new(right),
possible_problem_vars: Rc::new(possible_problem_vars.into_iter().collect()),
}
}
GraphPattern::Filter { expr, inner } => PlanNode::Filter {
child: Rc::new(self.build_for_graph_pattern(inner, variables, graph_name)?),
expression: Rc::new(self.build_for_expression(expr, variables, graph_name)?),
child: Box::new(self.build_for_graph_pattern(inner, variables, graph_name)?),
expression: Box::new(self.build_for_expression(expr, variables, graph_name)?),
},
GraphPattern::Union { left, right } => {
//We flatten the UNIONs
@ -135,9 +135,9 @@ impl<'a> PlanBuilder<'a> {
stack.push(left);
stack.push(right);
}
Some(p) => children.push(Rc::new(
self.build_for_graph_pattern(p, variables, graph_name)?,
)),
Some(p) => {
children.push(self.build_for_graph_pattern(p, variables, graph_name)?)
}
}
}
PlanNode::Union { children }
@ -151,13 +151,13 @@ impl<'a> PlanBuilder<'a> {
variable,
expression,
} => PlanNode::Extend {
child: Rc::new(self.build_for_graph_pattern(inner, variables, graph_name)?),
child: Box::new(self.build_for_graph_pattern(inner, variables, graph_name)?),
position: variable_key(variables, variable),
expression: Rc::new(self.build_for_expression(expression, variables, graph_name)?),
expression: Box::new(self.build_for_expression(expression, variables, graph_name)?),
},
GraphPattern::Minus { left, right } => PlanNode::AntiJoin {
left: Rc::new(self.build_for_graph_pattern(left, variables, graph_name)?),
right: Rc::new(self.build_for_graph_pattern(right, variables, graph_name)?),
left: Box::new(self.build_for_graph_pattern(left, variables, graph_name)?),
right: Box::new(self.build_for_graph_pattern(right, variables, graph_name)?),
},
GraphPattern::Service {
name,
@ -175,7 +175,7 @@ impl<'a> PlanBuilder<'a> {
.map(|v| OxVariable::new_unchecked(v.name.clone()))
.collect(),
),
child: Rc::new(child),
child: Box::new(child),
graph_pattern: Rc::new(inner.as_ref().clone()),
silent: *silent,
}
@ -190,7 +190,7 @@ impl<'a> PlanBuilder<'a> {
self.convert_pattern_value_id(graph_name, variables, &mut inner_variables);
PlanNode::Aggregate {
child: Rc::new(self.build_for_graph_pattern(
child: Box::new(self.build_for_graph_pattern(
inner,
&mut inner_variables,
&inner_graph_name,
@ -237,7 +237,7 @@ impl<'a> PlanBuilder<'a> {
})
.collect();
PlanNode::Sort {
child: Rc::new(self.build_for_graph_pattern(inner, variables, graph_name)?),
child: Box::new(self.build_for_graph_pattern(inner, variables, graph_name)?),
by: condition?,
}
}
@ -249,7 +249,7 @@ impl<'a> PlanBuilder<'a> {
let inner_graph_name =
self.convert_pattern_value_id(graph_name, variables, &mut inner_variables);
PlanNode::Project {
child: Rc::new(self.build_for_graph_pattern(
child: Box::new(self.build_for_graph_pattern(
inner,
&mut inner_variables,
&inner_graph_name,
@ -266,7 +266,7 @@ impl<'a> PlanBuilder<'a> {
}
}
GraphPattern::Distinct { inner } => PlanNode::HashDeduplicate {
child: Rc::new(self.build_for_graph_pattern(inner, variables, graph_name)?),
child: Box::new(self.build_for_graph_pattern(inner, variables, graph_name)?),
},
GraphPattern::Reduced { inner } => {
self.build_for_graph_pattern(inner, variables, graph_name)?
@ -279,13 +279,13 @@ impl<'a> PlanBuilder<'a> {
let mut plan = self.build_for_graph_pattern(inner, variables, graph_name)?;
if *start > 0 {
plan = PlanNode::Skip {
child: Rc::new(plan),
child: Box::new(plan),
count: *start,
};
}
if let Some(length) = length {
plan = PlanNode::Limit {
child: Rc::new(plan),
child: Box::new(plan),
count: *length,
};
}

Loading…
Cancel
Save