[tracker/wip/carlosg/update-perf: 42/65] core: Add direct getters for nrl:added/modified properties
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/update-perf: 42/65] core: Add direct getters for nrl:added/modified properties
- Date: Tue, 23 Aug 2022 09:32:53 +0000 (UTC)
commit 5be9cb04829ee7550c08456ff754b46a9005e6c1
Author: Carlos Garnacho <carlosg gnome org>
Date: Mon Aug 15 21:08:13 2022 +0200
core: Add direct getters for nrl:added/modified properties
Since those are very frequently used properties, it makes sense to have
a fast path lookup like we have for rdf:type, so that we don't have to
perform a hashtable lookup every time these properties are used.
src/libtracker-sparql/core/tracker-data-update.c | 11 +++-----
src/libtracker-sparql/core/tracker-ontologies.c | 34 +++++++++++++++++++++---
src/libtracker-sparql/core/tracker-ontologies.h | 2 ++
3 files changed, 36 insertions(+), 11 deletions(-)
---
diff --git a/src/libtracker-sparql/core/tracker-data-update.c
b/src/libtracker-sparql/core/tracker-data-update.c
index 8cc565f02..d90dd7be8 100644
--- a/src/libtracker-sparql/core/tracker-data-update.c
+++ b/src/libtracker-sparql/core/tracker-data-update.c
@@ -462,7 +462,7 @@ tracker_data_update_initialize_modseq (TrackerData *data,
temp_iface = tracker_data_manager_get_writable_db_interface (data->manager);
ontologies = tracker_data_manager_get_ontologies (data->manager);
- property = tracker_ontologies_get_property_by_uri (ontologies, TRACKER_PREFIX_NRL "modified");
+ property = tracker_ontologies_get_nrl_modified (ontologies);
stmt = tracker_db_interface_create_vstatement (temp_iface, TRACKER_DB_STATEMENT_CACHE_TYPE_SELECT,
&inner_error,
"SELECT MAX(object) FROM tracker_triples "
@@ -1440,8 +1440,7 @@ cache_create_service_decomposed (TrackerData *data,
data->resource_buffer->modified = TRUE;
ontologies = tracker_data_manager_get_ontologies (data->manager);
- modified = tracker_ontologies_get_property_by_uri (ontologies,
- TRACKER_PREFIX_NRL "modified");
+ modified = tracker_ontologies_get_nrl_modified (ontologies);
g_value_init (&gvalue, G_TYPE_INT64);
g_value_set_int64 (&gvalue, get_transaction_modseq (data));
@@ -1458,8 +1457,7 @@ cache_create_service_decomposed (TrackerData *data,
GValue gvalue = { 0 };
ontologies = tracker_data_manager_get_ontologies (data->manager);
- added = tracker_ontologies_get_property_by_uri (ontologies,
- TRACKER_PREFIX_NRL "added");
+ added = tracker_ontologies_get_nrl_added (ontologies);
g_value_init (&gvalue, G_TYPE_INT64);
g_value_set_int64 (&gvalue, data->resource_time);
@@ -1957,8 +1955,7 @@ cache_insert_metadata_decomposed (TrackerData *data,
data->resource_buffer->modified = TRUE;
ontologies = tracker_data_manager_get_ontologies (data->manager);
- modified = tracker_ontologies_get_property_by_uri (ontologies,
- TRACKER_PREFIX_NRL "modified");
+ modified = tracker_ontologies_get_nrl_modified (ontologies);
g_value_init (&gvalue, G_TYPE_INT64);
g_value_set_int64 (&gvalue, get_transaction_modseq (data));
diff --git a/src/libtracker-sparql/core/tracker-ontologies.c b/src/libtracker-sparql/core/tracker-ontologies.c
index ef0f8306d..c9b3b4906 100644
--- a/src/libtracker-sparql/core/tracker-ontologies.c
+++ b/src/libtracker-sparql/core/tracker-ontologies.c
@@ -65,8 +65,10 @@ struct _TrackerOntologiesPrivate {
/* Hash (int id, const gchar *uri) */
GHashTable *id_uri_pairs;
- /* rdf:type */
+ /* Some fast paths for frequent properties */
TrackerProperty *rdf_type;
+ TrackerProperty *nrl_added;
+ TrackerProperty *nrl_modified;
GvdbTable *gvdb_table;
GvdbTable *gvdb_namespaces_table;
@@ -134,9 +136,9 @@ tracker_ontologies_finalize (GObject *object)
g_ptr_array_free (priv->properties, TRUE);
g_hash_table_unref (priv->property_uris);
- if (priv->rdf_type) {
- g_object_unref (priv->rdf_type);
- }
+ g_clear_object (&priv->rdf_type);
+ g_clear_object (&priv->nrl_added);
+ g_clear_object (&priv->nrl_modified);
if (priv->gvdb_table) {
gvdb_table_unref (priv->gvdb_properties_table);
@@ -172,6 +174,26 @@ tracker_ontologies_get_rdf_type (TrackerOntologies *ontologies)
return priv->rdf_type;
}
+TrackerProperty *
+tracker_ontologies_get_nrl_added (TrackerOntologies *ontologies)
+{
+ TrackerOntologiesPrivate *priv = tracker_ontologies_get_instance_private (ontologies);
+
+ g_return_val_if_fail (priv->nrl_added != NULL, NULL);
+
+ return priv->nrl_added;
+}
+
+TrackerProperty *
+tracker_ontologies_get_nrl_modified (TrackerOntologies *ontologies)
+{
+ TrackerOntologiesPrivate *priv = tracker_ontologies_get_instance_private (ontologies);
+
+ g_return_val_if_fail (priv->nrl_modified != NULL, NULL);
+
+ return priv->nrl_modified;
+}
+
const gchar*
tracker_ontologies_get_uri_by_id (TrackerOntologies *ontologies,
TrackerRowid id)
@@ -350,6 +372,10 @@ tracker_ontologies_add_property (TrackerOntologies *ontologies,
if (g_strcmp0 (uri, TRACKER_PREFIX_RDF "type") == 0) {
g_set_object (&priv->rdf_type, field);
+ } else if (g_strcmp0 (uri, TRACKER_PREFIX_NRL "added") == 0) {
+ g_set_object (&priv->nrl_added, field);
+ } else if (g_strcmp0 (uri, TRACKER_PREFIX_NRL "modified") == 0) {
+ g_set_object (&priv->nrl_modified, field);
}
g_ptr_array_add (priv->properties, g_object_ref (field));
diff --git a/src/libtracker-sparql/core/tracker-ontologies.h b/src/libtracker-sparql/core/tracker-ontologies.h
index 6abcd5830..a92b7e289 100644
--- a/src/libtracker-sparql/core/tracker-ontologies.h
+++ b/src/libtracker-sparql/core/tracker-ontologies.h
@@ -64,6 +64,8 @@ TrackerClass ** tracker_ontologies_get_classes (TrackerOntologies *o
TrackerProperty ** tracker_ontologies_get_properties (TrackerOntologies *ontologies,
guint *length);
TrackerProperty * tracker_ontologies_get_rdf_type (TrackerOntologies *ontologies);
+TrackerProperty * tracker_ontologies_get_nrl_added (TrackerOntologies *ontologies);
+TrackerProperty * tracker_ontologies_get_nrl_modified (TrackerOntologies *ontologies);
/* Field mechanics */
void tracker_ontologies_add_property (TrackerOntologies *ontologies,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]