[tracker/gdbus-store: 4/9] libtracker-data: Use GenericArray in Sparql.Query.execute_update



commit ea217f1229f1f0efe4ccf4301140b39b4d4307c5
Author: Jürg Billeter <j bitron ch>
Date:   Wed Jan 12 11:49:20 2011 +0100

    libtracker-data: Use GenericArray in Sparql.Query.execute_update

 src/libtracker-data/tracker-sparql-query.vala     |   17 ++++++++---------
 src/tracker-store/tracker-store.c                 |    6 ------
 tests/libtracker-data/tracker-sparql-blank-test.c |    4 ----
 3 files changed, 8 insertions(+), 19 deletions(-)
---
diff --git a/src/libtracker-data/tracker-sparql-query.vala b/src/libtracker-data/tracker-sparql-query.vala
index 1fafb99..4ccb793 100644
--- a/src/libtracker-data/tracker-sparql-query.vala
+++ b/src/libtracker-data/tracker-sparql-query.vala
@@ -437,7 +437,7 @@ public class Tracker.Sparql.Query : Object {
 		}
 	}
 
-	public PtrArray? execute_update (bool blank) throws DBInterfaceError, Sparql.Error, DateError {
+	public GenericArray<GenericArray<HashTable<string,string>>>? execute_update (bool blank) throws DBInterfaceError, Sparql.Error, DateError {
 		assert (update_extensions);
 
 		scanner = new SparqlScanner ((char*) query_string, (long) query_string.length);
@@ -456,9 +456,9 @@ public class Tracker.Sparql.Query : Object {
 
 		parse_prologue ();
 
-		PtrArray blank_nodes = null;
+		GenericArray<GenericArray<HashTable<string,string>>> blank_nodes = null;
 		if (blank) {
-			blank_nodes = new PtrArray ();
+			blank_nodes = new GenericArray<GenericArray<HashTable<string,string>>> ();
 		}
 
 		// SPARQL update supports multiple operations in a single query
@@ -468,7 +468,7 @@ public class Tracker.Sparql.Query : Object {
 			case SparqlTokenType.WITH:
 			case SparqlTokenType.INSERT:
 			case SparqlTokenType.DELETE:
-				PtrArray* ptr = execute_insert_or_delete (blank);
+				GenericArray<HashTable<string,string>> ptr = execute_insert_or_delete (blank);
 				if (ptr != null) {
 					blank_nodes.add (ptr);
 				}
@@ -604,7 +604,7 @@ public class Tracker.Sparql.Query : Object {
 		}
 	}
 
-	PtrArray? execute_insert_or_delete (bool blank) throws DBInterfaceError, Sparql.Error, DateError {
+	GenericArray<HashTable<string,string>>? execute_insert_or_delete (bool blank) throws DBInterfaceError, Sparql.Error, DateError {
 		// INSERT or DELETE
 
 		if (accept (SparqlTokenType.WITH)) {
@@ -697,10 +697,10 @@ public class Tracker.Sparql.Query : Object {
 
 		this.delete_statements = delete_statements;
 
-		PtrArray update_blank_nodes = null;
+		GenericArray<HashTable<string,string>> update_blank_nodes = null;
 
 		if (blank) {
-			update_blank_nodes = new PtrArray ();
+			update_blank_nodes = new GenericArray<HashTable<string,string>> ();
 		}
 
 		// iterate over all solutions
@@ -726,8 +726,7 @@ public class Tracker.Sparql.Query : Object {
 				parse_construct_triples_block (var_value_map);
 
 				if (blank) {
-					HashTable<string,string>* ptr = (owned) blank_nodes;
-					update_blank_nodes.add (ptr);
+					update_blank_nodes.add ((owned) blank_nodes);
 				}
 
 				Data.update_buffer_might_flush ();
diff --git a/src/tracker-store/tracker-store.c b/src/tracker-store/tracker-store.c
index 6a53264..09ed667 100644
--- a/src/tracker-store/tracker-store.c
+++ b/src/tracker-store/tracker-store.c
@@ -282,12 +282,6 @@ task_finish_cb (gpointer data)
 		}
 
 		if (task->data.update.blank_nodes) {
-			gint i;
-
-			for (i = 0; i < task->data.update.blank_nodes->len; i++) {
-				g_ptr_array_foreach (task->data.update.blank_nodes->pdata[i], (GFunc) g_hash_table_unref, NULL);
-				g_ptr_array_free (task->data.update.blank_nodes->pdata[i], TRUE);
-			}
 			g_ptr_array_free (task->data.update.blank_nodes, TRUE);
 		}
 
diff --git a/tests/libtracker-data/tracker-sparql-blank-test.c b/tests/libtracker-data/tracker-sparql-blank-test.c
index ec14117..afbd5ea 100644
--- a/tests/libtracker-data/tracker-sparql-blank-test.c
+++ b/tests/libtracker-data/tracker-sparql-blank-test.c
@@ -78,10 +78,6 @@ test_blank (void)
 
 	/* cleanup */
 
-	g_hash_table_unref (blank_nodes[0]);
-	g_hash_table_unref (blank_nodes[1]);
-	g_ptr_array_free (updates->pdata[0], TRUE);
-	g_ptr_array_free (updates->pdata[1], TRUE);
 	g_ptr_array_free (updates, TRUE);
 
 	tracker_data_manager_shutdown ();



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