[tracker] tracker-miner-fs, libtracker-db: Performance improvement for tracker:uri-is-parent



commit 272ed852942b0a841908c188786577734a28d4d1
Author: Philip Van Hoof <philip codeminded be>
Date:   Thu Apr 29 22:45:06 2010 +0200

    tracker-miner-fs, libtracker-db: Performance improvement for tracker:uri-is-parent

 src/libtracker-db/tracker-db-interface-sqlite.c |   14 +++++++++-----
 src/libtracker-miner/tracker-miner-fs.c         |    7 +++----
 2 files changed, 12 insertions(+), 9 deletions(-)
---
diff --git a/src/libtracker-db/tracker-db-interface-sqlite.c b/src/libtracker-db/tracker-db-interface-sqlite.c
index 15e2573..b39dba2 100644
--- a/src/libtracker-db/tracker-db-interface-sqlite.c
+++ b/src/libtracker-db/tracker-db-interface-sqlite.c
@@ -244,16 +244,18 @@ function_sparql_uri_is_parent (sqlite3_context *context,
 		return;
 	}
 
+	parent_len = sqlite3_value_bytes (argv[0]);
+
 	/* Check only one argument, it's going to
 	 * be compared with the other anyway.
 	 */
-	if (strstr (parent, "://") == NULL) {
+
+	if (!(parent_len >= 7 && (parent[4] == ':' && parent[5] == '/' && parent[6] == '/')) ||
+	    strstr (parent, "://") == NULL) {
 		sqlite3_result_int (context, FALSE);
 		return;
 	}
 
-	parent_len = strlen (parent);
-
 	/* Remove trailing '/', will
 	 * be checked later on uri.
 	 */
@@ -313,15 +315,17 @@ function_sparql_uri_is_descendant (sqlite3_context *context,
 		return;
 	}
 
+	parent_len = sqlite3_value_bytes (argv[0]);
+
 	/* Check only one argument, it's going to
 	 * be compared with the other anyway.
 	 */
-	if (strstr (parent, "://") == NULL) {
+	if (!(parent_len >= 7 && (parent[4] == ':' && parent[5] == '/' && parent[6] == '/')) ||
+	    strstr (parent, "://") == NULL) {
 		sqlite3_result_int (context, FALSE);
 		return;
 	}
 
-	parent_len = strlen (parent);
 
 	/* Remove trailing '/', will
 	 * be checked later on uri.
diff --git a/src/libtracker-miner/tracker-miner-fs.c b/src/libtracker-miner/tracker-miner-fs.c
index 2d59aa7..419e6f4 100644
--- a/src/libtracker-miner/tracker-miner-fs.c
+++ b/src/libtracker-miner/tracker-miner-fs.c
@@ -2155,7 +2155,7 @@ ensure_mtime_cache (TrackerMinerFS *fs,
 	CacheQueryData data;
 	GFile *parent;
 
-        if (G_UNLIKELY (!fs->private->mtime_cache)) {
+	if (G_UNLIKELY (!fs->private->mtime_cache)) {
 		fs->private->mtime_cache = g_hash_table_new_full (g_file_hash,
 		                                                  (GEqualFunc) g_file_equal,
 		                                                  (GDestroyNotify) g_object_unref,
@@ -2182,9 +2182,8 @@ ensure_mtime_cache (TrackerMinerFS *fs,
 
 	g_debug ("Generating mtime cache for folder: %s", uri);
 
-	query = g_strdup_printf ("SELECT ?uri ?time { "
-	                         "  ?u nfo:fileLastModified ?time ; "
-	                         "     nie:url ?uri . "
+	query = g_strdup_printf ("SELECT ?uri nfo:fileLastModified (?u) { "
+	                         "  ?u nie:url ?uri . "
 	                         "  FILTER (tracker:uri-is-parent (\"%s\", ?uri)) "
 	                         "}",
 	                         uri);



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