[tracker: 2/9] tracker-data-manager: Simplify set_index_for_multi_value_property()
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker: 2/9] tracker-data-manager: Simplify set_index_for_multi_value_property()
- Date: Sun, 9 May 2021 11:33:36 +0000 (UTC)
commit 7093cd9151c9cabe23b916e53488214af196931c
Author: Daniele Nicolodi <daniele grinta net>
Date: Tue May 4 09:37:26 2021 +0200
tracker-data-manager: Simplify set_index_for_multi_value_property()
Make set_index_for_multi_value_property() take a TrackerClass argument
rather than the class name. Also rename varibales internal to the
function from service_name to class_name and from field_name to
property_name to better reflect RDF terminology.
src/libtracker-data/tracker-data-manager.c | 57 +++++++++++++++---------------
1 file changed, 29 insertions(+), 28 deletions(-)
---
diff --git a/src/libtracker-data/tracker-data-manager.c b/src/libtracker-data/tracker-data-manager.c
index abd6cb221..b54cc249b 100644
--- a/src/libtracker-data/tracker-data-manager.c
+++ b/src/libtracker-data/tracker-data-manager.c
@@ -340,24 +340,25 @@ set_index_for_single_value_property (TrackerDBInterface *iface,
static void
set_index_for_multi_value_property (TrackerDBInterface *iface,
const gchar *database,
- const gchar *service_name,
+ TrackerClass *class,
TrackerProperty *property,
GError **error)
{
GError *internal_error = NULL;
gchar *expr;
- const gchar *field_name = tracker_property_get_name (property);
+ const gchar *class_name = tracker_class_get_name (class);
+ const gchar *property_name = tracker_property_get_name (property);
TRACKER_NOTE (ONTOLOGY_CHANGES,
g_message ("Dropping index (multi-value property): "
"DROP INDEX IF EXISTS \"%s_%s_ID_ID\"",
- service_name, field_name));
+ class_name, property_name));
tracker_db_interface_execute_query (iface, &internal_error,
"DROP INDEX IF EXISTS \"%s\".\"%s_%s_ID_ID\"",
database,
- service_name,
- field_name);
+ class_name,
+ property_name);
if (internal_error) {
g_propagate_error (error, internal_error);
@@ -370,12 +371,12 @@ set_index_for_multi_value_property (TrackerDBInterface *iface,
TRACKER_NOTE (ONTOLOGY_CHANGES,
g_message ("Dropping index (multi-value property): "
"DROP INDEX IF EXISTS \"%s_%s_ID\"",
- service_name, field_name));
+ class_name, property_name));
tracker_db_interface_execute_query (iface, &internal_error,
"DROP INDEX IF EXISTS \"%s\".\"%s_%s_ID\"",
database,
- service_name,
- field_name);
+ class_name,
+ property_name);
if (internal_error) {
g_propagate_error (error, internal_error);
@@ -383,9 +384,9 @@ set_index_for_multi_value_property (TrackerDBInterface *iface,
}
if (tracker_property_get_data_type (property) == TRACKER_PROPERTY_TYPE_DATETIME)
- expr = g_strdup_printf ("SparqlTimeSort(\"%s\")", field_name);
+ expr = g_strdup_printf ("SparqlTimeSort(\"%s\")", property_name);
else
- expr = g_strdup_printf ("\"%s\"", field_name);
+ expr = g_strdup_printf ("\"%s\"", property_name);
if (tracker_property_get_indexed (property)) {
/* use different UNIQUE index for properties whose
@@ -394,15 +395,15 @@ set_index_for_multi_value_property (TrackerDBInterface *iface,
TRACKER_NOTE (ONTOLOGY_CHANGES,
g_message ("Creating index (multi-value property): "
"CREATE INDEX \"%s_%s_ID\" ON \"%s_%s\" (ID)",
- service_name, field_name, service_name, field_name));
+ class_name, property_name, class_name, property_name));
tracker_db_interface_execute_query (iface, &internal_error,
"CREATE INDEX \"%s\".\"%s_%s_ID\" ON \"%s_%s\" (ID)",
database,
- service_name,
- field_name,
- service_name,
- field_name);
+ class_name,
+ property_name,
+ class_name,
+ property_name);
if (internal_error)
goto out;
@@ -410,15 +411,15 @@ set_index_for_multi_value_property (TrackerDBInterface *iface,
TRACKER_NOTE (ONTOLOGY_CHANGES,
g_message ("Creating index (multi-value property): "
"CREATE UNIQUE INDEX \"%s_%s_ID_ID\" ON \"%s_%s\" (%s, ID)",
- service_name, field_name, service_name, field_name, expr));
+ class_name, property_name, class_name, property_name, expr));
tracker_db_interface_execute_query (iface, &internal_error,
"CREATE UNIQUE INDEX \"%s\".\"%s_%s_ID_ID\" ON \"%s_%s\"
(%s, ID)",
database,
- service_name,
- field_name,
- service_name,
- field_name,
+ class_name,
+ property_name,
+ class_name,
+ property_name,
expr);
if (internal_error)
@@ -430,15 +431,15 @@ set_index_for_multi_value_property (TrackerDBInterface *iface,
TRACKER_NOTE (ONTOLOGY_CHANGES,
g_message ("Creating index (multi-value property): "
"CREATE UNIQUE INDEX \"%s_%s_ID_ID\" ON \"%s_%s\" (ID, %s)",
- service_name, field_name, service_name, field_name, expr));
+ class_name, property_name, class_name, property_name, expr));
tracker_db_interface_execute_query (iface, &internal_error,
"CREATE UNIQUE INDEX \"%s\".\"%s_%s_ID_ID\" ON \"%s_%s\"
(ID, %s)",
database,
- service_name,
- field_name,
- service_name,
- field_name,
+ class_name,
+ property_name,
+ class_name,
+ property_name,
expr);
if (internal_error)
@@ -630,7 +631,7 @@ fix_indexed_on_db (TrackerDataManager *manager,
service_name = tracker_class_get_name (class);
if (tracker_property_get_multiple_values (property)) {
- set_index_for_multi_value_property (iface, database, service_name, property, &internal_error);
+ set_index_for_multi_value_property (iface, database, class, property, &internal_error);
} else {
TrackerProperty *secondary_index;
TrackerClass **domain_index_classes;
@@ -2611,7 +2612,7 @@ create_decomposed_metadata_property_table (TrackerDBInterface *iface,
}
/* multiple values */
- set_index_for_multi_value_property (iface, database, service_name, property,
&internal_error);
+ set_index_for_multi_value_property (iface, database, service, property,
&internal_error);
if (internal_error) {
g_propagate_error (error, internal_error);
goto error_out;
@@ -2645,7 +2646,7 @@ create_decomposed_metadata_property_table (TrackerDBInterface *iface,
}
/* multiple values */
- set_index_for_multi_value_property (iface, database, service_name, property,
&internal_error);
+ set_index_for_multi_value_property (iface, database, service, property,
&internal_error);
if (internal_error) {
g_propagate_error (error, internal_error);
goto error_out;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]