[tracker/ontology-cope: 3/11] libtracker-data: Pass the id_uri_map to journal-replayer



commit b6e84e3aeea7265e59bb9092aeca883d8b645ed5
Author: Philip Van Hoof <philip codeminded be>
Date:   Fri Mar 19 15:23:23 2010 +0100

    libtracker-data: Pass the id_uri_map to journal-replayer

 src/libtracker-data/tracker-data-manager.c |   13 ++++++++-----
 src/libtracker-data/tracker-data-update.c  |   19 ++++++++++++-------
 src/libtracker-data/tracker-data-update.h  |    3 ++-
 3 files changed, 22 insertions(+), 13 deletions(-)
---
diff --git a/src/libtracker-data/tracker-data-manager.c b/src/libtracker-data/tracker-data-manager.c
index f812e47..9a9ce67 100644
--- a/src/libtracker-data/tracker-data-manager.c
+++ b/src/libtracker-data/tracker-data-manager.c
@@ -510,7 +510,8 @@ load_ontology_file (const gchar               *filename,
 
 static void
 load_ontology_from_journal (GHashTable **classes_out,
-                            GHashTable **properties_out)
+                            GHashTable **properties_out,
+                            GHashTable **id_uri_map_out)
 {
 	GHashTable *id_uri_map;
 	GHashTable *classes, *properties;
@@ -560,8 +561,7 @@ load_ontology_from_journal (GHashTable **classes_out,
 
 	*classes_out = classes;
 	*properties_out = properties;
-
-	g_hash_table_unref (id_uri_map);
+	*id_uri_map_out = id_uri_map;
 }
 
 void
@@ -1517,11 +1517,12 @@ tracker_data_manager_init (TrackerDBManagerFlags  flags,
 
 	if (read_journal) {
 		GHashTable *classes = NULL, *properties = NULL;
+		GHashTable *id_uri_map = NULL;
 
 		in_journal_replay = TRUE;
 
 		/* load ontology from journal into memory */
-		load_ontology_from_journal (&classes, &properties);
+		load_ontology_from_journal (&classes, &properties, &id_uri_map);
 
 		tracker_data_begin_db_transaction_for_replay (tracker_db_journal_reader_get_time ());
 		tracker_db_interface_sqlite_fts_init (TRACKER_DB_INTERFACE_SQLITE (iface), TRUE);
@@ -1530,7 +1531,7 @@ tracker_data_manager_init (TrackerDBManagerFlags  flags,
 
 		tracker_db_journal_reader_shutdown ();
 
-		tracker_data_replay_journal (classes, properties);
+		tracker_data_replay_journal (classes, properties, id_uri_map);
 
 		in_journal_replay = FALSE;
 
@@ -1541,6 +1542,8 @@ tracker_data_manager_init (TrackerDBManagerFlags  flags,
 
 		g_hash_table_unref (classes);
 		g_hash_table_unref (properties);
+		g_hash_table_unref (id_uri_map);
+
 	} else if (is_first_time_index) {
 		gchar *test_schema_path = NULL;
 
diff --git a/src/libtracker-data/tracker-data-update.c b/src/libtracker-data/tracker-data-update.c
index 3fec0c1..df36901 100644
--- a/src/libtracker-data/tracker-data-update.c
+++ b/src/libtracker-data/tracker-data-update.c
@@ -2349,18 +2349,19 @@ ontology_statement_insert (GList       *ontology_queue,
                            gint         predicate_id,
                            const gchar *object,
                            GHashTable  *classes,
-                           GHashTable  *properties)
+                           GHashTable  *properties,
+                           GHashTable  *id_uri_map)
 {
 	gchar *graph, *subject, *predicate;
 
 	if (graph_id > 0) {
-		graph = query_resource_by_id (graph_id);
+		graph = g_hash_table_lookup (id_uri_map, GINT_TO_POINTER (graph_id));
 	} else {
 		graph = NULL;
 	}
 
-	subject = query_resource_by_id (subject_id);
-	predicate = query_resource_by_id (predicate_id);
+	subject = g_hash_table_lookup (id_uri_map, GINT_TO_POINTER (subject_id));
+	predicate = g_hash_table_lookup (id_uri_map, GINT_TO_POINTER (predicate_id));
 
 	tracker_data_ontology_load_statement ("journal", subject_id, subject, predicate, 
 	                                      object, NULL, FALSE, classes, properties);
@@ -2376,7 +2377,8 @@ ontology_statement_insert (GList       *ontology_queue,
 
 void
 tracker_data_replay_journal (GHashTable *classes,
-                             GHashTable *properties)
+                             GHashTable *properties,
+                             GHashTable *id_uri_map)
 {
 	GError *journal_error = NULL;
 	static TrackerProperty *rdf_type = NULL;
@@ -2410,6 +2412,7 @@ tracker_data_replay_journal (GHashTable *classes,
 			tracker_db_journal_reader_get_resource (&id, &uri);
 
 			if (in_ontology) {
+				g_hash_table_insert (id_uri_map, GINT_TO_POINTER (id), (gpointer) uri);
 				continue;
 			}
 
@@ -2468,7 +2471,8 @@ tracker_data_replay_journal (GHashTable *classes,
 				                                            predicate_id,
 				                                            object,
 				                                            classes,
-				                                            properties);
+				                                            properties,
+				                                            id_uri_map);
 				continue;
 			}
 
@@ -2513,7 +2517,8 @@ tracker_data_replay_journal (GHashTable *classes,
 				                                            predicate_id,
 				                                            object_n,
 				                                            classes,
-				                                            properties);
+				                                            properties,
+				                                            id_uri_map);
 				g_free (object_n);
 				continue;
 			}
diff --git a/src/libtracker-data/tracker-data-update.h b/src/libtracker-data/tracker-data-update.h
index 40dba01..529d7c1 100644
--- a/src/libtracker-data/tracker-data-update.h
+++ b/src/libtracker-data/tracker-data-update.h
@@ -93,7 +93,8 @@ void     tracker_data_update_buffer_might_flush     (GError                   **
 
 void     tracker_data_sync                          (void);
 void     tracker_data_replay_journal                (GHashTable                *classes,
-                                                     GHashTable                *properties);
+                                                     GHashTable                *properties,
+                                                     GHashTable                *id_uri_map);
 
 /* Calling back */
 void     tracker_data_add_insert_statement_callback   (TrackerStatementCallback   callback,



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