[tracker/tracker-store-queue] Jürg had the luminous idea to ask me to change the queue API a bit
- From: Philip Van Hoof <pvanhoof src gnome org>
- To: svn-commits-list gnome org
- Subject: [tracker/tracker-store-queue] Jürg had the luminous idea to ask me to change the queue API a bit
- Date: Fri, 22 May 2009 08:54:57 -0400 (EDT)
commit 301ba0330cc2508eb4b984202893274c49daa44d
Author: Philip Van Hoof <philip codeminded be>
Date: Fri May 22 14:52:16 2009 +0200
Jürg had the luminous idea to ask me to change the queue API a bit
The changes include:
- Rename TrackerStoreQueue to TrackerStore
- Rename batch to queue
- Don't put single update and single queries on the queue
- Handle transaction-max in tracker-store.c, don't make the callers have
to care about it
This last one implied that I could remove most of the ++priv->batch_count
callbacks from tracker-resource.c and that I had to fixup the push modules
a bit too.
---
.../evolution/tracker-evolution-registrar.c | 37 +--
src/plugins/kmail/tracker-kmail-registrar.c | 37 +--
src/tracker-store/Makefile.am | 4 +-
src/tracker-store/tracker-main.c | 6 +-
src/tracker-store/tracker-resources.c | 229 +++--------
src/tracker-store/tracker-store-queue.c | 448 --------------------
src/tracker-store/tracker-store-queue.h | 81 ----
src/tracker-store/tracker-store.c | 344 +++++++++++++++
src/tracker-store/tracker-store.h | 66 +++
9 files changed, 486 insertions(+), 766 deletions(-)
diff --git a/src/plugins/evolution/tracker-evolution-registrar.c b/src/plugins/evolution/tracker-evolution-registrar.c
index 6574c44..652a91b 100644
--- a/src/plugins/evolution/tracker-evolution-registrar.c
+++ b/src/plugins/evolution/tracker-evolution-registrar.c
@@ -32,7 +32,7 @@
#include <libtracker-common/tracker-ontology.h>
#include <tracker-store/tracker-push-registrar.h>
-#include <tracker-store/tracker-store-queue.h>
+#include <tracker-store/tracker-store.h>
#define __TRACKER_EVOLUTION_REGISTRAR_C__
@@ -44,8 +44,6 @@
#define TRACKER_TYPE_EVOLUTION_PUSH_REGISTRAR (tracker_evolution_push_registrar_get_type ())
#define TRACKER_EVOLUTION_PUSH_REGISTRAR(module) (G_TYPE_CHECK_INSTANCE_CAST ((module), TRACKER_TYPE_EVOLUTION_PUSH_REGISTRAR, TrackerEvolutionPushRegistrar))
-#define TRANSACTION_MAX TRACKER_STORE_TRANSACTION_MAX
-
#define NIE_DATASOURCE TRACKER_NIE_PREFIX "DataSource"
#define NIE_DATASOURCE_P TRACKER_NIE_PREFIX "dataSource"
@@ -270,30 +268,13 @@ get_email_and_fullname (const gchar *line, gchar **email, gchar **fullname)
}
static void
-insert_callback (GError *error, gpointer user_data)
-{
- TrackerEvolutionRegistrar *object = user_data;
- TrackerEvolutionRegistrarPrivate *priv;
-
- priv = TRACKER_EVOLUTION_REGISTRAR_GET_PRIVATE (object);
-
- if (++priv->batch_count >= TRACKER_STORE_TRANSACTION_MAX) {
- tracker_store_queue_batch_commit (NULL, NULL, NULL);
- priv->batch_count = 0;
- }
-
-}
-
-static void
data_insert_statement (TrackerEvolutionRegistrar *self,
const gchar *subject,
const gchar *predicate,
const gchar *object)
{
- tracker_store_queue_batch_insert_statement (subject, predicate, object,
- insert_callback,
- g_object_ref (self),
- (GDestroyNotify) g_object_unref);
+ tracker_store_queue_insert_statement (subject, predicate, object,
+ NULL, NULL, NULL);
}
static void
@@ -523,11 +504,9 @@ perform_unset (TrackerEvolutionRegistrar *object,
gchar *sparql = g_strdup_printf ("DELETE { <%s> a rdfs:Resource }", subject);
if (batch) {
- tracker_store_queue_sparql_update (sparql, NULL, NULL, NULL);
+ tracker_store_sparql_update (sparql, NULL);
} else {
- tracker_store_queue_batch_sparql_update (sparql, insert_callback,
- g_object_ref (object),
- (GDestroyNotify) g_object_unref);
+ tracker_store_queue_sparql_update (sparql, NULL, NULL, NULL);
}
g_free (sparql);
@@ -568,7 +547,7 @@ tracker_evolution_registrar_set (TrackerEvolutionRegistrar *object,
set_stored_last_modseq (modseq);
- tracker_store_queue_batch_commit (NULL, NULL, NULL);
+ tracker_store_queue_commit (NULL, NULL, NULL);
dbus_g_method_return (context);
}
@@ -632,7 +611,7 @@ set_many_destroy (gpointer user_data)
set_stored_last_modseq (info->modseq);
- tracker_store_queue_batch_commit (NULL, NULL, NULL);
+ tracker_store_queue_commit (NULL, NULL, NULL);
dbus_g_method_return (info->context);
@@ -728,7 +707,7 @@ unset_many_destroy (gpointer user_data)
set_stored_last_modseq (info->modseq);
- tracker_store_queue_batch_commit (NULL, NULL, NULL);
+ tracker_store_queue_commit (NULL, NULL, NULL);
dbus_g_method_return (info->context);
diff --git a/src/plugins/kmail/tracker-kmail-registrar.c b/src/plugins/kmail/tracker-kmail-registrar.c
index 84d2d4a..8eae787 100644
--- a/src/plugins/kmail/tracker-kmail-registrar.c
+++ b/src/plugins/kmail/tracker-kmail-registrar.c
@@ -31,12 +31,10 @@
#include <libtracker-data/tracker-data-manager.h>
#include <tracker-store/tracker-push-registrar.h>
-#include <tracker-store/tracker-store-queue.h>
+#include <tracker-store/tracker-store.h>
#define __TRACKER_KMAIL_REGISTRAR_C__
-#define TRANSACTION_MAX TRACKER_STORE_TRANSACTION_MAX
-
#include "tracker-kmail-registrar.h"
#include "tracker-kmail-registrar-glue.h"
@@ -155,30 +153,13 @@ get_email_and_fullname (const gchar *line, gchar **email, gchar **fullname)
}
static void
-insert_callback (GError *error, gpointer user_data)
-{
- TrackerKMailRegistrar *object = user_data;
- TrackerKMailRegistrarPrivate *priv;
-
- priv = TRACKER_KMAIL_REGISTRAR_GET_PRIVATE (object);
-
- if (++priv->batch_count >= TRACKER_STORE_TRANSACTION_MAX) {
- tracker_store_queue_batch_commit (NULL, NULL, NULL);
- priv->batch_count = 0;
- }
-
-}
-
-static void
data_insert_statement (TrackerKMailRegistrar *self,
const gchar *subject,
const gchar *predicate,
const gchar *object)
{
- tracker_store_queue_batch_insert_statement (subject, predicate, object,
- insert_callback,
- g_object_ref (self),
- (GDestroyNotify) g_object_unref);
+ tracker_store_queue_insert_statement (subject, predicate, object,
+ NULL, NULL, NULL);
}
static void
@@ -306,11 +287,9 @@ perform_unset (TrackerKMailRegistrar *object,
gchar *sparql = g_strdup_printf ("DELETE { <%s> a rdfs:Resource }", subject);
if (batch) {
- tracker_store_queue_sparql_update (sparql, NULL, NULL, NULL);
+ tracker_store_sparql_update (sparql, NULL);
} else {
- tracker_store_queue_batch_sparql_update (sparql, insert_callback,
- g_object_ref (object),
- (GDestroyNotify) g_object_unref);
+ tracker_store_queue_sparql_update (sparql, NULL, NULL, NULL);
}
g_free (sparql);
@@ -351,7 +330,7 @@ tracker_kmail_registrar_set (TrackerKMailRegistrar *object,
set_stored_last_modseq (modseq);
- tracker_store_queue_batch_commit (NULL, NULL, NULL);
+ tracker_store_queue_commit (NULL, NULL, NULL);
dbus_g_method_return (context);
}
@@ -413,7 +392,7 @@ set_many_destroy (gpointer user_data)
set_stored_last_modseq (info->modseq);
- tracker_store_queue_batch_commit (NULL, NULL, NULL);
+ tracker_store_queue_commit (NULL, NULL, NULL);
dbus_g_method_return (info->context);
@@ -509,7 +488,7 @@ unset_many_destroy (gpointer user_data)
set_stored_last_modseq (info->modseq);
- tracker_store_queue_batch_commit (NULL, NULL, NULL);
+ tracker_store_queue_commit (NULL, NULL, NULL);
dbus_g_method_return (info->context);
diff --git a/src/tracker-store/Makefile.am b/src/tracker-store/Makefile.am
index a96b918..13d76f4 100644
--- a/src/tracker-store/Makefile.am
+++ b/src/tracker-store/Makefile.am
@@ -64,8 +64,8 @@ tracker_store_SOURCES = \
tracker-push-registrar.h \
tracker-resource-class.c \
tracker-resource-class.h \
- tracker-store-queue.c \
- tracker-store-queue.h
+ tracker-store.c \
+ tracker-store.h
if OS_WIN32
tracker_store_win_libs = -lws2_32 -lkernel32
diff --git a/src/tracker-store/tracker-main.c b/src/tracker-store/tracker-main.c
index 151e246..5176003 100644
--- a/src/tracker-store/tracker-main.c
+++ b/src/tracker-store/tracker-main.c
@@ -75,7 +75,7 @@
#include "tracker-volume-cleanup.h"
#include "tracker-backup.h"
#include "tracker-daemon.h"
-#include "tracker-store-queue.h"
+#include "tracker-store.h"
#ifdef G_OS_WIN32
#include <windows.h>
@@ -983,7 +983,7 @@ main (gint argc, gchar *argv[])
NULL);
#endif /* HAVE_HAL */
- tracker_store_queue_init ();
+ tracker_store_init ();
tracker_status_init (config, hal_power);
tracker_module_config_init ();
@@ -1126,7 +1126,7 @@ main (gint argc, gchar *argv[])
tracker_nfs_lock_shutdown ();
tracker_status_shutdown ();
tracker_turtle_shutdown ();
- tracker_store_queue_shutdown ();
+ tracker_store_shutdown ();
tracker_thumbnailer_shutdown ();
tracker_log_shutdown ();
diff --git a/src/tracker-store/tracker-resources.c b/src/tracker-store/tracker-resources.c
index f6bc986..37617a4 100644
--- a/src/tracker-store/tracker-resources.c
+++ b/src/tracker-store/tracker-resources.c
@@ -41,7 +41,7 @@
#include "tracker-resources.h"
#include "tracker-resource-class.h"
#include "tracker-events.h"
-#include "tracker-store-queue.h"
+#include "tracker-store.h"
#define RDF_PREFIX TRACKER_RDF_PREFIX
#define RDF_TYPE RDF_PREFIX "type"
@@ -53,15 +53,12 @@ G_DEFINE_TYPE(TrackerResources, tracker_resources, G_TYPE_OBJECT)
typedef struct {
- gboolean batch_mode;
- gint batch_count;
GSList *event_sources;
} TrackerResourcesPrivate;
typedef struct {
DBusGMethodInvocation *context;
guint request_id;
- TrackerResources *self;
} TrackerDBusMethodInfo;
static void
@@ -151,7 +148,6 @@ tracker_resources_insert (TrackerResources *self,
{
TrackerResourcesPrivate *priv;
guint request_id;
- TrackerDBusMethodInfo *info;
request_id = tracker_dbus_get_next_request_id ();
@@ -166,31 +162,11 @@ tracker_resources_insert (TrackerResources *self,
priv = TRACKER_RESOURCES_GET_PRIVATE (self);
- if (priv->batch_mode) {
- /* commit pending batch items */
-
- tracker_store_queue_batch_commit (NULL, NULL, NULL);
-
- /* Question, must we wait here until callback of commit is
- * completed? I guess this just depends on the priority rules
- * of a single update vs. a commit of a batch. If a commit
- * comes first, we don't need to await its callback. Right? */
-
- priv->batch_mode = FALSE;
- priv->batch_count = 0;
- }
-
-
- info = g_slice_new (TrackerDBusMethodInfo);
-
- info->request_id = request_id;
- info->context = context;
-
- tracker_store_queue_insert_statement (subject, predicate, object,
- update_callback, info,
- destroy_method_info);
+ tracker_store_insert_statement (subject, predicate, object);
+ dbus_g_method_return (context);
+ tracker_dbus_request_success (request_id);
}
void
@@ -203,7 +179,6 @@ tracker_resources_delete (TrackerResources *self,
{
TrackerResourcesPrivate *priv;
guint request_id;
- TrackerDBusMethodInfo *info;
request_id = tracker_dbus_get_next_request_id ();
@@ -218,73 +193,30 @@ tracker_resources_delete (TrackerResources *self,
priv = TRACKER_RESOURCES_GET_PRIVATE (self);
- if (priv->batch_mode) {
- /* commit pending batch items */
+ tracker_store_delete_statement (subject, predicate, object);
- tracker_store_queue_batch_commit (NULL, NULL, NULL);
-
- /* Question, must we wait here until callback of commit is
- * completed? I guess this just depends on the priority rules
- * of a single update vs. a commit of a batch. If a commit
- * comes first, we don't need to await its callback. Right? */
-
- priv->batch_mode = FALSE;
- priv->batch_count = 0;
- }
-
-
- info = g_slice_new (TrackerDBusMethodInfo);
-
- info->request_id = request_id;
- info->context = context;
-
- tracker_store_queue_delete_statement (subject, predicate, object,
- update_callback, info,
- destroy_method_info);
+ dbus_g_method_return (context);
+ tracker_dbus_request_success (request_id);
}
-static void
-turtle_update_callback (GError *error, gpointer user_data)
-{
- TrackerResources *object = user_data;
- TrackerResourcesPrivate *priv;
-
- priv = TRACKER_RESOURCES_GET_PRIVATE (object);
-
- if (++priv->batch_count >= TRACKER_STORE_TRANSACTION_MAX) {
- tracker_store_queue_batch_commit (NULL, NULL, NULL);
- priv->batch_count = 0;
- }
-}
static gboolean
process_turtle_idle (gpointer user_data)
{
- TrackerResources *object = user_data;
- TrackerResourcesPrivate *priv;
guint i = 0;
gboolean cont = FALSE;
- priv = TRACKER_RESOURCES_GET_PRIVATE (object);
-
- if (!priv->batch_mode) {
- priv->batch_mode = TRUE;
- priv->batch_count = 0;
- }
-
while (tracker_turtle_reader_next ()) {
const gchar *subject = tracker_turtle_reader_get_subject ();
const gchar *predicate = tracker_turtle_reader_get_predicate ();
const gchar *object_ = tracker_turtle_reader_get_object ();
if (subject && predicate && object_) {
- tracker_store_queue_batch_insert_statement (subject,
- predicate,
- object_,
- turtle_update_callback,
- g_object_ref (object),
- (GDestroyNotify) g_object_unref);
+ tracker_store_queue_insert_statement (subject,
+ predicate,
+ object_,
+ NULL, NULL, NULL);
}
cont = TRUE;
@@ -302,15 +234,7 @@ process_turtle_idle (gpointer user_data)
static void
process_turtle_destroy (gpointer user_data)
{
- TrackerResources *object = user_data;
- TrackerResourcesPrivate *priv;
-
- priv = TRACKER_RESOURCES_GET_PRIVATE (object);
-
- tracker_store_queue_batch_commit (NULL, NULL, NULL);
- priv->batch_count = 0;
- priv->batch_mode = FALSE;
- g_object_unref (object);
+ tracker_store_queue_commit (NULL, NULL, NULL);
}
void
@@ -319,10 +243,10 @@ tracker_resources_load (TrackerResources *object,
DBusGMethodInvocation *context,
GError **error)
{
- guint request_id;
+ guint request_id;
GFile *file;
gchar *path;
- GError *actual_error = NULL;
+ GError *actual_error = NULL;
request_id = tracker_dbus_get_next_request_id ();
@@ -340,7 +264,7 @@ tracker_resources_load (TrackerResources *object,
g_idle_add_full (G_PRIORITY_DEFAULT,
process_turtle_idle,
- g_object_ref (object),
+ NULL,
process_turtle_destroy);
g_free (path);
@@ -358,41 +282,16 @@ tracker_resources_load (TrackerResources *object,
tracker_dbus_request_success (request_id);
}
-
-static void
-query_callback (TrackerDBResultSet *result_set,
- GError *error,
- gpointer user_data)
-{
- TrackerDBusMethodInfo *info = user_data;
- GPtrArray *values;
-
- if (error) {
- tracker_dbus_request_failed (info->request_id,
- &error,
- NULL);
- dbus_g_method_return_error (info->context, error);
- return;
- }
-
- values = tracker_dbus_query_result_to_ptr_array (result_set);
-
- dbus_g_method_return (info->context, values);
-
- tracker_dbus_results_ptr_array_free (&values);
-
- tracker_dbus_request_success (info->request_id);
-}
-
-
void
tracker_resources_sparql_query (TrackerResources *self,
const gchar *query,
DBusGMethodInvocation *context,
GError **error)
{
- TrackerDBusMethodInfo *info;
guint request_id;
+ GPtrArray *values;
+ TrackerDBResultSet *result_set;
+ GError *actual_error = NULL;
request_id = tracker_dbus_get_next_request_id ();
@@ -403,13 +302,24 @@ tracker_resources_sparql_query (TrackerResources *self,
"query:'%s'",
query);
- info = g_slice_new (TrackerDBusMethodInfo);
+ result_set = tracker_store_sparql_query (query, &actual_error);
- info->request_id = request_id;
- info->context = context;
+ if (actual_error) {
+ tracker_dbus_request_failed (request_id,
+ &actual_error,
+ NULL);
+ dbus_g_method_return_error (context, actual_error);
+ g_error_free (actual_error);
+ return;
+ }
+
+ values = tracker_dbus_query_result_to_ptr_array (result_set);
- tracker_store_queue_sparql_query (query, query_callback, info,
- destroy_method_info);
+ dbus_g_method_return (context, values);
+
+ tracker_dbus_results_ptr_array_free (&values);
+
+ tracker_dbus_request_success (request_id);
}
void
@@ -419,8 +329,8 @@ tracker_resources_sparql_update (TrackerResources *self,
GError **error)
{
TrackerResourcesPrivate *priv;
- guint request_id;
- TrackerDBusMethodInfo *info;
+ guint request_id;
+ GError *actual_error = NULL;
priv = TRACKER_RESOURCES_GET_PRIVATE (self);
@@ -428,53 +338,42 @@ tracker_resources_sparql_update (TrackerResources *self,
tracker_dbus_async_return_if_fail (update != NULL, context);
- if (priv->batch_mode) {
- tracker_store_queue_batch_commit (NULL, NULL, NULL);
- priv->batch_count = 0;
- priv->batch_mode = FALSE;
- }
-
tracker_dbus_request_new (request_id,
"DBus request for SPARQL Update, "
"update:'%s'",
update);
- info = g_slice_new (TrackerDBusMethodInfo);
+ tracker_store_sparql_update (update, &actual_error);
- info->request_id = request_id;
- info->context = context;
+ if (actual_error) {
+ tracker_dbus_request_failed (request_id,
+ &actual_error,
+ NULL);
+ dbus_g_method_return_error (context, actual_error);
+ g_error_free (actual_error);
+ return;
+ }
- tracker_store_queue_sparql_update (update, update_callback, info,
- destroy_method_info);
+ dbus_g_method_return (context);
+ tracker_dbus_request_success (request_id);
}
static void
batch_update_callback (GError *error, gpointer user_data)
{
TrackerDBusMethodInfo *info = user_data;
- TrackerResourcesPrivate *priv;
if (error) {
tracker_dbus_request_failed (info->request_id,
&error,
NULL);
dbus_g_method_return_error (info->context, error);
- g_object_unref (info->self);
return;
}
- priv = TRACKER_RESOURCES_GET_PRIVATE (info->self);
-
- if (++priv->batch_count >= TRACKER_STORE_TRANSACTION_MAX) {
- tracker_store_queue_batch_commit (NULL, NULL, NULL);
- priv->batch_count = 0;
- }
-
dbus_g_method_return (info->context);
- g_object_unref (info->self);
-
tracker_dbus_request_success (info->request_id);
}
@@ -499,19 +398,13 @@ tracker_resources_batch_sparql_update (TrackerResources *self,
"update:'%s'",
update);
- if (!priv->batch_mode) {
- priv->batch_mode = TRUE;
- priv->batch_count = 0;
- }
-
info = g_slice_new (TrackerDBusMethodInfo);
- info->self = g_object_ref (self);
info->request_id = request_id;
info->context = context;
- tracker_store_queue_batch_sparql_update (update, batch_update_callback,
- info, destroy_method_info);
+ tracker_store_queue_sparql_update (update, batch_update_callback,
+ info, destroy_method_info);
}
@@ -529,6 +422,7 @@ tracker_resources_batch_commit (TrackerResources *self,
DBusGMethodInvocation *context,
GError **error)
{
+ TrackerDBusMethodInfo *info;
TrackerResourcesPrivate *priv;
guint request_id;
@@ -539,26 +433,13 @@ tracker_resources_batch_commit (TrackerResources *self,
tracker_dbus_request_new (request_id,
"DBus request for batch commit");
- if (priv->batch_mode) {
- TrackerDBusMethodInfo *info;
-
- /* commit pending batch items */
-
- info = g_slice_new (TrackerDBusMethodInfo);
-
- info->request_id = request_id;
- info->context = context;
-
- tracker_store_queue_batch_commit (batch_commit_callback, info,
- destroy_method_info);
+ info = g_slice_new (TrackerDBusMethodInfo);
- priv->batch_count = 0;
- priv->batch_mode = FALSE;
+ info->request_id = request_id;
+ info->context = context;
- } else {
- dbus_g_method_return (context);
- tracker_dbus_request_success (request_id);
- }
+ tracker_store_queue_commit (batch_commit_callback, info,
+ destroy_method_info);
}
diff --git a/src/tracker-store/tracker-store-queue.c b/src/tracker-store/tracker-store-queue.c
deleted file mode 100644
index 0030dcc..0000000
--- a/src/tracker-store/tracker-store-queue.c
+++ /dev/null
@@ -1,448 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2008, Nokia
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- * Author: Philip Van Hoof <philip codeminded be>
- */
-
-#include "config.h"
-
-#include <libtracker-common/tracker-dbus.h>
-#include <libtracker-db/tracker-db-dbus.h>
-
-#include <libtracker-data/tracker-data-update.h>
-#include <libtracker-data/tracker-data-query.h>
-
-#include "tracker-store-queue.h"
-
-typedef struct {
- gboolean have_handler;
- gboolean final;
- gboolean in_batch;
- GQueue *batch_queue;
- GQueue *single_queue;
-} TrackerStoreQueuePrivate;
-
-typedef enum {
- TRACKER_STORE_QUEUE_TASK_TYPE_QUERY = 0,
- TRACKER_STORE_QUEUE_TASK_TYPE_UPDATE = 1,
- TRACKER_STORE_QUEUE_TASK_TYPE_COMMIT = 2,
- TRACKER_STORE_QUEUE_TASK_TYPE_INSERT_STATEMENT = 3,
- TRACKER_STORE_QUEUE_TASK_TYPE_DELETE_STATEMENT = 4,
-} TrackerStoreQueueTaskType;
-
-typedef struct {
- TrackerStoreQueueTaskType type;
- union {
- gchar *query;
- struct {
- gchar *subject;
- gchar *predicate;
- gchar *object;
- } statement;
- } data;
- gpointer user_data;
- GDestroyNotify destroy;
- union {
- TrackerStoreQueueSparqlUpdateCallback update_callback;
- TrackerStoreQueueCommitCallback commit_callback;
- TrackerStoreQueueSparqlQueryCallback query_callback;
- } callback;
-} TrackerStoreQueueTask;
-
-static GStaticPrivate private_key = G_STATIC_PRIVATE_INIT;
-static gboolean im_done = TRUE;
-
-static void
-private_free (gpointer data)
-{
- TrackerStoreQueuePrivate *private = data;
-
- g_queue_free (private->batch_queue);
- g_queue_free (private->single_queue);
- g_free (private);
-}
-
-static void
-tracker_store_queue_task_free (TrackerStoreQueueTask *task)
-{
- if (task->type >= TRACKER_STORE_QUEUE_TASK_TYPE_INSERT_STATEMENT) {
- g_free (task->data.statement.subject);
- g_free (task->data.statement.predicate);
- g_free (task->data.statement.object);
- } else {
- g_free (task->data.query);
- }
- g_slice_free (TrackerStoreQueueTask, task);
-}
-
-static gboolean
-queue_idle_handler (gpointer user_data)
-{
- TrackerStoreQueuePrivate *private = user_data;
- TrackerStoreQueueTask *task;
- GError *error = NULL;
- TrackerDBResultSet *result_set;
- gboolean in_batch = FALSE;
-
- /* The tasks on single_queue always get priority over the batch_queue */
-
- task = g_queue_pop_head (private->single_queue);
-
- /* If no more single_queue task, we start processing the batch_queue */
-
- if (!task) {
- task = g_queue_pop_head (private->batch_queue);
- in_batch = TRUE;
- }
-
- /* If neither, we stop the handler */
-
- if (!task) {
- return FALSE;
- }
-
- /* Implicit transaction start */
-
- if (in_batch && !private->in_batch) {
- tracker_data_begin_transaction ();
- private->in_batch = TRUE;
- }
-
- switch (task->type) {
- case TRACKER_STORE_QUEUE_TASK_TYPE_QUERY:
- result_set = tracker_data_query_sparql (task->data.query, &error);
- if (task->callback.query_callback) {
- task->callback.query_callback (result_set, error,
- task->user_data);
- }
- if (result_set) {
- g_object_unref (result_set);
- }
- break;
-
- case TRACKER_STORE_QUEUE_TASK_TYPE_COMMIT:
-
- /* Explicit transaction commit */
-
- tracker_data_commit_transaction ();
- private->in_batch = FALSE;
-
- if (task->callback.commit_callback) {
- task->callback.commit_callback (task->user_data);
- }
-
- break;
-
- case TRACKER_STORE_QUEUE_TASK_TYPE_INSERT_STATEMENT:
- tracker_data_insert_statement (task->data.statement.subject,
- task->data.statement.predicate,
- task->data.statement.object);
-
- if (task->callback.update_callback) {
- task->callback.update_callback (error, task->user_data);
- }
- break;
-
- case TRACKER_STORE_QUEUE_TASK_TYPE_DELETE_STATEMENT:
- tracker_data_delete_statement (task->data.statement.subject,
- task->data.statement.predicate,
- task->data.statement.object);
-
- if (task->callback.update_callback) {
- task->callback.update_callback (error, task->user_data);
- }
- break;
-
- case TRACKER_STORE_QUEUE_TASK_TYPE_UPDATE:
- tracker_data_update_sparql (task->data.query, &error);
- if (task->callback.update_callback) {
- task->callback.update_callback (error, task->user_data);
- }
- default:
- break;
- }
-
- if (task->destroy) {
- task->destroy (task->user_data);
- }
-
- if (error) {
- g_clear_error (&error);
- }
-
- tracker_store_queue_task_free (task);
-
- return TRUE;
-}
-
-static void
-queue_idle_destroy (gpointer user_data)
-{
- TrackerStoreQueuePrivate *private = user_data;
-
- private->have_handler = FALSE;
-
- if (private->final) {
- g_static_private_set (&private_key, NULL, NULL);
- }
-
- im_done = TRUE;
-}
-
-void
-tracker_store_queue_init (void)
-{
- TrackerStoreQueuePrivate *private;
-
- private = g_new0 (TrackerStoreQueuePrivate, 1);
-
- private->final = FALSE;
- private->single_queue = g_queue_new ();
- private->batch_queue = g_queue_new ();
-
- g_static_private_set (&private_key,
- private,
- private_free);
-}
-
-void
-tracker_store_queue_shutdown (void)
-{
- TrackerStoreQueuePrivate *private;
-
- private = g_static_private_get (&private_key);
- g_return_if_fail (private != NULL);
-
- private->final = TRUE;
-
- if (!im_done) {
- g_debug ("Can't exit until store-queue is finished ...");
- while (!im_done) {
- g_main_context_iteration (NULL, TRUE);
- }
- g_debug ("Store-queue finished");
- }
-}
-
-static void
-start_handler (TrackerStoreQueuePrivate *private)
-{
- im_done = FALSE;
- private->have_handler = TRUE;
-
- g_idle_add_full (G_PRIORITY_DEFAULT,
- queue_idle_handler,
- private,
- queue_idle_destroy);
-}
-
-void
-tracker_store_queue_batch_commit (TrackerStoreQueueCommitCallback callback,
- gpointer user_data,
- GDestroyNotify destroy)
-{
- TrackerStoreQueuePrivate *private;
- TrackerStoreQueueTask *task;
-
- private = g_static_private_get (&private_key);
- g_return_if_fail (private != NULL);
-
- task = g_slice_new0 (TrackerStoreQueueTask);
- task->type = TRACKER_STORE_QUEUE_TASK_TYPE_COMMIT;
- task->user_data = user_data;
- task->callback.commit_callback = callback;
- task->destroy = destroy;
-
- g_queue_push_tail (private->batch_queue, task);
-
- if (!private->have_handler) {
- start_handler (private);
- }
-}
-
-
-void
-tracker_store_queue_batch_sparql_update (const gchar *sparql,
- TrackerStoreQueueSparqlUpdateCallback callback,
- gpointer user_data,
- GDestroyNotify destroy)
-{
- TrackerStoreQueuePrivate *private;
- TrackerStoreQueueTask *task;
-
- private = g_static_private_get (&private_key);
- g_return_if_fail (private != NULL);
-
- task = g_slice_new0 (TrackerStoreQueueTask);
- task->type = TRACKER_STORE_QUEUE_TASK_TYPE_UPDATE;
- task->data.query = g_strdup (sparql);
- task->user_data = user_data;
- task->callback.update_callback = callback;
- task->destroy = destroy;
-
- g_queue_push_tail (private->batch_queue, task);
-
- if (!private->have_handler) {
- start_handler (private);
- }
-}
-
-void
-tracker_store_queue_sparql_update (const gchar *sparql,
- TrackerStoreQueueSparqlUpdateCallback callback,
- gpointer user_data,
- GDestroyNotify destroy)
-{
- TrackerStoreQueueTask *task;
- TrackerStoreQueuePrivate *private;
-
- private = g_static_private_get (&private_key);
- g_return_if_fail (private != NULL);
-
- task = g_slice_new0 (TrackerStoreQueueTask);
- task->type = TRACKER_STORE_QUEUE_TASK_TYPE_UPDATE;
- task->data.query = g_strdup (sparql);
- task->user_data = user_data;
- task->callback.update_callback = callback;
- task->destroy = destroy;
-
- g_queue_push_tail (private->single_queue, task);
-
- if (!private->have_handler) {
- start_handler (private);
- }
-}
-
-void
-tracker_store_queue_sparql_query (const gchar *sparql,
- TrackerStoreQueueSparqlQueryCallback callback,
- gpointer user_data,
- GDestroyNotify destroy)
-{
- TrackerStoreQueueTask *task;
- TrackerStoreQueuePrivate *private;
-
- private = g_static_private_get (&private_key);
- g_return_if_fail (private != NULL);
-
- task = g_slice_new0 (TrackerStoreQueueTask);
- task->type = TRACKER_STORE_QUEUE_TASK_TYPE_QUERY;
- task->data.query = g_strdup (sparql);
- task->user_data = user_data;
- task->callback.query_callback = callback;
- task->destroy = destroy;
-
- g_queue_push_tail (private->single_queue, task);
-
- if (!private->have_handler) {
- start_handler (private);
- }
-}
-
-void
-tracker_store_queue_batch_insert_statement (const gchar *subject,
- const gchar *predicate,
- const gchar *object,
- TrackerStoreQueueSparqlUpdateCallback callback,
- gpointer user_data,
- GDestroyNotify destroy)
-{
- TrackerStoreQueuePrivate *private;
- TrackerStoreQueueTask *task;
-
- private = g_static_private_get (&private_key);
- g_return_if_fail (private != NULL);
-
- task = g_slice_new0 (TrackerStoreQueueTask);
- task->type = TRACKER_STORE_QUEUE_TASK_TYPE_INSERT_STATEMENT;
- task->data.statement.subject = g_strdup (subject);
- task->data.statement.predicate = g_strdup (predicate);
- task->data.statement.object = g_strdup (object);
- task->user_data = user_data;
- task->callback.update_callback = callback;
- task->destroy = destroy;
-
- g_queue_push_tail (private->batch_queue, task);
-
- if (!private->have_handler) {
- start_handler (private);
- }
-}
-
-
-void
-tracker_store_queue_insert_statement (const gchar *subject,
- const gchar *predicate,
- const gchar *object,
- TrackerStoreQueueSparqlUpdateCallback callback,
- gpointer user_data,
- GDestroyNotify destroy)
-{
- TrackerStoreQueuePrivate *private;
- TrackerStoreQueueTask *task;
-
- private = g_static_private_get (&private_key);
- g_return_if_fail (private != NULL);
-
- task = g_slice_new0 (TrackerStoreQueueTask);
- task->type = TRACKER_STORE_QUEUE_TASK_TYPE_INSERT_STATEMENT;
- task->data.statement.subject = g_strdup (subject);
- task->data.statement.predicate = g_strdup (predicate);
- task->data.statement.object = g_strdup (object);
- task->user_data = user_data;
- task->callback.update_callback = callback;
- task->destroy = destroy;
-
- g_queue_push_tail (private->single_queue, task);
-
- if (!private->have_handler) {
- start_handler (private);
- }
-}
-
-void
-tracker_store_queue_delete_statement (const gchar *subject,
- const gchar *predicate,
- const gchar *object,
- TrackerStoreQueueSparqlUpdateCallback callback,
- gpointer user_data,
- GDestroyNotify destroy)
-{
- TrackerStoreQueuePrivate *private;
- TrackerStoreQueueTask *task;
-
- private = g_static_private_get (&private_key);
- g_return_if_fail (private != NULL);
-
- task = g_slice_new0 (TrackerStoreQueueTask);
- task->type = TRACKER_STORE_QUEUE_TASK_TYPE_DELETE_STATEMENT;
- task->data.statement.subject = g_strdup (subject);
- task->data.statement.predicate = g_strdup (predicate);
- task->data.statement.object = g_strdup (object);
- task->user_data = user_data;
- task->callback.update_callback = callback;
- task->destroy = destroy;
-
- g_queue_push_tail (private->single_queue, task);
-
- if (!private->have_handler) {
- start_handler (private);
- }
-}
-
diff --git a/src/tracker-store/tracker-store-queue.h b/src/tracker-store/tracker-store-queue.h
deleted file mode 100644
index fe435ba..0000000
--- a/src/tracker-store/tracker-store-queue.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2008, Nokia
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- * Author: Philip Van Hoof <philip codeminded be>
- */
-
-#ifndef __TRACKER_STORE_QUEUE_H__
-#define __TRACKER_STORE_QUEUE_H__
-
-#include <stdio.h>
-
-#include <libtracker-common/tracker-common.h>
-#include <libtracker-db/tracker-db-interface.h>
-
-#define TRACKER_STORE_TRANSACTION_MAX 4000
-
-G_BEGIN_DECLS
-
-typedef void (* TrackerStoreQueueSparqlUpdateCallback) (GError *error,
- gpointer user_data);
-typedef void (* TrackerStoreQueueCommitCallback) (gpointer user_data);
-typedef void (* TrackerStoreQueueSparqlQueryCallback) (TrackerDBResultSet *results,
- GError *error,
- gpointer user_data);
-
-void tracker_store_queue_init (void);
-void tracker_store_queue_shutdown (void);
-void tracker_store_queue_batch_commit (TrackerStoreQueueCommitCallback callback,
- gpointer user_data,
- GDestroyNotify destroy);
-void tracker_store_queue_batch_sparql_update (const gchar *sparql,
- TrackerStoreQueueSparqlUpdateCallback callback,
- gpointer user_data,
- GDestroyNotify destroy);
-void tracker_store_queue_batch_insert_statement (const gchar *subject,
- const gchar *predicate,
- const gchar *object,
- TrackerStoreQueueSparqlUpdateCallback callback,
- gpointer user_data,
- GDestroyNotify destroy);
-void tracker_store_queue_sparql_update (const gchar *sparql,
- TrackerStoreQueueSparqlUpdateCallback callback,
- gpointer user_data,
- GDestroyNotify destroy);
-void tracker_store_queue_insert_statement (const gchar *subject,
- const gchar *predicate,
- const gchar *object,
- TrackerStoreQueueSparqlUpdateCallback callback,
- gpointer user_data,
- GDestroyNotify destroy);
-void tracker_store_queue_delete_statement (const gchar *subject,
- const gchar *predicate,
- const gchar *object,
- TrackerStoreQueueSparqlUpdateCallback callback,
- gpointer user_data,
- GDestroyNotify destroy);
-void tracker_store_queue_sparql_query (const gchar *sparql,
- TrackerStoreQueueSparqlQueryCallback callback,
- gpointer user_data,
- GDestroyNotify destroy);
-
-
-G_END_DECLS
-
-#endif /* __TRACKER_STORE_QUEUE_H__ */
diff --git a/src/tracker-store/tracker-store.c b/src/tracker-store/tracker-store.c
new file mode 100644
index 0000000..a2d1ca6
--- /dev/null
+++ b/src/tracker-store/tracker-store.c
@@ -0,0 +1,344 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2008, Nokia
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: Philip Van Hoof <philip codeminded be>
+ */
+
+#include "config.h"
+
+#include <libtracker-common/tracker-dbus.h>
+#include <libtracker-db/tracker-db-dbus.h>
+
+#include <libtracker-data/tracker-data-update.h>
+#include <libtracker-data/tracker-data-query.h>
+
+#include "tracker-store.h"
+
+#define TRACKER_STORE_TRANSACTION_MAX 4000
+
+typedef struct {
+ gboolean have_handler;
+ gboolean final;
+ gboolean batch_mode;
+ guint batch_count;
+ GQueue *queue;
+} TrackerStorePrivate;
+
+typedef enum {
+ TRACKER_STORE_TASK_TYPE_UPDATE = 0,
+ TRACKER_STORE_TASK_TYPE_COMMIT = 1,
+ TRACKER_STORE_TASK_TYPE_INSERT_STATEMENT = 2
+} TrackerStoreTaskType;
+
+typedef struct {
+ TrackerStoreTaskType type;
+ union {
+ gchar *query;
+ struct {
+ gchar *subject;
+ gchar *predicate;
+ gchar *object;
+ } statement;
+ } data;
+ gpointer user_data;
+ GDestroyNotify destroy;
+ union {
+ TrackerStoreSparqlUpdateCallback update_callback;
+ TrackerStoreCommitCallback commit_callback;
+ } callback;
+} TrackerStoreTask;
+
+static GStaticPrivate private_key = G_STATIC_PRIVATE_INIT;
+static gboolean im_done = TRUE;
+
+static void
+private_free (gpointer data)
+{
+ TrackerStorePrivate *private = data;
+
+ g_queue_free (private->queue);
+ g_free (private);
+}
+
+static void
+tracker_store_task_free (TrackerStoreTask *task)
+{
+ if (task->type >= TRACKER_STORE_TASK_TYPE_INSERT_STATEMENT) {
+ g_free (task->data.statement.subject);
+ g_free (task->data.statement.predicate);
+ g_free (task->data.statement.object);
+ } else {
+ g_free (task->data.query);
+ }
+ g_slice_free (TrackerStoreTask, task);
+}
+
+static gboolean
+queue_idle_handler (gpointer user_data)
+{
+ TrackerStorePrivate *private = user_data;
+ TrackerStoreTask *task;
+ GError *error = NULL;
+
+ task = g_queue_pop_head (private->queue);
+
+ if (!task) {
+ return FALSE;
+ }
+
+ /* Implicit transaction start */
+
+ if (!private->batch_mode && task->type != TRACKER_STORE_TASK_TYPE_COMMIT) {
+ tracker_data_begin_transaction ();
+ private->batch_mode = TRUE;
+ private->batch_count = 0;
+ }
+
+ switch (task->type) {
+
+ case TRACKER_STORE_TASK_TYPE_COMMIT:
+
+ /* Explicit transaction commit */
+
+ if (private->batch_mode) {
+ tracker_data_commit_transaction ();
+ }
+
+ private->batch_mode = FALSE;
+ private->batch_count = 0;
+
+ if (task->callback.commit_callback) {
+ task->callback.commit_callback (task->user_data);
+ }
+ break;
+
+ case TRACKER_STORE_TASK_TYPE_INSERT_STATEMENT:
+ tracker_data_insert_statement (task->data.statement.subject,
+ task->data.statement.predicate,
+ task->data.statement.object);
+
+ if (task->callback.update_callback) {
+ task->callback.update_callback (error, task->user_data);
+ }
+
+ private->batch_count++;
+ break;
+
+ case TRACKER_STORE_TASK_TYPE_UPDATE:
+ tracker_data_update_sparql (task->data.query, &error);
+ if (task->callback.update_callback) {
+ task->callback.update_callback (error, task->user_data);
+ }
+
+ private->batch_count++;
+ default:
+ break;
+ }
+
+ if (private->batch_count >= TRACKER_STORE_TRANSACTION_MAX) {
+ tracker_store_queue_commit (NULL, NULL, NULL);
+ private->batch_count = 0;
+ }
+
+ if (task->destroy) {
+ task->destroy (task->user_data);
+ }
+
+ if (error) {
+ g_clear_error (&error);
+ }
+
+ tracker_store_task_free (task);
+
+ return TRUE;
+}
+
+static void
+queue_idle_destroy (gpointer user_data)
+{
+ TrackerStorePrivate *private = user_data;
+
+ private->have_handler = FALSE;
+
+ if (private->final) {
+ g_static_private_set (&private_key, NULL, NULL);
+ }
+
+ im_done = TRUE;
+}
+
+void
+tracker_store_init (void)
+{
+ TrackerStorePrivate *private;
+
+ private = g_new0 (TrackerStorePrivate, 1);
+
+ private->final = FALSE;
+ private->queue = g_queue_new ();
+
+ g_static_private_set (&private_key,
+ private,
+ private_free);
+}
+
+void
+tracker_store_shutdown (void)
+{
+ TrackerStorePrivate *private;
+
+ private = g_static_private_get (&private_key);
+ g_return_if_fail (private != NULL);
+
+ private->final = TRUE;
+
+ if (!im_done) {
+ g_debug ("Can't exit until store-queue is finished ...");
+ while (!im_done) {
+ g_main_context_iteration (NULL, TRUE);
+ }
+ g_debug ("Store-queue finished");
+ }
+}
+
+static void
+start_handler (TrackerStorePrivate *private)
+{
+ im_done = FALSE;
+ private->have_handler = TRUE;
+
+ g_idle_add_full (G_PRIORITY_DEFAULT,
+ queue_idle_handler,
+ private,
+ queue_idle_destroy);
+}
+
+void
+tracker_store_queue_commit (TrackerStoreCommitCallback callback,
+ gpointer user_data,
+ GDestroyNotify destroy)
+{
+ TrackerStorePrivate *private;
+ TrackerStoreTask *task;
+
+ private = g_static_private_get (&private_key);
+ g_return_if_fail (private != NULL);
+
+
+ task = g_slice_new0 (TrackerStoreTask);
+ task->type = TRACKER_STORE_TASK_TYPE_COMMIT;
+ task->user_data = user_data;
+ task->callback.commit_callback = callback;
+ task->destroy = destroy;
+
+ g_queue_push_tail (private->queue, task);
+
+ if (!private->have_handler) {
+ start_handler (private);
+ }
+}
+
+
+void
+tracker_store_queue_sparql_update (const gchar *sparql,
+ TrackerStoreSparqlUpdateCallback callback,
+ gpointer user_data,
+ GDestroyNotify destroy)
+{
+ TrackerStorePrivate *private;
+ TrackerStoreTask *task;
+
+ private = g_static_private_get (&private_key);
+ g_return_if_fail (private != NULL);
+
+ task = g_slice_new0 (TrackerStoreTask);
+ task->type = TRACKER_STORE_TASK_TYPE_UPDATE;
+ task->data.query = g_strdup (sparql);
+ task->user_data = user_data;
+ task->callback.update_callback = callback;
+ task->destroy = destroy;
+
+ g_queue_push_tail (private->queue, task);
+
+ if (!private->have_handler) {
+ start_handler (private);
+ }
+}
+
+void
+tracker_store_sparql_update (const gchar *sparql,
+ GError **error)
+{
+ tracker_data_update_sparql (sparql, error);
+}
+
+TrackerDBResultSet*
+tracker_store_sparql_query (const gchar *sparql,
+ GError **error)
+{
+ return tracker_data_query_sparql (sparql, error);
+}
+
+void
+tracker_store_queue_insert_statement (const gchar *subject,
+ const gchar *predicate,
+ const gchar *object,
+ TrackerStoreSparqlUpdateCallback callback,
+ gpointer user_data,
+ GDestroyNotify destroy)
+{
+ TrackerStorePrivate *private;
+ TrackerStoreTask *task;
+
+ private = g_static_private_get (&private_key);
+ g_return_if_fail (private != NULL);
+
+ task = g_slice_new0 (TrackerStoreTask);
+ task->type = TRACKER_STORE_TASK_TYPE_INSERT_STATEMENT;
+ task->data.statement.subject = g_strdup (subject);
+ task->data.statement.predicate = g_strdup (predicate);
+ task->data.statement.object = g_strdup (object);
+ task->user_data = user_data;
+ task->callback.update_callback = callback;
+ task->destroy = destroy;
+
+ g_queue_push_tail (private->queue, task);
+
+ if (!private->have_handler) {
+ start_handler (private);
+ }
+}
+
+
+void
+tracker_store_insert_statement (const gchar *subject,
+ const gchar *predicate,
+ const gchar *object)
+{
+ tracker_data_insert_statement (subject, predicate, object);
+}
+
+void
+tracker_store_delete_statement (const gchar *subject,
+ const gchar *predicate,
+ const gchar *object)
+{
+ tracker_data_delete_statement (subject, predicate, object);
+}
+
diff --git a/src/tracker-store/tracker-store.h b/src/tracker-store/tracker-store.h
new file mode 100644
index 0000000..deb4976
--- /dev/null
+++ b/src/tracker-store/tracker-store.h
@@ -0,0 +1,66 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2008, Nokia
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: Philip Van Hoof <philip codeminded be>
+ */
+
+#ifndef __TRACKER_STORE_H__
+#define __TRACKER_STORE_H__
+
+#include <stdio.h>
+
+#include <libtracker-common/tracker-common.h>
+#include <libtracker-db/tracker-db-interface.h>
+
+G_BEGIN_DECLS
+
+typedef void (* TrackerStoreSparqlUpdateCallback) (GError *error,
+ gpointer user_data);
+typedef void (* TrackerStoreCommitCallback) (gpointer user_data);
+
+void tracker_store_init (void);
+void tracker_store_shutdown (void);
+void tracker_store_queue_commit (TrackerStoreCommitCallback callback,
+ gpointer user_data,
+ GDestroyNotify destroy);
+void tracker_store_queue_sparql_update (const gchar *sparql,
+ TrackerStoreSparqlUpdateCallback callback,
+ gpointer user_data,
+ GDestroyNotify destroy);
+void tracker_store_queue_insert_statement (const gchar *subject,
+ const gchar *predicate,
+ const gchar *object,
+ TrackerStoreSparqlUpdateCallback callback,
+ gpointer user_data,
+ GDestroyNotify destroy);
+void tracker_store_sparql_update (const gchar *sparql,
+ GError **error);
+void tracker_store_insert_statement (const gchar *subject,
+ const gchar *predicate,
+ const gchar *object);
+void tracker_store_delete_statement (const gchar *subject,
+ const gchar *predicate,
+ const gchar *object);
+TrackerDBResultSet*
+ tracker_store_sparql_query (const gchar *sparql,
+ GError **error);
+
+G_END_DECLS
+
+#endif /* __TRACKER_STORE_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]