[tracker/wip/carlosg/serialize-api: 2/11] libtracker-data: Store the number of columns in select contexts
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/serialize-api: 2/11] libtracker-data: Store the number of columns in select contexts
- Date: Wed, 2 Feb 2022 11:06:21 +0000 (UTC)
commit 312447b864f9b3403aae8455d2b3674ca14120b0
Author: Carlos Garnacho <carlosg gnome org>
Date: Sun Jan 30 12:25:37 2022 +0100
libtracker-data: Store the number of columns in select contexts
Store the number of columns propagated from a TrackerSelectContext
during SPARQL parsing. This will be useful to have.
src/libtracker-data/tracker-sparql-types.h | 3 +++
src/libtracker-data/tracker-sparql.c | 14 ++++++++++++++
2 files changed, 17 insertions(+)
---
diff --git a/src/libtracker-data/tracker-sparql-types.h b/src/libtracker-data/tracker-sparql-types.h
index e676f3f02..3829fd1d6 100644
--- a/src/libtracker-data/tracker-sparql-types.h
+++ b/src/libtracker-data/tracker-sparql-types.h
@@ -214,6 +214,9 @@ struct _TrackerSelectContext {
/* Property path elements */
GPtrArray *path_elements;
+
+ /* Number of variables retrieved in the SELECT */
+ guint n_columns;
};
struct _TrackerSelectContextClass {
diff --git a/src/libtracker-data/tracker-sparql.c b/src/libtracker-data/tracker-sparql.c
index ca9e4b528..e527a217f 100644
--- a/src/libtracker-data/tracker-sparql.c
+++ b/src/libtracker-data/tracker-sparql.c
@@ -2892,6 +2892,7 @@ translate_SelectClause (TrackerSparql *sparql,
tracker_sparql_swap_builder (sparql, old);
first = FALSE;
+ select_context->n_columns++;
}
} else {
do {
@@ -2980,6 +2981,7 @@ translate_SelectClause (TrackerSparql *sparql,
}
first = FALSE;
+ select_context->n_columns++;
} while (TRUE);
}
@@ -3288,6 +3290,7 @@ translate_ConstructQuery (TrackerSparql *sparql,
GError **error)
{
TrackerParserNode *node = NULL;
+ TrackerSelectContext *select_context;
TrackerStringBuilder *old;
/* ConstructQuery ::= 'CONSTRUCT' ( ConstructTemplate DatasetClause* WhereClause SolutionModifier |
@@ -3346,6 +3349,9 @@ translate_ConstructQuery (TrackerSparql *sparql,
}
}
+ select_context = TRACKER_SELECT_CONTEXT (sparql->current_state->select_context);
+ select_context->n_columns = 3;
+
return TRUE;
}
@@ -3354,6 +3360,7 @@ translate_DescribeQuery (TrackerSparql *sparql,
GError **error)
{
TrackerStringBuilder *where_str = NULL;
+ TrackerSelectContext *select_context;
TrackerVariable *variable;
TrackerBinding *binding;
GList *resources = NULL, *l;
@@ -3503,6 +3510,9 @@ translate_DescribeQuery (TrackerSparql *sparql,
g_list_free_full (resources, g_object_unref);
g_clear_pointer (&where_str, tracker_string_builder_free);
+ select_context = TRACKER_SELECT_CONTEXT (sparql->current_state->select_context);
+ select_context->n_columns = 4;
+
return TRUE;
}
@@ -3511,6 +3521,7 @@ translate_AskQuery (TrackerSparql *sparql,
GError **error)
{
TrackerStringBuilder *str, *old;
+ TrackerSelectContext *select_context;
/* AskQuery ::= 'ASK' DatasetClause* WhereClause SolutionModifier
*/
@@ -3531,6 +3542,9 @@ translate_AskQuery (TrackerSparql *sparql,
_append_string (sparql, ") WHEN 1 THEN 'true' WHEN 0 THEN 'false' ELSE NULL END");
+ select_context = TRACKER_SELECT_CONTEXT (sparql->current_state->select_context);
+ select_context->n_columns = 1;
+
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]