[tracker] libtracker-data: Limit update buffer size
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker] libtracker-data: Limit update buffer size
- Date: Tue, 2 Mar 2010 12:40:07 +0000 (UTC)
commit 2c8a8ca4843dcea00e37dc8486355af1863ed872
Author: Jürg Billeter <j bitron ch>
Date: Tue Mar 2 10:51:55 2010 +0100
libtracker-data: Limit update buffer size
INSERT {...} WHERE {...} updates with many solutions to the WHERE
clause were causing high memory usage due to the update buffer.
src/libtracker-data/libtracker-data.vapi | 1 +
src/libtracker-data/tracker-data-update.c | 9 +++++++++
src/libtracker-data/tracker-data-update.h | 1 +
src/libtracker-data/tracker-sparql-query.vala | 2 ++
4 files changed, 13 insertions(+), 0 deletions(-)
---
diff --git a/src/libtracker-data/libtracker-data.vapi b/src/libtracker-data/libtracker-data.vapi
index 31a04a7..490612c 100644
--- a/src/libtracker-data/libtracker-data.vapi
+++ b/src/libtracker-data/libtracker-data.vapi
@@ -36,6 +36,7 @@ namespace Tracker {
public void insert_statement_with_string (string graph, string subject, string predicate, string object) throws DataError;
public void delete_resource_description (string graph, string uri) throws DataError;
public void update_buffer_flush () throws DBInterfaceError;
+ public void update_buffer_might_flush () throws DBInterfaceError;
}
}
diff --git a/src/libtracker-data/tracker-data-update.c b/src/libtracker-data/tracker-data-update.c
index f2713b7..e4ab24d 100644
--- a/src/libtracker-data/tracker-data-update.c
+++ b/src/libtracker-data/tracker-data-update.c
@@ -711,6 +711,15 @@ tracker_data_update_buffer_flush (GError **error)
resource_buffer = NULL;
}
+void
+tracker_data_update_buffer_might_flush (GError **error)
+{
+ /* avoid high memory usage by update buffer */
+ if (g_hash_table_size (update_buffer.resources) >= 1000) {
+ tracker_data_update_buffer_flush (error);
+ }
+}
+
static void
tracker_data_update_buffer_clear (void)
{
diff --git a/src/libtracker-data/tracker-data-update.h b/src/libtracker-data/tracker-data-update.h
index da3d429..f239493 100644
--- a/src/libtracker-data/tracker-data-update.h
+++ b/src/libtracker-data/tracker-data-update.h
@@ -85,6 +85,7 @@ GPtrArray *
tracker_data_update_sparql_blank (const gchar *update,
GError **error);
void tracker_data_update_buffer_flush (GError **error);
+void tracker_data_update_buffer_might_flush (GError **error);
void tracker_data_sync (void);
diff --git a/src/libtracker-data/tracker-sparql-query.vala b/src/libtracker-data/tracker-sparql-query.vala
index ec5599e..88e01ae 100644
--- a/src/libtracker-data/tracker-sparql-query.vala
+++ b/src/libtracker-data/tracker-sparql-query.vala
@@ -1075,6 +1075,8 @@ public class Tracker.SparqlQuery : Object {
HashTable<string,string>* ptr = (owned) blank_nodes;
update_blank_nodes.add (ptr);
}
+
+ Data.update_buffer_might_flush ();
} while (result_set.iter_next ());
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]