summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2023-01-22 15:06:42 +0100
committerCarlos Garnacho <carlosg@gnome.org>2023-01-23 15:50:06 +0100
commiteb75f65bc2c4611e5a7c97c584f39f5ea0757788 (patch)
treef4e4d6be6db76bb210207433f18cf5bfa5e02f7e
parentc17afbb00a1fb57e2df9bf2ca11b77db0424b586 (diff)
downloadtracker-eb75f65bc2c4611e5a7c97c584f39f5ea0757788.tar.gz
core: Fallback to resource creation case if resource has no types yet
It might happen that a resource IRI is first registered, the buffer fills up and flushes with data not yet related to this resource, and this resource is not considered "new" anymore on later buffer handling. Even though the worst thing that might happen here are some redundant queries, we might still avoid them completely. So enable the "create" flag if the resource does not have RDF types, meaning it was only inserted to the Resource table.
-rw-r--r--src/libtracker-sparql/core/tracker-data-update.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/libtracker-sparql/core/tracker-data-update.c b/src/libtracker-sparql/core/tracker-data-update.c
index b481c23d3..046b4abe5 100644
--- a/src/libtracker-sparql/core/tracker-data-update.c
+++ b/src/libtracker-sparql/core/tracker-data-update.c
@@ -2568,7 +2568,9 @@ resource_buffer_switch (TrackerData *data,
create = g_hash_table_contains (data->update_buffer.new_resources,
&subject);
- if (!create) {
+ if (create) {
+ rdf_types = g_ptr_array_new ();
+ } else {
rdf_types = tracker_data_query_rdf_type (data,
graph_buffer,
subject,
@@ -2577,17 +2579,15 @@ resource_buffer_switch (TrackerData *data,
g_propagate_error (error, inner_error);
return FALSE;
}
+
+ if (rdf_types->len == 0)
+ create = TRUE;
}
resource_buffer = g_slice_new0 (TrackerDataUpdateBufferResource);
resource_buffer->id = subject;
resource_buffer->create = create;
-
- if (resource_buffer->create) {
- resource_buffer->types = g_ptr_array_new ();
- } else {
- resource_buffer->types = rdf_types;
- }
+ resource_buffer->types = rdf_types;
resource_buffer->graph = graph_buffer;
g_hash_table_insert (graph_buffer->resources, &resource_buffer->id, resource_buffer);