[tracker/journal: 6/18] libtracker-data: Use ontology journal for replay



commit db13b02e0073b476215e630e6af7b8f9ae8d85d6
Author: Jürg Billeter <j bitron ch>
Date:   Wed Oct 6 12:49:40 2010 +0200

    libtracker-data: Use ontology journal for replay

 src/libtracker-data/tracker-data-manager.c |  123 +++++---------
 src/libtracker-data/tracker-data-update.c  |  244 +---------------------------
 src/libtracker-data/tracker-data-update.h  |    5 +-
 src/libtracker-data/tracker-db-journal.c   |   23 +++
 src/libtracker-data/tracker-db-journal.h   |    1 +
 5 files changed, 75 insertions(+), 321 deletions(-)
---
diff --git a/src/libtracker-data/tracker-data-manager.c b/src/libtracker-data/tracker-data-manager.c
index 92f087f..f7c3b86 100644
--- a/src/libtracker-data/tracker-data-manager.c
+++ b/src/libtracker-data/tracker-data-manager.c
@@ -1123,7 +1123,8 @@ load_ontology_file_from_path (const gchar        *ontology_path,
                               gint               *max_id,
                               gboolean            in_update,
                               GPtrArray          *seen_classes,
-                              GPtrArray          *seen_properties)
+                              GPtrArray          *seen_properties,
+                              GHashTable         *uri_id_map)
 {
 	TrackerTurtleReader *reader;
 	GError              *error = NULL;
@@ -1140,11 +1141,16 @@ load_ontology_file_from_path (const gchar        *ontology_path,
 
 	while (error == NULL && tracker_turtle_reader_next (reader, &error)) {
 		const gchar *subject, *predicate, *object;
+		gint subject_id;
 
 		subject = tracker_turtle_reader_get_subject (reader);
 		predicate = tracker_turtle_reader_get_predicate (reader);
 		object = tracker_turtle_reader_get_object (reader);
 
+		if (uri_id_map) {
+			subject_id = GPOINTER_TO_INT (g_hash_table_lookup (uri_id_map, subject));
+		}
+
 		tracker_data_ontology_load_statement (ontology_path, 0, subject, predicate, object,
 		                                      max_id, in_update, NULL, NULL,
 		                                      seen_classes, seen_properties);
@@ -1230,21 +1236,12 @@ get_ontology_from_path (const gchar *ontology_path)
 }
 
 static void
-load_ontology_from_journal (GHashTable **classes_out,
-                            GHashTable **properties_out,
-                            GHashTable **id_uri_map_out)
+load_ontology_ids_from_journal (GHashTable **uri_id_map_out)
 {
-	GHashTable *id_uri_map;
-	GHashTable *classes, *properties;
-
-	classes = g_hash_table_new_full (g_direct_hash, g_direct_equal,
-	                                 NULL, (GDestroyNotify) g_object_unref);
+	GHashTable *uri_id_map;
 
-	properties = g_hash_table_new_full (g_direct_hash, g_direct_equal,
-	                                    NULL, (GDestroyNotify) g_object_unref);
-
-	id_uri_map = g_hash_table_new_full (g_direct_hash, g_direct_equal,
-	                                    NULL, g_free);
+	uri_id_map = g_hash_table_new_full (g_str_hash, g_str_equal,
+	                                    g_free, NULL);
 
 	while (tracker_db_journal_reader_next (NULL)) {
 		TrackerDBJournalEntryType type;
@@ -1255,38 +1252,11 @@ load_ontology_from_journal (GHashTable **classes_out,
 			const gchar *uri;
 
 			tracker_db_journal_reader_get_resource (&id, &uri);
-			g_hash_table_insert (id_uri_map, GINT_TO_POINTER (id), g_strdup (uri));
-		} else if (type == TRACKER_DB_JOURNAL_END_TRANSACTION) {
-			/* end of initial transaction => end of ontology */
-			break;
-		} else {
-			const gchar *subject, *predicate, *object;
-			gint subject_id, predicate_id, object_id;
-
-			if (type == TRACKER_DB_JOURNAL_INSERT_STATEMENT) {
-				tracker_db_journal_reader_get_statement (NULL, &subject_id, &predicate_id, &object);
-			} else if (type == TRACKER_DB_JOURNAL_INSERT_STATEMENT_ID) {
-				tracker_db_journal_reader_get_statement_id (NULL, &subject_id, &predicate_id, &object_id);
-				object = g_hash_table_lookup (id_uri_map, GINT_TO_POINTER (object_id));
-			} else {
-				continue;
-			}
-
-			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));
-
-			/* Post checks are only needed for ontology updates, not the initial
-			 * ontology */
-
-			tracker_data_ontology_load_statement ("journal", subject_id, subject, predicate,
-			                                      object, NULL, FALSE, classes, properties,
-			                                      NULL, NULL);
+			g_hash_table_insert (uri_id_map, g_strdup (uri), GINT_TO_POINTER (id));
 		}
 	}
 
-	*classes_out = classes;
-	*properties_out = properties;
-	*id_uri_map_out = id_uri_map;
+	*uri_id_map_out = uri_id_map;
 }
 
 void
