tracker r2604 - branches/turtle/src/libtracker-data



Author: pvanhoof
Date: Thu Nov 27 16:49:28 2008
New Revision: 2604
URL: http://svn.gnome.org/viewvc/tracker?rev=2604&view=rev

Log:
Support for removal predicates in the optimizer

Modified:
   branches/turtle/src/libtracker-data/tracker-turtle.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	Thu Nov 27 16:49:28 2008
@@ -121,7 +121,6 @@
 				      info);
 
 		g_hash_table_destroy (info->hash);
-
 		g_free (info->last_subject);
 		info->last_subject = NULL;
 		info->hash = NULL;
@@ -137,6 +136,7 @@
 	gchar               *predicate;
 
 	subject = (gchar *) raptor_uri_as_string ((raptor_uri *) triple->subject);
+	predicate = (gchar *) raptor_uri_as_string ((raptor_uri *) triple->predicate);
 
 	if (!info->last_subject || strcmp (subject, info->last_subject) != 0) {
 		/* Commit previous subject */
@@ -147,17 +147,25 @@
 						    (GDestroyNotify) g_free);
 	}
 
-	predicate = g_strdup ((const gchar *) raptor_uri_as_string ((raptor_uri *) triple->predicate));
 
 	/* TODO: Add conflict resolution here (if any is needed) */
 
-	/* TODO: deal with <URI> <:> <:>              (removal of resource) */
-	/* TODO: deal with <URI> <Pfx:Predicate> <:>  (reset of list, removal of
-						       value) */
-
-	g_hash_table_replace (info->hash,
-			      predicate,
-			      g_strdup (triple->object));
+	if (triple->object_type == RAPTOR_IDENTIFIER_TYPE_RESOURCE) {
+		if (g_str_has_prefix (predicate, "file://")) {
+			/* <URI> <:> <:> */
+			g_hash_table_destroy (info->hash);
+			g_free (info->last_subject);
+			info->last_subject = NULL;
+			info->hash = NULL;
+		} else {
+			/* <URI> <Pfx:Predicate> <:> */
+			g_hash_table_remove (info->hash, predicate);
+		}
+	} else {
+		g_hash_table_replace (info->hash,
+				      g_strdup (predicate),
+				      g_strdup (triple->object));
+	}
 
 }
 
@@ -352,7 +360,13 @@
 	TurtleOptimizerInfo *info;
 	gchar               *tmp_file;
 	FILE                *target_file;
+#endif
+
+	if (!initialized) {
+		g_critical ("Using tracker_turtle module without initialization");
+	}
 
+#ifdef HAVE_RAPTOR
 	tmp_file = g_strdup_printf ("%s.tmp", turtle_file);
 
 	target_file = fopen (tmp_file, "a");



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