[tracker] Don't store last modseq, use max(tracker:modified) instead
- From: Philip Van Hoof <pvanhoof src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [tracker] Don't store last modseq, use max(tracker:modified) instead
- Date: Fri, 14 Aug 2009 10:53:16 +0000 (UTC)
commit f9b87f0bde34a6539ddcf5147bf57e5f862fcfc2
Author: Philip Van Hoof <philip codeminded be>
Date: Fri Aug 14 12:51:43 2009 +0200
Don't store last modseq, use max(tracker:modified) instead
Also changed the ontology to use xsd:integer instead of xsd:datetime.
This change requires running tracker-processes -r to restart the
ontology initialization.
data/ontologies/11-rdf.ontology | 2 +-
src/libtracker-data/tracker-data-manager.c | 18 ----------
src/libtracker-data/tracker-data-update.c | 52 +++++++++++++++++++--------
src/libtracker-data/tracker-data-update.h | 3 --
4 files changed, 37 insertions(+), 38 deletions(-)
---
diff --git a/data/ontologies/11-rdf.ontology b/data/ontologies/11-rdf.ontology
index 28c7589..717343a 100644
--- a/data/ontologies/11-rdf.ontology
+++ b/data/ontologies/11-rdf.ontology
@@ -89,5 +89,5 @@ tracker:transient a rdf:Property ;
tracker:modified a rdf:Property ;
nrl:maxCardinality 1 ;
rdfs:domain rdfs:Resource ;
- rdfs:range xsd:dateTime .
+ rdfs:range xsd:integer .
diff --git a/src/libtracker-data/tracker-data-manager.c b/src/libtracker-data/tracker-data-manager.c
index 773fef8..d0f2d93 100644
--- a/src/libtracker-data/tracker-data-manager.c
+++ b/src/libtracker-data/tracker-data-manager.c
@@ -66,21 +66,6 @@ static gchar *ontologies_dir;
static gboolean initialized;
static void
-tracker_data_store_modseq (void)
-{
- tracker_data_manager_set_db_option_int64 ("ModificationSequence",
- tracker_data_get_modification_sequence ());
-
-}
-
-static void
-tracker_data_restore_modseq (void)
-{
- tracker_data_set_modification_sequence (tracker_data_manager_get_db_option_int64 ("ModificationSequence"));
-}
-
-
-static void
load_ontology_file_from_path (const gchar *ontology_file)
{
tracker_turtle_reader_init (ontology_file, NULL);
@@ -875,8 +860,6 @@ tracker_data_manager_init (TrackerDBManagerFlags flags,
create_decomposed_transient_metadata_tables (iface);
}
- tracker_data_restore_modseq ();
-
initialized = TRUE;
return TRUE;
@@ -888,7 +871,6 @@ tracker_data_manager_shutdown (void)
{
g_return_if_fail (initialized == TRUE);
- tracker_data_store_modseq ();
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 011001d..316752e 100644
--- a/src/libtracker-data/tracker-data-update.c
+++ b/src/libtracker-data/tracker-data-update.c
@@ -88,19 +88,6 @@ static TrackerStatementCallback delete_callback = NULL;
static gpointer delete_data;
static TrackerCommitCallback commit_callback = NULL;
static gpointer commit_data;
-static gint64 modification_sequence;
-
-gint64
-tracker_data_get_modification_sequence (void)
-{
- return modification_sequence;
-}
-
-void
-tracker_data_set_modification_sequence (gint64 modseq)
-{
- modification_sequence = modseq;
-}
void
tracker_data_set_commit_statement_callback (TrackerCommitCallback callback,
@@ -161,6 +148,39 @@ tracker_data_update_get_new_service_id (TrackerDBInterface *iface)
return ++max;
}
+
+static guint32
+tracker_data_update_get_next_modseq (void)
+{
+ guint32 files_max;
+ TrackerDBResultSet *result_set;
+ TrackerDBInterface *temp_iface;
+ static guint32 max = 0;
+
+ if (G_LIKELY (max != 0)) {
+ return ++max;
+ }
+
+ temp_iface = tracker_db_manager_get_db_interface ();
+
+ result_set = tracker_db_interface_execute_query (temp_iface, NULL,
+ "SELECT MAX(\"tracker:modified\") AS A FROM \"rdfs:Resource\"");
+
+ if (result_set) {
+ GValue val = {0, };
+ _tracker_db_result_set_get_value (result_set, 0, &val);
+ if (G_VALUE_TYPE (&val) == G_TYPE_INT) {
+ files_max = g_value_get_int (&val);
+ max = MAX (files_max, max);
+ g_value_unset (&val);
+ }
+ g_object_unref (result_set);
+ }
+
+ return ++max;
+}
+
+
static TrackerDataUpdateBufferTable *
cache_table_new (gboolean multiple_values)
{
@@ -269,7 +289,7 @@ ensure_resource_id (const gchar *uri)
stmt = tracker_db_interface_create_statement (iface, "INSERT INTO \"rdfs:Resource\" (ID, Uri, \"tracker:modified\", Available) VALUES (?, ?, ?, 1)");
tracker_db_statement_bind_int (stmt, 0, id);
tracker_db_statement_bind_text (stmt, 1, uri);
- tracker_db_statement_bind_int64 (stmt, 2, ++modification_sequence);
+ tracker_db_statement_bind_int (stmt, 2, tracker_data_update_get_next_modseq ());
tracker_db_statement_execute (stmt, NULL);
g_object_unref (stmt);
@@ -1010,14 +1030,14 @@ tracker_data_insert_statement_common (const gchar *subject,
if (update_buffer.subject == NULL) {
GValue gvalue = { 0 };
- g_value_init (&gvalue, G_TYPE_INT64);
+ g_value_init (&gvalue, G_TYPE_INT);
/* subject not yet in cache, retrieve or create ID */
update_buffer.subject = g_strdup (subject);
update_buffer.id = ensure_resource_id (update_buffer.subject);
update_buffer.types = tracker_data_query_rdf_type (update_buffer.id);
- g_value_set_int64 (&gvalue, ++modification_sequence);
+ g_value_set_int (&gvalue, tracker_data_update_get_next_modseq ());
cache_insert_value ("rdfs:Resource", "tracker:modified", &gvalue, FALSE, FALSE);
}
diff --git a/src/libtracker-data/tracker-data-update.h b/src/libtracker-data/tracker-data-update.h
index aac85f1..d9215b1 100644
--- a/src/libtracker-data/tracker-data-update.h
+++ b/src/libtracker-data/tracker-data-update.h
@@ -69,9 +69,6 @@ void tracker_data_commit_transaction (void);
void tracker_data_update_sparql (const gchar *update,
GError **error);
-gint64 tracker_data_get_modification_sequence (void);
-void tracker_data_set_modification_sequence (gint64 modseq);
-
/* Volume handling */
void tracker_data_update_enable_volume (const gchar *udi,
const gchar *mount_path);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]