[tracker/rtcom: 2/4] SPARQL: Create new context for each triple block



commit f43e97f4aa8dc34af9db1b28cf750812ffd338b1
Author: Jürg Billeter <j bitron ch>
Date:   Mon May 17 12:45:28 2010 +0200

    SPARQL: Create new context for each triple block

 src/libtracker-data/tracker-sparql-pattern.vala |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/src/libtracker-data/tracker-sparql-pattern.vala b/src/libtracker-data/tracker-sparql-pattern.vala
index aac144f..63373b7 100644
--- a/src/libtracker-data/tracker-sparql-pattern.vala
+++ b/src/libtracker-data/tracker-sparql-pattern.vala
@@ -198,7 +198,7 @@ class Tracker.Sparql.Pattern : Object {
 		return query.get_last_string (strip);
 	}
 
-	class TripleContext {
+	class TripleContext : Context {
 		// SQL tables
 		public List<DataTable> tables;
 		public HashTable<string,DataTable> table_map;
@@ -208,7 +208,9 @@ class Tracker.Sparql.Pattern : Object {
 		public List<Variable> variables;
 		public HashTable<Variable,VariableBindingList> var_map;
 
-		public TripleContext () {
+		public TripleContext (Context parent_context) {
+			base (parent_context);
+
 			tables = new List<DataTable> ();
 			table_map = new HashTable<string,DataTable>.full (str_hash, str_equal, g_free, g_object_unref);
 
@@ -574,7 +576,7 @@ class Tracker.Sparql.Pattern : Object {
 	}
 
 	void start_triples_block (StringBuilder sql) throws SparqlError {
-		triple_context = new TripleContext ();
+		context = triple_context = new TripleContext (context);
 
 		sql.append ("SELECT ");
 	}
@@ -669,7 +671,12 @@ class Tracker.Sparql.Pattern : Object {
 			sql.append (")");
 		}
 
+		foreach (var v in context.var_set.get_keys ()) {
+			context.parent_context.var_set.insert (v, VariableState.BOUND);
+		}
+
 		triple_context = null;
+		context = context.parent_context;
 	}
 
 	void parse_triples (StringBuilder sql, long group_graph_pattern_start, ref bool in_triples_block, ref bool first_where, ref bool in_group_graph_pattern, bool found_simple_optional) throws SparqlError {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]