tracker r2572 - in branches/turtle: . src/libtracker-data src/tracker-indexer tests/tracker-indexer



Author: pvanhoof
Date: Wed Nov 26 11:32:07 2008
New Revision: 2572
URL: http://svn.gnome.org/viewvc/tracker?rev=2572&view=rev

Log:
2008-11-26  Philip Van Hoof  <philip codeminded be>

	* src/tracker-indexer/tracker-removable-device.c
	* src/tracker-indexer/tracker-removable-device.h
	* src/tracker-indexer/tracker-indexer.c
	* src/tracker-indexer/Makefile.am
	* src/tracker-indexer/tracker-indexer.h
	* src/libtracker-data/tracker-data-update.c
	* src/libtracker-data/tracker-data-update.h
	* tests/tracker-indexer/Makefile.am
	* configure.ac: Further merging with JÃrg's git's Turtle branch.
	Note for the person who'll merg JÃrg's git with this work:
	tracker-indexer/tracker-turtle.c is replaced with 
	tracker-indexer/tracker-removable-device.c and with 
	libtracker-data/tracker-turtle.c (the code is split over the two
	files). The function tracker_data_replace_service in 
	libtracker-data/tracker-data-update.c was replaced with an empty
	body implementation. Of course should the version in JÃrg's git
	branch be taken for the decomposed data model (instead of the empty
	body implementation).



Modified:
   branches/turtle/ChangeLog
   branches/turtle/configure.ac
   branches/turtle/src/libtracker-data/tracker-data-update.c
   branches/turtle/src/libtracker-data/tracker-data-update.h
   branches/turtle/src/tracker-indexer/Makefile.am
   branches/turtle/src/tracker-indexer/tracker-indexer.c
   branches/turtle/src/tracker-indexer/tracker-indexer.h
   branches/turtle/src/tracker-indexer/tracker-removable-device.c
   branches/turtle/src/tracker-indexer/tracker-removable-device.h
   branches/turtle/tests/tracker-indexer/Makefile.am

Modified: branches/turtle/configure.ac
==============================================================================
--- branches/turtle/configure.ac	(original)
+++ branches/turtle/configure.ac	Wed Nov 26 11:32:07 2008
@@ -1185,6 +1185,8 @@
                 tests/tracker-indexer/tracker-module-file.h:src/tracker-indexer/tracker-module-file.h
                 tests/tracker-indexer/tracker-module-iteratable.c:src/tracker-indexer/tracker-module-iteratable.c
                 tests/tracker-indexer/tracker-module-iteratable.h:src/tracker-indexer/tracker-module-iteratable.h
+		tests/tracker-indexer/tracker-removable-device.c:src/tracker-indexer/tracker-removable-device.c
+		tests/tracker-indexer/tracker-removable-device.h:src/tracker-indexer/tracker-removable-device.h
 )
 
 ##################################################################

Modified: branches/turtle/src/libtracker-data/tracker-data-update.c
==============================================================================
--- branches/turtle/src/libtracker-data/tracker-data-update.c	(original)
+++ branches/turtle/src/libtracker-data/tracker-data-update.c	Wed Nov 26 11:32:07 2008
@@ -571,6 +571,16 @@
 	tracker_data_manager_exec (iface, "DELETE FROM Events WHERE BeingHandled = 1");
 }
 
+
+void 
+tracker_data_replace_service (const gchar         *uri,
+			      const gchar         *rdf_type,
+			      TrackerDataMetadata *metadata)
+{
+	/* Unimplemented in this branch of Tracker (it's implemented in JÃrg's
+	 * new data model, it's only here for API consistency with JÃrg's work) */
+}
+
 void
 tracker_data_update_enable_volume (const gchar *udi,
                                    const gchar *mount_path)

Modified: branches/turtle/src/libtracker-data/tracker-data-update.h
==============================================================================
--- branches/turtle/src/libtracker-data/tracker-data-update.h	(original)
+++ branches/turtle/src/libtracker-data/tracker-data-update.h	Wed Nov 26 11:32:07 2008
@@ -51,6 +51,9 @@
 void     tracker_data_update_move_service               (TrackerService      *service,
 							 const gchar         *from,
 							 const gchar         *to);
