[tracker/wip/carlosg/tracker-3.0-api-breaks: 8/92] libtracker-sparql: Drop statistics() API



commit 043a71fc933bfa7fb310f540373ea6b7b9b3e143
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sat Aug 10 23:46:59 2019 +0200

    libtracker-sparql: Drop statistics() API
    
    We have a whole query language to fetch statistics.

 .../libtracker-sparql-sections.txt                 |  3 --
 .../reference/libtracker-sparql/migrating-2to3.xml | 21 +++++++++
 src/libtracker-bus/tracker-bus.vala                | 48 --------------------
 src/libtracker-sparql-backend/tracker-backend.vala | 16 -------
 src/libtracker-sparql/tracker-connection.vala      | 52 ----------------------
 5 files changed, 21 insertions(+), 119 deletions(-)
---
diff --git a/docs/reference/libtracker-sparql/libtracker-sparql-sections.txt 
b/docs/reference/libtracker-sparql/libtracker-sparql-sections.txt
index 709bac827..3dee48c12 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_statistics
-tracker_sparql_connection_statistics_async
-tracker_sparql_connection_statistics_finish
 tracker_sparql_connection_get_namespace_manager
 tracker_sparql_connection_set_domain
 tracker_sparql_connection_get_domain
diff --git a/docs/reference/libtracker-sparql/migrating-2to3.xml 
b/docs/reference/libtracker-sparql/migrating-2to3.xml
index 6ab2ba071..beaa60433 100644
--- a/docs/reference/libtracker-sparql/migrating-2to3.xml
+++ b/docs/reference/libtracker-sparql/migrating-2to3.xml
@@ -92,4 +92,25 @@ SELECT ?s { ?s a nfo:FileDataObject }
       This is superseded by the "LOAD &lt;url&gt;" SPARQL syntax.
     </para>
   </section>
+  <section>
+    <title>No tracker_sparql_connection_statistics()/statistics_async()/statistics_finish()</title>
+    <para>
+      It is possible to query statistics through SPARQL. This query would
+      provide a similar return value than the statistics API:
+    </para>
+    <programlisting>
+SELECT
+  ?class
+  (COUNT(?resource) AS ?count)
+{
+  ?class a rdfs:Class .
+  ?resource a ?class
+}
+GROUP BY ?class
+ORDER BY DESC ?count
+    </programlisting>
+    <para>
+      But of course, other more detailed statistics may be obtained.
+    </para>
+  </section>
 </chapter>
diff --git a/src/libtracker-bus/tracker-bus.vala b/src/libtracker-bus/tracker-bus.vala
index 8dfbf56b7..e02eef7d7 100644
--- a/src/libtracker-bus/tracker-bus.vala
+++ b/src/libtracker-bus/tracker-bus.vala
@@ -288,52 +288,4 @@ public class Tracker.Bus.Connection : Tracker.Sparql.Connection {
                handle_error_reply (reply);
                return reply.get_body ().get_child_value (0);
        }
-
-       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");
-
-               var reply = bus.send_message_with_reply_sync (message, DBusSendMessageFlags.NONE, int.MAX, 
null, cancellable);
-               handle_error_reply (reply);
-
-               string[,] results = (string[,]) reply.get_body ().get_child_value (0);
-               Sparql.ValueType[] types = new Sparql.ValueType[2];
-               string[] var_names = new string[2];
-
-               var_names[0] = "class";
-               var_names[1] = "count";
-               types[0] = Sparql.ValueType.STRING;
-               types[1] = Sparql.ValueType.INTEGER;
-
-               int rows = results.length[0];
-               int cols = results.length[1];
-               return new Tracker.Bus.ArrayCursor ((owned) results,
-                                                   rows,
-                                                   cols,
-                                                   var_names,
-                                                   types);
-       }
-
-       public async override Sparql.Cursor? statistics_async (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");
-
-               var reply = yield bus.send_message_with_reply (message, DBusSendMessageFlags.NONE, int.MAX, 
null, cancellable);
-               handle_error_reply (reply);
-
-               string[,] results = (string[,]) reply.get_body ().get_child_value (0);
-               Sparql.ValueType[] types = new Sparql.ValueType[2];
-               string[] var_names = new string[2];
-
-               var_names[0] = "class";
-               var_names[1] = "count";
-               types[0] = Sparql.ValueType.STRING;
-               types[1] = Sparql.ValueType.INTEGER;
-
-               int rows = results.length[0];
-               int cols = results.length[1];
-               return new Tracker.Bus.ArrayCursor ((owned) results,
-                                                   rows,
-                                                   cols,
-                                                   var_names,
-                                                   types);
-       }
 }