@@ -2774,6 +2744,7 @@ tracker_data_manager_init (TrackerDBManagerFlags  flags,
 	const gchar *env_path;
 	gint max_id = 0;
 	gboolean read_only;
+	GHashTable *uri_id_map = NULL;
 
 	tracker_data_update_init ();
 
@@ -2815,9 +2786,8 @@ tracker_data_manager_init (TrackerDBManagerFlags  flags,
 				/* journal with at least one valid transaction
 				   is required to trigger journal replay */
 				read_journal = TRUE;
-			} else {
-				tracker_db_journal_reader_shutdown ();
 			}
+			tracker_db_journal_reader_shutdown ();
 		}
 	}
 
@@ -2833,46 +2803,24 @@ 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 and cache ID v. uri mappings */
-		load_ontology_from_journal (&classes, &properties, &id_uri_map);
+		tracker_db_journal_reader_ontology_init (NULL);
 
-		/* Read first ontology and commit it into the DB */
-		tracker_data_begin_transaction_for_replay (tracker_db_journal_reader_get_time (), NULL);
-
-		/* This is a no-op when FTS is disabled */
-		tracker_db_interface_sqlite_fts_init (iface, TRUE);
+		/* Load ontology IDs from journal into memory */
+		load_ontology_ids_from_journal (&uri_id_map);
 
-		tracker_data_ontology_import_into_db (FALSE);
-		tracker_data_commit_transaction (NULL);
 		tracker_db_journal_reader_shutdown ();
+	}
 
