[grilo-plugins/wip/carlosg/tracker3: 24/39] tracker3: Port grl_source_query() to the statement cache
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [grilo-plugins/wip/carlosg/tracker3: 24/39] tracker3: Port grl_source_query() to the statement cache
- Date: Sun, 14 Jun 2020 18:38:34 +0000 (UTC)
commit 33eb78e68a6109a60d0a9237a21a63d97c047fd1
Author: Carlos Garnacho <carlosg gnome org>
Date: Sat May 23 13:15:52 2020 +0200
tracker3: Port grl_source_query() to the statement cache
We drop the support for full queries, the query is extended so that
subselects work.
src/tracker3/grl-tracker-source-api.c | 51 ++++++-----------------------------
1 file changed, 8 insertions(+), 43 deletions(-)
---
diff --git a/src/tracker3/grl-tracker-source-api.c b/src/tracker3/grl-tracker-source-api.c
index 2000f9bf..87f251ef 100644
--- a/src/tracker3/grl-tracker-source-api.c
+++ b/src/tracker3/grl-tracker-source-api.c
@@ -57,20 +57,6 @@ GRL_LOG_DOMAIN_STATIC(tracker_source_result_log_domain);
/* ------- Definitions ------- */
-#define TRACKER_QUERY_LIMIT \
- "OFFSET %u " \
- "LIMIT %u"
-
-#define TRACKER_QUERY_PARTIAL_REQUEST \
- "SELECT rdf:type(?urn) %s " \
- "WHERE { %s } " \
- "ORDER BY DESC(nfo:fileLastModified(?urn)) " \
- TRACKER_QUERY_LIMIT
-
-#define TRACKER_QUERY_FULL_REQUEST \
- "%s " \
- TRACKER_QUERY_LIMIT
-
#define TRACKER_DELETE_REQUEST \
"DELETE { <%s> %s } WHERE { <%s> a nfo:Media . %s }"
@@ -696,12 +682,7 @@ grl_tracker_source_query (GrlSource *source,
GrlSourceQuerySpec *qs)
{
GError *error = NULL;
- GrlTrackerSourcePriv *priv = GRL_TRACKER_SOURCE_GET_PRIVATE (source);
- gchar *sparql_final;
- gchar *sparql_select;
GrlTrackerOp *os;
- gint count = grl_operation_options_get_count (qs->options);
- guint skip = grl_operation_options_get_skip (qs->options);
TrackerSparqlStatement *statement;
GRL_IDEBUG ("%s: id=%u", __FUNCTION__, qs->operation_id);
@@ -713,31 +694,15 @@ grl_tracker_source_query (GrlSource *source,
goto send_error;
}
- /* Check if it is a full sparql query */
- if (g_ascii_strncasecmp (qs->query, "select ", 7) != 0) {
- sparql_select = grl_tracker_source_get_select_string (qs->keys);
- sparql_final = g_strdup_printf (TRACKER_QUERY_PARTIAL_REQUEST,
- sparql_select,
- qs->query,
- skip,
- count);
- g_free (qs->query);
- g_free (sparql_select);
- qs->query = sparql_final;
- } else {
- /* Append offset and limit */
- sparql_final = g_strdup_printf (TRACKER_QUERY_FULL_REQUEST,
- qs->query,
- skip,
- count);
- g_free (qs->query);
- qs->query = sparql_final;
- }
-
statement =
- tracker_sparql_connection_query_statement (priv->tracker_connection,
- qs->query,
- NULL, NULL);
+ grl_tracker_source_create_statement (GRL_TRACKER_SOURCE (source),
+ GRL_TRACKER_QUERY_ALL,
+ qs->options,
+ qs->keys,
+ qs->query,
+ &error);
+ if (!statement)
+ goto send_error;
os = grl_tracker_op_new (grl_operation_options_get_type_filter (qs->options),
qs->keys, qs);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]