[tracker] libtracker-data: Bypass update buffer for rdf:type deletes if possible
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker] libtracker-data: Bypass update buffer for rdf:type deletes if possible
- Date: Mon, 27 Dec 2010 15:12:39 +0000 (UTC)
commit f3b177eb8e245ae5f380df7c7a8a2905b3be20cc
Author: Jürg Billeter <j bitron ch>
Date: Mon Dec 27 14:52:57 2010 +0100
libtracker-data: Bypass update buffer for rdf:type deletes if possible
This improves delete performance.
src/libtracker-data/tracker-data-update.c | 46 +++++++++++++++++++++++++++-
1 files changed, 44 insertions(+), 2 deletions(-)
---
diff --git a/src/libtracker-data/tracker-data-update.c b/src/libtracker-data/tracker-data-update.c
index c615ce7..6e46c5f 100644
--- a/src/libtracker-data/tracker-data-update.c
+++ b/src/libtracker-data/tracker-data-update.c
@@ -1649,6 +1649,31 @@ delete_metadata_decomposed (TrackerProperty *property,
}
static void
+db_delete_row (TrackerDBInterface *iface,
+ const gchar *table_name,
+ gint id)
+{
+ TrackerDBStatement *stmt;
+ GError *error = NULL;
+
+ stmt = tracker_db_interface_create_statement (iface, TRACKER_DB_STATEMENT_CACHE_TYPE_UPDATE, &error,
+ "DELETE FROM \"%s\" WHERE ID = ?",
+ table_name);
+
+ if (stmt) {
+ tracker_db_statement_bind_int (stmt, 0, id);
+ tracker_db_statement_execute (stmt, &error);
+ g_object_unref (stmt);
+ }
+
+ if (error) {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ error = NULL;
+ }
+}
+
+static void
cache_delete_resource_type (TrackerClass *class,
const gchar *graph,
gint graph_id)
@@ -1657,7 +1682,7 @@ cache_delete_resource_type (TrackerClass *class,
TrackerDBStatement *stmt;
TrackerDBResultSet *result_set = NULL;
TrackerProperty **properties, *prop;
- gboolean found;
+ gboolean found, direct_delete;
gint i;
guint p, n_props;
GError *error = NULL;
@@ -1694,6 +1719,7 @@ cache_delete_resource_type (TrackerClass *class,
if (error) {
g_warning ("%s", error->message);
g_error_free (error);
+ error = NULL;
}
if (result_set) {
@@ -1709,6 +1735,10 @@ cache_delete_resource_type (TrackerClass *class,
g_object_unref (result_set);
}
+ /* bypass buffer if possible
+ we need old property values with FTS */
+ direct_delete = (!HAVE_TRACKER_FTS && g_hash_table_size (resource_buffer->tables) == 0);
+
/* delete all property values */
properties = tracker_ontologies_get_properties (&n_props);
@@ -1730,6 +1760,14 @@ cache_delete_resource_type (TrackerClass *class,
table_name = tracker_property_get_table_name (prop);
field_name = tracker_property_get_name (prop);
+ if (direct_delete) {
+ if (multiple_values) {
+ db_delete_row (iface, table_name, resource_buffer->id);
+ }
+ /* single-valued property values are deleted right after the loop by deleting the row in the class table */
+ continue;
+ }
+
old_values = get_old_property_values (prop, NULL);
for (y = old_values->n_values - 1; y >= 0 ; y--) {
@@ -1766,7 +1804,11 @@ cache_delete_resource_type (TrackerClass *class,
}
}
- cache_delete_row (class);
+ if (direct_delete) {
+ db_delete_row (iface, tracker_class_get_name (class), resource_buffer->id);
+ } else {
+ cache_delete_row (class);
+ }
if (!in_journal_replay && delete_callbacks) {
guint n;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]