+void     tracker_data_replace_service                   (const gchar         *uri,
+							 const gchar         *rdf_type,
+							 TrackerDataMetadata *metadata);
 
 /* Metadata */
 void     tracker_data_update_set_metadata               (TrackerService      *service,

Modified: branches/turtle/src/tracker-indexer/Makefile.am
==============================================================================
--- branches/turtle/src/tracker-indexer/Makefile.am	(original)
+++ branches/turtle/src/tracker-indexer/Makefile.am	Wed Nov 26 11:32:07 2008
@@ -13,6 +13,7 @@
 	-I$(top_srcdir)/src						\
 	$(DBUS_CFLAGS)							\
 	$(PANGO_CFLAGS)							\
+	$(RAPTOR_CFLAGS)						\
 	$(GMODULE_CFLAGS)
 
 libtracker_indexerdir = $(libdir)/tracker
@@ -55,6 +56,7 @@
 	$(PANGO_LIBS)							\
 	$(GIO_LIBS)							\
 	$(GLIB2_LIBS)							\
+	$(RAPTOR_LIBS)							\
 	-lz								\
 	-lm
 

Modified: branches/turtle/src/tracker-indexer/tracker-indexer.c
==============================================================================
--- branches/turtle/src/tracker-indexer/tracker-indexer.c	(original)
+++ branches/turtle/src/tracker-indexer/tracker-indexer.c	Wed Nov 26 11:32:07 2008
@@ -74,6 +74,7 @@
 #include "tracker-indexer.h"
 #include "tracker-indexer-module.h"
 #include "tracker-marshal.h"
+#include "tracker-removable-device.h"
 
 #define TRACKER_INDEXER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TRACKER_TYPE_INDEXER, TrackerIndexerPrivate))
 
@@ -383,6 +384,22 @@
 							    indexer);
 }
 
+
+void 
+tracker_indexer_commit_transaction (TrackerIndexer *indexer)
+{
+	stop_transaction (indexer);
+	tracker_indexer_set_running (indexer, TRUE);
+
+}
+
+void
+tracker_indexer_open_transaction   (TrackerIndexer *indexer)
+{
+	tracker_indexer_set_running (indexer, FALSE);
+	start_transaction (indexer);
+}
+
 #ifdef HAVE_HAL
 
 static void
@@ -2762,6 +2779,13 @@
 
 	dbus_g_method_return (context);
 	tracker_dbus_request_success (request_id);
+
+	/* tracker_turtle_process_ttl will be spinning the mainloop, therefore
+	   we can already return the DBus method */
+
+	if (enabled) {
+		tracker_removable_device_load (indexer, path);
+	}
 }
 
 void

Modified: branches/turtle/src/tracker-indexer/tracker-indexer.h
==============================================================================
--- branches/turtle/src/tracker-indexer/tracker-indexer.h	(original)
+++ branches/turtle/src/tracker-indexer/tracker-indexer.h	Wed Nov 26 11:32:07 2008
@@ -80,6 +80,8 @@
 void            tracker_indexer_process_all         (TrackerIndexer         *indexer);
 void            tracker_indexer_process_modules     (TrackerIndexer         *indexer,
 						     gchar                 **modules);
