[tracker/wip/carlosg/deserializer-cursors: 4/15] libtracker-sparql: Replace remote connection cursors with deserializers




commit 6a68b951ef25bcb5773363da9244adaac11cb952
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed Apr 27 17:35:05 2022 +0200

    libtracker-sparql: Replace remote connection cursors with deserializers
    
    We have now both implementation in place, so we can start using
    TrackerDeserializer to deserialize JSON/XML cursor formats into a
    TrackerSparqlCursor that we can iterate.
    
    As a result, the ad-hoc implementations become unused and can now
    be removed.

 src/libtracker-sparql/remote/meson.build           |   2 -
 .../remote/tracker-json-cursor.vala                | 140 --------------
 src/libtracker-sparql/remote/tracker-remote.vala   |  18 +-
 src/libtracker-sparql/remote/tracker-remote.vapi   |   4 +
 .../remote/tracker-xml-cursor.vala                 | 204 ---------------------
 5 files changed, 6 insertions(+), 362 deletions(-)
---
diff --git a/src/libtracker-sparql/remote/meson.build b/src/libtracker-sparql/remote/meson.build
index 3d9e0c653..92816781a 100644
--- a/src/libtracker-sparql/remote/meson.build
+++ b/src/libtracker-sparql/remote/meson.build
@@ -2,8 +2,6 @@ remote_files = files(
     'tracker-http.c',
     'tracker-remote-statement.c',
     'tracker-remote.vapi',
-    'tracker-json-cursor.vala',
-    'tracker-xml-cursor.vala',
     'tracker-remote.vala',
 )
 
diff --git a/src/libtracker-sparql/remote/tracker-remote.vala 
b/src/libtracker-sparql/remote/tracker-remote.vala
index aef5325c6..c6073b8a2 100644
--- a/src/libtracker-sparql/remote/tracker-remote.vala
+++ b/src/libtracker-sparql/remote/tracker-remote.vala
@@ -28,20 +28,6 @@ public class Tracker.Remote.Connection : Tracker.Sparql.Connection {
                _client = new HttpClient();
        }
 
-       private Sparql.Cursor create_cursor (GLib.InputStream stream, SerializerFormat format) throws 
GLib.Error, Sparql.Error {
-               var buffer = new uchar[20 * 1024 * 1024];
-               size_t len;
-               stream.read_all (buffer, out len, null);
-
-               if (format == SerializerFormat.JSON) {
-                       return new Tracker.Remote.JsonCursor ((string) buffer, (long) len);
-               } else if (format == SerializerFormat.XML) {
-                       return new Tracker.Remote.XmlCursor ((string) buffer, (long) len);
-               } else {
-                       throw new Sparql.Error.UNSUPPORTED ("Unparseable content type, document is: %s", 
(string) buffer);
-               }
-       }
-
        public override Sparql.Cursor query (string sparql, Cancellable? cancellable) throws GLib.Error, 
Sparql.Error, IOError {
                uint flags =
                        (1 << SerializerFormat.JSON) |
@@ -49,7 +35,7 @@ public class Tracker.Remote.Connection : Tracker.Sparql.Connection {
                SerializerFormat format;
                var istream = _client.send_message (_base_uri, sparql, flags, cancellable, out format);
 
-               return create_cursor (istream, format);
+               return new Tracker.Deserializer(istream, null, format);
        }
 
        public async override Sparql.Cursor query_async (string sparql, Cancellable? cancellable) throws 
GLib.Error, Sparql.Error, IOError {
@@ -59,7 +45,7 @@ public class Tracker.Remote.Connection : Tracker.Sparql.Connection {
                SerializerFormat format;
                var istream = yield _client.send_message_async (_base_uri, sparql, flags, cancellable, out 
format);
 
-               return create_cursor (istream, format);
+               return new Tracker.Deserializer(istream, null, format);
        }
 
        public override Sparql.Statement? query_statement (string sparql, GLib.Cancellable? cancellable = 
null) throws Sparql.Error {
diff --git a/src/libtracker-sparql/remote/tracker-remote.vapi 
b/src/libtracker-sparql/remote/tracker-remote.vapi
index d266470e1..fdcc62a5d 100644
--- a/src/libtracker-sparql/remote/tracker-remote.vapi
+++ b/src/libtracker-sparql/remote/tracker-remote.vapi
@@ -18,4 +18,8 @@ namespace Tracker {
                TTL,
                TRIG,
         }
+
+       class Deserializer : Sparql.Cursor {
+               public Deserializer (GLib.InputStream stream, NamespaceManager? namespaces, SerializerFormat 
format);
+       }
 }


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