[tracker/wip/carlosg/in-memory-databases: 4/5] libtracker-sparql: Expose in-memory databases
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/in-memory-databases: 4/5] libtracker-sparql: Expose in-memory databases
- Date: Sat, 22 Feb 2020 16:02:59 +0000 (UTC)
commit 772442a14028af2b9776d26ad338408b46cb0992
Author: Carlos Garnacho <carlosg gnome org>
Date: Sat Feb 22 16:34:50 2020 +0100
libtracker-sparql: Expose in-memory databases
Those are now possible by simply passing a NULL argument for the
store location in tracker_sparql_connection_new().
src/libtracker-direct/tracker-direct.c | 5 ++++-
src/libtracker-sparql-backend/tracker-backend.vala | 2 +-
src/libtracker-sparql/tracker-connection.c | 6 ++++--
3 files changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/src/libtracker-direct/tracker-direct.c b/src/libtracker-direct/tracker-direct.c
index 862dbffec..c625cee10 100644
--- a/src/libtracker-direct/tracker-direct.c
+++ b/src/libtracker-direct/tracker-direct.c
@@ -257,6 +257,9 @@ tracker_direct_connection_initable_init (GInitable *initable,
db_flags = translate_flags (priv->flags);
+ if (!priv->store)
+ db_flags |= TRACKER_DB_MANAGER_IN_MEMORY;
+
/* Init data manager */
if (!priv->ontology &&
(db_flags & TRACKER_DB_MANAGER_READONLY) == 0) {
@@ -1035,7 +1038,7 @@ tracker_direct_connection_new (TrackerSparqlConnectionFlags flags,
GFile *ontology,
GError **error)
{
- g_return_val_if_fail (G_IS_FILE (store), NULL);
+ g_return_val_if_fail (!store || G_IS_FILE (store), NULL);
g_return_val_if_fail (!ontology || G_IS_FILE (ontology), NULL);
g_return_val_if_fail (!error || !*error, NULL);
diff --git a/src/libtracker-sparql-backend/tracker-backend.vala
b/src/libtracker-sparql-backend/tracker-backend.vala
index 34e95bd6a..7e8ee79fb 100644
--- a/src/libtracker-sparql-backend/tracker-backend.vala
+++ b/src/libtracker-sparql-backend/tracker-backend.vala
@@ -38,7 +38,7 @@ public static Tracker.Sparql.Connection tracker_sparql_connection_bus_new (strin
return new Tracker.Bus.Connection (service, path, dbus_conn);
}
-public static Tracker.Sparql.Connection tracker_sparql_connection_new (Tracker.Sparql.ConnectionFlags flags,
File store, File? ontology, Cancellable? cancellable = null) throws GLib.Error, Tracker.Sparql.Error, IOError
{
+public static Tracker.Sparql.Connection tracker_sparql_connection_new (Tracker.Sparql.ConnectionFlags flags,
File? store, File? ontology, Cancellable? cancellable = null) throws GLib.Error, Tracker.Sparql.Error,
IOError {
var conn = new Tracker.Direct.Connection (flags, store, ontology);
conn.init (cancellable);
return conn;
diff --git a/src/libtracker-sparql/tracker-connection.c b/src/libtracker-sparql/tracker-connection.c
index c5be4831e..16c72d723 100644
--- a/src/libtracker-sparql/tracker-connection.c
+++ b/src/libtracker-sparql/tracker-connection.c
@@ -53,7 +53,7 @@ tracker_sparql_connection_class_init (TrackerSparqlConnectionClass *klass)
/**
* tracker_sparql_connection_new:
* @flags: values from #TrackerSparqlConnectionFlags
- * @store: the directory that contains the database, as a #GFile
+ * @store: the directory that contains the database as a #GFile, or %NULL
* @ontology: (nullable): the directory that contains the database schemas as
* a #GFile, or %NULL to use the default schemas.
* @cancellable: (nullable): a #GCancellable, or %NULL
@@ -64,6 +64,8 @@ tracker_sparql_connection_class_init (TrackerSparqlConnectionClass *klass)
* To connect to databases managed by other processes, use
* tracker_sparql_connection_bus_new().
*
+ * If @store is %NULL, the database will be created in memory.
+ *
* Returns: (transfer full): a new #TrackerSparqlConnection. Call
* g_object_unref() on the object when no longer used.
*
@@ -73,7 +75,7 @@ tracker_sparql_connection_class_init (TrackerSparqlConnectionClass *klass)
/**
* tracker_sparql_connection_new_async:
* @flags: values from #TrackerSparqlConnectionFlags
- * @store: the directory that contains the database, as a #GFile
+ * @store: the directory that contains the database as a #GFile, or %NULL
* @ontology: (nullable): the directory that contains the database schemas as
* a #GFile, or %NULL to use the default schemas.
* @cancellable: (nullable): a #GCancellable, or %NULL
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]