+void		tracker_indexer_commit_transaction  (TrackerIndexer         *indexer);
+void		tracker_indexer_open_transaction    (TrackerIndexer         *indexer);
 
 /* DBus methods */
 void            tracker_indexer_pause               (TrackerIndexer         *indexer,

Modified: branches/turtle/src/tracker-indexer/tracker-removable-device.c
==============================================================================
--- branches/turtle/src/tracker-indexer/tracker-removable-device.c	(original)
+++ branches/turtle/src/tracker-indexer/tracker-removable-device.c	Wed Nov 26 11:32:07 2008
@@ -21,6 +21,8 @@
  * Author: Philip Van Hoof <philip codeminded be>
  */
 
+#include "config.h"
+
 #include "tracker-removable-device.h"
 
 #ifdef HAVE_RAPTOR
@@ -52,6 +54,10 @@
 #include <libtracker-data/tracker-data-query.h>
 #include <libtracker-data/tracker-data-update.h>
 
+typedef void (*executer_func) (const gchar *subject, 
+			       const gchar *rdf_type, 
+			       TrackerDataMetadata *metadata);
+
 typedef struct {
 	const gchar *ttl_file;
 	gchar *last_subject;
@@ -60,20 +66,30 @@
 	guint amount;
 	TrackerIndexer *indexer;
 	gchar *rdf_type;
+	executer_func exec_func;
 } TurtleParseInfo;
 
+
+static void
+put_in_tracker_data (const gchar *subject, const gchar *rdf_type, TrackerDataMetadata *metadata)
+{
+	/* We have it as a URI, database api wants Paths. Update this when
+	 * the database api becomes sane and uses URIs everywhere */
+
+	tracker_data_replace_service (subject + 7, 
+				      rdf_type, 
+				      metadata);
+}
+
 static void
-commit_turtle_parse_info_data (TurtleParseInfo *info, gboolean may_flush)
+commit_turtle_parse_info_data (TurtleParseInfo *info, gboolean may_flush, executer_func exec_func)
 {
 	
 	if (info->last_subject) {
 
-		/* We have it as a URI, database api wants Paths. Update this when
-		 * the database api becomes sane and uses URIs everywhere */
-
-		tracker_data_replace_service (info->last_subject + 7, 
-					      info->rdf_type, 
-					      info->metadata);
+		exec_func (info->last_subject, 
+			   info->rdf_type, 
+			   info->metadata);
 
 		info->amount++;
 
@@ -109,7 +125,7 @@
 
 		/* Commit previous subject */
 
-		commit_turtle_parse_info_data (info, TRUE);
+		commit_turtle_parse_info_data (info, TRUE, info->exec_func);
 		info->last_subject = g_strdup (subject);
 		info->metadata = tracker_data_metadata_new ();
 	}
@@ -161,85 +177,99 @@
 #endif /* HAVE_RAPTOR */
 
 void
-tracker_removable_device_process_ttl (TrackerIndexer *indexer, const gchar *file)
+tracker_removable_device_optimize (TrackerIndexer *indexer, const gchar *mount_point)
+{
+}
+
+void
+tracker_removable_device_load (TrackerIndexer *indexer, const gchar *mount_point)
 {
 #ifdef HAVE_RAPTOR
+	gchar           *file;
 
-	unsigned char   *uri_stringa, *uri_stringb;
-	raptor_uri      *uri, *base_uri;
-	static gboolean  has_init = FALSE;
-	raptor_parser   *parser;
-	TurtleParseInfo *info;
-	gchar           *copy_file, *ptr;
-
-	raptor_init();
-
-	parser = raptor_new_parser ("turtle");
-
-	info = g_slice_new0 (TurtleParseInfo);
-
-	info->ttl_file = file;
-	info->indexer = g_object_ref (indexer);
-	info->amount = 0;
-
-	raptor_set_statement_handler (parser, info, consume_triple);
-	raptor_set_fatal_error_handler (parser, info, raptor_error);
-	raptor_set_error_handler (parser, info, raptor_error);
-	raptor_set_warning_handler (parser, info, raptor_error);
-
-	copy_file = g_strdup (file);
-
-	ptr = strstr (copy_file, "/metadata/metadata.ttl");
-	if (ptr) {
-		/* .cache remains, and will be cut later, just like dummy_file is */
-		*ptr = '\0';
-	} else {
-		g_free (copy_file);
-		copy_file = g_strdup ("/home/pvanhoof/dummy_file");
-	}
+	file = g_build_filename (mount_point, ".cache", 
+				 "metadata", "metadata.ttl", NULL);
+
+	if (g_file_test (file, G_FILE_TEST_EXISTS)) {
+		unsigned char   *uri_stringa, *uri_stringb;
+		raptor_uri      *uri, *base_uri;
+		static gboolean  has_init = FALSE;
+		raptor_parser   *parser;
+		TurtleParseInfo *info;
+		gchar           *copy_file, *ptr;
+
+		raptor_init();
+
+		parser = raptor_new_parser ("turtle");
+
+		info = g_slice_new0 (TurtleParseInfo);
+
+		info->ttl_file = file;
+		info->indexer = g_object_ref (indexer);
+		info->amount = 0;
+		info->exec_func = put_in_tracker_data;
+	
+		raptor_set_statement_handler (parser, info, consume_triple);
+		raptor_set_fatal_error_handler (parser, info, raptor_error);
+		raptor_set_error_handler (parser, info, raptor_error);
+		raptor_set_warning_handler (parser, info, raptor_error);
+
+		copy_file = g_strdup (file);
+
+		ptr = strstr (copy_file, "/metadata/metadata.ttl");
+		if (ptr) {
+			/* .cache remains, and will be cut later, just like dummy_file is */
+			*ptr = '\0';
+		} else {
+			g_free (copy_file);
+			copy_file = g_strdup ("/home/pvanhoof/dummy_file");
+		}
 
 
-	uri_stringa = raptor_uri_filename_to_uri_string (file);
-	uri_stringb = raptor_uri_filename_to_uri_string (copy_file);
+		uri_stringa = raptor_uri_filename_to_uri_string (file);
+		uri_stringb = raptor_uri_filename_to_uri_string (copy_file);
 
-	uri = raptor_new_uri (uri_stringa);
-	base_uri = raptor_new_uri (uri_stringb);
+		uri = raptor_new_uri (uri_stringa);
+		base_uri = raptor_new_uri (uri_stringb);
 
-	/* Take the file (dummy_file or .cache) from base */
-	ptr = strrchr (copy_file, '/');
-	if (ptr)
-		*ptr = '\0';
+		/* Take the file (dummy_file or .cache) from base */
+		ptr = strrchr (copy_file, '/');
+		if (ptr)
+			*ptr = '\0';
 
-	info->base = copy_file;
+		info->base = copy_file;
 
-	tracker_indexer_open_transaction (info->indexer);
+		tracker_indexer_open_transaction (info->indexer);
 
-	GTimer *timer = g_timer_new ();
-	g_timer_start (timer);
+		GTimer *timer = g_timer_new ();
+		g_timer_start (timer);
 
-	raptor_parse_file (parser, uri, base_uri);
-	/* Commit final subject */
+		raptor_parse_file (parser, uri, base_uri);
+		/* Commit final subject */
 
-	commit_turtle_parse_info_data (info, FALSE);
+		commit_turtle_parse_info_data (info, FALSE, info->exec_func);
 
-	g_timer_stop (timer);
-	g_print ("\nTIME: %f\n", g_timer_elapsed (timer, NULL));
+		g_timer_stop (timer);
+		g_print ("\nTIME: %f\n", g_timer_elapsed (timer, NULL));
 
-	tracker_indexer_commit_transaction (info->indexer);
+		tracker_indexer_commit_transaction (info->indexer);
 
-	g_free (copy_file);
-	g_object_unref (info->indexer);
-	g_slice_free (TurtleParseInfo, info);
+		g_free (copy_file);
+		g_object_unref (info->indexer);
+		g_slice_free (TurtleParseInfo, info);
+
+		raptor_free_parser (parser);
 
-	raptor_free_parser (parser);
+		raptor_free_uri (base_uri);
+		raptor_free_uri (uri);
+		raptor_free_memory (uri_stringa);
+		raptor_free_memory (uri_stringb);
 
-	raptor_free_uri (base_uri);
-	raptor_free_uri (uri);
-	raptor_free_memory (uri_stringa);
-	raptor_free_memory (uri_stringb);
 
+		raptor_finish();
+	}
 
-	raptor_finish();
+	g_free (file);
 
 #endif /* HAVE_RAPTOR */
 

Modified: branches/turtle/src/tracker-indexer/tracker-removable-device.h
==============================================================================
--- branches/turtle/src/tracker-indexer/tracker-removable-device.h	(original)
+++ branches/turtle/src/tracker-indexer/tracker-removable-device.h	Wed Nov 26 11:32:07 2008
@@ -27,7 +27,8 @@
 #include "tracker-indexer.h"
 #include <libtracker-data/tracker-data-metadata.h>
 
-void    tracker_removable_device_process_ttl      (TrackerIndexer *indexer, const gchar *file);
+void    tracker_removable_device_load      (TrackerIndexer *indexer, const gchar *mount_point);
+void    tracker_removable_device_optimize  (TrackerIndexer *indexer, const gchar *mount_point);
 
 
 #endif /* __TRACKER_REMOVABLE_DEVICE_H__ */

Modified: branches/turtle/tests/tracker-indexer/Makefile.am
==============================================================================
--- branches/turtle/tests/tracker-indexer/Makefile.am	(original)
+++ branches/turtle/tests/tracker-indexer/Makefile.am	Wed Nov 26 11:32:07 2008
@@ -18,6 +18,7 @@
 	$(PANGO_CFLAGS)							\
 	$(GMODULE_CFLAGS)						\
 	$(GTHREAD_CFLAGS)						\
+	$(RAPTOR_CFLAGS)						\
 	$(GLIB2_CFLAGS)
 
 tracker_metadata_utils_SOURCES = 					\
@@ -34,7 +35,9 @@
 	tracker-module-file.c						\
 	tracker-module-file.h						\
 	tracker-module-iteratable.c					\
-	tracker-module-iteratable.h
+	tracker-module-iteratable.h					\
+	tracker-removable-device.c					\
+	tracker-removable-device.h
 
 tracker_metadata_utils_LDADD =	                                        \
 	$(top_builddir)/src/libtracker-data/libtracker-data.la 		\
@@ -46,6 +49,7 @@
 	$(GMODULE_LIBS)							\
 	$(GTHREAD_LIBS)							\
 	$(GIO_LIBS)							\
+	$(RAPTOR_LIBS)							\
 	$(GLIB2_LIBS)							
 
 #



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