[tracker/wip/carlosg/tracker-3.0-api-breaks: 3/79] libtracker-sparql: Drop load() API



commit af964d2ef892e214b5d2cc1fd9ea79fcc5e148f4
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sat Aug 10 23:46:32 2019 +0200

    libtracker-sparql: Drop load() API
    
    This is replaced by the LOAD update syntax.

 .../libtracker-sparql-sections.txt                 |  3 -
 .../reference/libtracker-sparql/migrating-2to3.xml |  6 ++
 src/libtracker-bus/tracker-bus.vala                | 16 ----
 src/libtracker-direct/tracker-direct.c             | 88 ++--------------------
 src/libtracker-sparql-backend/tracker-backend.vala | 18 -----
 src/libtracker-sparql/tracker-connection.vala      | 44 -----------
 src/tracker-store/tracker-resources.vala           | 21 ------
 src/tracker-store/tracker-store.vala               |  9 ---
 8 files changed, 12 insertions(+), 193 deletions(-)
---
diff --git a/docs/reference/libtracker-sparql/libtracker-sparql-sections.txt 
b/docs/reference/libtracker-sparql/libtracker-sparql-sections.txt
index 8c0b6a4ef..709bac827 100644
--- a/docs/reference/libtracker-sparql/libtracker-sparql-sections.txt
+++ b/docs/reference/libtracker-sparql/libtracker-sparql-sections.txt
@@ -179,9 +179,6 @@ tracker_sparql_connection_update_array_finish
 tracker_sparql_connection_update_blank
 tracker_sparql_connection_update_blank_async
 tracker_sparql_connection_update_blank_finish
-tracker_sparql_connection_load
-tracker_sparql_connection_load_async
-tracker_sparql_connection_load_finish
 tracker_sparql_connection_statistics
 tracker_sparql_connection_statistics_async
 tracker_sparql_connection_statistics_finish
diff --git a/docs/reference/libtracker-sparql/migrating-2to3.xml 
b/docs/reference/libtracker-sparql/migrating-2to3.xml
index b9bcfc07f..6ab2ba071 100644
--- a/docs/reference/libtracker-sparql/migrating-2to3.xml
+++ b/docs/reference/libtracker-sparql/migrating-2to3.xml
@@ -86,4 +86,10 @@ SELECT ?s { ?s a nfo:FileDataObject }
       no provided migration path, use TrackerSparqlConnection directly.
     </para>
   </section>
+  <section>
+    <title>No tracker_sparql_connection_load()/load_async()/load_finish()</title>
+    <para>
+      This is superseded by the "LOAD &lt;url&gt;" SPARQL syntax.
+    </para>
+  </section>
 </chapter>
diff --git a/src/libtracker-bus/tracker-bus.vala b/src/libtracker-bus/tracker-bus.vala
index a257c51c8..8dfbf56b7 100644
--- a/src/libtracker-bus/tracker-bus.vala
+++ b/src/libtracker-bus/tracker-bus.vala
@@ -289,22 +289,6 @@ public class Tracker.Bus.Connection : Tracker.Sparql.Connection {
                return reply.get_body ().get_child_value (0);
        }
 
-       public override void load (File file, Cancellable? cancellable = null) throws Sparql.Error, IOError, 
DBusError {
-               var message = new DBusMessage.method_call (dbus_name, Tracker.DBUS_OBJECT_RESOURCES, 
Tracker.DBUS_INTERFACE_RESOURCES, "Load");
-               message.set_body (new Variant ("(s)", file.get_uri ()));
-
-               var reply = bus.send_message_with_reply_sync (message, DBusSendMessageFlags.NONE, int.MAX, 
null, cancellable);
-               handle_error_reply (reply);
-       }
-
-       public async override void load_async (File file, Cancellable? cancellable = null) throws 
Sparql.Error, IOError, DBusError {
-               var message = new DBusMessage.method_call (dbus_name, Tracker.DBUS_OBJECT_RESOURCES, 
Tracker.DBUS_INTERFACE_RESOURCES, "Load");
-               message.set_body (new Variant ("(s)", file.get_uri ()));
-
-               var reply = yield bus.send_message_with_reply (message, DBusSendMessageFlags.NONE, int.MAX, 
null, cancellable);
-               handle_error_reply (reply);
-       }
-
        public override Sparql.Cursor? statistics (Cancellable? cancellable = null) throws Sparql.Error, 
