[tracker/wip/carlosg/anonymous-nodes: 37/46] libtracker-data: Handle blank node tokens in TrackerSparql
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/anonymous-nodes: 37/46] libtracker-data: Handle blank node tokens in TrackerSparql
- Date: Sun, 12 Dec 2021 14:15:43 +0000 (UTC)
commit a2b6b6e062c2a035ff3fc103090904faf919da87
Author: Carlos Garnacho <carlosg gnome org>
Date: Sat Sep 25 14:32:05 2021 +0200
libtracker-data: Handle blank node tokens in TrackerSparql
These are unused yet, but the machinery is now able to resolve
those to resource ROWIDs.
src/libtracker-data/tracker-sparql.c | 33 ++++++++++++++++++++++++++++-----
1 file changed, 28 insertions(+), 5 deletions(-)
---
diff --git a/src/libtracker-data/tracker-sparql.c b/src/libtracker-data/tracker-sparql.c
index 4077aa6c2..f57b54bc5 100644
--- a/src/libtracker-data/tracker-sparql.c
+++ b/src/libtracker-data/tracker-sparql.c
@@ -2082,6 +2082,15 @@ value_init_from_token (TrackerSparql *sparql,
GError **error)
{
GBytes *literal;
+ gint64 bnode_id;
+
+ bnode_id = tracker_token_get_bnode (token);
+
+ if (bnode_id != 0) {
+ g_value_init (value, G_TYPE_INT64);
+ g_value_set_int64 (value, bnode_id);
+ return;
+ }
literal = tracker_token_get_literal (token);
@@ -2105,6 +2114,23 @@ value_init_from_token (TrackerSparql *sparql,
}
}
+static gint64
+tracker_sparql_get_subject_id (TrackerSparql *sparql,
+ GError **error)
+{
+ const gchar *subject_str;
+ gint64 bnode_id;
+
+ bnode_id = tracker_token_get_bnode (&sparql->current_state->subject);
+ if (bnode_id != 0)
+ return bnode_id;
+
+ subject_str = tracker_token_get_idstring (&sparql->current_state->subject);
+ return tracker_data_update_ensure_resource (tracker_data_manager_get_data (sparql->data_manager),
+ subject_str,
+ error);
+}
+
static gboolean
tracker_sparql_apply_quad (TrackerSparql *sparql,
GError **error)
@@ -2127,7 +2153,7 @@ tracker_sparql_apply_quad (TrackerSparql *sparql,
sparql->current_state->type == TRACKER_SPARQL_TYPE_DELETE ||
sparql->current_state->type == TRACKER_SPARQL_TYPE_UPDATE) {
TrackerOntologies *ontologies;
- const gchar *property, *subject_str;
+ const gchar *property;
ontologies = tracker_data_manager_get_ontologies (sparql->data_manager);
property = tracker_token_get_idstring (&sparql->current_state->predicate);
@@ -2151,10 +2177,7 @@ tracker_sparql_apply_quad (TrackerSparql *sparql,
return FALSE;
}
- subject_str = tracker_token_get_idstring (&sparql->current_state->subject);
- subject = tracker_data_update_ensure_resource (tracker_data_manager_get_data
(sparql->data_manager),
- subject_str,
- error);
+ subject = tracker_sparql_get_subject_id (sparql, error);
if (subject == 0)
return FALSE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]