diff --git a/src/libtracker-sparql-backend/tracker-backend.vala 
b/src/libtracker-sparql-backend/tracker-backend.vala
index afc6235d8..0dc974d75 100644
--- a/src/libtracker-sparql-backend/tracker-backend.vala
+++ b/src/libtracker-sparql-backend/tracker-backend.vala
@@ -130,22 +130,6 @@ class Tracker.Sparql.Backend : Connection {
                return yield bus.update_blank_async (sparql, priority, cancellable);
        }
 
-       public override Cursor? statistics (Cancellable? cancellable = null) throws Sparql.Error, IOError, 
DBusError {
-               debug ("%s()", GLib.Log.METHOD);
-               if (bus == null) {
-                       throw new Sparql.Error.UNSUPPORTED ("Statistics support not available for direct-only 
connection");
-               }
-               return bus.statistics (cancellable);
-       }
-
-       public async override Cursor? statistics_async (Cancellable? cancellable = null) throws Sparql.Error, 
IOError, DBusError {
-               debug ("%s()", GLib.Log.METHOD);
-               if (bus == null) {
-                       throw new Sparql.Error.UNSUPPORTED ("Statistics support not available for direct-only 
connection");
-               }
-               return yield bus.statistics_async (cancellable);
-       }
-
        public override NamespaceManager? get_namespace_manager () {
                if (direct != null)
                        return direct.get_namespace_manager ();
diff --git a/src/libtracker-sparql/tracker-connection.vala b/src/libtracker-sparql/tracker-connection.vala
index 848b9b6b0..da6480155 100644
--- a/src/libtracker-sparql/tracker-connection.vala
+++ b/src/libtracker-sparql/tracker-connection.vala
@@ -468,58 +468,6 @@ public abstract class Tracker.Sparql.Connection : Object {
                return null;
        }
 
-       /**
-        * tracker_sparql_connection_statistics:
-        * @self: a #TrackerSparqlConnection
-        * @cancellable: a #GCancellable used to cancel the operation
-        * @error: #GError for error reporting.
-        *
-        * Retrieves the statistics from the Store. The API call is completely
-        * synchronous, so it may block.
-        *
-        * Returns: a #TrackerSparqlCursor to iterate the reply if successful, #NULL
-        * on error. Call g_object_unref() on the returned cursor when no longer
-        * needed.
-        *
-        * Since: 0.10
-        */
-       public virtual Cursor? statistics (Cancellable? cancellable = null) throws Sparql.Error, IOError, 
DBusError {
-               warning ("Interface 'statistics' not implemented");
-               return null;
-       }
-
-       /**
-        * tracker_sparql_connection_statistics_async:
-        * @self: a #TrackerSparqlConnection
-        * @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_
-        *
-        * Retrieves, asynchronously, the statistics from the Store.
-        *
-        * Since: 0.10
-        */
-
-       /**
-        * tracker_sparql_connection_statistics_finish:
-        * @self: a #TrackerSparqlConnection
-        * @_res_: a #GAsyncResult with the result of the operation
-        * @error: #GError for error reporting.
-        *
-        * Finishes the asynchronous retrieval of statistics from the Store.
-        *
-        * Returns: a #TrackerSparqlCursor to iterate the reply if successful, #NULL
-        * on error. Call g_object_unref() on the returned cursor when no longer
-        * needed.
-        *
-        * Since: 0.10
-        */
-       public async virtual Cursor? statistics_async (Cancellable? cancellable = null) throws Sparql.Error, 
IOError, DBusError {
-               warning ("Interface 'statistics_async' not implemented");
-               return null;
-       }
-
        /**
         * tracker_sparql_connection_get_namespace_manager:
         * @self: a #TrackerSparqlConnection


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