[tracker/wip/carlosg/update-perf: 6/43] libtracker-sparql/core: Do not pass graph ID to notifier hooks
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/update-perf: 6/43] libtracker-sparql/core: Do not pass graph ID to notifier hooks
- Date: Wed, 24 Aug 2022 00:49:48 +0000 (UTC)
commit 4cec7a3c0a9822b19e38adfd3dab92611a92215b
Author: Carlos Garnacho <carlosg gnome org>
Date: Sat Jul 30 12:17:29 2022 +0200
libtracker-sparql/core: Do not pass graph ID to notifier hooks
It is just used as the key in a hashtable, we can use the graph name for
that.
src/libtracker-sparql/core/tracker-data-update.c | 6 ++---
src/libtracker-sparql/core/tracker-data-update.h | 15 ++++++-----
src/libtracker-sparql/direct/tracker-direct.c | 32 ++++++++++++------------
src/libtracker-sparql/tracker-notifier-private.h | 2 ++
src/libtracker-sparql/tracker-notifier.c | 6 +++++
5 files changed, 33 insertions(+), 28 deletions(-)
---
diff --git a/src/libtracker-sparql/core/tracker-data-update.c
b/src/libtracker-sparql/core/tracker-data-update.c
index 8504da173..be6423d85 100644
--- a/src/libtracker-sparql/core/tracker-data-update.c
+++ b/src/libtracker-sparql/core/tracker-data-update.c
@@ -328,8 +328,7 @@ tracker_data_dispatch_insert_statement_callbacks (TrackerData *data,
TrackerStatementDelegate *delegate;
delegate = g_ptr_array_index (data->insert_callbacks, n);
- delegate->callback (data->resource_buffer->graph->id,
- data->resource_buffer->graph->graph,
+ delegate->callback (data->resource_buffer->graph->graph,
data->resource_buffer->id,
predicate_id,
class_id,
@@ -389,8 +388,7 @@ tracker_data_dispatch_delete_statement_callbacks (TrackerData *data,
TrackerStatementDelegate *delegate;
delegate = g_ptr_array_index (data->delete_callbacks, n);
- delegate->callback (data->resource_buffer->graph->id,
- data->resource_buffer->graph->graph,
+ delegate->callback (data->resource_buffer->graph->graph,
data->resource_buffer->id,
predicate_id,
class_id,
diff --git a/src/libtracker-sparql/core/tracker-data-update.h
b/src/libtracker-sparql/core/tracker-data-update.h
index e00d5edcb..04c480401 100644
--- a/src/libtracker-sparql/core/tracker-data-update.h
+++ b/src/libtracker-sparql/core/tracker-data-update.h
@@ -43,14 +43,13 @@ typedef struct _TrackerDataClass TrackerDataClass;
typedef struct _TrackerData TrackerDataUpdate;
-typedef void (*TrackerStatementCallback) (TrackerRowid graph_id,
- const gchar *graph,
- TrackerRowid subject_id,
- TrackerRowid predicate_id,
- TrackerRowid object_id,
- GPtrArray *rdf_types,
- gpointer user_data);
-typedef void (*TrackerCommitCallback) (gpointer user_data);
+typedef void (*TrackerStatementCallback) (const gchar *graph,
+ TrackerRowid subject_id,
+ TrackerRowid predicate_id,
+ TrackerRowid object_id,
+ GPtrArray *rdf_types,
+ gpointer user_data);
+typedef void (*TrackerCommitCallback) (gpointer user_data);
GQuark tracker_data_error_quark (void);
diff --git a/src/libtracker-sparql/direct/tracker-direct.c b/src/libtracker-sparql/direct/tracker-direct.c
index a8c965520..0b4fe9d00 100644
--- a/src/libtracker-sparql/direct/tracker-direct.c
+++ b/src/libtracker-sparql/direct/tracker-direct.c
@@ -568,9 +568,7 @@ get_event_cache_ht (TrackerNotifier *notifier)
events = g_object_get_qdata (G_OBJECT (notifier), tracker_direct_notifier_quark ());
if (!events) {
- events = g_hash_table_new_full (tracker_rowid_hash,
- tracker_rowid_equal,
- (GDestroyNotify) tracker_rowid_free,
+ events = g_hash_table_new_full (g_str_hash, g_str_equal, NULL,
(GDestroyNotify) _tracker_notifier_event_cache_free);
g_object_set_qdata_full (G_OBJECT (notifier), tracker_direct_notifier_quark (),
events, (GDestroyNotify) g_hash_table_unref);
@@ -581,18 +579,22 @@ get_event_cache_ht (TrackerNotifier *notifier)
static TrackerNotifierEventCache *
lookup_event_cache (TrackerNotifier *notifier,
- TrackerRowid graph_id,
const gchar *graph)
{
TrackerNotifierEventCache *cache;
GHashTable *events;
+ if (!graph)
+ graph = "";
+
events = get_event_cache_ht (notifier);
- cache = g_hash_table_lookup (events, &graph_id);
+ cache = g_hash_table_lookup (events, graph);
if (!cache) {
cache = _tracker_notifier_event_cache_new (notifier, graph);
- g_hash_table_insert (events, tracker_rowid_copy (&graph_id), cache);
+ g_hash_table_insert (events,
+ (gpointer) tracker_notifier_event_cache_get_graph (cache),
+ cache);
}
return cache;
@@ -602,13 +604,12 @@ lookup_event_cache (TrackerNotifier *notifier,
* (always the same one though), handle with care.
*/
static void
-insert_statement_cb (TrackerRowid graph_id,
- const gchar *graph,
+insert_statement_cb (const gchar *graph,
TrackerRowid subject_id,
TrackerRowid predicate_id,
TrackerRowid object_id,
- GPtrArray *rdf_types,
- gpointer user_data)
+ GPtrArray *rdf_types,
+ gpointer user_data)
{
TrackerNotifier *notifier = user_data;
TrackerSparqlConnection *conn = _tracker_notifier_get_connection (notifier);
@@ -620,7 +621,7 @@ insert_statement_cb (TrackerRowid graph_id,
TrackerClass *new_class = NULL;
guint i;
- cache = lookup_event_cache (notifier, graph_id, graph);
+ cache = lookup_event_cache (notifier, graph);
if (predicate_id == tracker_property_get_id (rdf_type)) {
const gchar *uri;
@@ -646,13 +647,12 @@ insert_statement_cb (TrackerRowid graph_id,
}
static void
-delete_statement_cb (TrackerRowid graph_id,
- const gchar *graph,
+delete_statement_cb (const gchar *graph,
TrackerRowid subject_id,
TrackerRowid predicate_id,
TrackerRowid object_id,
- GPtrArray *rdf_types,
- gpointer user_data)
+ GPtrArray *rdf_types,
+ gpointer user_data)
{
TrackerNotifier *notifier = user_data;
TrackerSparqlConnection *conn = _tracker_notifier_get_connection (notifier);
@@ -664,7 +664,7 @@ delete_statement_cb (TrackerRowid graph_id,
TrackerClass *class_being_removed = NULL;
guint i;
- cache = lookup_event_cache (notifier, graph_id, graph);
+ cache = lookup_event_cache (notifier, graph);
if (predicate_id == tracker_property_get_id (rdf_type)) {
const gchar *uri;
diff --git a/src/libtracker-sparql/tracker-notifier-private.h
b/src/libtracker-sparql/tracker-notifier-private.h
index e808be1e2..c9bc73e18 100644
--- a/src/libtracker-sparql/tracker-notifier-private.h
+++ b/src/libtracker-sparql/tracker-notifier-private.h
@@ -39,6 +39,8 @@ _tracker_notifier_event_cache_push_event (TrackerNotifierEventCache *cache,
void _tracker_notifier_event_cache_flush_events (TrackerNotifierEventCache *cache);
+const gchar * tracker_notifier_event_cache_get_graph (TrackerNotifierEventCache *cache);
+
void tracker_notifier_disable_urn_query (TrackerNotifier *notifier);
#endif /* __TRACKER_NOTIFIER_PRIVATE_H__ */
diff --git a/src/libtracker-sparql/tracker-notifier.c b/src/libtracker-sparql/tracker-notifier.c
index 86329ce9d..78056c2c0 100644
--- a/src/libtracker-sparql/tracker-notifier.c
+++ b/src/libtracker-sparql/tracker-notifier.c
@@ -262,6 +262,12 @@ _tracker_notifier_event_cache_push_event (TrackerNotifierEventCache *cache,
event->type = event_type;
}
+const gchar *
+tracker_notifier_event_cache_get_graph (TrackerNotifierEventCache *cache)
+{
+ return cache->graph ? cache->graph : "";
+}
+
static void
handle_events (TrackerNotifier *notifier,
TrackerNotifierEventCache *cache,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]