[tracker/binary-log-2: 21/35] 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: 21/35] libtracker-data: Append updates to journal
- Date: Tue, 12 Jan 2010 14:49:54 +0000 (UTC)
commit abe5f745aac08664f7180e22a6a527b05180b2c8
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 | 7 ++++++
src/libtracker-data/tracker-data-update.c | 31 ++++++++++++++++++++++++++++
2 files changed, 38 insertions(+), 0 deletions(-)
---
diff --git a/src/libtracker-data/tracker-data-manager.c b/src/libtracker-data/tracker-data-manager.c
index 201ffa0..7988a08 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_init (NULL);
+
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,7 @@ tracker_data_manager_shutdown (void)
{
g_return_if_fail (initialized == TRUE);
+ tracker_db_journal_shutdown ();
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..b5e8a4f 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,
@@ -1522,6 +1539,10 @@ tracker_data_insert_statement_with_uri (const gchar *graph,
}
}
}
+
+ tracker_db_journal_append_insert_statement_code (resource_buffer->id,
+ tracker_data_query_resource_id (predicate),
+ query_resource_id (object));
}
void
@@ -1578,6 +1599,10 @@ tracker_data_insert_statement_with_string (const gchar *graph,
delegate->user_data);
}
}
+
+ tracker_db_journal_append_insert_statement (resource_buffer->id,
+ tracker_data_query_resource_id (predicate),
+ object);
}
static void
@@ -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]