[tracker/wip/carlosg/update-perf: 43/61] core: Add fast path to look up class/property URIs
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/update-perf: 43/61] core: Add fast path to look up class/property URIs
- Date: Mon, 22 Aug 2022 22:07:43 +0000 (UTC)
commit 83f2fb6ab4f708bd820f31c25718b858d64505f3
Author: Carlos Garnacho <carlosg gnome org>
Date: Thu Aug 18 20:13:32 2022 +0200
core: Add fast path to look up class/property URIs
We already have the data in memory, so use that instead of querying the
database for these. If the URI does not turn out to be a class/property
one, the database lookup is performed.
src/libtracker-sparql/core/tracker-data-update.c | 25 +++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
---
diff --git a/src/libtracker-sparql/core/tracker-data-update.c
b/src/libtracker-sparql/core/tracker-data-update.c
index f21c24a6d..740a29d39 100644
--- a/src/libtracker-sparql/core/tracker-data-update.c
+++ b/src/libtracker-sparql/core/tracker-data-update.c
@@ -860,7 +860,9 @@ tracker_data_update_ensure_resource (TrackerData *data,
TrackerDBStatement *stmt = NULL;
GError *inner_error = NULL;
gchar *key;
- TrackerRowid *value, id;
+ TrackerRowid *value, id = 0;
+ TrackerOntologies *ontologies;
+ TrackerClass *class;
value = g_hash_table_lookup (data->update_buffer.resource_cache, uri);
@@ -868,6 +870,27 @@ tracker_data_update_ensure_resource (TrackerData *data,
return *value;
}
+ ontologies = tracker_data_manager_get_ontologies (data->manager);
+ class = tracker_ontologies_get_class_by_uri (ontologies, uri);
+
+ /* Fast path, look up classes/properties directly */
+ if (class) {
+ id = tracker_class_get_id (class);
+ } else {
+ TrackerProperty *property;
+
+ property = tracker_ontologies_get_property_by_uri (ontologies, uri);
+ if (property)
+ id = tracker_property_get_id (property);
+ }
+
+ if (id != 0) {
+ g_hash_table_insert (data->update_buffer.resource_cache,
+ g_strdup (uri),
+ tracker_rowid_copy (&id));
+ return id;
+ }
+
db_manager = tracker_data_manager_get_db_manager (data->manager);
db_flags = tracker_db_manager_get_flags (db_manager, NULL, NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]