|
|
@ -4,6 +4,7 @@ use sparql::algebra::*; |
|
|
|
use std::collections::BTreeSet; |
|
|
|
use std::collections::BTreeSet; |
|
|
|
use store::encoded::EncodedQuadsStore; |
|
|
|
use store::encoded::EncodedQuadsStore; |
|
|
|
use store::numeric_encoder::EncodedTerm; |
|
|
|
use store::numeric_encoder::EncodedTerm; |
|
|
|
|
|
|
|
use store::numeric_encoder::ENCODED_DEFAULT_GRAPH; |
|
|
|
use Result; |
|
|
|
use Result; |
|
|
|
|
|
|
|
|
|
|
|
pub type EncodedTuple = Vec<Option<EncodedTerm>>; |
|
|
|
pub type EncodedTuple = Vec<Option<EncodedTerm>>; |
|
|
@ -19,7 +20,7 @@ pub enum PlanNode { |
|
|
|
subject: PatternValue, |
|
|
|
subject: PatternValue, |
|
|
|
predicate: PatternValue, |
|
|
|
predicate: PatternValue, |
|
|
|
object: PatternValue, |
|
|
|
object: PatternValue, |
|
|
|
graph_name: Option<PatternValue>, |
|
|
|
graph_name: PatternValue, |
|
|
|
}, |
|
|
|
}, |
|
|
|
Join { |
|
|
|
Join { |
|
|
|
left: Box<PlanNode>, |
|
|
|
left: Box<PlanNode>, |
|
|
@ -99,7 +100,7 @@ impl PlanNode { |
|
|
|
if let PatternValue::Variable(var) = object { |
|
|
|
if let PatternValue::Variable(var) = object { |
|
|
|
set.insert(*var); |
|
|
|
set.insert(*var); |
|
|
|
} |
|
|
|
} |
|
|
|
if let Some(PatternValue::Variable(var)) = graph_name { |
|
|
|
if let PatternValue::Variable(var) = graph_name { |
|
|
|
set.insert(*var); |
|
|
|
set.insert(*var); |
|
|
|
} |
|
|
|
} |
|
|
|
child.add_variables(set); |
|
|
|
child.add_variables(set); |
|
|
@ -353,7 +354,7 @@ impl<'a, S: EncodedQuadsStore> PlanBuilder<'a, S> { |
|
|
|
pattern, |
|
|
|
pattern, |
|
|
|
PlanNode::Init, |
|
|
|
PlanNode::Init, |
|
|
|
&mut variables, |
|
|
|
&mut variables, |
|
|
|
None, |
|
|
|
PatternValue::Constant(ENCODED_DEFAULT_GRAPH), |
|
|
|
)?; |
|
|
|
)?; |
|
|
|
Ok((plan, variables)) |
|
|
|
Ok((plan, variables)) |
|
|
|
} |
|
|
|
} |
|
|
@ -371,7 +372,7 @@ 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>, |
|
|
|
graph_name: PatternValue, |
|
|
|
) -> Result<PlanNode> { |
|
|
|
) -> Result<PlanNode> { |
|
|
|
Ok(match pattern { |
|
|
|
Ok(match pattern { |
|
|
|
GraphPattern::BGP(p) => { |
|
|
|
GraphPattern::BGP(p) => { |
|
|
@ -459,7 +460,7 @@ impl<'a, S: EncodedQuadsStore> PlanBuilder<'a, S> { |
|
|
|
} |
|
|
|
} |
|
|
|
GraphPattern::Graph(g, p) => { |
|
|
|
GraphPattern::Graph(g, p) => { |
|
|
|
let graph_name = self.pattern_value_from_named_node_or_variable(g, variables)?; |
|
|
|
let graph_name = self.pattern_value_from_named_node_or_variable(g, variables)?; |
|
|
|
self.build_for_graph_pattern(p, input, variables, Some(graph_name))? |
|
|
|
self.build_for_graph_pattern(p, input, variables, 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, graph_name)?), |
|
|
|
child: Box::new(self.build_for_graph_pattern(p, input, variables, graph_name)?), |
|
|
|