tracker r2566 - in branches/turtle/src: libtracker-data trackerd
- From: ifrade svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r2566 - in branches/turtle/src: libtracker-data trackerd
- Date: Tue, 25 Nov 2008 17:08:18 +0000 (UTC)
Author: ifrade
Date: Tue Nov 25 17:08:18 2008
New Revision: 2566
URL: http://svn.gnome.org/viewvc/tracker?rev=2566&view=rev
Log:
Using raptor to write on the file
Modified:
branches/turtle/src/libtracker-data/tracker-turtle.c
branches/turtle/src/trackerd/tracker-backup.c
Modified: branches/turtle/src/libtracker-data/tracker-turtle.c
==============================================================================
--- branches/turtle/src/libtracker-data/tracker-turtle.c (original)
+++ branches/turtle/src/libtracker-data/tracker-turtle.c Tue Nov 25 17:08:18 2008
@@ -204,7 +204,6 @@
{
#ifdef HAVE_RAPTOR
TurtleFile *turtle = NULL;
- gchar *uri_string;
turtle = g_new0 (TurtleFile, 1);
@@ -214,17 +213,13 @@
turtle->file = fopen (turtle_file, "w");
/*
-
- Looks like there's no turtle serializer in Raptor, no worries it's not
- a hard format to serialize by ourselves.
-
+ * Looks like there's no turtle serializer in Raptor, no worries it's not
+ * a hard format to serialize by ourselves.
+ */
turtle->serializer = raptor_new_serializer ("turtle");
- uri_string = raptor_uri_filename_to_uri_string (turtle_file);
- turtle->uri = raptor_new_uri (uri_string);
+ turtle->uri = raptor_new_uri ("/");
raptor_serialize_start_to_file_handle (turtle->serializer,
- NULL, turtle->file);
-
- g_free (uri_string);*/
+ turtle->uri, turtle->file);
return turtle;
#else
@@ -241,26 +236,7 @@
{
#ifdef HAVE_RAPTOR
- gchar *about_uri = NULL;
-
- /* raptor_statement statement;
-
- if (g_str_has_prefix (uri, "file://")) {
- about_uri = g_strdup_printf ("<%s>", uri);
- } else {
- about_uri = g_strdup_printf ("<file://%s>", uri);
- } */
-
- if (!g_str_has_prefix (uri, "file://")) {
- about_uri = g_strdup_printf ("file://%s", uri);
- }
-
- g_debug ("in ttl: <%s> <%s> %s%s%s .\n",
- about_uri?about_uri:uri,
- tracker_field_get_name (property),
- value?"\"":"<",
- value?value:":",
- value?"\"":">");
+ raptor_statement *statement;
/* TODO: cope with group values by making them ; separated, perhaps by
* reading the type from the TrackerField? Also, numeric values don't
@@ -272,28 +248,25 @@
* File:Modified and rdf:type are added per record (uyou seperate triples
* using a ; and you end a record using a . (a dot).*/
- fprintf (turtle->file, "<%s> <%s> %s%s%s .\n",
- about_uri?about_uri:uri,
- tracker_field_get_name (property),
- value?"\"":"<",
- value?value:":",
- value?"\"":">");
+ statement = g_new0 (raptor_statement, 1);
- g_free (about_uri);
+ statement->subject = (void *)raptor_new_uri (uri);
+ statement->subject_type = RAPTOR_IDENTIFIER_TYPE_RESOURCE;
- /*
- statement.subject = about_uri;
- statement.subject_type = RAPTOR_IDENTIFIER_TYPE_RESOURCE;
- statement.predicate = tracker_field_get_name (property);
- statement.predicate_type = RAPTOR_IDENTIFIER_TYPE_LITERAL;
- statement.object = value;
- statement.object_type = RAPTOR_IDENTIFIER_TYPE_LITERAL;
+ statement->predicate = (void *)raptor_new_uri (tracker_field_get_name (property));
+ statement->predicate_type = RAPTOR_IDENTIFIER_TYPE_RESOURCE;
+
+ statement->object = (unsigned char *)g_strdup (value);
+ statement->object_type = RAPTOR_IDENTIFIER_TYPE_LITERAL;
raptor_serialize_statement (turtle->serializer,
- &statement);
+ statement);
+
+ raptor_free_uri ((raptor_uri *)statement->subject);
+ raptor_free_uri ((raptor_uri *)statement->predicate);
+ g_free ((unsigned char *)statement->object);
- g_free (about_uri);
- */
+ g_free (statement);
#endif
}
@@ -303,11 +276,11 @@
tracker_turtle_close (TurtleFile *turtle)
{
#ifdef HAVE_RAPTOR
- /*raptor_free_uri (turtle->uri);
+ raptor_free_uri (turtle->uri);
raptor_serialize_end (turtle->serializer);
- raptor_free_serializer(turtle->serializer);*/
- fclose (turtle->file);
- /*raptor_finish ();*/
+ raptor_free_serializer(turtle->serializer);
+ //fclose (turtle->file);
+ raptor_finish ();
g_free (turtle);
#endif
}
Modified: branches/turtle/src/trackerd/tracker-backup.c
==============================================================================
--- branches/turtle/src/trackerd/tracker-backup.c (original)
+++ branches/turtle/src/trackerd/tracker-backup.c Tue Nov 25 17:08:18 2008
@@ -55,6 +55,8 @@
TrackerDataMetadata *metadata;
TurtleFile *turtle_file;
+ tracker_turtle_init ();
+
/* TODO: temporary location */
turtle_file = tracker_turtle_open ("/tmp/tracker-saving-things.ttl");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]