[tracker/wip/carlosg/sparql1.1: 38/56] libtracker-data: Pass graph parameter to turtle reader



commit ce9db33dd652aa0f7ffa1301873e9c3226653cb4
Author: Carlos Garnacho <carlosg gnome org>
Date:   Fri May 31 17:56:09 2019 +0200

    libtracker-data: Pass graph parameter to turtle reader
    
    The TTL format just describes triples, so the graph it should get into
    should be specified externally. We just pass NULL in the callers so far
    as those should eventually disappear.

 src/libtracker-data/tracker-data-update.c      | 3 ++-
 src/libtracker-data/tracker-data-update.h      | 1 +
 src/libtracker-data/tracker-sparql.c           | 1 +
 src/libtracker-data/tracker-turtle-reader.vala | 6 +++---
 src/libtracker-direct/tracker-direct.c         | 4 ++--
 tests/libtracker-data/tracker-backup-test.c    | 2 +-
 tests/libtracker-data/tracker-ontology-test.c  | 2 +-
 tests/libtracker-data/tracker-sparql-test.c    | 2 +-
 8 files changed, 12 insertions(+), 9 deletions(-)
---
diff --git a/src/libtracker-data/tracker-data-update.c b/src/libtracker-data/tracker-data-update.c
index 99495a3d0..d42d967a7 100644
--- a/src/libtracker-data/tracker-data-update.c
+++ b/src/libtracker-data/tracker-data-update.c
@@ -3424,11 +3424,12 @@ tracker_data_update_sparql_blank (TrackerData  *data,
 void
 tracker_data_load_turtle_file (TrackerData  *data,
                                GFile        *file,
+                               const gchar  *graph,
                                GError      **error)
 {
        g_return_if_fail (G_IS_FILE (file));
 
-       tracker_turtle_reader_load (file, data, error);
+       tracker_turtle_reader_load (file, data, graph, error);
 }
 
 gint
diff --git a/src/libtracker-data/tracker-data-update.h b/src/libtracker-data/tracker-data-update.h
index 5241167fb..eda5514b9 100644
--- a/src/libtracker-data/tracker-data-update.h
+++ b/src/libtracker-data/tracker-data-update.h
@@ -114,6 +114,7 @@ void     tracker_data_update_buffer_might_flush     (TrackerData               *
                                                      GError                   **error);
 void     tracker_data_load_turtle_file              (TrackerData               *data,
                                                      GFile                     *file,
+                                                     const gchar               *graph,
                                                      GError                   **error);
 
 void     tracker_data_sync                          (TrackerData               *data);
diff --git a/src/libtracker-data/tracker-sparql.c b/src/libtracker-data/tracker-sparql.c
index bdeaf82e9..d2711de70 100644
--- a/src/libtracker-data/tracker-sparql.c
+++ b/src/libtracker-data/tracker-sparql.c
@@ -29,6 +29,7 @@
 #include "tracker-sparql-grammar.h"
 #include "tracker-collation.h"
 #include "tracker-db-interface-sqlite.h"
+#include "tracker-sparql-query.h"
 
 #define TRACKER_NS "http://www.tracker-project.org/ontologies/tracker#";
 #define RDF_NS "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
diff --git a/src/libtracker-data/tracker-turtle-reader.vala b/src/libtracker-data/tracker-turtle-reader.vala
index 662ce8f43..43006ca46 100644
--- a/src/libtracker-data/tracker-turtle-reader.vala
+++ b/src/libtracker-data/tracker-turtle-reader.vala
@@ -381,16 +381,16 @@ public class Tracker.TurtleReader : Object {
                }
        }
 
