[tracker/binary-log-2: 9/46] libtracker-data: Append updates to journal
- From: Jürg Billeter <juergbi src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [tracker/binary-log-2: 9/46] libtracker-data: Append updates to journal
- Date: Mon, 11 Jan 2010 17:19:03 +0000 (UTC)
commit 123ae7aceb342cb9bc9e33e546f19432bec550a5
Author: Jürg Billeter <j bitron ch>
Date: Tue Dec 29 14:11:29 2009 +0100
libtracker-data: Append updates to journal
src/libtracker-data/tracker-data-manager.c | 8 +++++++
src/libtracker-data/tracker-data-update.c | 31 ++++++++++++++++++++++++++++
2 files changed, 39 insertions(+), 0 deletions(-)
---
diff --git a/src/libtracker-data/tracker-data-manager.c b/src/libtracker-data/tracker-data-manager.c
index 201ffa0..8068b8d 100644
--- a/src/libtracker-data/tracker-data-manager.c
+++ b/src/libtracker-data/tracker-data-manager.c
@@ -36,6 +36,7 @@
#include <libtracker-db/tracker-db-interface-sqlite.h>
#include <libtracker-db/tracker-db-manager.h>
+#include <libtracker-db/tracker-db-journal.h>
#include "tracker-data-manager.h"
#include "tracker-data-update.h"
@@ -575,6 +576,7 @@ insert_uri_in_resource_table (TrackerDBInterface *iface, const gchar *uri, gint
g_clear_error (&error);
}
+ tracker_db_journal_append_resource (id, uri);
tracker_ontology_add_id_uri_pair (id, uri);
g_object_unref (stmt);
@@ -815,6 +817,8 @@ tracker_data_manager_init (TrackerDBManagerFlags flags,
iface = tracker_db_manager_get_db_interface ();
+ tracker_db_journal_open ();
+
if (is_first_time_index) {
TrackerClass **classes;
TrackerProperty **properties;
@@ -879,6 +883,7 @@ tracker_data_manager_init (TrackerDBManagerFlags flags,
classes = tracker_ontology_get_classes (&n_classes);
tracker_data_begin_transaction ();
+ tracker_db_journal_start_transaction ();
/* create tables */
for (i = 0; i < n_classes; i++) {
@@ -915,6 +920,7 @@ tracker_data_manager_init (TrackerDBManagerFlags flags,
}
}
+ tracker_db_journal_commit_transaction ();
tracker_data_commit_transaction ();
g_list_foreach (sorted, (GFunc) g_free, NULL);
@@ -942,6 +948,8 @@ tracker_data_manager_shutdown (void)
{
g_return_if_fail (initialized == TRUE);
+ tracker_db_journal_close ();
+
tracker_db_manager_shutdown ();
initialized = FALSE;
diff --git a/src/libtracker-data/tracker-data-update.c b/src/libtracker-data/tracker-data-update.c
index d9a73c0..e207929 100644
--- a/src/libtracker-data/tracker-data-update.c
+++ b/src/libtracker-data/tracker-data-update.c
@@ -33,6 +33,7 @@
#include <libtracker-db/tracker-db-manager.h>
#include <libtracker-db/tracker-db-dbus.h>
+#include <libtracker-db/tracker-db-journal.h>
#include "tracker-data-manager.h"
#include "tracker-data-update.h"
@@ -394,6 +395,8 @@ ensure_resource_id (const gchar *uri)
tracker_db_statement_execute (stmt, NULL);
g_object_unref (stmt);
+ tracker_db_journal_append_resource (id, uri);
+
g_hash_table_insert (update_buffer.resource_cache, g_strdup (uri), GUINT_TO_POINTER (id));
}
@@ -1277,6 +1280,10 @@ tracker_data_delete_statement (const gchar *graph,
if (object && g_strcmp0 (predicate, RDF_PREFIX "type") == 0) {
class = tracker_ontology_get_class_by_uri (object);
if (class != NULL) {
+ tracker_db_journal_append_delete_statement_code (resource_buffer->id,
+ tracker_data_query_resource_id (predicate),
+ query_resource_id (object));
+
cache_delete_resource_type (class, graph);
} else {
g_set_error (error, TRACKER_DATA_ERROR, TRACKER_DATA_ERROR_UNKNOWN_CLASS,
@@ -1285,6 +1292,16 @@ tracker_data_delete_statement (const gchar *graph,
} else {
field = tracker_ontology_get_property_by_uri (predicate);
if (field != NULL) {
+ if (tracker_property_get_data_type (field) == TRACKER_PROPERTY_TYPE_RESOURCE) {
+ tracker_db_journal_append_delete_statement_code (resource_buffer->id,
+ tracker_data_query_resource_id (predicate),
+ query_resource_id (object));
+ } else {
+ tracker_db_journal_append_delete_statement (resource_buffer->id,
+ tracker_data_query_resource_id (predicate),
+ object);
+ }
+
delete_metadata_decomposed (field, object, error);
} else {
g_set_error (error, TRACKER_DATA_ERROR, TRACKER_DATA_ERROR_UNKNOWN_PROPERTY,
@@ -1488,6 +1505,10 @@ tracker_data_insert_statement_with_uri (const gchar *graph,
return;
}
+ tracker_db_journal_append_insert_statement_code (resource_buffer->id,
+ tracker_data_query_resource_id (predicate),
+ query_resource_id (object));
+
if (strcmp (predicate, RDF_PREFIX "type") == 0) {
/* handle rdf:type statements specially to
cope with inference and insert blank rows */
@@ -1559,6 +1580,10 @@ tracker_data_insert_statement_with_string (const gchar *graph,
return;
}
+ tracker_db_journal_append_insert_statement (resource_buffer->id,
+ tracker_data_query_resource_id (predicate),
+ object);
+
/* add value to metadata database */
cache_set_metadata_decomposed (property, object, &actual_error);
if (actual_error) {
@@ -2066,12 +2091,14 @@ tracker_data_update_sparql (const gchar *update,
sparql_query = tracker_sparql_query_new_update (update);
tracker_db_interface_execute_query (iface, NULL, "SAVEPOINT sparql");
+ tracker_db_journal_start_transaction ();
tracker_sparql_query_execute_update (sparql_query, FALSE, &actual_error);
if (actual_error) {
tracker_data_update_buffer_clear ();
tracker_db_interface_execute_query (iface, NULL, "ROLLBACK TO sparql");
+ tracker_db_journal_rollback_transaction ();
if (rollback_callbacks) {
guint n;
@@ -2088,6 +2115,7 @@ tracker_data_update_sparql (const gchar *update,
return;
}
+ tracker_db_journal_commit_transaction ();
tracker_db_interface_execute_query (iface, NULL, "RELEASE sparql");
g_object_unref (sparql_query);
@@ -2110,12 +2138,14 @@ tracker_data_update_sparql_blank (const gchar *update,
sparql_query = tracker_sparql_query_new_update (update);
tracker_db_interface_execute_query (iface, NULL, "SAVEPOINT sparql");
+ tracker_db_journal_start_transaction ();
blank_nodes = tracker_sparql_query_execute_update (sparql_query, TRUE, &actual_error);
if (actual_error) {
tracker_data_update_buffer_clear ();
tracker_db_interface_execute_query (iface, NULL, "ROLLBACK TO sparql");
+ tracker_db_journal_rollback_transaction ();
if (rollback_callbacks) {
guint n;
@@ -2132,6 +2162,7 @@ tracker_data_update_sparql_blank (const gchar *update,
return NULL;
}
+ tracker_db_journal_commit_transaction ();
tracker_db_interface_execute_query (iface, NULL, "RELEASE sparql");
g_object_unref (sparql_query);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]