summaryrefslogtreecommitdiff
path: root/src/libtracker-sparql
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2022-11-13 15:20:59 +0100
committerCarlos Garnacho <carlosg@gnome.org>2022-12-05 15:34:30 +0100
commit38ec817c81f9d2d4261135e8e7bfb3a049b8a2b5 (patch)
tree7c98c0b5d940a097a9721b1423c8816bc3f70cd2 /src/libtracker-sparql
parent5d04f6a4d9d1078919c699084ba05b7d0b4b25ed (diff)
downloadtracker-38ec817c81f9d2d4261135e8e7bfb3a049b8a2b5.tar.gz
core: Move cacheable TrackerSelectContext data to TrackerSparql
After done with query processing, we can keep just small pieces of the TrackerSelectContext data for the (possibly repeatable) query execution step. Move this data to the TrackerSparql, so we can move the TrackerSelectContext to the more transient TrackerSparqlState struct and stick to the essential data.
Diffstat (limited to 'src/libtracker-sparql')
-rw-r--r--src/libtracker-sparql/core/tracker-sparql.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/libtracker-sparql/core/tracker-sparql.c b/src/libtracker-sparql/core/tracker-sparql.c
index b6a912c2a..9f10f5cb3 100644
--- a/src/libtracker-sparql/core/tracker-sparql.c
+++ b/src/libtracker-sparql/core/tracker-sparql.c
@@ -193,6 +193,9 @@ struct _TrackerSparql
TrackerContext *context;
gchar *sql_string;
+ GPtrArray *literal_bindings;
+ guint n_columns;
+
GVariantBuilder *blank_nodes;
GHashTable *solution_var_map;
@@ -10038,7 +10041,6 @@ tracker_sparql_execute_cursor (TrackerSparql *sparql,
TrackerDBStatement *stmt;
TrackerDBInterface *iface = NULL;
TrackerDBCursor *cursor = NULL;
- TrackerSelectContext *select_context;
g_mutex_lock (&sparql->mutex);
@@ -10060,6 +10062,7 @@ tracker_sparql_execute_cursor (TrackerSparql *sparql,
if (tracker_sparql_needs_update (sparql)) {
TrackerSparqlState state = { 0 };
+ TrackerSelectContext *select_context;
gboolean retval;
sparql->current_state = &state;
@@ -10067,6 +10070,13 @@ tracker_sparql_execute_cursor (TrackerSparql *sparql,
tracker_sparql_reset_state (sparql);
retval = _call_rule_func (sparql, NAMED_RULE_Query, error);
sparql->sql_string = tracker_string_builder_to_string (state.result);
+
+ select_context = TRACKER_SELECT_CONTEXT (sparql->context);
+ sparql->n_columns = select_context->n_columns;
+ sparql->literal_bindings =
+ select_context->literal_bindings ?
+ g_ptr_array_ref (select_context->literal_bindings) :
+ NULL;
sparql->current_state = NULL;
tracker_sparql_state_clear (&state);
@@ -10079,9 +10089,8 @@ tracker_sparql_execute_cursor (TrackerSparql *sparql,
if (!iface)
goto error;
- select_context = TRACKER_SELECT_CONTEXT (sparql->context);
stmt = prepare_query (sparql, iface,
- select_context->literal_bindings,
+ sparql->literal_bindings,
parameters,
sparql->cacheable,
error);
@@ -10089,7 +10098,7 @@ tracker_sparql_execute_cursor (TrackerSparql *sparql,
goto error;
cursor = tracker_db_statement_start_sparql_cursor (stmt,
- select_context->n_columns,
+ sparql->n_columns,
error);
g_object_unref (stmt);