[tracker/miner-fs-queries-performance: 4/6] TrackerDBInterfaceSqlite: Add function to get an uri dirname.
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/miner-fs-queries-performance: 4/6] TrackerDBInterfaceSqlite: Add function to get an uri dirname.
- Date: Wed, 21 Apr 2010 13:41:57 +0000 (UTC)
commit 128e49ada6e0497a67d0459431817c82c9ee0a94
Author: Carlos Garnacho <carlosg gnome org>
Date: Wed Apr 21 15:37:30 2010 +0200
TrackerDBInterfaceSqlite: Add function to get an uri dirname.
src/libtracker-db/tracker-db-interface-sqlite.c | 42 +++++++++++++++++++++++
1 files changed, 42 insertions(+), 0 deletions(-)
---
diff --git a/src/libtracker-db/tracker-db-interface-sqlite.c b/src/libtracker-db/tracker-db-interface-sqlite.c
index 878d1f2..78efc3a 100644
--- a/src/libtracker-db/tracker-db-interface-sqlite.c
+++ b/src/libtracker-db/tracker-db-interface-sqlite.c
@@ -222,6 +222,44 @@ function_sparql_string_from_filename (sqlite3_context *context,
}
static void
+function_sparql_uri_dirname (sqlite3_context *context,
+ int argc,
+ sqlite3_value *argv[])
+{
+ gchar *uri, *pos;
+
+ if (argc != 1) {
+ sqlite3_result_error (context, "Invalid argument count", -1);
+ return;
+ }
+
+ uri = g_strdup (sqlite3_value_text (argv[0]));
+
+ /* Ignore trailing '/' */
+ if (g_str_has_suffix (uri, "/")) {
+ uri[strlen (uri) - 1] = '\0';
+ }
+
+ if ((pos = strrchr (uri, '/')) == NULL) {
+ /* No parent */
+ sqlite3_result_null (context);
+ g_free (uri);
+ return;
+ } else {
+ *(pos + 1) = '\0';
+ }
+
+ /* No valid uri form */
+ if (strstr (uri, "://") == 0) {
+ sqlite3_result_null (context);
+ g_free (uri);
+ return;
+ }
+
+ sqlite3_result_text (context, uri, -1, g_free);
+}
+
+static void
function_sparql_cartesian_distance (sqlite3_context *context,
int argc,
sqlite3_value *argv[])
@@ -399,6 +437,10 @@ open_database (TrackerDBInterfaceSqlitePrivate *priv)
priv, &function_sparql_string_join,
NULL, NULL);
+ sqlite3_create_function (priv->db, "SparqlUriDirname", -1, SQLITE_ANY,
+ priv, &function_sparql_uri_dirname,
+ NULL, NULL);
+
sqlite3_extended_result_codes (priv->db, 0);
sqlite3_busy_timeout (priv->db, 100000);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]