[tracker/domain-specific-indexes] Commit to cleanup, remove the debugging aid: First baby steps at altering the tables for domain-spec
- From: Philip Van Hoof <pvanhoof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/domain-specific-indexes] Commit to cleanup, remove the debugging aid: First baby steps at altering the tables for domain-spec
- Date: Wed, 30 Jun 2010 12:23:07 +0000 (UTC)
commit c674570017f4fab668ba89d476a1ffb11dec02e9
Author: Philip Van Hoof <philip codeminded be>
Date: Wed Jun 30 14:21:05 2010 +0200
Commit to cleanup, remove the debugging aid: First baby steps at altering the tables for domain-specific indices
data/ontologies/38-nmm.ontology | 5 +-
src/libtracker-data/tracker-data-manager.c | 78 +++++++++++++++++--
src/libtracker-data/tracker-property.c | 26 ++++++
src/libtracker-data/tracker-property.h | 117 ++++++++++++++--------------
4 files changed, 159 insertions(+), 67 deletions(-)
---
diff --git a/data/ontologies/38-nmm.ontology b/data/ontologies/38-nmm.ontology
index 7a34865..cc42233 100644
--- a/data/ontologies/38-nmm.ontology
+++ b/data/ontologies/38-nmm.ontology
@@ -13,12 +13,13 @@
nmm: a tracker:Namespace, tracker:Ontology ;
tracker:prefix "nmm" ;
- nao:lastModified "2010-06-02T00:00:50Z" .
+ nao:lastModified "2010-06-29T00:00:50Z" .
nmm:MusicPiece a rdfs:Class ;
rdfs:label "Music" ;
tracker:notify true ;
- rdfs:subClassOf nfo:Media .
+ rdfs:subClassOf nfo:Media ;
+ tracker:domainIndex nie:title, nie:subject .
nmm:SynchronizedText a rdfs:Class ;
rdfs:label "Synchronized text (use nie:language to set the language). Valid for subtitles and lyrics" ;
diff --git a/src/libtracker-data/tracker-data-manager.c b/src/libtracker-data/tracker-data-manager.c
index 3e2b018..81b491d 100644
--- a/src/libtracker-data/tracker-data-manager.c
+++ b/src/libtracker-data/tracker-data-manager.c
@@ -540,14 +540,13 @@ tracker_data_ontology_load_statement (const gchar *ontology_path,
properties = tracker_class_get_domain_indexes (class);
while (*properties) {
if (property == *properties) {
- g_critical ("%s: property %s already a tracker:domainIndex in %s",
- ontology_path, object, subject);
ignore = TRUE;
}
properties++;
}
if (!ignore) {
+ tracker_property_set_is_new_domain_index (property, in_update);
tracker_class_add_domain_index (class, property);
}
@@ -1627,6 +1626,7 @@ db_get_static_data (TrackerDBInterface *iface)
default_value = tracker_db_cursor_get_string (cursor, 13, NULL);
+ tracker_property_set_is_new_domain_index (property, FALSE);
tracker_property_set_is_new (property, FALSE);
tracker_property_set_transient (property, transient);
tracker_property_set_uri (property, uri);
@@ -1791,6 +1791,7 @@ create_decomposed_metadata_property_table (TrackerDBInterface *iface,
}
if (!in_update || (in_update && (tracker_property_get_is_new (property) ||
+ tracker_property_get_is_new_domain_index (property) ||
tracker_property_get_db_schema_changed (property)))) {
if (transient || tracker_property_get_multiple_values (property)) {
GString *sql;
@@ -1920,6 +1921,35 @@ create_decomposed_metadata_property_table (TrackerDBInterface *iface,
}
+static gboolean
+is_a_domain_index (TrackerProperty **domain_indexes, TrackerProperty *property)
+{
+ while (*domain_indexes) {
+
+ if (*domain_indexes == property) {
+ return TRUE;
+ }
+
+ domain_indexes++;
+ }
+
+ return FALSE;
+}
+
+static void
+gdb_point (const gchar *str) {
+ static int i = 0;
+
+ g_print ("GDB! %d (%s)\n", i++, str ? str : "null");
+}
+
+static void
+gdb_point2 (const gchar *str) {
+ static int i = 0;
+
+ g_print ("GDB! %d (%s)\n", i++, str ? str : "null");
+}
+
static void
create_decomposed_metadata_tables (TrackerDBInterface *iface,
TrackerClass *service,
@@ -1930,12 +1960,13 @@ create_decomposed_metadata_tables (TrackerDBInterface *iface,
GString *create_sql = NULL;
GString *in_col_sql = NULL;
GString *sel_col_sql = NULL;
- TrackerProperty **properties, *property;
+ TrackerProperty **properties, *property, **domain_indexes;
GSList *class_properties, *field_it;
gboolean main_class;
gint i, n_props;
gboolean in_alter = in_update;
GError *error = NULL;
+ GSList *domain_indexes_to_copy = NULL, *l;
service_name = tracker_class_get_name (service);
main_class = (strcmp (service_name, "rdfs:Resource") == 0);
@@ -1972,12 +2003,29 @@ create_decomposed_metadata_tables (TrackerDBInterface *iface,
}
properties = tracker_ontologies_get_properties (&n_props);
+ domain_indexes = tracker_class_get_domain_indexes (service);
+
+ if (g_strcmp0 (service_name, "nmm:MusicPiece") == 0) {
+ gdb_point ("nmm:MusicPiece");
+ }
+
+// if (domain_indexes) {
+// gdb_point();
+// }
+
class_properties = NULL;
for (i = 0; i < n_props; i++) {
+ gboolean is_domain_index;
+
property = properties[i];
+ is_domain_index = is_a_domain_index (domain_indexes, property);
- if (tracker_property_get_domain (property) == service) {
+ if (g_strcmp0 (tracker_property_get_name (property), "nie:title") == 0) {
+ gdb_point2 ("nie:title");
+ }
+
+ if (tracker_property_get_domain (property) == service || is_domain_index) {
gboolean put_change;
const gchar *sql_type_for_single_value = NULL;
const gchar *field_name;
@@ -2030,11 +2078,12 @@ create_decomposed_metadata_tables (TrackerDBInterface *iface,
/* xsd:dateTime is stored in three columns:
* universal time, local date, local time of day */
g_string_append_printf (create_sql, ", \"%s:localDate\" INTEGER, \"%s:localTime\" INTEGER",
- tracker_property_get_name (property),
- tracker_property_get_name (property));
+ tracker_property_get_name (property),
+ tracker_property_get_name (property));
}
- } else if (tracker_property_get_is_new (property)) {
+ } else if ((!is_domain_index && tracker_property_get_is_new (property)) ||
+ (is_domain_index && tracker_property_get_is_new_domain_index (property))) {
GString *alter_sql = NULL;
put_change = FALSE;
@@ -2103,6 +2152,10 @@ create_decomposed_metadata_tables (TrackerDBInterface *iface,
if (in_change && put_change) {
range_change_for (property, in_col_sql, sel_col_sql, field_name);
}
+
+ if (is_domain_index && put_change) {
+ domain_indexes_to_copy = g_slist_prepend (domain_indexes_to_copy, property);
+ }
}
}
}
@@ -2137,7 +2190,6 @@ create_decomposed_metadata_tables (TrackerDBInterface *iface,
g_slist_free (class_properties);
-
if (in_change && sel_col_sql && in_col_sql) {
gchar *query;
GError *error = NULL;
@@ -2165,6 +2217,15 @@ create_decomposed_metadata_tables (TrackerDBInterface *iface,
if (sel_col_sql)
g_string_free (sel_col_sql, TRUE);
+ domain_indexes = tracker_class_get_domain_indexes (service);
+
+ for (l = domain_indexes_to_copy; l != NULL; l = l->next) {
+ TrackerProperty *domain_index = l->data;
+ g_print ("to copy: %s", tracker_property_get_name (domain_index));
+ /* TODO */
+ }
+
+ g_slist_free (domain_indexes_to_copy);
}
static void
@@ -2212,6 +2273,7 @@ tracker_data_ontology_import_finished (void)
}
for (i = 0; i < n_props; i++) {
+ tracker_property_set_is_new_domain_index (properties[i], FALSE);
tracker_property_set_is_new (properties[i], FALSE);
tracker_property_set_db_schema_changed (properties[i], FALSE);
}
diff --git a/src/libtracker-data/tracker-property.c b/src/libtracker-data/tracker-property.c
index 9e8ad3a..72e3dd2 100644
--- a/src/libtracker-data/tracker-property.c
+++ b/src/libtracker-data/tracker-property.c
@@ -62,6 +62,7 @@ struct _TrackerPropertyPrivate {
gboolean db_schema_changed;
gboolean writeback;
gchar *default_value;
+ gboolean is_new_domain_index;
GArray *super_properties;
};
@@ -371,6 +372,18 @@ tracker_property_get_is_new (TrackerProperty *property)
}
gboolean
+tracker_property_get_is_new_domain_index (TrackerProperty *property)
+{
+ TrackerPropertyPrivate *priv;
+
+ g_return_val_if_fail (TRACKER_IS_PROPERTY (property), FALSE);
+
+ priv = GET_PRIV (property);
+
+ return priv->is_new_domain_index;
+}
+
+gboolean
tracker_property_get_writeback (TrackerProperty *property)
{
TrackerPropertyPrivate *priv;
@@ -637,6 +650,19 @@ tracker_property_set_is_new (TrackerProperty *property,
}
void
+tracker_property_set_is_new_domain_index (TrackerProperty *property,
+ gboolean value)
+{
+ TrackerPropertyPrivate *priv;
+
+ g_return_if_fail (TRACKER_IS_PROPERTY (property));
+
+ priv = GET_PRIV (property);
+
+ priv->is_new_domain_index = value;
+}
+
+void
tracker_property_set_writeback (TrackerProperty *property,
gboolean value)
{
diff --git a/src/libtracker-data/tracker-property.h b/src/libtracker-data/tracker-property.h
index 01ce5f7..d9c9c01 100644
--- a/src/libtracker-data/tracker-property.h
+++ b/src/libtracker-data/tracker-property.h
@@ -72,65 +72,68 @@ struct _TrackerPropertyClass {
GObjectClass parent_class;
};
-GType tracker_property_get_type (void) G_GNUC_CONST;
-TrackerProperty * tracker_property_new (void);
-const gchar * tracker_property_get_uri (TrackerProperty *property);
-const gchar * tracker_property_get_name (TrackerProperty *property);
-const gchar * tracker_property_get_table_name (TrackerProperty *property);
-TrackerPropertyType tracker_property_get_data_type (TrackerProperty *property);
-TrackerClass * tracker_property_get_domain (TrackerProperty *property);
-TrackerClass * tracker_property_get_range (TrackerProperty *property);
-gint tracker_property_get_weight (TrackerProperty *property);
-gint tracker_property_get_id (TrackerProperty *property);
-gboolean tracker_property_get_indexed (TrackerProperty *property);
-TrackerProperty * tracker_property_get_secondary_index (TrackerProperty *property);
-gboolean tracker_property_get_fulltext_indexed (TrackerProperty *property);
-gboolean tracker_property_get_fulltext_no_limit (TrackerProperty *property);
-gboolean tracker_property_get_embedded (TrackerProperty *property);
-gboolean tracker_property_get_multiple_values (TrackerProperty *property);
-gboolean tracker_property_get_transient (TrackerProperty *property);
-gboolean tracker_property_get_is_new (TrackerProperty *property);
-gboolean tracker_property_get_writeback (TrackerProperty *property);
-const gchar * tracker_property_get_default_value (TrackerProperty *property);
-gboolean tracker_property_get_db_schema_changed (TrackerProperty *property);
+GType tracker_property_get_type (void) G_GNUC_CONST;
+TrackerProperty * tracker_property_new (void);
+const gchar * tracker_property_get_uri (TrackerProperty *property);
+const gchar * tracker_property_get_name (TrackerProperty *property);
+const gchar * tracker_property_get_table_name (TrackerProperty *property);
+TrackerPropertyType tracker_property_get_data_type (TrackerProperty *property);
+TrackerClass * tracker_property_get_domain (TrackerProperty *property);
+TrackerClass * tracker_property_get_range (TrackerProperty *property);
+gint tracker_property_get_weight (TrackerProperty *property);
+gint tracker_property_get_id (TrackerProperty *property);
+gboolean tracker_property_get_indexed (TrackerProperty *property);
+TrackerProperty * tracker_property_get_secondary_index (TrackerProperty *property);
+gboolean tracker_property_get_fulltext_indexed (TrackerProperty *property);
+gboolean tracker_property_get_fulltext_no_limit (TrackerProperty *property);
+gboolean tracker_property_get_embedded (TrackerProperty *property);
+gboolean tracker_property_get_multiple_values (TrackerProperty *property);
+gboolean tracker_property_get_transient (TrackerProperty *property);
+gboolean tracker_property_get_is_new (TrackerProperty *property);
+gboolean tracker_property_get_is_new_domain_index (TrackerProperty *property);
+gboolean tracker_property_get_writeback (TrackerProperty *property);
+const gchar * tracker_property_get_default_value (TrackerProperty *property);
+gboolean tracker_property_get_db_schema_changed (TrackerProperty *property);
gboolean tracker_property_get_is_inverse_functional_property
-(TrackerProperty *property);
-TrackerProperty ** tracker_property_get_super_properties (TrackerProperty *property);
-void tracker_property_set_uri (TrackerProperty *property,
- const gchar *value);
-void tracker_property_set_domain (TrackerProperty *property,
- TrackerClass *value);
-void tracker_property_set_range (TrackerProperty *property,
- TrackerClass *range);
-void tracker_property_set_weight (TrackerProperty *property,
- gint value);
-void tracker_property_set_id (TrackerProperty *property,
- gint value);
-void tracker_property_set_indexed (TrackerProperty *property,
- gboolean value);
-void tracker_property_set_secondary_index (TrackerProperty *property,
- TrackerProperty *value);
-void tracker_property_set_fulltext_indexed (TrackerProperty *property,
- gboolean value);
-void tracker_property_set_fulltext_no_limit (TrackerProperty *property,
- gboolean value);
-void tracker_property_set_embedded (TrackerProperty *property,
- gboolean value);
-void tracker_property_set_multiple_values (TrackerProperty *property,
- gboolean value);
-void tracker_property_set_transient (TrackerProperty *property,
- gboolean value);
-void tracker_property_set_is_new (TrackerProperty *property,
- gboolean value);
-void tracker_property_set_writeback (TrackerProperty *property,
- gboolean value);
-void tracker_property_set_default_value (TrackerProperty *property,
- const gchar *value);
-void tracker_property_set_db_schema_changed (TrackerProperty *property,
- gboolean value);
+ (TrackerProperty *property);
+TrackerProperty ** tracker_property_get_super_properties (TrackerProperty *property);
+void tracker_property_set_uri (TrackerProperty *property,
+ const gchar *value);
+void tracker_property_set_domain (TrackerProperty *property,
+ TrackerClass *value);
+void tracker_property_set_range (TrackerProperty *property,
+ TrackerClass *range);
+void tracker_property_set_weight (TrackerProperty *property,
+ gint value);
+void tracker_property_set_id (TrackerProperty *property,
+ gint value);
+void tracker_property_set_indexed (TrackerProperty *property,
+ gboolean value);
+void tracker_property_set_secondary_index (TrackerProperty *property,
+ TrackerProperty *value);
+void tracker_property_set_fulltext_indexed (TrackerProperty *property,
+ gboolean value);
+void tracker_property_set_fulltext_no_limit (TrackerProperty *property,
+ gboolean value);
+void tracker_property_set_embedded (TrackerProperty *property,
+ gboolean value);
+void tracker_property_set_multiple_values (TrackerProperty *property,
+ gboolean value);
+void tracker_property_set_transient (TrackerProperty *property,
+ gboolean value);
+void tracker_property_set_is_new (TrackerProperty *property,
+ gboolean value);
+void tracker_property_set_is_new_domain_index (TrackerProperty *property,
+ gboolean value);
+void tracker_property_set_writeback (TrackerProperty *property,
+ gboolean value);
+void tracker_property_set_default_value (TrackerProperty *property,
+ const gchar *value);
+void tracker_property_set_db_schema_changed (TrackerProperty *property,
+ gboolean value);
void tracker_property_set_is_inverse_functional_property
-(TrackerProperty *property,
- gboolean value);
+ (TrackerProperty *property,
+ gboolean value);
void tracker_property_add_super_property (TrackerProperty *property,
TrackerProperty *value);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]