[tracker: 1/5] SPARQL: Ensure that WHERE clause is evaluated before performing updates
- From: JÃrg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker: 1/5] SPARQL: Ensure that WHERE clause is evaluated before performing updates
- Date: Thu, 25 Aug 2011 08:50:29 +0000 (UTC)
commit ace86702d90692feb145793a871a06d5f5b59b69
Author: JÃrg Billeter <j bitron ch>
Date: Mon Aug 22 16:00:50 2011 +0200
SPARQL: Ensure that WHERE clause is evaluated before performing updates
This will increase peak memory usage for updates with a WHERE clause
that returns many solutions.
Fixes NB#242979.
src/libtracker-data/tracker-sparql-query.vala | 21 ++++++++++++++-------
1 files changed, 14 insertions(+), 7 deletions(-)
---
diff --git a/src/libtracker-data/tracker-sparql-query.vala b/src/libtracker-data/tracker-sparql-query.vala
index 056719e..171922b 100644
--- a/src/libtracker-data/tracker-sparql-query.vala
+++ b/src/libtracker-data/tracker-sparql-query.vala
@@ -688,24 +688,31 @@ public class Tracker.Sparql.Query : Object {
this.delete_statements = delete_statements;
this.update_statements = update_statements;
- // iterate over all solutions
- while (cursor.next ()) {
- // blank nodes in construct templates are per solution
-
- uuid_generate (base_uuid);
- blank_nodes = new HashTable<string,string>.full (str_hash, str_equal, g_free, g_free);
+ var solutions = new GenericArray<HashTable<string,string>> ();
+ while (cursor.next ()) {
// get values of all variables to be bound
var var_value_map = new HashTable<string,string>.full (str_hash, str_equal, g_free, g_free);
int var_idx = 0;
foreach (var variable in context.var_set.get_keys ()) {
var_value_map.insert (variable.name, cursor.get_string (var_idx++));
}
+ solutions.add (var_value_map);
+ }
+
+ cursor = null;
+
+ // iterate over all solutions
+ for (int i = 0; i < solutions.length; i++) {
+ // blank nodes in construct templates are per solution
+
+ uuid_generate (base_uuid);
+ blank_nodes = new HashTable<string,string>.full (str_hash, str_equal, g_free, g_free);
set_location (template_location);
// iterate over each triple in the template
- parse_construct_triples_block (var_value_map);
+ parse_construct_triples_block (solutions[i]);
if (blank && update_blank_nodes != null) {
update_blank_nodes.add_value (blank_nodes);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]