[tracker/journal] libtracker-data: STATEMENT_INSERT journal replay performance improvement



commit 3cca243d95fc6b01c7b0e4542c88f01b8abe93c6
Author: Philip Van Hoof <philip codeminded be>
Date:   Mon Mar 15 10:38:30 2010 +0100

    libtracker-data: STATEMENT_INSERT journal replay performance improvement

 src/libtracker-data/tracker-data-update.c |   32 +++++++++++++++++++---------
 1 files changed, 22 insertions(+), 10 deletions(-)
---
diff --git a/src/libtracker-data/tracker-data-update.c b/src/libtracker-data/tracker-data-update.c
index 6cb28e2..4ad35e3 100644
--- a/src/libtracker-data/tracker-data-update.c
+++ b/src/libtracker-data/tracker-data-update.c
@@ -1176,6 +1176,7 @@ static gboolean
 cache_set_metadata_decomposed (TrackerProperty  *property,
                                const gchar      *value,
                                const gchar      *graph,
+                               gint              graph_id,
                                GError          **error)
 {
 	gboolean            multiple_values, fts;
@@ -1190,7 +1191,7 @@ cache_set_metadata_decomposed (TrackerProperty  *property,
 	/* also insert super property values */
 	super_properties = tracker_property_get_super_properties (property);
 	while (*super_properties) {
-		cache_set_metadata_decomposed (*super_properties, value, graph, &new_error);
+		cache_set_metadata_decomposed (*super_properties, value, graph, graph_id, &new_error);
 		if (new_error) {
 			g_propagate_error (error, new_error);
 			return FALSE;
@@ -1239,7 +1240,7 @@ cache_set_metadata_decomposed (TrackerProperty  *property,
 		             field_name);
 	} else {
 		cache_insert_value (table_name, field_name, &gvalue,
-		                    graph != NULL ? ensure_resource_id (graph, NULL) : 0,
+		                    graph != NULL ? ensure_resource_id (graph, NULL) : graph_id,
 		                    multiple_values, fts,
 		                    tracker_property_get_data_type (property) == TRACKER_PROPERTY_TYPE_DATETIME);
 
@@ -1754,7 +1755,7 @@ tracker_data_insert_statement_with_uri (const gchar            *graph,
 		change = TRUE;
 	} else {
 		/* add value to metadata database */
-		change = cache_set_metadata_decomposed (property, object, graph, &actual_error);
+		change = cache_set_metadata_decomposed (property, object, graph, 0, &actual_error);
 		if (actual_error) {
 			tracker_data_update_buffer_clear ();
 			g_propagate_error (error, actual_error);
@@ -1825,7 +1826,7 @@ tracker_data_insert_statement_with_string (const gchar            *graph,
 	}
 
 	/* add value to metadata database */
-	change = cache_set_metadata_decomposed (property, object, graph, &actual_error);
+	change = cache_set_metadata_decomposed (property, object, graph, 0, &actual_error);
 	if (actual_error) {
 		tracker_data_update_buffer_clear ();
 		g_propagate_error (error, actual_error);
@@ -2513,17 +2514,28 @@ tracker_data_replay_journal (GHashTable *classes,
 		} else if (type == TRACKER_DB_JOURNAL_END_TRANSACTION) {
 			tracker_data_commit_transaction ();
 		} else if (type == TRACKER_DB_JOURNAL_INSERT_STATEMENT) {
+			TrackerProperty *property;
+
 			tracker_db_journal_reader_get_statement (&graph_id, &subject_id, &predicate_id, &object);
 
-			if (graph_id > 0) {
-				graph = query_resource_by_id (graph_id);
+			resource_buffer_switch (NULL, graph_id, NULL, subject_id);
+
+			property = g_hash_table_lookup (properties, GINT_TO_POINTER (predicate_id));
+
+			if (property) {
+				GError *new_error = NULL;
+
+				cache_set_metadata_decomposed (property, object, NULL, graph_id, &new_error);
+
+				if (new_error) {
+					g_warning ("TODO: handle %s", new_error->message);
+					g_error_free (new_error);
+				}
+
 			} else {
-				graph = NULL;
+				g_warning ("TODO: handle property not in ontology anymore");
 			}
-			subject = query_resource_by_id (subject_id);
-			predicate = query_resource_by_id (predicate_id);
 
-			tracker_data_insert_statement_with_string (graph, subject, predicate, object, &error);
 		} else if (type == TRACKER_DB_JOURNAL_INSERT_STATEMENT_ID) {
 			tracker_db_journal_reader_get_statement_id (&graph_id, &subject_id, &predicate_id, &object_id);
 



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