-       public static void load (File file, Data.Update data) throws Error, FileError, Sparql.Error, 
DateError, DBInterfaceError {
+       public static void load (File file, Data.Update data, string graph) throws Error, FileError, 
Sparql.Error, DateError, DBInterfaceError {
                try {
                        data.begin_transaction ();
 
                        var reader = new TurtleReader (file);
                        while (reader.next ()) {
                                if (reader.object_is_uri) {
-                                       data.insert_statement_with_uri (reader.graph, reader.subject, 
reader.predicate, reader.object);
+                                       data.insert_statement_with_uri (graph, reader.subject, 
reader.predicate, reader.object);
                                } else {
-                                       data.insert_statement_with_string (reader.graph, reader.subject, 
reader.predicate, reader.object);
+                                       data.insert_statement_with_string (graph, reader.subject, 
reader.predicate, reader.object);
                                }
                                data.update_buffer_might_flush ();
                        }
diff --git a/src/libtracker-direct/tracker-direct.c b/src/libtracker-direct/tracker-direct.c
index 9edfb2e2e..f692b5da4 100644
--- a/src/libtracker-direct/tracker-direct.c
+++ b/src/libtracker-direct/tracker-direct.c
@@ -151,7 +151,7 @@ update_thread_func (gpointer data,
                destroy_notify = (GDestroyNotify) g_variant_unref;
                break;
        case TASK_TYPE_TURTLE:
-               tracker_data_load_turtle_file (tracker_data, task_data->data.turtle_file, &error);
+               tracker_data_load_turtle_file (tracker_data, task_data->data.turtle_file, NULL, &error);
                break;
        }
 
@@ -696,7 +696,7 @@ tracker_direct_connection_load (TrackerSparqlConnection  *self,
 
        g_mutex_lock (&priv->mutex);
        data = tracker_data_manager_get_data (priv->data_manager);
-       tracker_data_load_turtle_file (data, file, error);
+       tracker_data_load_turtle_file (data, file, NULL, error);
        g_mutex_unlock (&priv->mutex);
 }
 
diff --git a/tests/libtracker-data/tracker-backup-test.c b/tests/libtracker-data/tracker-backup-test.c
index 4e0fb602a..0079f9c0a 100644
--- a/tests/libtracker-data/tracker-backup-test.c
+++ b/tests/libtracker-data/tracker-backup-test.c
@@ -134,7 +134,7 @@ test_backup_and_restore_helper (const gchar *db_location,
        if (g_file_test (data_filename, G_FILE_TEST_IS_REGULAR)) {
                GFile *file = g_file_new_for_path (data_filename);
                data_update = tracker_data_manager_get_data (manager);
-               tracker_turtle_reader_load (file, data_update, &error);
+               tracker_turtle_reader_load (file, data_update, NULL, &error);
                g_assert_no_error (error);
                g_object_unref (file);
        } else {
diff --git a/tests/libtracker-data/tracker-ontology-test.c b/tests/libtracker-data/tracker-ontology-test.c
index f0933e3c2..897e97170 100644
--- a/tests/libtracker-data/tracker-ontology-test.c
+++ b/tests/libtracker-data/tracker-ontology-test.c
@@ -239,7 +239,7 @@ test_query (TestInfo      *test_info,
        data_filename = g_strconcat (data_prefix, ".ttl", NULL);
        file = g_file_new_for_path (data_filename);
        data_update = tracker_data_manager_get_data (manager);
-       tracker_turtle_reader_load (file, data_update, &error);
+       tracker_turtle_reader_load (file, data_update, NULL, &error);
        g_assert_no_error (error);
        g_object_unref (file);
 
diff --git a/tests/libtracker-data/tracker-sparql-test.c b/tests/libtracker-data/tracker-sparql-test.c
index a0911ab30..cd04119af 100644
--- a/tests/libtracker-data/tracker-sparql-test.c
+++ b/tests/libtracker-data/tracker-sparql-test.c
@@ -312,7 +312,7 @@ test_sparql_query (TestInfo      *test_info,
        data_filename = g_strconcat (data_prefix, ".ttl", NULL);
        if (g_file_test (data_filename, G_FILE_TEST_IS_REGULAR)) {
                GFile *file = g_file_new_for_path (data_filename);
-               tracker_turtle_reader_load (file, data_update, &error);
+               tracker_turtle_reader_load (file, data_update, NULL, &error);
                g_assert_no_error (error);
                g_object_unref (file);
        } else {


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