IOError, DBusError {
                var message = new DBusMessage.method_call (dbus_name, Tracker.DBUS_OBJECT_STATISTICS, 
Tracker.DBUS_INTERFACE_STATISTICS, "Get");
 
diff --git a/src/libtracker-direct/tracker-direct.c b/src/libtracker-direct/tracker-direct.c
index 3452579c7..6eeaf4220 100644
--- a/src/libtracker-direct/tracker-direct.c
+++ b/src/libtracker-direct/tracker-direct.c
@@ -61,15 +61,11 @@ typedef enum {
        TASK_TYPE_QUERY,
        TASK_TYPE_UPDATE,
        TASK_TYPE_UPDATE_BLANK,
-       TASK_TYPE_TURTLE
 } TaskType;
 
 typedef struct {
        TaskType type;
-       union {
-               gchar *query;
-               GFile *turtle_file;
-       } data;
+       gchar *query;
 } TaskData;
 
 static void tracker_direct_connection_initable_iface_init (GInitableIface *iface);
@@ -89,22 +85,9 @@ task_data_query_new (TaskType     type,
 {
        TaskData *data;
 
-       g_assert (type != TASK_TYPE_TURTLE);
        data = g_new0 (TaskData, 1);
        data->type = type;
-       data->data.query = g_strdup (sparql);
-
-       return data;
-}
-
-static TaskData *
-task_data_turtle_new (GFile *file)
-{
-       TaskData *data;
-
-       data = g_new0 (TaskData, 1);
-       data->type = TASK_TYPE_TURTLE;
-       g_set_object (&data->data.turtle_file, file);
+       data->query = g_strdup (sparql);
 
        return data;
 }
@@ -112,11 +95,7 @@ task_data_turtle_new (GFile *file)
 static void
 task_data_free (TaskData *task)
 {
-       if (task->type == TASK_TYPE_TURTLE)
-               g_object_unref (task->data.turtle_file);
-       else
-               g_free (task->data.query);
-
+       g_free (task->query);
        g_free (task);
 }
 
@@ -144,15 +123,12 @@ update_thread_func (gpointer data,
                g_warning ("Queries don't go through this thread");
                break;
        case TASK_TYPE_UPDATE:
-               tracker_data_update_sparql (tracker_data, task_data->data.query, &error);
+               tracker_data_update_sparql (tracker_data, task_data->query, &error);
                break;
        case TASK_TYPE_UPDATE_BLANK:
-               retval = tracker_data_update_sparql_blank (tracker_data, task_data->data.query, &error);
+               retval = tracker_data_update_sparql_blank (tracker_data, task_data->query, &error);
                destroy_notify = (GDestroyNotify) g_variant_unref;
                break;
-       case TASK_TYPE_TURTLE:
-               tracker_data_load_turtle_file (tracker_data, task_data->data.turtle_file, NULL, &error);
-               break;
        }
 
        if (error)
@@ -177,7 +153,7 @@ query_thread_pool_func (gpointer data,
 
        g_assert (task_data->type == TASK_TYPE_QUERY);
        cursor = tracker_sparql_connection_query (TRACKER_SPARQL_CONNECTION (g_task_get_source_object (task)),
-                                                 task_data->data.query,
+                                                 task_data->query,
                                                  g_task_get_cancellable (task),
                                                  &error);
        if (cursor)
@@ -687,55 +663,6 @@ tracker_direct_connection_update_blank_finish (TrackerSparqlConnection  *self,
        return g_task_propagate_pointer (G_TASK (res), error);
 }
 
-static void
-tracker_direct_connection_load (TrackerSparqlConnection  *self,
-                                GFile                    *file,
-                                GCancellable             *cancellable,
-                                GError                  **error)
-{
-       TrackerDirectConnectionPrivate *priv;
-       TrackerDirectConnection *conn;
-       TrackerData *data;
-
-       conn = TRACKER_DIRECT_CONNECTION (self);
-       priv = tracker_direct_connection_get_instance_private (conn);
-
-       g_mutex_lock (&priv->mutex);
-       data = tracker_data_manager_get_data (priv->data_manager);
-       tracker_data_load_turtle_file (data, file, NULL, error);
-       g_mutex_unlock (&priv->mutex);
-}
-
-static void
-tracker_direct_connection_load_async (TrackerSparqlConnection *self,
-                                      GFile                   *file,
-                                      GCancellable            *cancellable,
-                                      GAsyncReadyCallback      callback,
-                                      gpointer                 user_data)
-{
-       TrackerDirectConnectionPrivate *priv;
-       TrackerDirectConnection *conn;
-       GTask *task;
-
-       conn = TRACKER_DIRECT_CONNECTION (self);
-       priv = tracker_direct_connection_get_instance_private (conn);
-
-       task = g_task_new (self, cancellable, callback, user_data);
-       g_task_set_task_data (task,
-                             task_data_turtle_new (file),
-                             (GDestroyNotify) task_data_free);
-
-       g_thread_pool_push (priv->update_thread, task, NULL);
-}
-
-static void
-tracker_direct_connection_load_finish (TrackerSparqlConnection  *self,
-                                       GAsyncResult             *res,
-                                       GError                  **error)
-{
-       g_task_propagate_pointer (G_TASK (res), error);
-}
-
 static TrackerNamespaceManager *
 tracker_direct_connection_get_namespace_manager (TrackerSparqlConnection *self)
 {
@@ -771,9 +698,6 @@ tracker_direct_connection_class_init (TrackerDirectConnectionClass *klass)
        sparql_connection_class->update_blank = tracker_direct_connection_update_blank;
        sparql_connection_class->update_blank_async = tracker_direct_connection_update_blank_async;
        sparql_connection_class->update_blank_finish = tracker_direct_connection_update_blank_finish;
-       sparql_connection_class->load = tracker_direct_connection_load;
-       sparql_connection_class->load_async = tracker_direct_connection_load_async;
-       sparql_connection_class->load_finish = tracker_direct_connection_load_finish;
        sparql_connection_class->get_namespace_manager = tracker_direct_connection_get_namespace_manager;
 
        props[PROP_FLAGS] =
diff --git a/src/libtracker-sparql-backend/tracker-backend.vala 
b/src/libtracker-sparql-backend/tracker-backend.vala
index 462091b98..afc6235d8 100644
--- a/src/libtracker-sparql-backend/tracker-backend.vala
+++ b/src/libtracker-sparql-backend/tracker-backend.vala
@@ -130,24 +130,6 @@ class Tracker.Sparql.Backend : Connection {
                return yield bus.update_blank_async (sparql, priority, cancellable);
        }
 
-       public override void load (File file, Cancellable? cancellable = null) throws Sparql.Error, IOError, 
DBusError {
-               var uri = file.get_uri ();
-               debug ("%s(): '%s'", GLib.Log.METHOD, uri);
-               if (bus == null) {
-                       throw new Sparql.Error.UNSUPPORTED ("Update support not available for direct-only 
connection");
-               }
-               bus.load (file, cancellable);
-       }
-
-       public async override void load_async (File file, Cancellable? cancellable = null) throws 
Sparql.Error, IOError, DBusError {
-               var uri = file.get_uri ();
-               debug ("%s(): '%s'", GLib.Log.METHOD, uri);
-               if (bus == null) {
-                       throw new Sparql.Error.UNSUPPORTED ("Update support not available for direct-only 
connection");
-               }
-               yield bus.load_async (file, cancellable);
-       }
-
        public override Cursor? statistics (Cancellable? cancellable = null) throws Sparql.Error, IOError, 
DBusError {
                debug ("%s()", GLib.Log.METHOD);
                if (bus == null) {
diff --git a/src/libtracker-sparql/tracker-connection.vala b/src/libtracker-sparql/tracker-connection.vala
index e0e0e04dd..848b9b6b0 100644
--- a/src/libtracker-sparql/tracker-connection.vala
+++ b/src/libtracker-sparql/tracker-connection.vala
@@ -468,50 +468,6 @@ public abstract class Tracker.Sparql.Connection : Object {
                return null;
        }
 
-       /**
-        * tracker_sparql_connection_load:
-        * @self: a #TrackerSparqlConnection
-        * @file: a #GFile
-        * @cancellable: a #GCancellable used to cancel the operation
-        * @error: #GError for error reporting.
-        *
-        * Loads a Turtle file (TTL) into the store. The API call is completely
-        * synchronous, so it may block.
-        *
-        * Since: 0.10
-        */
-       public virtual void load (File file, Cancellable? cancellable = null) throws Sparql.Error, IOError, 
DBusError {
-               warning ("Interface 'load' not implemented");
-       }
-
-       /**
-        * tracker_sparql_connection_load_async:
-        * @self: a #TrackerSparqlConnection
-        * @file: a #GFile
-        * @cancellable: a #GCancellable used to cancel the operation
-        * @_callback_: user-defined #GAsyncReadyCallback to be called when
-        *              asynchronous operation is finished.
-        * @_user_data_: user-defined data to be passed to @_callback_
-        *
-        * Loads, asynchronously, a Turtle file (TTL) into the store.
-        *
-        * Since: 0.10
-        */
-
-       /**
-        * tracker_sparql_connection_load_finish:
-        * @self: a #TrackerSparqlConnection
-        * @_res_: a #GAsyncResult with the result of the operation
-        * @error: #GError for error reporting.
-        *
-        * Finishes the asynchronous load of the Turtle file.
-        *
-        * Since: 0.10
-        */
-       public async virtual void load_async (File file, Cancellable? cancellable = null) throws 
Sparql.Error, IOError, DBusError {
-               warning ("Interface 'load_async' not implemented");
-       }
-
        /**
         * tracker_sparql_connection_statistics:
         * @self: a #TrackerSparqlConnection
diff --git a/src/tracker-store/tracker-resources.vala b/src/tracker-store/tracker-resources.vala
index cda827250..4bb581bdf 100644
--- a/src/tracker-store/tracker-resources.vala
+++ b/src/tracker-store/tracker-resources.vala
@@ -57,27 +57,6 @@ public class Tracker.Resources : Object {
                Tracker.Store.set_signal_callback (on_emit_signals);
        }
 
-       public async void load (BusName sender, string uri) throws Error {
-               var request = DBusRequest.begin (sender, "Resources.Load (uri: '%s')", uri);
-               try {
-                       var file = File.new_for_uri (uri);
-                       var sparql_conn = Tracker.Main.get_sparql_connection ();
-
-                       yield Tracker.Store.queue_turtle_import (sparql_conn, file, sender);
-
-                       request.end ();
-               } catch (DBInterfaceError.NO_SPACE ie) {
-                       throw new Sparql.Error.NO_SPACE (ie.message);
-               } catch (Error e) {
-                       request.end (e);
-                       if (e is Sparql.Error) {
-                               throw e;
-                       } else {
-                               throw new Sparql.Error.INTERNAL (e.message);
-                       }
-               }
-       }
-
        [DBus (signature = "aas")]
        public async Variant sparql_query (BusName sender, string query) throws Error {
                var request = DBusRequest.begin (sender, "Resources.SparqlQuery");
diff --git a/src/tracker-store/tracker-store.vala b/src/tracker-store/tracker-store.vala
index f7b03a601..7c05c8ff6 100644
--- a/src/tracker-store/tracker-store.vala
+++ b/src/tracker-store/tracker-store.vala
@@ -206,15 +206,6 @@ public class Tracker.Store {
                return nodes;
        }
 
-       public static async void queue_turtle_import (Tracker.Direct.Connection conn, File file, string 
client_id) throws Error {
-               if (!active)
-                       throw new Sparql.Error.UNSUPPORTED ("Store is not active");
-               pre_update ();
-               var cancellable = create_cancellable (client_id);
-               yield conn.load_async (file, cancellable);
-               post_update ();
-       }
-
        public static void unreg_batches (string client_id) {
                Cancellable cancellable = client_cancellables.lookup (client_id);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]