-		/* Start replay. Ontology changes might happen during replay of the journal. */
-
-		tracker_data_replay_journal (classes, properties, id_uri_map,
-		                             busy_callback, busy_user_data, busy_status);
-
-		in_journal_replay = FALSE;
-
-		/* open journal for writing */
-		tracker_db_journal_init (NULL, FALSE);
-
-		check_ontology = TRUE;
-
-		g_hash_table_unref (classes);
-		g_hash_table_unref (properties);
-		g_hash_table_unref (id_uri_map);
-
-	} else if (is_first_time_index && !read_only) {
+	if (is_first_time_index && !read_only) {
 		sorted = get_ontologies (test_schemas != NULL, ontologies_dir);
 
-		/* Truncate journal as it does not even contain a single valid transaction
-		 * or is explicitly ignored (journal_check == FALSE, only for test cases) */
-		tracker_db_journal_init (NULL, TRUE);
+		if (!read_journal) {
+			/* Truncate journal as it does not even contain a single valid transaction
+			 * or is explicitly ignored (journal_check == FALSE, only for test cases) */
+			tracker_db_journal_init (NULL, TRUE);
+		}
 
 		/* load ontology from files into memory (max_id starts at zero: first-time) */
 
@@ -2880,7 +2828,7 @@ tracker_data_manager_init (TrackerDBManagerFlags  flags,
 			gchar *ontology_path;
 			g_debug ("Loading ontology %s", (char *) l->data);
 			ontology_path = g_build_filename (ontologies_dir, l->data, NULL);
-			load_ontology_file_from_path (ontology_path, &max_id, FALSE, NULL, NULL);
+			load_ontology_file_from_path (ontology_path, &max_id, FALSE, NULL, NULL, uri_id_map);
 			g_free (ontology_path);
 		}
 
@@ -2892,7 +2840,7 @@ tracker_data_manager_init (TrackerDBManagerFlags  flags,
 
 				g_debug ("Loading ontology:'%s' (TEST ONTOLOGY)", test_schema_path);
 
-				load_ontology_file_from_path (test_schema_path, &max_id, FALSE, NULL, NULL);
+				load_ontology_file_from_path (test_schema_path, &max_id, FALSE, NULL, NULL, uri_id_map);
 				g_free (test_schema_path);
 			}
 		}
@@ -3060,7 +3008,7 @@ tracker_data_manager_init (TrackerDBManagerFlags  flags,
 					/* load ontology from files into memory, set all new's
 					 * is_new to TRUE */
 					load_ontology_file_from_path (ontology_path, &max_id, TRUE,
-					                              seen_classes, seen_properties);
+					                              seen_classes, seen_properties, uri_id_map);
 					to_reload = g_list_prepend (to_reload, l->data);
 					update_nao = TRUE;
 				}
@@ -3073,7 +3021,7 @@ tracker_data_manager_init (TrackerDBManagerFlags  flags,
 				/* load ontology from files into memory, set all new's
 				 * is_new to TRUE */
 				load_ontology_file_from_path (ontology_path, &max_id, TRUE,
-				                              seen_classes, seen_properties);
+				                              seen_classes, seen_properties, uri_id_map);
 				to_reload = g_list_prepend (to_reload, l->data);
 				update_nao = TRUE;
 			}
@@ -3136,6 +3084,19 @@ tracker_data_manager_init (TrackerDBManagerFlags  flags,
 		g_list_free (ontos);
 	}
 
+	if (read_journal) {
+		/* Start replay */
+
+		tracker_data_replay_journal (busy_callback, busy_user_data, busy_status);
+
+		in_journal_replay = FALSE;
+
+		/* open journal for writing */
+		tracker_db_journal_init (NULL, FALSE);
+
+		g_hash_table_unref (uri_id_map);
+	}
+
 	/* If locale changed, re-create indexes */
 	if (!read_only && tracker_db_manager_locale_changed ()) {
 		tracker_data_manager_recreate_indexes ();
diff --git a/src/libtracker-data/tracker-data-update.c b/src/libtracker-data/tracker-data-update.c
index cea2baf..5df0414 100644
--- a/src/libtracker-data/tracker-data-update.c
+++ b/src/libtracker-data/tracker-data-update.c
@@ -2699,161 +2699,14 @@ tracker_data_sync (void)
 	tracker_db_journal_fsync ();
 }
 
