[tracker/wip/carlosg/graphs: 9/12] libtracker-sparql: Don't skip TrackerResources by URI
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/graphs: 9/12] libtracker-sparql: Don't skip TrackerResources by URI
- Date: Wed, 29 Apr 2020 20:33:47 +0000 (UTC)
commit 569b0a9cb3112ddb2e00e83f5e1c4cc976e34141
Author: Carlos Garnacho <carlosg gnome org>
Date: Thu Apr 23 23:28:32 2020 +0200
libtracker-sparql: Don't skip TrackerResources by URI
If different relations are set on different TrackerResources with
the same uri, only the first would be found at the same of printing
the resulting sparql/json/ttl output. This may miss properties being
set on the other resources that are skipped.
This is a case happening in the nie:DataObject/nie:InformationElement
split, as tracker-extract will receive a TrackerResource to be used
for the nie:InformationElement, but nie:hasHash and nie:dataSource
need to be set on the nie:DataObject at places isolated from each
other.
The solution to that is have those places create an intermediate
TrackerResource for the nie:DataObject each, and set the desired
properties.
In order to have all those properties properly printed, we don't
need to skip resources based on their identifier URI, detecting
cycles is still necessary. This may break if several of these
resources where to do tracker_resource_set_*() on the very same
property, and all expected the property to be cleared. Let's deem
this much of a corner case to justify larger refactors.
src/libtracker-sparql/tracker-resource.c | 16 ++++------------
1 file changed, 4 insertions(+), 12 deletions(-)
---
diff --git a/src/libtracker-sparql/tracker-resource.c b/src/libtracker-sparql/tracker-resource.c
index bf0c40a4c..8bbe3ba46 100644
--- a/src/libtracker-sparql/tracker-resource.c
+++ b/src/libtracker-sparql/tracker-resource.c
@@ -963,14 +963,6 @@ tracker_resource_compare (TrackerResource *a,
return strcmp (a_priv->identifier, b_priv->identifier);
};
-/* Internal helper. */
-static GList *
-g_list_find_resource (GList *list,
- TrackerResource *resource) {
- return g_list_find_custom (list, resource, (GCompareFunc) tracker_resource_compare);
-}
-
-
/* Helper function for serialization code. This allows you to selectively
* populate 'interned_namespaces' from 'all_namespaces' based on when a
* particular prefix is actually used. This is quite inefficient compared
@@ -1053,7 +1045,7 @@ generate_nested_turtle_resource (TrackerResource *resource,
data->all_namespaces))
return;
- if (g_list_find_resource (data->done_list, resource) == NULL) {
+ if (g_list_find (data->done_list, resource) == NULL) {
data->done_list = g_list_prepend (data->done_list, resource);
generate_turtle (resource, data);
g_string_append (data->string, "\n");
@@ -1435,7 +1427,7 @@ generate_sparql_deletes (TrackerResource *resource,
{
TrackerResourcePrivate *priv = GET_PRIVATE (resource);
- if (g_list_find_resource (data->done_list, resource) != NULL)
+ if (g_list_find (data->done_list, resource) != NULL)
/* We already processed this resource. */
return;
@@ -1460,7 +1452,7 @@ generate_sparql_insert_pattern (TrackerResource *resource,
const GValue *value;
gboolean had_property = FALSE;
- if (g_list_find_resource (data->done_list, resource) != NULL)
+ if (g_list_find (data->done_list, resource) != NULL)
/* We already processed this resource. */
return;
@@ -1617,7 +1609,7 @@ generate_jsonld_value (const GValue *value,
resource = TRACKER_RESOURCE (g_value_get_object (value));
- if (g_list_find_resource (data->done_list, resource) == NULL) {
+ if (g_list_find (data->done_list, resource) == NULL) {
data->done_list = g_list_prepend (data->done_list, resource);
json_builder_begin_object (data->builder);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]