|
|
@ -12,11 +12,12 @@ pub enum PlanNode { |
|
|
|
StaticBindings { |
|
|
|
StaticBindings { |
|
|
|
tuples: Vec<EncodedTuple>, |
|
|
|
tuples: Vec<EncodedTuple>, |
|
|
|
}, |
|
|
|
}, |
|
|
|
TriplePatternJoin { |
|
|
|
QuadPatternJoin { |
|
|
|
child: Box<PlanNode>, |
|
|
|
child: Box<PlanNode>, |
|
|
|
subject: PatternValue, |
|
|
|
subject: PatternValue, |
|
|
|
predicate: PatternValue, |
|
|
|
predicate: PatternValue, |
|
|
|
object: PatternValue, |
|
|
|
object: PatternValue, |
|
|
|
|
|
|
|
graph_name: Option<PatternValue>, |
|
|
|
}, |
|
|
|
}, |
|
|
|
Filter { |
|
|
|
Filter { |
|
|
|
child: Box<PlanNode>, |
|
|
|
child: Box<PlanNode>, |
|
|
@ -162,6 +163,7 @@ impl<'a, S: EncodedQuadsStore> PlanBuilder<'a, S> { |
|
|
|
pattern, |
|
|
|
pattern, |
|
|
|
PlanNode::Init, |
|
|
|
PlanNode::Init, |
|
|
|
&mut variables, |
|
|
|
&mut variables, |
|
|
|
|
|
|
|
None, |
|
|
|
)?; |
|
|
|
)?; |
|
|
|
Ok((plan, variables)) |
|
|
|
Ok((plan, variables)) |
|
|
|
} |
|
|
|
} |
|
|
@ -171,13 +173,14 @@ impl<'a, S: EncodedQuadsStore> PlanBuilder<'a, S> { |
|
|
|
pattern: &GraphPattern, |
|
|
|
pattern: &GraphPattern, |
|
|
|
input: PlanNode, |
|
|
|
input: PlanNode, |
|
|
|
variables: &mut Vec<Variable>, |
|
|
|
variables: &mut Vec<Variable>, |
|
|
|
|
|
|
|
graph_name: Option<PatternValue>, |
|
|
|
) -> Result<PlanNode> { |
|
|
|
) -> Result<PlanNode> { |
|
|
|
Ok(match pattern { |
|
|
|
Ok(match pattern { |
|
|
|
GraphPattern::BGP(p) => { |
|
|
|
GraphPattern::BGP(p) => { |
|
|
|
let mut plan = input; |
|
|
|
let mut plan = input; |
|
|
|
for pattern in p { |
|
|
|
for pattern in p { |
|
|
|
plan = match pattern { |
|
|
|
plan = match pattern { |
|
|
|
TripleOrPathPattern::Triple(pattern) => PlanNode::TriplePatternJoin { |
|
|
|
TripleOrPathPattern::Triple(pattern) => PlanNode::QuadPatternJoin { |
|
|
|
child: Box::new(plan), |
|
|
|
child: Box::new(plan), |
|
|
|
subject: self |
|
|
|
subject: self |
|
|
|
.pattern_value_from_term_or_variable(&pattern.subject, variables)?, |
|
|
|
.pattern_value_from_term_or_variable(&pattern.subject, variables)?, |
|
|
@ -187,6 +190,7 @@ impl<'a, S: EncodedQuadsStore> PlanBuilder<'a, S> { |
|
|
|
)?, |
|
|
|
)?, |
|
|
|
object: self |
|
|
|
object: self |
|
|
|
.pattern_value_from_term_or_variable(&pattern.object, variables)?, |
|
|
|
.pattern_value_from_term_or_variable(&pattern.object, variables)?, |
|
|
|
|
|
|
|
graph_name, |
|
|
|
}, |
|
|
|
}, |
|
|
|
TripleOrPathPattern::Path(pattern) => unimplemented!(), |
|
|
|
TripleOrPathPattern::Path(pattern) => unimplemented!(), |
|
|
|
} |
|
|
|
} |
|
|
@ -195,12 +199,13 @@ impl<'a, S: EncodedQuadsStore> PlanBuilder<'a, S> { |
|
|
|
} |
|
|
|
} |
|
|
|
GraphPattern::Join(a, b) => self.build_for_graph_pattern( |
|
|
|
GraphPattern::Join(a, b) => self.build_for_graph_pattern( |
|
|
|
b, |
|
|
|
b, |
|
|
|
self.build_for_graph_pattern(a, input, variables)?, |
|
|
|
self.build_for_graph_pattern(a, input, variables, graph_name)?, |
|
|
|
variables, |
|
|
|
variables, |
|
|
|
|
|
|
|
graph_name, |
|
|
|
)?, |
|
|
|
)?, |
|
|
|
GraphPattern::LeftJoin(a, b, e) => unimplemented!(), |
|
|
|
GraphPattern::LeftJoin(a, b, e) => unimplemented!(), |
|
|
|
GraphPattern::Filter(e, p) => PlanNode::Filter { |
|
|
|
GraphPattern::Filter(e, p) => PlanNode::Filter { |
|
|
|
child: Box::new(self.build_for_graph_pattern(p, input, variables)?), |
|
|
|
child: Box::new(self.build_for_graph_pattern(p, input, variables, graph_name)?), |
|
|
|
expression: self.build_for_expression(e, variables)?, |
|
|
|
expression: self.build_for_expression(e, variables)?, |
|
|
|
}, |
|
|
|
}, |
|
|
|
GraphPattern::Union(a, b) => { |
|
|
|
GraphPattern::Union(a, b) => { |
|
|
@ -218,6 +223,7 @@ impl<'a, S: EncodedQuadsStore> PlanBuilder<'a, S> { |
|
|
|
a, |
|
|
|
a, |
|
|
|
PlanNode::Init, |
|
|
|
PlanNode::Init, |
|
|
|
variables, |
|
|
|
variables, |
|
|
|
|
|
|
|
graph_name, |
|
|
|
)?), |
|
|
|
)?), |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -226,9 +232,12 @@ impl<'a, S: EncodedQuadsStore> PlanBuilder<'a, S> { |
|
|
|
children, |
|
|
|
children, |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
GraphPattern::Graph(g, p) => unimplemented!(), |
|
|
|
GraphPattern::Graph(g, p) => { |
|
|
|
|
|
|
|
let graph_name = self.pattern_value_from_named_node_or_variable(g, variables)?; |
|
|
|
|
|
|
|
self.build_for_graph_pattern(p, input, variables, Some(graph_name))? |
|
|
|
|
|
|
|
} |
|
|
|
GraphPattern::Extend(p, v, e) => PlanNode::Extend { |
|
|
|
GraphPattern::Extend(p, v, e) => PlanNode::Extend { |
|
|
|
child: Box::new(self.build_for_graph_pattern(p, input, variables)?), |
|
|
|
child: Box::new(self.build_for_graph_pattern(p, input, variables, graph_name)?), |
|
|
|
position: variable_key(variables, &v), |
|
|
|
position: variable_key(variables, &v), |
|
|
|
expression: self.build_for_expression(e, variables)?, |
|
|
|
expression: self.build_for_expression(e, variables)?, |
|
|
|
}, |
|
|
|
}, |
|
|
@ -238,12 +247,15 @@ impl<'a, S: EncodedQuadsStore> PlanBuilder<'a, S> { |
|
|
|
GraphPattern::Data(bs) => PlanNode::StaticBindings { |
|
|
|
GraphPattern::Data(bs) => PlanNode::StaticBindings { |
|
|
|
tuples: self.encode_bindings(bs, variables)?, |
|
|
|
tuples: self.encode_bindings(bs, variables)?, |
|
|
|
}, |
|
|
|
}, |
|
|
|
GraphPattern::OrderBy(l, o) => self.build_for_graph_pattern(l, input, variables)?, //TODO
|
|
|
|
GraphPattern::OrderBy(l, o) => { |
|
|
|
|
|
|
|
self.build_for_graph_pattern(l, input, variables, graph_name)? |
|
|
|
|
|
|
|
} //TODO
|
|
|
|
GraphPattern::Project(l, new_variables) => PlanNode::Project { |
|
|
|
GraphPattern::Project(l, new_variables) => PlanNode::Project { |
|
|
|
child: Box::new(self.build_for_graph_pattern( |
|
|
|
child: Box::new(self.build_for_graph_pattern( |
|
|
|
l, |
|
|
|
l, |
|
|
|
input, |
|
|
|
input, |
|
|
|
&mut new_variables.clone(), |
|
|
|
&mut new_variables.clone(), |
|
|
|
|
|
|
|
graph_name, |
|
|
|
)?), |
|
|
|
)?), |
|
|
|
mapping: new_variables |
|
|
|
mapping: new_variables |
|
|
|
.iter() |
|
|
|
.iter() |
|
|
@ -251,11 +263,13 @@ impl<'a, S: EncodedQuadsStore> PlanBuilder<'a, S> { |
|
|
|
.collect(), |
|
|
|
.collect(), |
|
|
|
}, |
|
|
|
}, |
|
|
|
GraphPattern::Distinct(l) => PlanNode::HashDeduplicate { |
|
|
|
GraphPattern::Distinct(l) => PlanNode::HashDeduplicate { |
|
|
|
child: Box::new(self.build_for_graph_pattern(l, input, variables)?), |
|
|
|
child: Box::new(self.build_for_graph_pattern(l, input, variables, graph_name)?), |
|
|
|
}, |
|
|
|
}, |
|
|
|
GraphPattern::Reduced(l) => self.build_for_graph_pattern(l, input, variables)?, |
|
|
|
GraphPattern::Reduced(l) => { |
|
|
|
|
|
|
|
self.build_for_graph_pattern(l, input, variables, graph_name)? |
|
|
|
|
|
|
|
} |
|
|
|
GraphPattern::Slice(l, start, length) => { |
|
|
|
GraphPattern::Slice(l, start, length) => { |
|
|
|
let mut plan = self.build_for_graph_pattern(l, input, variables)?; |
|
|
|
let mut plan = self.build_for_graph_pattern(l, input, variables, graph_name)?; |
|
|
|
if *start > 0 { |
|
|
|
if *start > 0 { |
|
|
|
plan = PlanNode::Skip { |
|
|
|
plan = PlanNode::Skip { |
|
|
|
child: Box::new(plan), |
|
|
|
child: Box::new(plan), |
|
|
|