[tracker/tracker-store] tracker-indexer: Simplify TrackerModuleMetadata



commit 00bc78e0fd0b604e26ae85a5399afb5be42f497a
Author: Jürg Billeter <j bitron ch>
Date:   Tue Jun 23 17:12:25 2009 +0200

    tracker-indexer: Simplify TrackerModuleMetadata

 .../tracker-module-metadata-private.h              |    8 ---
 src/tracker-indexer/tracker-module-metadata.c      |   57 +-------------------
 src/tracker-indexer/tracker-removable-device.c     |    2 +
 3 files changed, 3 insertions(+), 64 deletions(-)
---
diff --git a/src/tracker-indexer/tracker-module-metadata-private.h b/src/tracker-indexer/tracker-module-metadata-private.h
index 24c9e53..1f1c342 100644
--- a/src/tracker-indexer/tracker-module-metadata-private.h
+++ b/src/tracker-indexer/tracker-module-metadata-private.h
@@ -28,14 +28,6 @@
 
 G_BEGIN_DECLS
 
-typedef void (* TrackerModuleMetadataForeach) (const gchar     *subject,
-					       const gchar     *predicate,
-					       const gchar     *object,
-					       gpointer      user_data);
-
-void		       tracker_module_metadata_foreach        (TrackerModuleMetadata        *metadata,
-							       TrackerModuleMetadataForeach  func,
-							       gpointer	                     user_data);
 gchar *                tracker_module_metadata_get_sparql     (TrackerModuleMetadata        *metadata);
 
 
diff --git a/src/tracker-indexer/tracker-module-metadata.c b/src/tracker-indexer/tracker-module-metadata.c
index ea6c439..679b023 100644
--- a/src/tracker-indexer/tracker-module-metadata.c
+++ b/src/tracker-indexer/tracker-module-metadata.c
@@ -26,19 +26,10 @@
 #include <libtracker-common/tracker-type-utils.h>
 #include "tracker-module-metadata-private.h"
 
-typedef struct _Statement Statement;
-
-struct _Statement {
-	gchar *subject;
-	gchar *predicate;
-	gchar *object;
-};
-
 struct TrackerModuleMetadata {
 	GObject parent_instance;
 	TrackerSparqlBuilder *sparql;
 	gboolean sparql_closed;
-	GArray *statements;
 };
 
 struct TrackerModuleMetadataClass {
@@ -64,31 +55,17 @@ tracker_module_metadata_init (TrackerModuleMetadata *metadata)
 {
 	metadata->sparql = tracker_sparql_builder_new_update ();
 	tracker_sparql_builder_insert_open (metadata->sparql);
-
-	metadata->statements = g_array_new (FALSE, TRUE, sizeof (Statement));
 }
 
 static void
 tracker_module_metadata_finalize (GObject *object)
 {
 	TrackerModuleMetadata *metadata;
-	gint i;
 
 	metadata = TRACKER_MODULE_METADATA (object);
 
 	g_object_unref (metadata->sparql);
 
-	for (i = 0; i < metadata->statements->len; i++) {
-		Statement *stmt;
-
-		stmt = &g_array_index (metadata->statements, Statement, i);
-		g_free (stmt->subject);
-		g_free (stmt->predicate);
-		g_free (stmt->object);
-	}
-
-	g_array_free (metadata->statements, TRUE);
-
 	G_OBJECT_CLASS (tracker_module_metadata_parent_class)->finalize (object);
 }
 
@@ -116,8 +93,6 @@ tracker_module_metadata_add_take_string (TrackerModuleMetadata *metadata,
 					 const gchar           *predicate,
 					 gchar                 *value)
 {
-	Statement stmt;
-
 	g_return_val_if_fail (metadata != NULL, FALSE);
 	g_return_val_if_fail (subject != NULL, FALSE);
 	g_return_val_if_fail (predicate != NULL, FALSE);
@@ -130,11 +105,7 @@ tracker_module_metadata_add_take_string (TrackerModuleMetadata *metadata,
 	tracker_sparql_builder_predicate_iri (metadata->sparql, predicate);
 	tracker_sparql_builder_object_string (metadata->sparql, value);
 
-	stmt.subject = g_strdup (subject);
-	stmt.predicate = g_strdup (predicate);
-	stmt.object = value;
-
-	g_array_append_val (metadata->statements, stmt);
+	g_free (value);
 
 	return TRUE;
 }
@@ -297,35 +268,9 @@ tracker_module_metadata_add_date (TrackerModuleMetadata *metadata,
 	}
 }
 
-/**
- * tracker_module_metadata_foreach:
- * @metadata: A #TrackerModuleMetadata.
- * @func: The function to call with each metadata.
- * @user_data: user data to pass to the function.
- *
- * Calls a function for each element in @metadata.
- **/
-void
-tracker_module_metadata_foreach (TrackerModuleMetadata        *metadata,
-				 TrackerModuleMetadataForeach  func,
-				 gpointer		       user_data)
-{
-	gint i;
-
-	for (i = 0; i < metadata->statements->len; i++) {
-		Statement *stmt;
-
-		stmt = &g_array_index (metadata->statements, Statement, i);
-		func (stmt->subject, stmt->predicate, stmt->object, user_data);
-	}
-}
-
 gchar *
 tracker_module_metadata_get_sparql (TrackerModuleMetadata        *metadata)
 {
-	TrackerSparqlBuilder *sparql;
-	gchar *result;
-
 	if (!metadata->sparql_closed) {
 		tracker_sparql_builder_insert_close (metadata->sparql);
 		metadata->sparql_closed = TRUE;
diff --git a/src/tracker-indexer/tracker-removable-device.c b/src/tracker-indexer/tracker-removable-device.c
index 4439f5d..bcd4b55 100644
--- a/src/tracker-indexer/tracker-removable-device.c
+++ b/src/tracker-indexer/tracker-removable-device.c
@@ -386,9 +386,11 @@ tracker_removable_device_add_metadata (TrackerIndexer        *indexer,
 					       suri,
 					       target_file);
 
+	/* TODO: Concatenate SPARQL queries instead
 	tracker_module_metadata_foreach (metadata, 
 					 foreach_in_metadata_set_metadata,
 					 &info);
+	 */
 
 	g_free (info.about_uri);
 



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