[tracker/wip/carlosg/update-perf: 26/72] libtracker-sparql: Refactor handling of domain indexes




commit ae25d7f2a2f304890f22916a6023ad53276c57c5
Author: Carlos Garnacho <carlosg gnome org>
Date:   Fri May 20 13:01:17 2022 +0200

    libtracker-sparql: Refactor handling of domain indexes
    
    This was separated on a separate function for inserts, but not deletes.
    Rename the domain index insertion function, and separate deletion handling
    to another separate function.

 src/libtracker-sparql/core/tracker-data-update.c | 57 ++++++++++++------------
 1 file changed, 28 insertions(+), 29 deletions(-)
---
diff --git a/src/libtracker-sparql/core/tracker-data-update.c 
b/src/libtracker-sparql/core/tracker-data-update.c
index 04b3c3b53..d96990fe9 100644
--- a/src/libtracker-sparql/core/tracker-data-update.c
+++ b/src/libtracker-sparql/core/tracker-data-update.c
@@ -1686,9 +1686,9 @@ resource_in_domain_index_class (TrackerData  *data,
 }
 
 static void
-process_domain_indexes (TrackerData     *data,
-                        TrackerProperty *property,
-                        const GValue    *gvalue)
+insert_property_domain_indexes (TrackerData     *data,
+                                TrackerProperty *property,
+                                const GValue    *gvalue)
 {
        TrackerClass **domain_index_classes;
 
@@ -1704,6 +1704,25 @@ process_domain_indexes (TrackerData     *data,
        }
 }
 
+static void
+delete_property_domain_indexes (TrackerData     *data,
+                                TrackerProperty *property,
+                                const GValue    *gvalue)
+{
+       TrackerClass **domain_index_classes;
+
+       domain_index_classes = tracker_property_get_domain_indexes (property);
+       while (*domain_index_classes) {
+               if (resource_in_domain_index_class (data, *domain_index_classes)) {
+                       cache_delete_value (data,
+                                           *domain_index_classes,
+                                           property,
+                                           gvalue);
+               }
+               domain_index_classes++;
+       }
+}
+
 static gboolean
 maybe_convert_value (TrackerData         *data,
                      TrackerPropertyType  source,
@@ -1880,9 +1899,8 @@ cache_insert_metadata_decomposed (TrackerData      *data,
                if (tracker_property_get_data_type (property) == TRACKER_PROPERTY_TYPE_RESOURCE)
                        tracker_data_resource_ref (data, g_value_get_int64 (object), multiple_values);
 
-               if (!multiple_values) {
-                       process_domain_indexes (data, property, object);
-               }
+               if (!multiple_values)
+                       insert_property_domain_indexes (data, property, object);
 
                change = TRUE;
        }
@@ -1922,18 +1940,8 @@ delete_metadata_decomposed (TrackerData      *data,
                if (tracker_property_get_data_type (property) == TRACKER_PROPERTY_TYPE_RESOURCE)
                        tracker_data_resource_unref (data, g_value_get_int64 (object), multiple_values);
 
-               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 (data, *domain_index_classes))
-                                       cache_delete_value (data, *domain_index_classes, property, object);
-
-                               domain_index_classes++;
-                       }
-               }
+               if (!multiple_values)
+                       delete_property_domain_indexes (data, property, object);
 
                change = TRUE;
        }
@@ -2089,17 +2097,8 @@ cache_delete_resource_type_full (TrackerData   *data,
                        if (tracker_property_get_data_type (prop) == TRACKER_PROPERTY_TYPE_RESOURCE)
                                tracker_data_resource_unref (data, g_value_get_int64 (&copy), 
multiple_values);
 
-                       if (!multiple_values) {
-                               TrackerClass **domain_index_classes;
-
-                               domain_index_classes = tracker_property_get_domain_indexes (prop);
-                               while (*domain_index_classes) {
-                                       if (resource_in_domain_index_class (data, *domain_index_classes))
-                                               cache_delete_value (data, *domain_index_classes, prop, &copy);
-
-                                       domain_index_classes++;
-                               }
-                       }
+                       if (!multiple_values)
+                               delete_property_domain_indexes (data, prop, &copy);
 
                        g_value_unset (&copy);
                }


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