[tracker/ontology-cope-for-master: 427/433] libtracker-data: Pass the id_uri_map to journal-replayer
- From: Philip Van Hoof <pvanhoof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/ontology-cope-for-master: 427/433] libtracker-data: Pass the id_uri_map to journal-replayer
- Date: Wed, 24 Mar 2010 12:10:41 +0000 (UTC)
commit f52e7c7934d815e0d6f748ee59168266328fc122
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 | 54 ++++++++--------------------
src/libtracker-data/tracker-data-update.h | 3 +-
3 files changed, 25 insertions(+), 45 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..7a7be49 100644
--- a/src/libtracker-data/tracker-data-update.c
+++ b/src/libtracker-data/tracker-data-update.c
@@ -2233,30 +2233,6 @@ tracker_data_sync (void)
tracker_db_journal_fsync ();
}
-static gchar *
-query_resource_by_id (gint id)
-{
- TrackerDBCursor *cursor;
- TrackerDBInterface *iface;
- TrackerDBStatement *stmt;
- gchar *uri;
-
- g_return_val_if_fail (id > 0, NULL);
-
- iface = tracker_db_manager_get_db_interface ();
-
- stmt = tracker_db_interface_create_statement (iface,
- "SELECT Uri FROM Resource WHERE ID = ?");
- tracker_db_statement_bind_int (stmt, 0, id);
- cursor = tracker_db_statement_start_cursor (stmt, NULL);
- g_object_unref (stmt);
-
- tracker_db_cursor_iter_next (cursor);
- uri = g_strdup (tracker_db_cursor_get_string (cursor, 0));
- g_object_unref (cursor);
-
- return uri;
-}
static void
free_queued_statement (QueuedStatement *queued)
{
@@ -2349,34 +2325,32 @@ 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;
+ const 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);
ontology_queue = queue_statement (ontology_queue, graph, subject, predicate, object, FALSE);
- g_free (graph);
- g_free (subject);
- g_free (predicate);
-
return 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 +2384,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 +2443,8 @@ tracker_data_replay_journal (GHashTable *classes,
predicate_id,
object,
classes,
- properties);
+ properties,
+ id_uri_map);
continue;
}
@@ -2505,16 +2481,16 @@ tracker_data_replay_journal (GHashTable *classes,
tracker_db_journal_reader_get_statement_id (&graph_id, &subject_id, &predicate_id, &object_id);
if (in_ontology) {
- gchar *object_n;
- object_n = query_resource_by_id (object_id);
+ const gchar *object_n;
+ object_n = g_hash_table_lookup (id_uri_map, GINT_TO_POINTER (object_id));
ontology_queue = ontology_statement_insert (ontology_queue,
graph_id,
subject_id,
predicate_id,
object_n,
classes,
- properties);
- g_free (object_n);
+ properties,
+ id_uri_map);
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]