[tracker] libtracker-data: Add support for STRSTARTS/STRENDS builtin functions
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker] libtracker-data: Add support for STRSTARTS/STRENDS builtin functions
- Date: Mon, 19 Oct 2015 12:15:09 +0000 (UTC)
commit 54aac6a12b2ae575421b391c2eb0812c3f6bc9c4
Author: Carlos Garnacho <carlosg gnome org>
Date: Tue Jul 28 20:29:59 2015 +0200
libtracker-data: Add support for STRSTARTS/STRENDS builtin functions
These are defined in Sparql 1.1 query language recommendation,
http://www.w3.org/TR/sparql11-query/#func-strstarts
http://www.w3.org/TR/sparql11-query/#func-strends
src/libtracker-data/tracker-sparql-expression.vala | 12 ++++++++++++
src/libtracker-data/tracker-sparql-scanner.vala | 12 ++++++++++++
2 files changed, 24 insertions(+), 0 deletions(-)
---
diff --git a/src/libtracker-data/tracker-sparql-expression.vala
b/src/libtracker-data/tracker-sparql-expression.vala
index bb31628..5b36d19 100644
--- a/src/libtracker-data/tracker-sparql-expression.vala
+++ b/src/libtracker-data/tracker-sparql-expression.vala
@@ -1230,6 +1230,18 @@ class Tracker.Sparql.Expression : Object {
type = translate_aggregate_expression (sql);
sql.append (")");
return PropertyType.INTEGER;
+ case SparqlTokenType.STRSTARTS:
+ next ();
+ expect (SparqlTokenType.OPEN_PARENS);
+ var result = translate_function (sql, FN_NS + "starts-with");
+ expect (SparqlTokenType.CLOSE_PARENS);
+ return result;
+ case SparqlTokenType.STRENDS:
+ next ();
+ expect (SparqlTokenType.OPEN_PARENS);
+ var result = translate_function (sql, FN_NS + "ends-with");
+ expect (SparqlTokenType.CLOSE_PARENS);
+ return result;
case SparqlTokenType.SUBSTR:
next ();
expect (SparqlTokenType.OPEN_PARENS);
diff --git a/src/libtracker-data/tracker-sparql-scanner.vala b/src/libtracker-data/tracker-sparql-scanner.vala
index 903de58..3ffeace 100644
--- a/src/libtracker-data/tracker-sparql-scanner.vala
+++ b/src/libtracker-data/tracker-sparql-scanner.vala
@@ -344,6 +344,10 @@ public class Tracker.SparqlScanner : Object {
break;
}
break;
+ case 'S':
+ case 's':
+ if (matches (begin, "STRENDS")) return SparqlTokenType.STRENDS;
+ break;
case 'I':
case 'i':
if (matches (begin, "ISBLANK")) return SparqlTokenType.ISBLANK;
@@ -402,6 +406,10 @@ public class Tracker.SparqlScanner : Object {
case 'i':
if (matches (begin, "ISLITERAL")) return SparqlTokenType.ISLITERAL;
break;
+ case 'S':
+ case 's':
+ if (matches (begin, "STRSTARTS")) return SparqlTokenType.STRSTARTS;
+ break;
}
break;
case 11:
@@ -985,11 +993,13 @@ public enum Tracker.SparqlTokenType {
SILENT,
STAR,
STR,
+ STRENDS,
STRING_LITERAL1,
STRING_LITERAL2,
STRING_LITERAL_LONG1,
STRING_LITERAL_LONG2,
STRLEN,
+ STRSTARTS,
SUBSTR,
SUM,
TRUE,
@@ -1087,11 +1097,13 @@ public enum Tracker.SparqlTokenType {
case SILENT: return "`SILENT'";
case STAR: return "`*'";
case STR: return "`STR'";
+ case STRENDS: return "`STRENDS'";
case STRING_LITERAL1: return "string literal";
case STRING_LITERAL2: return "string literal";
case STRING_LITERAL_LONG1: return "string literal";
case STRING_LITERAL_LONG2: return "string literal";
case STRLEN: return "`STRLEN'";
+ case STRSTARTS: return "`STRSTARTS'";
case SUBSTR: return "`SUBSTR'";
case SUM: return "`SUM'";
case TRUE: return "`true'";
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]