[tracker/sparql-update: 14/23] libtracker-data: Move domain index handling to a shared function



commit ecc43afd6bf77a61b0365d0fdf56005320c6aec7
Author: Philip Van Hoof <philip codeminded be>
Date:   Fri Mar 11 18:11:58 2011 +0100

    libtracker-data: Move domain index handling to a shared function

 src/libtracker-data/tracker-data-update.c |   74 ++++++++++++----------------
 1 files changed, 32 insertions(+), 42 deletions(-)
---
diff --git a/src/libtracker-data/tracker-data-update.c b/src/libtracker-data/tracker-data-update.c
index 74db458..325eff9 100644
--- a/src/libtracker-data/tracker-data-update.c
+++ b/src/libtracker-data/tracker-data-update.c
@@ -1528,6 +1528,36 @@ resource_in_domain_index_class (TrackerClass *domain_index_class)
 	return FALSE;
 }
 
+static void
+process_domain_indexes (TrackerProperty *property,
+                        GValue          *gvalue,
+                        const gchar     *field_name,
+                        const gchar     *graph,
+                        gint             graph_id)
+{
+	TrackerClass **domain_index_classes;
+
+	domain_index_classes = tracker_property_get_domain_indexes (property);
+	while (*domain_index_classes) {
+		if (resource_in_domain_index_class (*domain_index_classes)) {
+			GValue gvalue_copy = { 0 };
+
+			g_value_init (&gvalue_copy, G_VALUE_TYPE (gvalue));
+			g_value_copy (gvalue, &gvalue_copy);
+
+			cache_insert_value (tracker_class_get_name (*domain_index_classes),
+			                    field_name,
+			                    tracker_property_get_transient (property),
+			                    &gvalue_copy,
+			                    graph != NULL ? ensure_resource_id (graph, NULL) : graph_id,
+			                    FALSE,
+			                    tracker_property_get_fulltext_indexed (property),
+			                    tracker_property_get_data_type (property) == TRACKER_PROPERTY_TYPE_DATETIME);
+		}
+		domain_index_classes++;
+	}
+}
+
 static gboolean
 cache_insert_metadata_decomposed (TrackerProperty  *property,
                                   const gchar      *value,
@@ -1623,27 +1653,7 @@ cache_insert_metadata_decomposed (TrackerProperty  *property,
 		                    tracker_property_get_data_type (property) == TRACKER_PROPERTY_TYPE_DATETIME);
 
 		if (!multiple_values) {
-			TrackerClass **domain_index_classes;
-
-			domain_index_classes = tracker_property_get_domain_indexes (property);
-			while (*domain_index_classes) {
-				if (resource_in_domain_index_class (*domain_index_classes)) {
-					GValue gvalue_copy = { 0 };
-
-					g_value_init (&gvalue_copy, G_VALUE_TYPE (&gvalue));
-					g_value_copy (&gvalue, &gvalue_copy);
-
-					cache_insert_value (tracker_class_get_name (*domain_index_classes),
-					                    field_name,
-					                    tracker_property_get_transient (property),
-					                    &gvalue_copy,
-					                    graph != NULL ? ensure_resource_id (graph, NULL) : graph_id,
-					                    multiple_values,
-					                    tracker_property_get_fulltext_indexed (property),
-					                    tracker_property_get_data_type (property) == TRACKER_PROPERTY_TYPE_DATETIME);
-				}
-				domain_index_classes++;
-			}
+			process_domain_indexes (property, &gvalue, field_name, graph, graph_id);
 		}
 
 		change = TRUE;
@@ -1705,27 +1715,7 @@ cache_update_metadata_decomposed (TrackerProperty  *property,
 	                    tracker_property_get_data_type (property) == TRACKER_PROPERTY_TYPE_DATETIME);
 
 	if (!multiple_values) {
-		TrackerClass **domain_index_classes;
-
-		domain_index_classes = tracker_property_get_domain_indexes (property);
-		while (*domain_index_classes) {
-			if (resource_in_domain_index_class (*domain_index_classes)) {
-				GValue gvalue_copy = { 0 };
-
-				g_value_init (&gvalue_copy, G_VALUE_TYPE (&gvalue));
-				g_value_copy (&gvalue, &gvalue_copy);
-
-				cache_insert_value (tracker_class_get_name (*domain_index_classes),
-				                    field_name,
-				                    tracker_property_get_transient (property),
-				                    &gvalue_copy,
-				                    graph != NULL ? ensure_resource_id (graph, NULL) : graph_id,
-				                    multiple_values,
-				                    tracker_property_get_fulltext_indexed (property),
-				                    tracker_property_get_data_type (property) == TRACKER_PROPERTY_TYPE_DATETIME);
-			}
-			domain_index_classes++;
-		}
+		process_domain_indexes (property, &gvalue, field_name, graph, graph_id);
 	}
 
 	return TRUE;



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