[tracker/busy-notifications] libtracker-data: Add busy notification support to journal-replay and restore



commit 5b81accbede15f5270f773bae7389e12bfb9e412
Author: Philip Van Hoof <philip codeminded be>
Date:   Fri Mar 26 12:19:21 2010 +0100

    libtracker-data: Add busy notification support to journal-replay and restore

 src/libtracker-data/tracker-data-backup.c         |    3 ++-
 src/libtracker-data/tracker-data-manager.c        |    7 +++++--
 src/libtracker-data/tracker-data-manager.h        |    6 +++++-
 src/libtracker-data/tracker-data-update.c         |   13 ++++++++++---
 src/libtracker-data/tracker-data-update.h         |    6 +++++-
 src/libtracker-db/tracker-db-journal.c            |    8 ++++++++
 src/libtracker-db/tracker-db-journal.h            |    2 ++
 src/tracker-store/tracker-main.c                  |    4 +++-
 tests/libtracker-data/tracker-backup-test.c       |    4 ++--
 tests/libtracker-data/tracker-ontology-test.c     |   16 +++++++++++-----
 tests/libtracker-data/tracker-sparql-blank-test.c |    4 +++-
 tests/libtracker-data/tracker-sparql-test.c       |    2 +-
 tests/libtracker-fts/tracker-fts-test.c           |    2 +-
 13 files changed, 58 insertions(+), 19 deletions(-)
