[tracker] TrackerOntology: Use ptr arrays for classes/props/namespaces bookkeeping.



commit 9a44ed4d206eaaac8cf8b24feed7dfd3c3944d10
Author: Carlos Garnacho <carlos gnome org>
Date:   Wed Dec 2 10:50:06 2009 +0200

    TrackerOntology: Use ptr arrays for classes/props/namespaces bookkeeping.
    
    The API had to change to return the array length in an out parameter instead
    of returning NULL-ended arrays. All callers have been modified.

 src/libtracker-common/libtracker-common.vapi |    3 -
 src/libtracker-common/tracker-ontology.c     |   76 ++++++++++++-----------
 src/libtracker-common/tracker-ontology.h     |    6 +-
 src/libtracker-data/tracker-data-manager.c   |   71 ++++++++++++----------
 src/libtracker-data/tracker-data-update.c    |   84 +++++++++++++++-----------
 src/libtracker-db/tracker-db-backup.c        |   30 +++++----
 src/libtracker-fts/tracker-fts.c             |   16 +++--
 src/tracker-store/tracker-statistics.c       |   35 ++++++-----
 8 files changed, 175 insertions(+), 146 deletions(-)
---
diff --git a/src/libtracker-common/libtracker-common.vapi b/src/libtracker-common/libtracker-common.vapi
index 6528da8..9be6d09 100644
--- a/src/libtracker-common/libtracker-common.vapi
+++ b/src/libtracker-common/libtracker-common.vapi
@@ -59,11 +59,8 @@ namespace Tracker {
 	namespace Ontology {
 		public weak Class get_class_by_uri (string class_uri);
 		public weak Property get_property_by_uri (string property_uri);
-		[CCode (array_length = false, array_null_terminated = true)]
 		public weak Namespace[] get_namespaces ();
-		[CCode (array_length = false, array_null_terminated = true)]
 		public weak Class[] get_classes ();
-		[CCode (array_length = false, array_null_terminated = true)]
 		public weak Property[] get_properties ();
 	}
 
diff --git a/src/libtracker-common/tracker-ontology.c b/src/libtracker-common/tracker-ontology.c
index 9effb46..2323ba7 100644
--- a/src/libtracker-common/tracker-ontology.c
+++ b/src/libtracker-common/tracker-ontology.c
@@ -28,27 +28,22 @@
 
 #include "tracker-ontology.h"
 
-typedef struct {
-	gchar  *name;
-	GArray *subcategories;
-} CalculateSubcategoriesForEach;
-
 static gboolean    initialized;
 
 /* List of TrackerNamespace objects */
-static GArray     *namespaces;
+static GPtrArray  *namespaces;
 
 /* Namespace uris */
 static GHashTable *namespace_uris;
 
 /* List of TrackerClass objects */
-static GArray     *classes;
+static GPtrArray  *classes;
 
 /* Hash (gchar *class_uri, TrackerClass *service) */
 static GHashTable *class_uris;
 
 /* List of TrackerProperty objects */
-static GArray     *properties;
+static GPtrArray  *properties;
 
 /* Field uris */
 static GHashTable *property_uris;
@@ -66,14 +61,14 @@ tracker_ontology_init (void)
 		return;
 	}
 
-	namespaces = g_array_new (TRUE, TRUE, sizeof (TrackerNamespace *));
+	namespaces = g_ptr_array_new ();
 
 	namespace_uris = g_hash_table_new_full (g_str_hash,
 					      g_str_equal,
 					      g_free,
 					      g_object_unref);
 
-	classes = g_array_new (TRUE, TRUE, sizeof (TrackerClass *));
+	classes = g_ptr_array_new ();
 
 	class_uris = g_hash_table_new_full (g_str_hash,
 					      g_str_equal,
@@ -84,7 +79,7 @@ tracker_ontology_init (void)
 	                                      NULL,
 	                                      g_free);
 