-static void
-free_queued_statement (QueuedStatement *queued)
-{
-	g_free (queued->subject);
-	g_free (queued->predicate);
-	g_free (queued->object);
-	g_free (queued->graph);
-	g_free (queued);
-}
-
-static GList*
-queue_statement (GList *queue,
-                 const gchar *graph,
-                 const gchar *subject,
-                 const gchar *predicate,
-                 const gchar *object,
-                 gboolean     is_uri)
-{
-	QueuedStatement *queued = g_new (QueuedStatement, 1);
-
-	queued->subject = g_strdup (subject);
-	queued->predicate = g_strdup (predicate);
-	queued->object = g_strdup (object);
-	queued->is_uri = is_uri;
-	queued->graph = graph ? g_strdup (graph) : NULL;
-
-	queue = g_list_append (queue, queued);
-
-	return queue;
-}
-
-static void
-ontology_transaction_end (GList *ontology_queue,
-                          GPtrArray *seen_classes,
-                          GPtrArray *seen_properties)
-{
-	GList *l;
-	const gchar *ontology_uri = NULL;
-
-	tracker_data_ontology_process_changes_pre_db (seen_classes, seen_properties);
-
-	/* Perform ALTER-TABLE and CREATE-TABLE calls for all that are is_new */
-	tracker_data_ontology_import_into_db (TRUE);
-
-	tracker_data_ontology_process_changes_post_db (seen_classes, seen_properties);
-
-	for (l = ontology_queue; l; l = l->next) {
-		QueuedStatement *queued = ontology_queue->data;
-
-		if (g_strcmp0 (queued->predicate, RDF_TYPE) == 0) {
-			if (g_strcmp0 (queued->object, TRACKER_PREFIX "Ontology") == 0) {
-				ontology_uri = queued->subject;
-			}
-		}
-
-		/* store ontology in database */
-		tracker_data_ontology_process_statement (queued->graph,
-		                                         queued->subject,
-		                                         queued->predicate,
-		                                         queued->object,
-		                                         queued->is_uri,
-		                                         TRUE, TRUE);
-
-	}
-
-	tracker_data_ontology_process_changes_post_import (seen_classes, seen_properties);
-
-	/* Update the nao:lastModified in the database */
-	if (ontology_uri) {
-		TrackerOntology *ontology;
-		ontology = tracker_ontologies_get_ontology_by_uri (ontology_uri);
-		if (ontology) {
-			gint last_mod = 0;
-			TrackerDBInterface *iface;
-			TrackerDBStatement *stmt;
-			GError *error = NULL;
-
-			iface = tracker_db_manager_get_db_interface ();
-
-			/* We can't do better than this cast, it's stored as an int in the
-			 * db. See tracker-data-manager.c for more info. */
-			last_mod = (gint) tracker_ontology_get_last_modified (ontology);
-
-			stmt = tracker_db_interface_create_statement (iface, TRACKER_DB_STATEMENT_CACHE_TYPE_UPDATE, &error,
-			        "UPDATE \"rdfs:Resource\" SET \"nao:lastModified\"= ? "
-			        "WHERE \"rdfs:Resource\".ID = "
-			        "(SELECT Resource.ID FROM Resource INNER JOIN \"rdfs:Resource\" "
-			        "ON \"rdfs:Resource\".ID = Resource.ID WHERE "
-			        "Resource.Uri = ?)");
-
-			if (stmt) {
-				tracker_db_statement_bind_int (stmt, 0, last_mod);
-				tracker_db_statement_bind_text (stmt, 1, ontology_uri);
-				tracker_db_statement_execute (stmt, NULL);
-			} else {
-				g_warning ("%s", error->message);
-				g_error_free (error);
-			}
-		}
-	}
-
-	/* Reset the is_new flag for all classes and properties */
-	tracker_data_ontology_import_finished ();
-}
-
-static GList*
-ontology_statement_insert (GList       *ontology_queue,
-                           gint         graph_id,
-                           gint         subject_id,
-                           gint         predicate_id,
-                           const gchar *object,
-                           GHashTable  *classes,
-                           GHashTable  *properties,
-                           GHashTable  *id_uri_map,
-                           gboolean     is_uri,
-                           GPtrArray   *seen_classes,
-                           GPtrArray   *seen_properties)
-{
-	const gchar *graph, *subject, *predicate;
-
-	if (graph_id > 0) {
-		graph = g_hash_table_lookup (id_uri_map, GINT_TO_POINTER (graph_id));
-	} else {
-		graph = NULL;
-	}
-
-	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));
-
-	/* load ontology from journal into memory, set all new's is_new to TRUE */
-	tracker_data_ontology_load_statement ("journal", subject_id, subject, predicate,
-	                                      object, NULL, TRUE, classes, properties,
-	                                      seen_classes, seen_properties);
-
-	/* Queue the statement for processing after ALTER in ontology_transaction_end */
-	ontology_queue = queue_statement (ontology_queue, graph, subject, predicate, object, is_uri);
-
-	return ontology_queue;
-}
-
 void