---
diff --git a/src/libtracker-data/tracker-data-backup.c b/src/libtracker-data/tracker-data-backup.c
index 9ec4de4..3601b88 100644
--- a/src/libtracker-data/tracker-data-backup.c
+++ b/src/libtracker-data/tracker-data-backup.c
@@ -164,7 +164,8 @@ tracker_data_backup_restore (GFile *journal,
 
 		tracker_db_journal_shutdown ();
 
-		tracker_data_manager_init (flags, test_schemas, &is_first, TRUE);
+		tracker_data_manager_init (flags, test_schemas, &is_first, TRUE,
+		                           NULL, NULL);
 
 	} else {
 		g_set_error (&info->error, TRACKER_DATA_BACKUP_ERROR, 0, 
diff --git a/src/libtracker-data/tracker-data-manager.c b/src/libtracker-data/tracker-data-manager.c
index b32d679..b3c715f 100644
--- a/src/libtracker-data/tracker-data-manager.c
+++ b/src/libtracker-data/tracker-data-manager.c
@@ -1436,7 +1436,9 @@ gboolean
 tracker_data_manager_init (TrackerDBManagerFlags  flags,
                            const gchar          **test_schemas,
                            gboolean              *first_time,
-                           gboolean               journal_check)
+                           gboolean               journal_check,
+                           TrackerBusyCallback    busy_callback,
+                           gpointer               busy_user_data)
 {
 	TrackerDBInterface *iface;
 	gboolean is_first_time_index, read_journal, check_ontology;
@@ -1516,7 +1518,8 @@ tracker_data_manager_init (TrackerDBManagerFlags  flags,
 
 		/* Start replay. Ontology changes might happen during replay of the journal. */
 
-		tracker_data_replay_journal (classes, properties, id_uri_map);
+		tracker_data_replay_journal (classes, properties, id_uri_map, 
+		                             busy_callback, busy_user_data);
 
 		in_journal_replay = FALSE;
 
diff --git a/src/libtracker-data/tracker-data-manager.h b/src/libtracker-data/tracker-data-manager.h
index 2613164..a2632a1 100644
--- a/src/libtracker-data/tracker-data-manager.h
+++ b/src/libtracker-data/tracker-data-manager.h
@@ -28,6 +28,8 @@
 #include <libtracker-common/tracker-language.h>
 #include <libtracker-common/tracker-ontologies.h>
 
+#include <libtracker-data/tracker-data-update.h>
+
 #include <libtracker-db/tracker-db-interface.h>
 #include <libtracker-db/tracker-db-manager.h>
 
@@ -40,7 +42,9 @@ G_BEGIN_DECLS
 gboolean tracker_data_manager_init                (TrackerDBManagerFlags  flags,
                                                    const gchar          **test_schema,
                                                    gboolean              *first_time,
-                                                   gboolean               journal_check);
+                                                   gboolean               journal_check,
+                                                   TrackerBusyCallback    busy_callback,
+                                                   gpointer               busy_user_data);
 void     tracker_data_manager_shutdown            (void);
 gint64   tracker_data_manager_get_db_option_int64 (const gchar           *option);
 void     tracker_data_manager_set_db_option_int64 (const gchar           *option,
diff --git a/src/libtracker-data/tracker-data-update.c b/src/libtracker-data/tracker-data-update.c
index b155e5f..b825f33 100644
--- a/src/libtracker-data/tracker-data-update.c
+++ b/src/libtracker-data/tracker-data-update.c
@@ -2363,9 +2363,11 @@ ontology_statement_insert (GList       *ontology_queue,
 }
 
 void
-tracker_data_replay_journal (GHashTable *classes,
-                             GHashTable *properties,
-                             GHashTable *id_uri_map)
+tracker_data_replay_journal (GHashTable          *classes,
+                             GHashTable          *properties,
+                             GHashTable          *id_uri_map,
+                             TrackerBusyCallback  busy_callback,
+                             gpointer             busy_user_data)
 {
 	GError *journal_error = NULL;
 	static TrackerProperty *rdf_type = NULL;
@@ -2386,6 +2388,11 @@ tracker_data_replay_journal (GHashTable *classes,
 		const gchar *object;
 		gint graph_id, subject_id, predicate_id, object_id;
 
+		if (busy_callback) {
+			busy_callback (tracker_db_journal_reader_get_progress (),
+			               busy_user_data);
+		}
+
 		type = tracker_db_journal_reader_get_type ();
 		if (type == TRACKER_DB_JOURNAL_RESOURCE) {
 			GError *new_error = NULL;
diff --git a/src/libtracker-data/tracker-data-update.h b/src/libtracker-data/tracker-data-update.h
index 21f98f2..643d349 100644
--- a/src/libtracker-data/tracker-data-update.h
+++ b/src/libtracker-data/tracker-data-update.h
@@ -50,6 +50,8 @@ typedef void (*TrackerStatementCallback) (const gchar *graph,
                                           GPtrArray   *rdf_types,
                                           gpointer     user_data);
 typedef void (*TrackerCommitCallback)    (gpointer     user_data);
+typedef void (*TrackerBusyCallback)      (gdouble      progress,
+                                          gpointer     user_data);
 
 GQuark   tracker_data_error_quark                   (void);
 
@@ -94,7 +96,9 @@ void     tracker_data_update_buffer_might_flush     (GError                   **
 void     tracker_data_sync                          (void);
 void     tracker_data_replay_journal                (GHashTable                *classes,
                                                      GHashTable                *properties,
-                                                     GHashTable                *id_uri_map);
+                                                     GHashTable                *id_uri_map,
+                                                     TrackerBusyCallback        busy_callback,
+                                                     gpointer                   busy_user_data);
 
 /* Calling back */
 void     tracker_data_add_insert_statement_callback   (TrackerStatementCallback   callback,
diff --git a/src/libtracker-db/tracker-db-journal.c b/src/libtracker-db/tracker-db-journal.c
index 86e138d..0f188ff 100644
--- a/src/libtracker-db/tracker-db-journal.c
+++ b/src/libtracker-db/tracker-db-journal.c
@@ -1144,3 +1144,11 @@ tracker_db_journal_reader_get_statement_id (gint *g_id,
 
 	return TRUE;
 }
+
+gdouble
+tracker_db_journal_reader_get_progress (void)
+{
+	gdouble percent = ((gdouble)(reader.end - reader.start));
+	return ((gdouble)(reader.current - reader.start)) / percent;
+}
+
diff --git a/src/libtracker-db/tracker-db-journal.h b/src/libtracker-db/tracker-db-journal.h
index b7b17b7..8d6530a 100644
--- a/src/libtracker-db/tracker-db-journal.h
+++ b/src/libtracker-db/tracker-db-journal.h
@@ -103,6 +103,8 @@ gboolean     tracker_db_journal_reader_get_statement_id      (gint         *g_id
                                                               gint         *p_id,
                                                               gint         *o_id);
 gsize        tracker_db_journal_reader_get_size_of_correct   (void);
+gdouble      tracker_db_journal_reader_get_progress          (void);
+
 gboolean     tracker_db_journal_reader_verify_last           (GError **error);
 
 G_END_DECLS
diff --git a/src/tracker-store/tracker-main.c b/src/tracker-store/tracker-main.c
index e21d8d4..af72d6c 100644
--- a/src/tracker-store/tracker-main.c
+++ b/src/tracker-store/tracker-main.c
@@ -453,7 +453,9 @@ main (gint argc, gchar *argv[])
 	if (!tracker_data_manager_init (flags,
 	                                NULL,
 	                                &is_first_time_index,
-	                                TRUE)) {
+	                                TRUE,
+	                                NULL,
+	                                NULL)) {
 		return EXIT_FAILURE;
 	}
 
diff --git a/tests/libtracker-data/tracker-backup-test.c b/tests/libtracker-data/tracker-backup-test.c
index 1e0abd4..d8a32e3 100644
--- a/tests/libtracker-data/tracker-backup-test.c
+++ b/tests/libtracker-data/tracker-backup-test.c
@@ -106,7 +106,7 @@ test_backup_and_restore (void)
 
 	tracker_data_manager_init (TRACKER_DB_MANAGER_FORCE_REINDEX,
 	                           (const gchar **) test_schemas,
-	                           NULL, FALSE);
+	                           NULL, FALSE, NULL, NULL);
 
 	/* load data set */
 	data_filename = g_strconcat (data_prefix, ".data", NULL);
@@ -156,7 +156,7 @@ test_backup_and_restore (void)
 
 	tracker_data_manager_init (TRACKER_DB_MANAGER_FORCE_REINDEX,
 	                           (const gchar **) test_schemas,
-	                           NULL, FALSE);
+	                           NULL, FALSE, NULL, NULL);
 	check_content_in_db (0, 0);
 
 	test_schemas[0] = data_prefix;
diff --git a/tests/libtracker-data/tracker-ontology-test.c b/tests/libtracker-data/tracker-ontology-test.c
index 7794e15..2bfb0f3 100644
--- a/tests/libtracker-data/tracker-ontology-test.c
+++ b/tests/libtracker-data/tracker-ontology-test.c
@@ -264,7 +264,7 @@ test_ontology_change (void)
                 g_chmod (ontology_file, 0666);
 
 		tracker_data_manager_init (0, (const gchar **) test_schemas,
-		                           NULL, FALSE);
+		                           NULL, FALSE, NULL, NULL);
 
 		if (g_file_get_contents (update, &queries, NULL, NULL)) {
 			gchar *query = strtok (queries, "\n");
@@ -290,7 +290,7 @@ test_ontology_change (void)
 	delete_db (FALSE);
 
 	tracker_data_manager_init (0, (const gchar **) test_schemas,
-	                           NULL, TRUE);
+	                           NULL, TRUE, NULL, NULL);
 
 	for (i = 0; change_tests[i].test_name != NULL; i++) {
 		gchar *query_filename;
@@ -327,7 +327,9 @@ test_ontology_init (void)
 	tracker_data_manager_init (TRACKER_DB_MANAGER_FORCE_REINDEX,
 	                           NULL,
 	                           NULL,
-	                           FALSE);
+	                           FALSE,
+	                           NULL,
+	                           NULL);
 
 	tracker_data_manager_shutdown ();
 
@@ -335,7 +337,9 @@ test_ontology_init (void)
 	tracker_data_manager_init (0,
 	                           NULL,
 	                           NULL,
-	                           FALSE);
+	                           FALSE,
+	                           NULL,
+	                           NULL);
 
 	tracker_data_manager_shutdown ();
 }
@@ -363,7 +367,9 @@ test_query (gconstpointer test_data)
 	tracker_data_manager_init (TRACKER_DB_MANAGER_FORCE_REINDEX,
 	                           NULL,
 	                           NULL, 
-	                           FALSE);
+	                           FALSE,
+	                           NULL,
+	                           NULL);
 
 	/* load data set */
 	data_filename = g_strconcat (data_prefix, ".ttl", NULL);
