[tracker/wip/carlosg/sparql1.1: 92/113] libtracker-data: Create union views on demand
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/sparql1.1: 92/113] libtracker-data: Create union views on demand
- Date: Sun, 21 Jul 2019 14:36:57 +0000 (UTC)
commit 536b745c61f3511f17e4e3496eb30446d6d936c1
Author: Carlos Garnacho <carlosg gnome org>
Date: Sun Jul 14 23:59:16 2019 +0200
libtracker-data: Create union views on demand
Keep track of the union views needed for a query, so they can be
updated before query execution.
src/libtracker-data/tracker-sparql.c | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
---
diff --git a/src/libtracker-data/tracker-sparql.c b/src/libtracker-data/tracker-sparql.c
index 18382fff3..4700557b3 100644
--- a/src/libtracker-data/tracker-sparql.c
+++ b/src/libtracker-data/tracker-sparql.c
@@ -132,6 +132,7 @@ struct _TrackerSparql
gboolean cacheable;
GHashTable *parameters;
+ GHashTable *union_views;
GPtrArray *anon_graphs;
GPtrArray *named_graphs;
@@ -179,6 +180,7 @@ tracker_sparql_finalize (GObject *object)
g_hash_table_destroy (sparql->prefix_map);
g_hash_table_destroy (sparql->parameters);
g_hash_table_destroy (sparql->cached_bindings);
+ g_clear_pointer (&sparql->union_views, g_hash_table_unref);
if (sparql->sql)
tracker_string_builder_free (sparql->sql);
@@ -577,6 +579,11 @@ _prepend_path_element (TrackerSparql *sparql,
table_name = g_strdup_printf ("\"unionGraph_%s\"",
tracker_property_get_table_name
(path_elem->data.property));
graph_column = g_strdup ("graph");
+
+ if (sparql->union_views) {
+ g_hash_table_add (sparql->union_views,
+ g_strdup (tracker_property_get_table_name
(path_elem->data.property)));
+ }
} else {
const gchar *graph;
@@ -688,6 +695,7 @@ _prepend_path_element (TrackerSparql *sparql,
}
_append_string (sparql, ") ");
+ g_clear_pointer (&sparql->union_views, g_hash_table_unref);
break;
case TRACKER_PATH_OPERATOR_INTERSECTION:
_append_string_printf (sparql,
@@ -1802,6 +1810,7 @@ _end_triples_block (TrackerSparql *sparql,
_append_string (sparql,
"(SELECT subject AS ID, predicate, "
"object, object_type, graph FROM tracker_triples) ");
+ g_clear_pointer (&sparql->union_views, g_hash_table_unref);
} else if (table->predicate_path) {
_append_string_printf (sparql, "\"%s\"", table->sql_db_tablename);
} else {
@@ -1821,6 +1830,9 @@ _end_triples_block (TrackerSparql *sparql,
_append_string_printf (sparql, "\"unionGraph_%s\" ",
table->sql_db_tablename);
}
+
+ if (sparql->union_views)
+ g_hash_table_add (sparql->union_views, g_strdup
(table->sql_db_tablename));
}
}
@@ -2433,6 +2445,8 @@ translate_DescribeQuery (TrackerSparql *sparql,
"FROM tracker_triples "
"WHERE object IS NOT NULL AND subject IN (");
+ g_clear_pointer (&sparql->union_views, g_hash_table_unref);
+
if (_accept (sparql, RULE_TYPE_LITERAL, LITERAL_GLOB)) {
glob = TRUE;
} else {
@@ -6453,6 +6467,10 @@ handle_property_function (TrackerSparql *sparql,
if (tracker_token_is_empty (&sparql->current_state.graph)) {
_append_string_printf (sparql, "FROM \"unionGraph_%s\" ",
tracker_property_get_table_name (property));
+ if (sparql->union_views) {
+ g_hash_table_add (sparql->union_views,
+ g_strdup (tracker_property_get_table_name (property)));
+ }
} else {
_append_string_printf (sparql, "FROM \"%s\".\"%s\" ",
tracker_token_get_idstring (&sparql->current_state.graph),
@@ -8198,6 +8216,8 @@ tracker_sparql_init (TrackerSparql *sparql)
g_free, g_object_unref);
sparql->parameters = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, g_object_unref);
+ sparql->union_views = g_hash_table_new_full (g_str_hash, g_str_equal,
+ g_free, NULL);
sparql->var_names = g_ptr_array_new_with_free_func (g_free);
sparql->var_types = g_array_new (FALSE, FALSE, sizeof (TrackerPropertyType));
sparql->anon_graphs = g_ptr_array_new_with_free_func (g_free);
@@ -8243,7 +8263,8 @@ prepare_query (TrackerSparql *sparql,
gchar *query;
guint i;
- if (!tracker_data_manager_update_union_views (sparql->data_manager, iface, NULL, error))
+ if (!tracker_data_manager_update_union_views (sparql->data_manager, iface,
+ sparql->union_views, error))
return NULL;
query = tracker_string_builder_to_string (str);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]