-tracker_data_replay_journal (GHashTable          *classes,
-                             GHashTable          *properties,
-                             GHashTable          *id_uri_map,
-                             TrackerBusyCallback  busy_callback,
+tracker_data_replay_journal (TrackerBusyCallback  busy_callback,
                              gpointer             busy_user_data,
                              const gchar         *busy_status)
 {
 	GError *journal_error = NULL;
 	TrackerProperty *rdf_type = NULL;
 	gint last_operation_type = 0;
-	gboolean in_ontology = FALSE;
-	GList *ontology_queue = NULL;
-	GPtrArray *seen_classes = NULL;
-	GPtrArray *seen_properties = NULL;
 
 	rdf_type = tracker_ontologies_get_rdf_type ();
 
@@ -2871,23 +2724,9 @@ tracker_data_replay_journal (GHashTable          *classes,
 			TrackerDBStatement *stmt;
 			gint id;
 			const gchar *uri;
-			TrackerProperty *property = NULL;
-			TrackerClass *class;
 
 			tracker_db_journal_reader_get_resource (&id, &uri);
 
-			if (in_ontology) {
-				g_hash_table_insert (id_uri_map, GINT_TO_POINTER (id), g_strdup (uri));
-				continue;
-			}
-
-			class = g_hash_table_lookup (classes, GINT_TO_POINTER (id));
-			if (!class)
-				property = g_hash_table_lookup (properties, GINT_TO_POINTER (id));
-
-			if (property || class)
-				continue;
-
 			iface = tracker_db_manager_get_db_interface ();
 
 			stmt = tracker_db_interface_create_statement (iface, TRACKER_DB_STATEMENT_CACHE_TYPE_UPDATE, &new_error,
@@ -2908,27 +2747,12 @@ tracker_data_replay_journal (GHashTable          *classes,
 				g_error_free (new_error);
 			}
 
-		} else if (type == TRACKER_DB_JOURNAL_START_ONTOLOGY_TRANSACTION) {
-			tracker_data_begin_transaction_for_replay (tracker_db_journal_reader_get_time (), NULL);
-			in_ontology = TRUE;
 		} else if (type == TRACKER_DB_JOURNAL_START_TRANSACTION) {
 			tracker_data_begin_transaction_for_replay (tracker_db_journal_reader_get_time (), NULL);
 		} else if (type == TRACKER_DB_JOURNAL_END_TRANSACTION) {
 			GError *new_error = NULL;
 			tracker_data_update_buffer_might_flush (&new_error);
 
-			if (in_ontology) {
-				ontology_transaction_end (ontology_queue, seen_classes, seen_properties);
-				g_list_foreach (ontology_queue, (GFunc) free_queued_statement, NULL);
-				g_list_free (ontology_queue);
-				ontology_queue = NULL;
-				in_ontology = FALSE;
-				tracker_data_ontology_free_seen (seen_classes);
-				seen_classes = NULL;
-				tracker_data_ontology_free_seen (seen_properties);
-				seen_properties = NULL;
-			}
-
 			tracker_data_commit_transaction (&new_error);
 			if (new_error) {
 				g_warning ("Journal replay error: '%s'", new_error->message);
@@ -2940,27 +2764,6 @@ tracker_data_replay_journal (GHashTable          *classes,
 
 			tracker_db_journal_reader_get_statement (&graph_id, &subject_id, &predicate_id, &object);
 
-			if (in_ontology) {
-
-				if (!seen_classes)
-					seen_classes = g_ptr_array_new ();
-				if (!seen_properties)
-					seen_properties = g_ptr_array_new ();
-
-				ontology_queue = ontology_statement_insert (ontology_queue,
-				                                            graph_id,
-				                                            subject_id,
-				                                            predicate_id,
-				                                            object,
-				                                            classes,
-				                                            properties,
-				                                            id_uri_map,
-				                                            FALSE,
-				                                            seen_classes,
-				                                            seen_properties);
-				continue;
-			}
-
 			if (last_operation_type == -1) {
 				tracker_data_update_buffer_flush (&new_error);
 				if (new_error) {
@@ -2970,7 +2773,7 @@ tracker_data_replay_journal (GHashTable          *classes,
 			}
 			last_operation_type = 1;
 
-			property = g_hash_table_lookup (properties, GINT_TO_POINTER (predicate_id));
+			property = tracker_ontologies_get_property_by_uri (tracker_ontologies_get_uri_by_id (predicate_id));
 
 			if (property) {
 				resource_buffer_switch (NULL, graph_id, NULL, subject_id);
@@ -2993,29 +2796,6 @@ tracker_data_replay_journal (GHashTable          *classes,
 
 			tracker_db_journal_reader_get_statement_id (&graph_id, &subject_id, &predicate_id, &object_id);
 
-			if (in_ontology) {
-				const gchar *object_n;
-				object_n = g_hash_table_lookup (id_uri_map, GINT_TO_POINTER (object_id));
-
-				if (!seen_classes)
-					seen_classes = g_ptr_array_new ();
-				if (!seen_properties)
-					seen_properties = g_ptr_array_new ();
-
-				ontology_queue = ontology_statement_insert (ontology_queue,
-				                                            graph_id,
-				                                            subject_id,
-				                                            predicate_id,
-				                                            object_n,
-				                                            classes,
-				                                            properties,
-				                                            id_uri_map,
-				                                            TRUE,
-				                                            seen_classes,
-				                                            seen_properties);
-				continue;
-			}
-
 			if (last_operation_type == -1) {
 				tracker_data_update_buffer_flush (&new_error);
 				if (new_error) {
@@ -3025,7 +2805,7 @@ tracker_data_replay_journal (GHashTable          *classes,
 			}
 			last_operation_type = 1;
 
-			property = g_hash_table_lookup (properties, GINT_TO_POINTER (predicate_id));
+			property = tracker_ontologies_get_property_by_uri (tracker_ontologies_get_uri_by_id (predicate_id));
 
 			if (property) {
 				if (tracker_property_get_data_type (property) != TRACKER_PROPERTY_TYPE_RESOURCE) {
@@ -3034,7 +2814,7 @@ tracker_data_replay_journal (GHashTable          *classes,
 					resource_buffer_switch (NULL, graph_id, NULL, subject_id);
 
 					if (property == rdf_type) {
-						class = g_hash_table_lookup (classes, GINT_TO_POINTER (object_id));
+						class = tracker_ontologies_get_class_by_uri (tracker_ontologies_get_uri_by_id (object_id));
 						if (class) {
 							cache_create_service_decomposed (class, NULL, graph_id);
 						} else {
@@ -3062,10 +2842,6 @@ tracker_data_replay_journal (GHashTable          *classes,
 
 			tracker_db_journal_reader_get_statement (&graph_id, &subject_id, &predicate_id, &object);
 
-			if (in_ontology) {
-				continue;
-			}
-
 			if (last_operation_type == 1) {
 				tracker_data_update_buffer_flush (&new_error);
 				if (new_error) {
@@ -3077,7 +2853,7 @@ tracker_data_replay_journal (GHashTable          *classes,
 
 			resource_buffer_switch (NULL, graph_id, NULL, subject_id);
 
-			property = g_hash_table_lookup (properties, GINT_TO_POINTER (predicate_id));
+			property = tracker_ontologies_get_property_by_uri (tracker_ontologies_get_uri_by_id (predicate_id));
 
 			if (property) {
 				GError *new_error = NULL;
@@ -3085,7 +2861,7 @@ tracker_data_replay_journal (GHashTable          *classes,
 				if (object && rdf_type == property) {
 					TrackerClass *class;
 
-					class = tracker_ontologies_get_class_by_uri (object);
+					class = tracker_ontologies_get_class_by_uri (tracker_ontologies_get_uri_by_id (object_id));
 					if (class != NULL) {
 						cache_delete_resource_type (class, NULL, graph_id);
 					} else {
@@ -3111,10 +2887,6 @@ tracker_data_replay_journal (GHashTable          *classes,
 
 			tracker_db_journal_reader_get_statement_id (&graph_id, &subject_id, &predicate_id, &object_id);
 
-			if (in_ontology) {
-				continue;
-			}
-
 			if (last_operation_type == 1) {
 				tracker_data_update_buffer_flush (&new_error);
 				if (new_error) {
@@ -3124,14 +2896,14 @@ tracker_data_replay_journal (GHashTable          *classes,
 			}
 			last_operation_type = -1;
 
-			property = g_hash_table_lookup (properties, GINT_TO_POINTER (predicate_id));
+			property = tracker_ontologies_get_property_by_uri (tracker_ontologies_get_uri_by_id (predicate_id));
 
 			if (property) {
 
 				resource_buffer_switch (NULL, graph_id, NULL, subject_id);
 
 				if (property == rdf_type) {
-					class = g_hash_table_lookup (classes, GINT_TO_POINTER (object_id));
+					class = tracker_ontologies_get_class_by_uri (tracker_ontologies_get_uri_by_id (object_id));
 					if (class) {
 						cache_delete_resource_type (class, NULL, graph_id);
 					} else {
diff --git a/src/libtracker-data/tracker-data-update.h b/src/libtracker-data/tracker-data-update.h
index de552d4..343674f 100644
--- a/src/libtracker-data/tracker-data-update.h
+++ b/src/libtracker-data/tracker-data-update.h
@@ -89,10 +89,7 @@ void     tracker_data_load_turtle_file              (GFile                     *
                                                      GError                   **error);
 
 void     tracker_data_sync                          (void);
-void     tracker_data_replay_journal                (GHashTable                *classes,
-                                                     GHashTable                *properties,
-                                                     GHashTable                *id_uri_map,
-                                                     TrackerBusyCallback        busy_callback,
+void     tracker_data_replay_journal                (TrackerBusyCallback        busy_callback,
                                                      gpointer                   busy_user_data,
                                                      const gchar               *busy_status);
 
diff --git a/src/libtracker-data/tracker-db-journal.c b/src/libtracker-data/tracker-db-journal.c
index f92af08..8fb0a48 100644
--- a/src/libtracker-data/tracker-db-journal.c
+++ b/src/libtracker-data/tracker-db-journal.c
@@ -1208,6 +1208,29 @@ tracker_db_journal_reader_init (const gchar *filename)
 	return db_journal_reader_init (&reader, TRUE, filename);
 }
 
+gboolean
+tracker_db_journal_reader_ontology_init (const gchar *filename) {
+	gchar *filename_used;
+	gboolean result;
+
+	/* Used mostly for testing */
+	if (G_UNLIKELY (filename)) {
+		filename_used = g_strdup (filename);
+	} else {
+		filename_used = g_build_filename (g_get_user_data_dir (),
+		                                  "tracker",
+		                                  "data",
+		                                  TRACKER_DB_JOURNAL_ONTOLOGY_FILENAME,
+		                                  NULL);
+	}
+
+	result = tracker_db_journal_reader_init (filename_used);
+
+	g_free (filename_used);
+
+	return result;
+}
+
 gsize
 tracker_db_journal_reader_get_size_of_correct (void)
 {
diff --git a/src/libtracker-data/tracker-db-journal.h b/src/libtracker-data/tracker-db-journal.h
index 71ec08b..149f360 100644
--- a/src/libtracker-data/tracker-db-journal.h
+++ b/src/libtracker-data/tracker-db-journal.h
@@ -96,6 +96,7 @@ gboolean     tracker_db_journal_truncate                     (gsize new_size);
  * Reader API
  */
 gboolean     tracker_db_journal_reader_init                  (const gchar  *filename);
+gboolean     tracker_db_journal_reader_ontology_init         (const gchar  *filename);
 gboolean     tracker_db_journal_reader_shutdown              (void);
 TrackerDBJournalEntryType
              tracker_db_journal_reader_get_type              (void);



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