diff --git a/tests/libtracker-data/tracker-sparql-blank-test.c b/tests/libtracker-data/tracker-sparql-blank-test.c
index 4490625..6313cc8 100644
--- a/tests/libtracker-data/tracker-sparql-blank-test.c
+++ b/tests/libtracker-data/tracker-sparql-blank-test.c
@@ -44,7 +44,9 @@ test_blank (void)
 	tracker_data_manager_init (TRACKER_DB_MANAGER_FORCE_REINDEX,
 	                           NULL,
 	                           NULL,
-	                           FALSE);
+	                           FALSE,
+	                           NULL,
+	                           NULL);
 
 	/* perform update in transaction */
 
diff --git a/tests/libtracker-data/tracker-sparql-test.c b/tests/libtracker-data/tracker-sparql-test.c
index 62841de..44750d9 100644
--- a/tests/libtracker-data/tracker-sparql-test.c
+++ b/tests/libtracker-data/tracker-sparql-test.c
@@ -131,7 +131,7 @@ test_sparql_query (gconstpointer test_data)
 	test_schemas[0] = data_prefix;
 	tracker_data_manager_init (TRACKER_DB_MANAGER_FORCE_REINDEX,
 	                           test_schemas,
-	                           NULL, FALSE);
+	                           NULL, FALSE, NULL, NULL);
 
 	/* data_path = g_build_path (G_DIR_SEPARATOR_S, TOP_SRCDIR, "tests", "libtracker-data", NULL); */
 
diff --git a/tests/libtracker-fts/tracker-fts-test.c b/tests/libtracker-fts/tracker-fts-test.c
index 3a136c6..5ef805a 100644
--- a/tests/libtracker-fts/tracker-fts-test.c
+++ b/tests/libtracker-fts/tracker-fts-test.c
@@ -74,7 +74,7 @@ test_sparql_query (gconstpointer test_data)
 	test_schemas[0] = data_prefix;
 	tracker_data_manager_init (TRACKER_DB_MANAGER_FORCE_REINDEX,
 	                           test_schemas,
-	                           NULL, FALSE);
+	                           NULL, FALSE, NULL, NULL);
 
 	/* load data / perform updates */
 



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