[tracker/domain-specific-indexes-review: 11/21] libtracker-data: Add support for domain specific indexes to the SPARQL engine



commit 2978e6fa4e443e0df50f1966f873074e3c0ddcfd
Author: Philip Van Hoof <philip codeminded be>
Date:   Tue Jul 6 12:09:05 2010 +0200

    libtracker-data: Add support for domain specific indexes to the SPARQL engine

 src/libtracker-data/libtracker-data.vapi        |    2 ++
 src/libtracker-data/tracker-sparql-pattern.vala |   21 +++++++++++++++++++--
 2 files changed, 21 insertions(+), 2 deletions(-)
---
diff --git a/src/libtracker-data/libtracker-data.vapi b/src/libtracker-data/libtracker-data.vapi
index 6a0afe9..a840977 100644
--- a/src/libtracker-data/libtracker-data.vapi
+++ b/src/libtracker-data/libtracker-data.vapi
@@ -42,6 +42,8 @@ namespace Tracker {
 		public Class range { get; set; }
 		public bool multiple_values { get; set; }
 		public bool is_inverse_functional_property { get; set; }
+		[CCode (array_length = false, array_null_terminated = true)]
+		public unowned Class[] get_domain_indexes ();
 	}
 
 	[CCode (cheader_filename = "libtracker-data/tracker-property.h")]
diff --git a/src/libtracker-data/tracker-sparql-pattern.vala b/src/libtracker-data/tracker-sparql-pattern.vala
index 39e4db5..06cff67 100644
--- a/src/libtracker-data/tracker-sparql-pattern.vala
+++ b/src/libtracker-data/tracker-sparql-pattern.vala
@@ -1168,7 +1168,7 @@ class Tracker.Sparql.Pattern : Object {
 		bool object_is_var;
 		string object = parse_var_or_term (sql, out object_is_var);
 
-		string db_table;
+		string db_table = null;
 		bool rdftype = false;
 		bool share_table = true;
 		bool is_fts_match = false;
@@ -1218,7 +1218,24 @@ class Tracker.Sparql.Pattern : Object {
 					pv.domain = domain;
 				}
 
-				db_table = prop.table_name;
+				if (current_subject_is_var) {
+					// Domain specific index might be a possibility, let's check
+					Variable v = context.get_variable (current_subject);
+					VariableBindingList list = triple_context.var_bindings.lookup (v);
+
+					foreach (Class cl in prop.get_domain_indexes ()) {
+						foreach (VariableBinding b in list.list) {
+							if (b.type == cl) {
+								db_table = cl.name;
+								break;
+							}
+						}
+					}
+				}
+
+				if (db_table == null)
+					db_table = prop.table_name;
+
 				if (prop.multiple_values) {
 					// we can never share the table with multiple triples
 					// for multi value properties as a property may consist of multiple rows



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