[tracker/journal] libtracker-data: Reflow the code a bit in the journal replayer
- From: Philip Van Hoof <pvanhoof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/journal] libtracker-data: Reflow the code a bit in the journal replayer
- Date: Mon, 25 Oct 2010 07:55:06 +0000 (UTC)
commit f19d07f78c787309fde0dd4ab91f66d218d4b46a
Author: Philip Van Hoof <philip codeminded be>
Date: Mon Oct 25 09:54:29 2010 +0200
libtracker-data: Reflow the code a bit in the journal replayer
src/libtracker-data/tracker-data-update.c | 181 ++++++++++++++---------------
1 files changed, 88 insertions(+), 93 deletions(-)
---
diff --git a/src/libtracker-data/tracker-data-update.c b/src/libtracker-data/tracker-data-update.c
index 28110a1..1816a3a 100644
--- a/src/libtracker-data/tracker-data-update.c
+++ b/src/libtracker-data/tracker-data-update.c
@@ -2730,10 +2730,7 @@ tracker_data_replay_journal (TrackerBusyCallback busy_callback,
iface = tracker_db_manager_get_db_interface ();
stmt = tracker_db_interface_create_statement (iface, TRACKER_DB_STATEMENT_CACHE_TYPE_UPDATE, &new_error,
- "INSERT "
- "INTO Resource "
- "(ID, Uri) "
- "VALUES (?, ?)");
+ "INSERT INTO Resource (ID, Uri) VALUES (?, ?)");
if (stmt) {
tracker_db_statement_bind_int (stmt, 0, id);
@@ -2760,7 +2757,6 @@ tracker_data_replay_journal (TrackerBusyCallback busy_callback,
}
} else if (type == TRACKER_DB_JOURNAL_INSERT_STATEMENT) {
GError *new_error = NULL;
- TrackerProperty *property = NULL;
tracker_db_journal_reader_get_statement (&graph_id, &subject_id, &predicate_id, &object);
@@ -2775,27 +2771,24 @@ tracker_data_replay_journal (TrackerBusyCallback busy_callback,
uri = tracker_ontologies_get_uri_by_id (predicate_id);
if (uri) {
- property = tracker_ontologies_get_property_by_uri (uri);
- }
+ TrackerProperty *property = NULL;
- if (property) {
- resource_buffer_switch (NULL, graph_id, NULL, subject_id);
+ property = tracker_ontologies_get_property_by_uri (uri);
+ if (property) {
+ resource_buffer_switch (NULL, graph_id, NULL, subject_id);
- cache_set_metadata_decomposed (property, object, 0, NULL, graph_id, &new_error);
+ cache_set_metadata_decomposed (property, object, 0, NULL, graph_id, &new_error);
- if (new_error) {
- g_warning ("Journal replay error: '%s'", new_error->message);
- g_clear_error (&new_error);
+ if (new_error) {
+ g_warning ("Journal replay error: '%s'", new_error->message);
+ g_clear_error (&new_error);
+ }
+ } else {
+ g_warning ("Journal replay error: 'property with ID %d doesn't exist'", predicate_id);
}
-
- } else {
- g_warning ("Journal replay error: 'property with ID %d doesn't exist'", predicate_id);
}
-
} else if (type == TRACKER_DB_JOURNAL_INSERT_STATEMENT_ID) {
GError *new_error = NULL;
- TrackerClass *class = NULL;
- TrackerProperty *property = NULL;
tracker_db_journal_reader_get_statement_id (&graph_id, &subject_id, &predicate_id, &object_id);
@@ -2810,44 +2803,45 @@ tracker_data_replay_journal (TrackerBusyCallback busy_callback,
uri = tracker_ontologies_get_uri_by_id (predicate_id);
if (uri) {
- property = tracker_ontologies_get_property_by_uri (uri);
- }
+ TrackerProperty *property = NULL;
- 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 (property == rdf_type) {
- uri = tracker_ontologies_get_uri_by_id (object_id);
- if (uri) {
- class = tracker_ontologies_get_class_by_uri (uri);
- }
- if (class) {
- cache_create_service_decomposed (class, NULL, graph_id);
- } else {
- g_warning ("Journal replay error: 'class with ID %d not found in the ontology'", object_id);
- }
+ property = tracker_ontologies_get_property_by_uri (uri);
+ 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 {
- GError *new_error = NULL;
+ resource_buffer_switch (NULL, graph_id, NULL, subject_id);
+
+ if (property == rdf_type) {
+ uri = tracker_ontologies_get_uri_by_id (object_id);
+ if (uri) {
+ TrackerClass *class = NULL;
+
+ class = tracker_ontologies_get_class_by_uri (uri);
+ if (class) {
+ cache_create_service_decomposed (class, NULL, graph_id);
+ } 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);
+ /* add value to metadata database */
+ cache_set_metadata_decomposed (property, NULL, object_id, NULL, graph_id, &new_error);
- if (new_error) {
- g_warning ("Journal replay error: '%s'", new_error->message);
- g_error_free (new_error);
+ if (new_error) {
+ g_warning ("Journal replay error: '%s'", new_error->message);
+ g_error_free (new_error);
+ }
}
}
+ } else {
+ g_warning ("Journal replay error: 'property with ID %d doesn't exist'", predicate_id);
}
- } else {
- g_warning ("Journal replay error: 'property with ID %d doesn't exist'", predicate_id);
}
-
} else if (type == TRACKER_DB_JOURNAL_DELETE_STATEMENT) {
GError *new_error = NULL;
- TrackerProperty *property = NULL;
tracker_db_journal_reader_get_statement (&graph_id, &subject_id, &predicate_id, &object);
@@ -2864,41 +2858,41 @@ tracker_data_replay_journal (TrackerBusyCallback busy_callback,
uri = tracker_ontologies_get_uri_by_id (predicate_id);
if (uri) {
+ TrackerProperty *property = NULL;
+
property = tracker_ontologies_get_property_by_uri (uri);
- }
- if (property) {
- GError *new_error = NULL;
+ if (property) {
+ GError *new_error = NULL;
- if (object && rdf_type == property) {
- TrackerClass *class = NULL;
+ if (object && rdf_type == property) {
- uri = tracker_ontologies_get_uri_by_id (object_id);
- if (uri) {
- class = tracker_ontologies_get_class_by_uri (uri);
- }
- if (class != NULL) {
- cache_delete_resource_type (class, NULL, graph_id);
+ uri = tracker_ontologies_get_uri_by_id (object_id);
+ if (uri) {
+ TrackerClass *class = NULL;
+
+ class = tracker_ontologies_get_class_by_uri (uri);
+ if (class != NULL) {
+ cache_delete_resource_type (class, NULL, graph_id);
+ } else {
+ g_warning ("Journal replay error: 'class with '%s' not found in the ontology'", object);
+ }
+ }
} else {
- g_warning ("Journal replay error: 'class with '%s' not found in the ontology'", object);
+ delete_metadata_decomposed (property, object, 0, &new_error);
}
- } else {
- delete_metadata_decomposed (property, object, 0, &new_error);
- }
- if (new_error) {
- g_warning ("Journal replay error: '%s'", new_error->message);
- g_error_free (new_error);
- }
+ if (new_error) {
+ g_warning ("Journal replay error: '%s'", new_error->message);
+ g_error_free (new_error);
+ }
- } else {
- g_warning ("Journal replay error: 'property with ID %d doesn't exist'", predicate_id);
+ } else {
+ g_warning ("Journal replay error: 'property with ID %d doesn't exist'", predicate_id);
+ }
}
-
} else if (type == TRACKER_DB_JOURNAL_DELETE_STATEMENT_ID) {
GError *new_error = NULL;
- TrackerClass *class = NULL;
- TrackerProperty *property = NULL;
tracker_db_journal_reader_get_statement_id (&graph_id, &subject_id, &predicate_id, &object_id);
@@ -2913,35 +2907,36 @@ tracker_data_replay_journal (TrackerBusyCallback busy_callback,
uri = tracker_ontologies_get_uri_by_id (predicate_id);
if (uri) {
- property = tracker_ontologies_get_property_by_uri (uri);
- }
+ TrackerProperty *property = NULL;
- if (property) {
-
- resource_buffer_switch (NULL, graph_id, NULL, subject_id);
+ property = tracker_ontologies_get_property_by_uri (uri);
+ if (property) {
+ resource_buffer_switch (NULL, graph_id, NULL, subject_id);
+ if (property == rdf_type) {
+ uri = tracker_ontologies_get_uri_by_id (object_id);
+ if (uri) {
+ TrackerClass *class = NULL;
- if (property == rdf_type) {
- uri = tracker_ontologies_get_uri_by_id (object_id);
- if (uri) {
- class = tracker_ontologies_get_class_by_uri (uri);
- }
- if (class) {
- cache_delete_resource_type (class, NULL, graph_id);
+ class = tracker_ontologies_get_class_by_uri (uri);
+ if (class) {
+ cache_delete_resource_type (class, NULL, graph_id);
+ } else {
+ g_warning ("Journal replay error: 'class with ID %d not found in the ontology'", object_id);
+ }
+ }
} else {
- g_warning ("Journal replay error: 'class with ID %d not found in the ontology'", object_id);
- }
- } else {
- GError *new_error = NULL;
+ GError *new_error = NULL;
- delete_metadata_decomposed (property, NULL, object_id, &new_error);
+ delete_metadata_decomposed (property, NULL, object_id, &new_error);
- if (new_error) {
- g_warning ("Journal replay error: '%s'", new_error->message);
- g_error_free (new_error);
+ if (new_error) {
+ g_warning ("Journal replay error: '%s'", new_error->message);
+ g_error_free (new_error);
+ }
}
+ } else {
+ g_warning ("Journal replay error: 'property with ID %d doesn't exist'", predicate_id);
}
- } else {
- g_warning ("Journal replay error: 'property with ID %d doesn't exist'", predicate_id);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]