-	properties = g_array_new (TRUE, TRUE, sizeof (TrackerProperty *));
+	properties = g_ptr_array_new ();
 
 	property_uris = g_hash_table_new_full (g_str_hash,
 					    g_str_equal,
@@ -103,24 +98,18 @@ tracker_ontology_init (void)
 void
 tracker_ontology_shutdown (void)
 {
-	gint i;
-
 	if (!initialized) {
 		return;
 	}
 
-	for (i = 0; i < namespaces->len; i++) {
-		g_object_unref (g_array_index (namespaces, TrackerNamespace *, i));
-	}
-	g_array_free (namespaces, TRUE);
+	g_ptr_array_foreach (namespaces, (GFunc) g_object_unref, NULL);
+	g_ptr_array_free (namespaces, TRUE);
 
 	g_hash_table_unref (namespace_uris);
 	namespace_uris = NULL;
 
-	for (i = 0; i < classes->len; i++) {
-		g_object_unref (g_array_index (classes, TrackerClass *, i));
-	}
-	g_array_free (classes, TRUE);
+	g_ptr_array_foreach (classes, (GFunc) g_object_unref, NULL);
+	g_ptr_array_free (classes, TRUE);
 
 	g_hash_table_unref (class_uris);
 	class_uris = NULL;
@@ -128,10 +117,8 @@ tracker_ontology_shutdown (void)
 	g_hash_table_unref (id_uri_pairs);
 	id_uri_pairs = NULL;
 
-	for (i = 0; i < properties->len; i++) {
-		g_object_unref (g_array_index (properties, TrackerProperty *, i));
-	}
-	g_array_free (properties, TRUE);
+	g_ptr_array_foreach (properties, (GFunc) g_object_unref, NULL);
+	g_ptr_array_free (properties, TRUE);
 
 	g_hash_table_unref (property_uris);
 	property_uris = NULL;
@@ -161,8 +148,7 @@ tracker_ontology_add_class (TrackerClass *service)
 	uri = tracker_class_get_uri (service);
 	name = tracker_class_get_name (service);
 
-	g_object_ref (service);
-	g_array_append_val (classes, service);
+	g_ptr_array_add (classes, g_object_ref (service));
 
 	if (uri) {
 		g_hash_table_insert (class_uris,
@@ -180,21 +166,39 @@ tracker_ontology_get_class_by_uri (const gchar *class_uri)
 }
 
 TrackerNamespace **
-tracker_ontology_get_namespaces (void)
+tracker_ontology_get_namespaces (guint *length)
 {
-	return (TrackerNamespace **) namespaces->data;
+	if (G_UNLIKELY (!namespaces)) {
+		*length = 0;
+		return NULL;
+	}
+
+	*length = namespaces->len;
+	return (TrackerNamespace **) namespaces->pdata;
 }
 
 TrackerClass **
-tracker_ontology_get_classes (void)
+tracker_ontology_get_classes (guint *length)
 {
-	return (TrackerClass **) classes->data;
+	if (G_UNLIKELY (!classes)) {
+		*length = 0;
+		return NULL;
+	}
+
+	*length = classes->len;
+	return (TrackerClass **) classes->pdata;
 }
 
 TrackerProperty **
-tracker_ontology_get_properties (void)
+tracker_ontology_get_properties (guint *length)
 {
-	return (TrackerProperty **) properties->data;
+	if (G_UNLIKELY (!properties)) {
+		*length = 0;
+		return NULL;
+	}
+
+	*length = properties->len;
+	return (TrackerProperty **) properties->pdata;
 }
 
 /* Field mechanics */
@@ -207,8 +211,7 @@ tracker_ontology_add_property (TrackerProperty *field)
 
 	uri = tracker_property_get_uri (field);
 
-	g_object_ref (field);
-	g_array_append_val (properties, field);
+	g_ptr_array_add (properties, g_object_ref (field));
 
 	g_hash_table_insert (property_uris,
 			     g_strdup (uri),
@@ -240,8 +243,7 @@ tracker_ontology_add_namespace (TrackerNamespace *namespace)
 
 	uri = tracker_namespace_get_uri (namespace);
 
-	g_object_ref (namespace);
-	g_array_append_val (namespaces, namespace);
+	g_ptr_array_add (namespaces, g_object_ref (namespace));
 
 	g_hash_table_insert (namespace_uris,
 			     g_strdup (uri),
diff --git a/src/libtracker-common/tracker-ontology.h b/src/libtracker-common/tracker-ontology.h
index d435e37..26bd6d6 100644
--- a/src/libtracker-common/tracker-ontology.h
+++ b/src/libtracker-common/tracker-ontology.h
@@ -65,9 +65,9 @@ void               tracker_ontology_shutdown             (void);
 /* Service mechanics */
 void               tracker_ontology_add_class            (TrackerClass     *service);
 TrackerClass *     tracker_ontology_get_class_by_uri     (const gchar      *service_uri);
-TrackerNamespace **tracker_ontology_get_namespaces       (void);
-TrackerClass  **   tracker_ontology_get_classes          (void);
-TrackerProperty ** tracker_ontology_get_properties       (void);
+TrackerNamespace **tracker_ontology_get_namespaces       (guint *length);
+TrackerClass  **   tracker_ontology_get_classes          (guint *length);
+TrackerProperty ** tracker_ontology_get_properties       (guint *length);
 
 /* Field mechanics */
 void               tracker_ontology_add_property         (TrackerProperty  *field);
diff --git a/src/libtracker-data/tracker-data-manager.c b/src/libtracker-data/tracker-data-manager.c
index 98cb7c0..67da442 100644
--- a/src/libtracker-data/tracker-data-manager.c
+++ b/src/libtracker-data/tracker-data-manager.c
@@ -582,8 +582,8 @@ insert_uri_in_resource_table (TrackerDBInterface *iface, const gchar *uri, gint
 }
 
 static void
-create_decomposed_metadata_property_table (TrackerDBInterface *iface, 
-					   TrackerProperty   **property, 
+create_decomposed_metadata_property_table (TrackerDBInterface *iface,
+					   TrackerProperty    *property,
 					   const gchar        *service_name,
 					   const gchar       **sql_type_for_single_value)
 {
@@ -591,15 +591,15 @@ create_decomposed_metadata_property_table (TrackerDBInterface *iface,
 	const char *sql_type;
 	gboolean    transient;
 
-	field_name = tracker_property_get_name (*property);
+	field_name = tracker_property_get_name (property);
 
 	transient = !sql_type_for_single_value;
 
 	if (!transient) {
-		transient = tracker_property_get_transient (*property);
+		transient = tracker_property_get_transient (property);
 	}
 
-	switch (tracker_property_get_data_type (*property)) {
+	switch (tracker_property_get_data_type (property)) {
 	case TRACKER_PROPERTY_TYPE_STRING:
 		sql_type = "TEXT";
 		break;
@@ -618,9 +618,9 @@ create_decomposed_metadata_property_table (TrackerDBInterface *iface,
 		break;
 	}
 
-	if (transient || tracker_property_get_multiple_values (*property)) {
+	if (transient || tracker_property_get_multiple_values (property)) {
 		/* multiple values */
-		if (tracker_property_get_indexed (*property)) {
+		if (tracker_property_get_indexed (property)) {
 			/* use different UNIQUE index for properties whose
 			 * value should be indexed to minimize index size */
 			tracker_db_interface_execute_query (iface, NULL,
@@ -668,9 +668,10 @@ create_decomposed_metadata_tables (TrackerDBInterface *iface,
 {
 	const char *service_name;
 	GString    *sql;
-	TrackerProperty	  **properties, **property;
+	TrackerProperty	  **properties, *property;
 	GSList      *class_properties, *field_it;
 	gboolean    main_class;
+	guint       i, n_props;
 
 	service_name = tracker_class_get_name (service);
 	main_class = (strcmp (service_name, "rdfs:Resource") == 0);
@@ -686,25 +687,28 @@ create_decomposed_metadata_tables (TrackerDBInterface *iface,
 		g_string_append (sql, ", Uri TEXT NOT NULL, Available INTEGER NOT NULL");
 	}
 
-	properties = tracker_ontology_get_properties ();
+	properties = tracker_ontology_get_properties (&n_props);
 	class_properties = NULL;
-	for (property = properties; *property; property++) {
-		if (tracker_property_get_domain (*property) == service) {
+
+	for (i = 0; i < n_props; i++) {
+		property = properties[i];
+
+		if (tracker_property_get_domain (property) == service) {
 			const gchar *sql_type_for_single_value = NULL;
 
-			create_decomposed_metadata_property_table (iface, property, 
-								   service_name, 
+			create_decomposed_metadata_property_table (iface, property,
+								   service_name,
 								   &sql_type_for_single_value);
 
 			if (sql_type_for_single_value) {
 				/* single value */
 
-				class_properties = g_slist_prepend (class_properties, *property);
+				class_properties = g_slist_prepend (class_properties, property);
 
-				g_string_append_printf (sql, ", \"%s\" %s", 
-							tracker_property_get_name (*property), 
+				g_string_append_printf (sql, ", \"%s\" %s",
+							tracker_property_get_name (property),
 							sql_type_for_single_value);
-				if (tracker_property_get_is_inverse_functional_property (*property)) {
+				if (tracker_property_get_is_inverse_functional_property (property)) {
 					g_string_append (sql, " UNIQUE");
 				}
 			}
@@ -752,20 +756,23 @@ static void
 create_decomposed_transient_metadata_tables (TrackerDBInterface *iface)
 {
 	TrackerProperty **properties;
-	TrackerProperty **property;
+	TrackerProperty *property;
+	guint i, n_props;
 
-	properties = tracker_ontology_get_properties ();
+	properties = tracker_ontology_get_properties (&n_props);
 
-	for (property = properties; *property; property++) {
-		if (tracker_property_get_transient (*property)) {
+	for (i = 0; i < n_props; i++) {
+		property = properties[i];
+
+		if (tracker_property_get_transient (property)) {
 
 			TrackerClass *domain;
 			const gchar *service_name;
 			const char *field_name;
 
-			field_name = tracker_property_get_name (*property);
+			field_name = tracker_property_get_name (property);
 
-			domain = tracker_property_get_domain (*property);
+			domain = tracker_property_get_domain (property);
 			service_name = tracker_class_get_name (domain);
 
 			/* create the TEMPORARY table */
@@ -818,17 +825,16 @@ tracker_data_manager_init (TrackerDBManagerFlags  flags,
 
 	if (is_first_time_index) {
 		TrackerClass **classes;
-		TrackerClass **cl;
 		TrackerProperty **properties;
-		TrackerProperty **property;
 		gint max_id = 0;
 		GList *sorted = NULL, *l;
 		gchar *test_schema_path;
 		const gchar *env_path;
 		GError *error = NULL;
+		guint i, n_props, n_classes;
 
 		env_path = g_getenv ("TRACKER_DB_ONTOLOGIES_DIR");
-		
+
 		if (G_LIKELY (!env_path)) {
 			ontologies_dir = g_build_filename (SHAREDIR,
 							   "tracker",
@@ -878,19 +884,20 @@ tracker_data_manager_init (TrackerDBManagerFlags  flags,
 			load_ontology_file_from_path (test_schema_path);
 		}
 
-		classes = tracker_ontology_get_classes ();
+		classes = tracker_ontology_get_classes (&n_classes);
 
 		tracker_data_begin_transaction ();
 
 		/* create tables */
-		for (cl = classes; *cl; cl++) {
-			create_decomposed_metadata_tables (iface, *cl, &max_id);
+		for (i = 0; i < n_classes; i++) {
+			create_decomposed_metadata_tables (iface, classes[i], &max_id);
 		}
 
 		/* insert properties into rdfs:Resource table */
-		properties = tracker_ontology_get_properties ();
-		for (property = properties; *property; property++) {
-			insert_uri_in_resource_table (iface, tracker_property_get_uri (*property),
+		properties = tracker_ontology_get_properties (&n_props);
+
+		for (i = 0; i < n_props; i++) {
+			insert_uri_in_resource_table (iface, tracker_property_get_uri (properties[i]),
 				                      &max_id);
 		}
 
diff --git a/src/libtracker-data/tracker-data-update.c b/src/libtracker-data/tracker-data-update.c
index 22a2fd3..7add9ff 100644
--- a/src/libtracker-data/tracker-data-update.c
+++ b/src/libtracker-data/tracker-data-update.c
@@ -893,7 +893,7 @@ get_old_property_values (TrackerProperty  *property,
                          GError          **error)
 {
 	gboolean            fts;
-	TrackerProperty   **properties, **prop;
+	TrackerProperty   **properties, *prop;
 	GValueArray        *old_values;
 
 	fts = tracker_property_get_fulltext_indexed (property);
@@ -911,19 +911,23 @@ get_old_property_values (TrackerProperty  *property,
 		}
 
 		if (fts && !resource_buffer->fts_updated && !resource_buffer->create) {
+			guint i, n_props;
+
 			/* first fulltext indexed property to be modified
 			 * retrieve values of all fulltext indexed properties
 			 */
 			tracker_fts_update_init (resource_buffer->id);
 
-			properties = tracker_ontology_get_properties ();
+			properties = tracker_ontology_get_properties (&n_props);
+
+			for (i = 0; i < n_props; i++) {
+				prop = properties[i];
 
-			for (prop = properties; *prop; prop++) {
-				if (tracker_property_get_fulltext_indexed (*prop)
-				    && check_property_domain (*prop)) {
+				if (tracker_property_get_fulltext_indexed (prop)
+				    && check_property_domain (prop)) {
 					gint i;
 
-					old_values = get_property_values (*prop);
+					old_values = get_property_values (prop);
 
 					/* delete old fts entries */
 					for (i = 0; i < old_values->n_values; i++) {
@@ -1111,9 +1115,10 @@ cache_delete_resource_type (TrackerClass *class,
 	TrackerDBInterface *iface;
 	TrackerDBStatement *stmt;
 	TrackerDBResultSet *result_set;
-	TrackerProperty   **properties, **prop;
+	TrackerProperty   **properties, *prop;
 	gboolean            found;
 	gint                i;
+	guint               p, n_props;
 
 	iface = tracker_db_manager_get_db_interface ();
 
@@ -1154,32 +1159,34 @@ cache_delete_resource_type (TrackerClass *class,
 
 	/* delete all property values */
 
-	properties = tracker_ontology_get_properties ();
+	properties = tracker_ontology_get_properties (&n_props);
 
-	for (prop = properties; *prop; prop++) {
+	for (p = 0; p < n_props; p++) {
 		gboolean            multiple_values, fts;
 		gchar              *table_name;
 		const gchar        *field_name;
 		GValueArray        *old_values;
 		gint                i;
 
-		if (tracker_property_get_domain (*prop) != class) {
+		prop = properties[p];
+
+		if (tracker_property_get_domain (prop) != class) {
 			continue;
 		}
 
-		multiple_values = tracker_property_get_multiple_values (*prop);
+		multiple_values = tracker_property_get_multiple_values (prop);
 		if (multiple_values) {
 			table_name = g_strdup_printf ("%s_%s",
 				tracker_class_get_name (class),
-				tracker_property_get_name (*prop));
+				tracker_property_get_name (prop));
 		} else {
 			table_name = g_strdup (tracker_class_get_name (class));
 		}
-		field_name = tracker_property_get_name (*prop);
+		field_name = tracker_property_get_name (prop);
 
-		fts = tracker_property_get_fulltext_indexed (*prop);
+		fts = tracker_property_get_fulltext_indexed (prop);
 
-		old_values = get_old_property_values (*prop, NULL);
+		old_values = get_old_property_values (prop, NULL);
 
 		for (i = old_values->n_values - 1; i >= 0 ; i--) {
 			GValue *old_gvalue;
@@ -1866,10 +1873,11 @@ tracker_data_delete_resource_description (const gchar *graph,
 	TrackerDBResultSet *result_set, *single_result, *multi_result;
 	TrackerClass	   *class;
 	GString		   *sql;
-	TrackerProperty	  **properties, **property;
+	TrackerProperty	  **properties, *property;
 	int		    i;
 	gboolean            first, bail_out = FALSE;
 	gint                resource_id;
+	guint               p, n_props;
 
 	/* We use result_sets instead of cursors here because it's possible
 	 * that otherwise the query of the outer cursor would be reused by the
@@ -1879,7 +1887,7 @@ tracker_data_delete_resource_description (const gchar *graph,
 
 	iface = tracker_db_manager_get_db_interface ();
 
-	properties = tracker_ontology_get_properties ();
+	properties = tracker_ontology_get_properties (&n_props);
 
 	stmt = tracker_db_interface_create_statement (iface, "SELECT (SELECT Uri FROM \"rdfs:Resource\" WHERE ID = \"rdf:type\") FROM \"rdfs:Resource_rdf:type\" WHERE ID = ?");
 	tracker_db_statement_bind_int (stmt, 0, resource_id);
@@ -1906,19 +1914,22 @@ tracker_data_delete_resource_description (const gchar *graph,
 			sql = g_string_new ("SELECT ");
 
 			first = TRUE;
-			for (property = properties; *property; property++) {
-				if (tracker_property_get_domain (*property) == class) {
-					if (!tracker_property_get_embedded (*property)) {
+
+			for (p = 0; p < n_props; p++) {
+				property = properties[p];
+
+				if (tracker_property_get_domain (property) == class) {
+					if (!tracker_property_get_embedded (property)) {
 						continue;
 					}
 
-					if (!tracker_property_get_multiple_values (*property)) {
+					if (!tracker_property_get_multiple_values (property)) {
 						if (!first) {
 							g_string_append (sql, ", ");
 						}
 						first = FALSE;
 
-						format_sql_value_as_string (sql, *property);
+						format_sql_value_as_string (sql, property);
 					}
 				}
 			}
@@ -1935,21 +1946,23 @@ tracker_data_delete_resource_description (const gchar *graph,
 			g_string_free (sql, TRUE);
 
 			i = 0;
-			for (property = properties; *property; property++) {
-				if (tracker_property_get_domain (*property) != class) {
+			for (p = 0; p < n_props; p++) {
+				property = properties[p];
+
+				if (tracker_property_get_domain (property) != class) {
 					continue;
 				}
 
-				if (!tracker_property_get_embedded (*property)) {
+				if (!tracker_property_get_embedded (property)) {
 					continue;
 				}
 
-				if (strcmp (tracker_property_get_uri (*property), RDF_PREFIX "type") == 0) {
+				if (strcmp (tracker_property_get_uri (property), RDF_PREFIX "type") == 0) {
 					/* Do not delete rdf:type statements */
 					continue;
 				}
 
-				if (!tracker_property_get_multiple_values (*property)) {
+				if (!tracker_property_get_multiple_values (property)) {
 					gchar *value;
 					GError *new_error = NULL;
 
@@ -1958,10 +1971,9 @@ tracker_data_delete_resource_description (const gchar *graph,
 					tracker_db_result_set_get (single_result, i++, &value, -1);
 
 					if (value) {
-						
-						tracker_data_delete_statement (graph, uri, 
-						                               tracker_property_get_uri (*property), 
-						                               value, 
+						tracker_data_delete_statement (graph, uri,
+						                               tracker_property_get_uri (property),
+						                               value,
 						                               &new_error);
 						if (new_error) {
 							g_propagate_error (error, new_error);
@@ -1975,12 +1987,12 @@ tracker_data_delete_resource_description (const gchar *graph,
 
 					sql = g_string_new ("SELECT ");
 
-					format_sql_value_as_string (sql, *property);
+					format_sql_value_as_string (sql, property);
 
 					g_string_append_printf (sql,
 								" FROM \"%s_%s\" WHERE ID = ?",
-								tracker_class_get_name (tracker_property_get_domain (*property)),
-								tracker_property_get_name (*property));
+								tracker_class_get_name (tracker_property_get_domain (property)),
+								tracker_property_get_name (property));
 
 					stmt = tracker_db_interface_create_statement (iface, "%s", sql->str);
 					tracker_db_statement_bind_int (stmt, 0, resource_id);
@@ -1994,8 +2006,8 @@ tracker_data_delete_resource_description (const gchar *graph,
 
 							tracker_db_result_set_get (multi_result, 0, &value, -1);
 
-							tracker_data_delete_statement (graph, uri, 
-							                               tracker_property_get_uri (*property), 
+							tracker_data_delete_statement (graph, uri,
+							                               tracker_property_get_uri (property),
 							                               value,
 							                               &new_error);
 
diff --git a/src/libtracker-db/tracker-db-backup.c b/src/libtracker-db/tracker-db-backup.c
index 80aab50..30e97ce 100644
--- a/src/libtracker-db/tracker-db-backup.c
+++ b/src/libtracker-db/tracker-db-backup.c
@@ -269,12 +269,13 @@ tracker_db_backup_save (TrackerDBBackupFinished callback,
 void
 tracker_db_backup_sync_fts (void)
 {
-	TrackerProperty   **properties, **property;
+	TrackerProperty   **properties, *property;
 	TrackerDBInterface *iface;
 	TrackerDBStatement *stmt;
 	TrackerDBCursor    *cursor;
 	TrackerClass       *prop_class;
 	gchar              *query;
+	guint               i, n_props;
 
 	iface = tracker_db_manager_get_db_interface ();
 
@@ -286,23 +287,26 @@ tracker_db_backup_sync_fts (void)
 	tracker_db_interface_execute_query (iface, NULL, "%s", query);
 	g_free (query);
 
-	properties = tracker_ontology_get_properties ();
-	for (property = properties; *property; property++) {
-		if (tracker_property_get_data_type (*property) == TRACKER_PROPERTY_TYPE_STRING &&
-		    tracker_property_get_fulltext_indexed (*property)) {
+	properties = tracker_ontology_get_properties (&n_props);
 
-			prop_class  = tracker_property_get_domain (*property);
+	for (i = 0; i < n_props; i++) {
+		property = properties[i];
 
-			if (tracker_property_get_multiple_values (*property)) {
-				query = g_strdup_printf ("SELECT ID, \"%s\" FROM \"%s_%s\"", 
-				                         tracker_property_get_name (*property), 
+		if (tracker_property_get_data_type (property) == TRACKER_PROPERTY_TYPE_STRING &&
+		    tracker_property_get_fulltext_indexed (property)) {
+
+			prop_class  = tracker_property_get_domain (property);
+
+			if (tracker_property_get_multiple_values (property)) {
+				query = g_strdup_printf ("SELECT ID, \"%s\" FROM \"%s_%s\"",
+				                         tracker_property_get_name (property),
 				                         tracker_class_get_name (prop_class),
-				                         tracker_property_get_name (*property));
+				                         tracker_property_get_name (property));
 			} else {
-				query = g_strdup_printf ("SELECT ID, \"%s\" FROM \"%s\" WHERE \"%s\" IS NOT NULL", 
-				                         tracker_property_get_name (*property), 
+				query = g_strdup_printf ("SELECT ID, \"%s\" FROM \"%s\" WHERE \"%s\" IS NOT NULL",
+				                         tracker_property_get_name (property),
 				                         tracker_class_get_name (prop_class),
-				                         tracker_property_get_name (*property));
+				                         tracker_property_get_name (property));
 			}
 
 			stmt = tracker_db_interface_create_statement (iface, "%s", query);
diff --git a/src/libtracker-fts/tracker-fts.c b/src/libtracker-fts/tracker-fts.c
index 9dc32f0..53238b0 100644
--- a/src/libtracker-fts/tracker-fts.c
+++ b/src/libtracker-fts/tracker-fts.c
@@ -7798,22 +7798,26 @@ gchar *
 tracker_fts_get_create_fts_table_query (void)
 {
 	GString    *sql;
-	TrackerProperty	  **properties, **property;
+	TrackerProperty	  **properties, *property;
 	gboolean first;
+        guint i, n_properties;
 
 	sql = g_string_new ("CREATE VIRTUAL TABLE fulltext.fts USING trackerfts (");
 
 	first = TRUE;
-	properties = tracker_ontology_get_properties ();
-	for (property = properties; *property; property++) {
-		if (tracker_property_get_data_type (*property) == TRACKER_PROPERTY_TYPE_STRING &&
-		    tracker_property_get_fulltext_indexed (*property)) {
+	properties = tracker_ontology_get_properties (&n_properties);
+
+        for (i = 0; i < n_properties; i++) {
+                property = properties[i];
+
+		if (tracker_property_get_data_type (property) == TRACKER_PROPERTY_TYPE_STRING &&
+		    tracker_property_get_fulltext_indexed (property)) {
 			if (first) {
 				first = FALSE;
 			} else {
 				g_string_append (sql, ", ");
 			}
-			g_string_append_printf (sql, "\"%s\"", tracker_property_get_name (*property));
+			g_string_append_printf (sql, "\"%s\"", tracker_property_get_name (property));
 		}
 	}
 
diff --git a/src/tracker-store/tracker-statistics.c b/src/tracker-store/tracker-statistics.c
index 4dc8849..ef37ce4 100644
--- a/src/tracker-store/tracker-statistics.c
+++ b/src/tracker-store/tracker-statistics.c
@@ -133,9 +133,9 @@ static GHashTable *
 cache_get_latest (void)
 {
 	GHashTable    *values;
-	TrackerClass **classes;
-	TrackerClass **cl;
+	TrackerClass **classes, *cl;
 	TrackerDBInterface *iface;
+	guint               i, n_classes;
 
 	g_message ("Requesting statistics from database for an accurate signal");
 
@@ -144,27 +144,29 @@ cache_get_latest (void)
 					g_free,
 					NULL);
 
-	classes = tracker_ontology_get_classes ();
+	classes = tracker_ontology_get_classes (&n_classes);
 
 	iface = tracker_db_manager_get_db_interface ();
 
-	for (cl = classes; *cl; cl++) {
+	for (i = 0; i < n_classes; i++) {
 		TrackerDBStatement *stmt;
 		TrackerDBResultSet *result_set;
 		gint count;
 
-		if (g_str_has_prefix (tracker_class_get_name (*cl), "xsd:")) {
+		cl = classes[i];
+
+		if (g_str_has_prefix (tracker_class_get_name (cl), "xsd:")) {
 			/* xsd classes do not derive from rdfs:Resource and do not use separate tables */
 			continue;
 		}
 
-		stmt = tracker_db_interface_create_statement (iface, "SELECT COUNT(1) FROM \"%s\"", tracker_class_get_name (*cl));
+		stmt = tracker_db_interface_create_statement (iface, "SELECT COUNT(1) FROM \"%s\"", tracker_class_get_name (cl));
 		result_set = tracker_db_statement_execute (stmt, NULL);
 
 		tracker_db_result_set_get (result_set, 0, &count, -1);
 
 		g_hash_table_insert (values, 
-				     g_strdup (tracker_class_get_name (*cl)),
+				     g_strdup (tracker_class_get_name (cl)),
 				     GINT_TO_POINTER (count));
 
 		g_object_unref (result_set);
@@ -186,9 +188,8 @@ cache_timeout (gpointer user_data)
 
 static gint
 cache_sort_func (gconstpointer a,
-		       gconstpointer b)
+		 gconstpointer b)
 {
-	
 	const GStrv *strv_a = (GStrv *) a;
 	const GStrv *strv_b = (GStrv *) b;
 
@@ -203,11 +204,11 @@ tracker_statistics_get (TrackerStatistics      *object,
 			DBusGMethodInvocation  *context,
 			GError		      **error)
 {
-	TrackerClass **classes;
-	TrackerClass **cl;
+	TrackerClass **classes, *cl;
 	TrackerStatisticsPrivate *priv;
 	guint		          request_id;
 	GPtrArray                *values;
+	guint                     i, n_classes;
 
 	request_id = tracker_dbus_get_next_request_id ();
 
@@ -218,19 +219,21 @@ tracker_statistics_get (TrackerStatistics      *object,
 
 	values = g_ptr_array_new ();
 
-	classes = tracker_ontology_get_classes ();
+	classes = tracker_ontology_get_classes (&n_classes);
 
-	for (cl = classes; *cl; cl++) {
+	for (i = 0; i < n_classes; i++) {
 		GStrv        strv;
 
-		if (tracker_class_get_count (*cl) == 0) {
+		cl = classes[i];
+
+		if (tracker_class_get_count (cl) == 0) {
 			/* skip classes without resources */
 			continue;
 		}
 
 		strv = g_new (gchar*, 3);
-		strv[0] = g_strdup (tracker_class_get_name (*cl));
-		strv[1] = g_strdup_printf ("%d", tracker_class_get_count (*cl));
+		strv[0] = g_strdup (tracker_class_get_name (cl));
+		strv[1] = g_strdup_printf ("%d", tracker_class_get_count (cl));
 		strv[2] = NULL;
 
 		g_ptr_array_add (values, strv);



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