[tracker/journal: 10/21] libtracker-data: STATEMENT_INSERT_ID journal replay performance improvement
- From: Philip Van Hoof <pvanhoof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/journal: 10/21] libtracker-data: STATEMENT_INSERT_ID journal replay performance improvement
- Date: Wed, 17 Mar 2010 09:33:24 +0000 (UTC)
commit 9e02ee9684f20eed4107a75b38363d16724c7945
Author: Philip Van Hoof <philip codeminded be>
Date: Mon Mar 15 14:19:12 2010 +0100
libtracker-data: STATEMENT_INSERT_ID journal replay performance improvement
src/libtracker-data/tracker-data-update.c | 56 ++++++++++++++++++++++++-----
1 files changed, 47 insertions(+), 9 deletions(-)
---
diff --git a/src/libtracker-data/tracker-data-update.c b/src/libtracker-data/tracker-data-update.c
index 4553604..6402075 100644
--- a/src/libtracker-data/tracker-data-update.c
+++ b/src/libtracker-data/tracker-data-update.c
@@ -2490,18 +2490,57 @@ tracker_data_replay_journal (GHashTable *classes,
}
} else if (type == TRACKER_DB_JOURNAL_INSERT_STATEMENT_ID) {
+ TrackerClass *class = NULL;
+ TrackerProperty *property;
+
tracker_db_journal_reader_get_statement_id (&graph_id, &subject_id, &predicate_id, &object_id);
- if (graph_id > 0) {
- graph = query_resource_by_id (graph_id);
+ property = g_hash_table_lookup (properties, GINT_TO_POINTER (predicate_id));
+
+ if (property) {
+ if (tracker_property_get_data_type (property) != TRACKER_PROPERTY_TYPE_RESOURCE) {
+ g_warning ("Journal replay error: 'property with ID %d does not account URIs'", predicate_id);
+ } else {
+ resource_buffer_switch (NULL, graph_id, NULL, subject_id);
+
+ if (!rdf_type) {
+ rdf_type = tracker_ontologies_get_property_by_uri (RDF_PREFIX "type");
+ }
+
+ if (property == rdf_type) {
+ /* TODO: refactor the necessity of this lookup away */
+ const gchar *object = query_resource_by_id (object_id);
+
+ /* handle rdf:type statements specially to
+ cope with inference and insert blank rows */
+
+ if (object) {
+ class = tracker_ontologies_get_class_by_uri (object);
+ }
+
+ if (class != NULL) {
+ cache_create_service_decomposed (class, NULL, graph_id, FALSE);
+ } else {
+ g_warning ("Journal replay error: 'class with ID %d not found in the ontology'", object_id);
+ }
+
+ } else {
+ GError *new_error = NULL;
+
+ /* add value to metadata database */
+ cache_set_metadata_decomposed (property, NULL, object_id, NULL, graph_id, &new_error);
+
+ if (new_error) {
+ tracker_data_update_buffer_clear ();
+ g_warning ("Journal replay error: '%s'", new_error->message);
+ g_error_free (new_error);
+ }
+ }
+ }
} else {
- graph = NULL;
+ g_warning ("Journal replay error: 'property with ID %d doesn't exist'", predicate_id);
}
- subject = query_resource_by_id (subject_id);
- predicate = query_resource_by_id (predicate_id);
- object = query_resource_by_id (object_id);
- tracker_data_insert_statement_with_uri (graph, subject, predicate, object, &error);
} else if (type == TRACKER_DB_JOURNAL_DELETE_STATEMENT) {
TrackerProperty *property;
@@ -2525,8 +2564,7 @@ tracker_data_replay_journal (GHashTable *classes,
if (class != NULL) {
cache_delete_resource_type (class, NULL, graph_id, FALSE);
} else {
- g_set_error (&new_error, TRACKER_DATA_ERROR, TRACKER_DATA_ERROR_UNKNOWN_CLASS,
- "Class '%s' not found in the ontology", object);
+ g_warning ("Journal replay error: 'class with '%s' not found in the ontology'", object);
}
} else {
delete_metadata_decomposed (property, object, &new_error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]