sparql 1.99.1 → 2.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/VERSION +1 -1
- data/lib/sparql.rb +1 -1
- data/lib/sparql/algebra.rb +1 -1
- data/lib/sparql/algebra/aggregate.rb +1 -4
- data/lib/sparql/algebra/extensions.rb +1 -1
- data/lib/sparql/algebra/operator.rb +1 -1
- data/lib/sparql/algebra/operator/abs.rb +2 -2
- data/lib/sparql/algebra/operator/alt.rb +5 -1
- data/lib/sparql/algebra/operator/and.rb +4 -7
- data/lib/sparql/algebra/operator/asc.rb +1 -1
- data/lib/sparql/algebra/operator/ask.rb +4 -2
- data/lib/sparql/algebra/operator/base.rb +2 -2
- data/lib/sparql/algebra/operator/bgp.rb +1 -1
- data/lib/sparql/algebra/operator/bnode.rb +2 -0
- data/lib/sparql/algebra/operator/bound.rb +2 -3
- data/lib/sparql/algebra/operator/ceil.rb +1 -1
- data/lib/sparql/algebra/operator/coalesce.rb +1 -4
- data/lib/sparql/algebra/operator/compare.rb +3 -3
- data/lib/sparql/algebra/operator/concat.rb +3 -1
- data/lib/sparql/algebra/operator/construct.rb +5 -6
- data/lib/sparql/algebra/operator/contains.rb +1 -1
- data/lib/sparql/algebra/operator/copy.rb +1 -1
- data/lib/sparql/algebra/operator/dataset.rb +2 -2
- data/lib/sparql/algebra/operator/datatype.rb +1 -1
- data/lib/sparql/algebra/operator/day.rb +1 -1
- data/lib/sparql/algebra/operator/desc.rb +1 -1
- data/lib/sparql/algebra/operator/describe.rb +2 -2
- data/lib/sparql/algebra/operator/distinct.rb +2 -2
- data/lib/sparql/algebra/operator/encode_for_uri.rb +1 -1
- data/lib/sparql/algebra/operator/equal.rb +7 -3
- data/lib/sparql/algebra/operator/exists.rb +3 -2
- data/lib/sparql/algebra/operator/exprlist.rb +1 -1
- data/lib/sparql/algebra/operator/extend.rb +2 -2
- data/lib/sparql/algebra/operator/filter.rb +3 -3
- data/lib/sparql/algebra/operator/floor.rb +3 -1
- data/lib/sparql/algebra/operator/graph.rb +2 -2
- data/lib/sparql/algebra/operator/greater_than.rb +1 -1
- data/lib/sparql/algebra/operator/greater_than_or_equal.rb +1 -1
- data/lib/sparql/algebra/operator/group.rb +1 -1
- data/lib/sparql/algebra/operator/group_concat.rb +5 -4
- data/lib/sparql/algebra/operator/hours.rb +1 -1
- data/lib/sparql/algebra/operator/if.rb +1 -1
- data/lib/sparql/algebra/operator/in.rb +3 -5
- data/lib/sparql/algebra/operator/iri.rb +5 -5
- data/lib/sparql/algebra/operator/is_blank.rb +1 -1
- data/lib/sparql/algebra/operator/is_iri.rb +1 -1
- data/lib/sparql/algebra/operator/is_literal.rb +1 -1
- data/lib/sparql/algebra/operator/join.rb +2 -2
- data/lib/sparql/algebra/operator/lang.rb +1 -1
- data/lib/sparql/algebra/operator/lang_matches.rb +1 -1
- data/lib/sparql/algebra/operator/left_join.rb +2 -2
- data/lib/sparql/algebra/operator/less_than.rb +1 -1
- data/lib/sparql/algebra/operator/less_than_or_equal.rb +1 -1
- data/lib/sparql/algebra/operator/md5.rb +2 -0
- data/lib/sparql/algebra/operator/minus.rb +1 -1
- data/lib/sparql/algebra/operator/minutes.rb +2 -0
- data/lib/sparql/algebra/operator/month.rb +2 -0
- data/lib/sparql/algebra/operator/not_equal.rb +2 -2
- data/lib/sparql/algebra/operator/notexists.rb +2 -0
- data/lib/sparql/algebra/operator/notoneof.rb +1 -1
- data/lib/sparql/algebra/operator/now.rb +2 -0
- data/lib/sparql/algebra/operator/or.rb +3 -3
- data/lib/sparql/algebra/operator/order.rb +2 -2
- data/lib/sparql/algebra/operator/path.rb +1 -1
- data/lib/sparql/algebra/operator/path_opt.rb +1 -1
- data/lib/sparql/algebra/operator/path_plus.rb +1 -1
- data/lib/sparql/algebra/operator/path_star.rb +1 -1
- data/lib/sparql/algebra/operator/prefix.rb +2 -2
- data/lib/sparql/algebra/operator/project.rb +2 -2
- data/lib/sparql/algebra/operator/rand.rb +2 -0
- data/lib/sparql/algebra/operator/reduced.rb +2 -2
- data/lib/sparql/algebra/operator/regex.rb +1 -1
- data/lib/sparql/algebra/operator/replace.rb +1 -1
- data/lib/sparql/algebra/operator/reverse.rb +1 -1
- data/lib/sparql/algebra/operator/round.rb +2 -0
- data/lib/sparql/algebra/operator/same_term.rb +1 -1
- data/lib/sparql/algebra/operator/seconds.rb +2 -0
- data/lib/sparql/algebra/operator/seq.rb +1 -1
- data/lib/sparql/algebra/operator/sequence.rb +1 -1
- data/lib/sparql/algebra/operator/sha1.rb +2 -0
- data/lib/sparql/algebra/operator/sha256.rb +2 -0
- data/lib/sparql/algebra/operator/sha384.rb +2 -0
- data/lib/sparql/algebra/operator/sha512.rb +2 -0
- data/lib/sparql/algebra/operator/slice.rb +2 -2
- data/lib/sparql/algebra/operator/str.rb +1 -1
- data/lib/sparql/algebra/operator/table.rb +1 -1
- data/lib/sparql/algebra/operator/timezone.rb +2 -0
- data/lib/sparql/algebra/operator/tz.rb +2 -0
- data/lib/sparql/algebra/operator/union.rb +2 -2
- data/lib/sparql/algebra/operator/year.rb +2 -0
- data/lib/sparql/algebra/query.rb +1 -1
- data/lib/sparql/grammar.rb +1 -1
- data/lib/sparql/grammar/parser11.rb +14 -15
- data/lib/sparql/version.rb +1 -1
- metadata +80 -46
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0f0674def56366f986d2d91cf7777c16552d64b
|
4
|
+
data.tar.gz: 2ccb0b9d631516cc71c0482d074bb65945af1ad6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4be041a007b6fd78818f5c9188744f081f3d1c321aed9e49629e48760d6b9531c01918fa690f3580fd7fac0c8d32f82e9dd870f8e45f3a0e775273fe971a49fe
|
7
|
+
data.tar.gz: e1dba08317fec9abe5051428628613c6a8761e7f4f6c6889b17eeab821c2a9b868d3567914a1a598517a443eddfbb118552c8a72e84d8bf8a1f7d9bd2986ef70
|
data/README.md
CHANGED
@@ -327,12 +327,12 @@ A copy of the [SPARQL 1.0 tests][] and [SPARQL 1.1 tests][] are also included in
|
|
327
327
|
[YARD-GS]: http://rubydoc.info/docs/yard/file/docs/GettingStarted.md
|
328
328
|
[PDD]: http://lists.w3.org/Archives/Public/public-rdf-ruby/2010May/0013.html
|
329
329
|
[SPARQL]: http://en.wikipedia.org/wiki/SPARQL
|
330
|
-
[SPARQL 1.0]: http://www.w3.org/TR/
|
330
|
+
[SPARQL 1.0]: http://www.w3.org/TR/sparql11-query/
|
331
331
|
[SPARQL 1.0 tests]:http://www.w3.org/2001/sw/DataAccess/tests/
|
332
332
|
[SPARQL 1.1 tests]: http://www.w3.org/2009/sparql/docs/tests/
|
333
333
|
[SSE]: http://openjena.org/wiki/SSE
|
334
334
|
[SXP]: http://www.rubydoc.info/github/bendiken/sxp-ruby
|
335
|
-
[grammar]: http://www.w3.org/TR/
|
335
|
+
[grammar]: http://www.w3.org/TR/sparql11-query/#grammar
|
336
336
|
[RDF 1.1]: http://www.w3.org/TR/rdf11-concepts
|
337
337
|
[RDF.rb]: http://rubydoc.info/github/ruby-rdf/rdf
|
338
338
|
[Backports]: http://rubygems.org/gems/backports
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
2.0.0.beta1
|
data/lib/sparql.rb
CHANGED
data/lib/sparql/algebra.rb
CHANGED
@@ -348,7 +348,7 @@ module SPARQL
|
|
348
348
|
# ====
|
349
349
|
# * Operator#optimize needs to be completed and tested.
|
350
350
|
#
|
351
|
-
# @see http://www.w3.org/TR/
|
351
|
+
# @see http://www.w3.org/TR/sparql11-query/#sparqlAlgebra
|
352
352
|
module Algebra
|
353
353
|
include RDF
|
354
354
|
|
@@ -15,8 +15,6 @@ module SPARQL; module Algebra
|
|
15
15
|
# Aggregates this operator accross its operands using
|
16
16
|
# a solutions enumerable.
|
17
17
|
#
|
18
|
-
# The first operand may be :distinct, in which case the result of applying the rest of the operands is uniqued before applying the expression.
|
19
|
-
#
|
20
18
|
# @param [Enumerable<RDF::Query::Solution>] solutions ([])
|
21
19
|
# an enumerable set of query solutions
|
22
20
|
# @param [Hash{Symbol => Object}] options ({})
|
@@ -25,7 +23,6 @@ module SPARQL; module Algebra
|
|
25
23
|
# @raise [TypeError]
|
26
24
|
# @abstract
|
27
25
|
def aggregate(solutions = [], options = {})
|
28
|
-
operands.shift if distinct = (operands.first == :distinct)
|
29
26
|
args_enum = solutions.map do |solution|
|
30
27
|
operands.map do |operand|
|
31
28
|
begin
|
@@ -36,7 +33,7 @@ module SPARQL; module Algebra
|
|
36
33
|
end
|
37
34
|
end.compact
|
38
35
|
end
|
39
|
-
apply(
|
36
|
+
apply(args_enum)
|
40
37
|
end
|
41
38
|
|
42
39
|
##
|
@@ -66,7 +66,7 @@ class Array
|
|
66
66
|
# @param [Hash{Symbol => Object}] options
|
67
67
|
# @raise [NotImplementedError]
|
68
68
|
# If an attempt is made to perform an unsupported operation
|
69
|
-
# @see http://www.w3.org/TR/
|
69
|
+
# @see http://www.w3.org/TR/sparql11-query/#sparqlAlgebra
|
70
70
|
def execute(queryable, options = {})
|
71
71
|
raise NotImplementedError, "SPARQL::Algebra '#{first}' operator not implemented"
|
72
72
|
end
|
@@ -647,7 +647,7 @@ module SPARQL; module Algebra
|
|
647
647
|
# @param [RDF::Literal] literal
|
648
648
|
# @return [RDF::Literal::Boolean] `true` or `false`
|
649
649
|
# @raise [TypeError] if the literal could not be coerced to an `RDF::Literal::Boolean`
|
650
|
-
# @see http://www.w3.org/TR/
|
650
|
+
# @see http://www.w3.org/TR/sparql11-query/#ebv
|
651
651
|
def boolean(literal)
|
652
652
|
case literal
|
653
653
|
when FalseClass then RDF::Literal::FALSE
|
@@ -14,8 +14,8 @@ module SPARQL; module Algebra
|
|
14
14
|
NAME = [:abs]
|
15
15
|
|
16
16
|
##
|
17
|
-
# Returns the absolute value of
|
18
|
-
#
|
17
|
+
# Returns the absolute value of `arg`. An error is raised if `arg` is not a numeric value.
|
18
|
+
#
|
19
19
|
# @param [RDF::Literal] operand
|
20
20
|
# the operand
|
21
21
|
# @return [RDF::Literal] literal of same type
|
@@ -3,6 +3,10 @@ module SPARQL; module Algebra
|
|
3
3
|
##
|
4
4
|
# The SPARQL Property Path `alt` (Alternative Property Path) operator.
|
5
5
|
#
|
6
|
+
# Let P and Q be property path expressions.
|
7
|
+
#
|
8
|
+
# eval(Path(X, alt(P,Q), Y)) = Union(eval(Path(X, P, Y)), eval(Path(X, Q, Y)))
|
9
|
+
#
|
6
10
|
# @example
|
7
11
|
# (alt a b)
|
8
12
|
#
|
@@ -28,7 +32,7 @@ module SPARQL; module Algebra
|
|
28
32
|
# each matching solution
|
29
33
|
# @yieldparam [RDF::Query::Solution] solution
|
30
34
|
# @yieldreturn [void] ignored
|
31
|
-
# @see http://www.w3.org/TR/
|
35
|
+
# @see http://www.w3.org/TR/sparql11-query/#sparqlAlgebra
|
32
36
|
def execute(queryable, options = {}, &block)
|
33
37
|
subject, object = options[:subject], options[:object]
|
34
38
|
debug(options) {"Alt #{[subject, operands, object].to_sse}"}
|
@@ -7,8 +7,8 @@ module SPARQL; module Algebra
|
|
7
7
|
# (&& ?x ?y)
|
8
8
|
# (and ?x ?y)
|
9
9
|
#
|
10
|
-
# @see http://www.w3.org/TR/
|
11
|
-
# @see http://www.w3.org/TR/
|
10
|
+
# @see http://www.w3.org/TR/sparql11-query/#func-logical-and
|
11
|
+
# @see http://www.w3.org/TR/sparql11-query/#evaluation
|
12
12
|
class And < Operator::Binary
|
13
13
|
include Evaluatable
|
14
14
|
|
@@ -29,10 +29,7 @@ module SPARQL; module Algebra
|
|
29
29
|
end
|
30
30
|
|
31
31
|
##
|
32
|
-
# Returns
|
33
|
-
#
|
34
|
-
# Note that this operator operates on the effective boolean value
|
35
|
-
# (EBV) of its operands.
|
32
|
+
# Returns a logical `AND` of `left` and `right`. Note that logical-and operates on the effective boolean value of its arguments.
|
36
33
|
#
|
37
34
|
# @param [RDF::Query::Solution] bindings
|
38
35
|
# a query solution containing zero or more variable bindings
|
@@ -53,7 +50,7 @@ module SPARQL; module Algebra
|
|
53
50
|
right = nil
|
54
51
|
end
|
55
52
|
|
56
|
-
# From http://www.w3.org/TR/
|
53
|
+
# From http://www.w3.org/TR/sparql11-query/#evaluation
|
57
54
|
# A logical-and that encounters an error on only one branch will return an error if the other branch is
|
58
55
|
# TRUE and FALSE if the other branch is FALSE.
|
59
56
|
case
|
@@ -9,7 +9,7 @@ module SPARQL; module Algebra
|
|
9
9
|
# (order ((asc ?name))
|
10
10
|
# (bgp (triple ?x foaf:name ?name)))))
|
11
11
|
#
|
12
|
-
# @see http://www.w3.org/TR/
|
12
|
+
# @see http://www.w3.org/TR/sparql11-query/#modOrderBy
|
13
13
|
class Asc < Operator::Unary
|
14
14
|
include Evaluatable
|
15
15
|
|
@@ -3,12 +3,14 @@ module SPARQL; module Algebra
|
|
3
3
|
##
|
4
4
|
# The SPARQL GraphPattern `ask` operator.
|
5
5
|
#
|
6
|
+
# Applications can use the ASK form to test whether or not a query pattern has a solution. No information is returned about the possible query solutions, just whether or not a solution exists.
|
7
|
+
#
|
6
8
|
# @example
|
7
9
|
# (prefix ((: <http://example/>))
|
8
10
|
# (ask
|
9
11
|
# (bgp (triple :x :p ?x))))
|
10
12
|
#
|
11
|
-
# @see http://www.w3.org/TR/
|
13
|
+
# @see http://www.w3.org/TR/sparql11-query/#ask
|
12
14
|
class Ask < Operator::Unary
|
13
15
|
include Query
|
14
16
|
|
@@ -26,7 +28,7 @@ module SPARQL; module Algebra
|
|
26
28
|
# @yieldparam [RDF::Query::Solution] solution
|
27
29
|
# @yieldreturn [void] ignored
|
28
30
|
# @return [RDF::Literal::Boolean]\
|
29
|
-
# @see http://www.w3.org/TR/
|
31
|
+
# @see http://www.w3.org/TR/sparql11-query/#sparqlAlgebra
|
30
32
|
def execute(queryable, options = {})
|
31
33
|
debug(options) {"Ask #{operands.first}"}
|
32
34
|
res = boolean(!queryable.query(operands.last, options.merge(depth: options[:depth].to_i + 1)).empty?)
|
@@ -7,7 +7,7 @@ module SPARQL; module Algebra
|
|
7
7
|
# (base <http://example.org/>
|
8
8
|
# (bgp (triple <a> <b> 123.0)))
|
9
9
|
#
|
10
|
-
# @see http://www.w3.org/TR/
|
10
|
+
# @see http://www.w3.org/TR/sparql11-query/#QSynIRI
|
11
11
|
class Base < Binary
|
12
12
|
include Query
|
13
13
|
|
@@ -28,7 +28,7 @@ module SPARQL; module Algebra
|
|
28
28
|
# @yieldreturn [void] ignored
|
29
29
|
# @return [RDF::Queryable, RDF::Query::Solutions]
|
30
30
|
# the resulting solution sequence
|
31
|
-
# @see http://www.w3.org/TR/
|
31
|
+
# @see http://www.w3.org/TR/sparql11-query/#sparqlAlgebra
|
32
32
|
def execute(queryable, options = {}, &block)
|
33
33
|
debug(options) {"Base #{operands.first}"}
|
34
34
|
Operator.base_uri = operands.first
|
@@ -9,7 +9,7 @@ module SPARQL; module Algebra
|
|
9
9
|
# (prefix ((: <http://example/>))
|
10
10
|
# (bgp (triple ?s ?p ?o)))
|
11
11
|
#
|
12
|
-
# @see http://www.w3.org/TR/
|
12
|
+
# @see http://www.w3.org/TR/sparql11-query/#sparqlAlgebra
|
13
13
|
class BGP < Operator
|
14
14
|
NAME = [:bgp]
|
15
15
|
##
|
@@ -3,6 +3,8 @@ module SPARQL; module Algebra
|
|
3
3
|
##
|
4
4
|
# The SPARQL `bnode` operator.
|
5
5
|
#
|
6
|
+
# The BNODE function constructs a blank node that is distinct from all blank nodes in the dataset being queried and distinct from all blank nodes created by calls to this constructor for other query solutions. If the no argument form is used, every call results in a distinct blank node. If the form with a simple literal is used, every call results in distinct blank nodes for different simple literals, and the same blank node for calls with the same simple literal within expressions for one solution mapping.
|
7
|
+
#
|
6
8
|
# @example
|
7
9
|
# (prefix ((: <http://example.org/>)
|
8
10
|
# (xsd: <http://www.w3.org/2001/XMLSchema#>))
|
@@ -11,7 +11,7 @@ module SPARQL; module Algebra
|
|
11
11
|
# (bgp (triple ?a :b ?c))
|
12
12
|
# (bgp (triple ?c :d ?e))))))
|
13
13
|
#
|
14
|
-
# @see http://www.w3.org/TR/
|
14
|
+
# @see http://www.w3.org/TR/sparql11-query/#func-bound
|
15
15
|
class Bound < Operator::Unary
|
16
16
|
include Evaluatable
|
17
17
|
|
@@ -30,8 +30,7 @@ module SPARQL; module Algebra
|
|
30
30
|
end
|
31
31
|
|
32
32
|
##
|
33
|
-
# Returns `true` if
|
34
|
-
# value in the given `bindings`, `false` otherwise.
|
33
|
+
# Returns `true` if `var` is bound to a value. Returns false otherwise. Variables with the value NaN or INF are considered bound.
|
35
34
|
#
|
36
35
|
# @param [RDF::Query::Solution] bindings
|
37
36
|
# a query solution containing zero or more variable bindings
|
@@ -14,7 +14,7 @@ module SPARQL; module Algebra
|
|
14
14
|
NAME = [:ceil]
|
15
15
|
|
16
16
|
##
|
17
|
-
# Returns the smallest (closest to negative infinity) number with no fractional part that is not less than the value of arg
|
17
|
+
# Returns the smallest (closest to negative infinity) number with no fractional part that is not less than the value of `arg`. An error is raised if `arg` is not a numeric value.
|
18
18
|
#
|
19
19
|
# @param [RDF::Literal] operand
|
20
20
|
# the operand
|
@@ -3,8 +3,6 @@ module SPARQL; module Algebra
|
|
3
3
|
##
|
4
4
|
# The SPARQL `coalesce` function.
|
5
5
|
#
|
6
|
-
# Used for filters with more than one expression.
|
7
|
-
#
|
8
6
|
# @example
|
9
7
|
# (prefix ((: <http://example.org/>)
|
10
8
|
# (xsd: <http://www.w3.org/2001/XMLSchema#>))
|
@@ -25,9 +23,8 @@ module SPARQL; module Algebra
|
|
25
23
|
|
26
24
|
##
|
27
25
|
# The COALESCE function form returns the RDF term value of the first expression that evaluates without error. In SPARQL, evaluating an unbound variable raises an error.
|
28
|
-
#
|
26
|
+
#
|
29
27
|
# If none of the arguments evaluates to an RDF term, an error is raised. If no expressions are evaluated without error, an error is raised.
|
30
|
-
#
|
31
28
|
#
|
32
29
|
# @example
|
33
30
|
# Suppose ?x = 2 and ?y is not bound in some query solution:
|
@@ -6,7 +6,7 @@ module SPARQL; module Algebra
|
|
6
6
|
# @example
|
7
7
|
# (<=> ?x ?y)
|
8
8
|
#
|
9
|
-
# @see http://www.w3.org/TR/
|
9
|
+
# @see http://www.w3.org/TR/sparql11-query/#OperatorMapping
|
10
10
|
# @see http://www.w3.org/TR/xpath-functions/#func-compare
|
11
11
|
class Compare < Operator::Binary
|
12
12
|
include Evaluatable
|
@@ -33,8 +33,8 @@ module SPARQL; module Algebra
|
|
33
33
|
# @raise [TypeError] if either operand is not a literal
|
34
34
|
def apply(left, right)
|
35
35
|
case
|
36
|
-
# @see http://www.w3.org/TR/
|
37
|
-
# @see http://www.w3.org/TR/
|
36
|
+
# @see http://www.w3.org/TR/sparql11-query/#OperatorMapping
|
37
|
+
# @see http://www.w3.org/TR/sparql11-query/#modOrderBy
|
38
38
|
when left.is_a?(RDF::Literal) && right.is_a?(RDF::Literal)
|
39
39
|
case
|
40
40
|
# @see http://www.w3.org/TR/xpath-functions/#string-compare
|
@@ -3,6 +3,8 @@ module SPARQL; module Algebra
|
|
3
3
|
##
|
4
4
|
# A SPARQL `concat` operator.
|
5
5
|
#
|
6
|
+
# The CONCAT function corresponds to the XPath fn:concat function. The function accepts string literals as arguments.
|
7
|
+
#
|
6
8
|
# @example
|
7
9
|
# (concat ?a ?b ...)
|
8
10
|
#
|
@@ -14,7 +16,7 @@ module SPARQL; module Algebra
|
|
14
16
|
NAME = :concat
|
15
17
|
|
16
18
|
##
|
17
|
-
# The lexical form of the returned literal is obtained by concatenating the lexical forms of its inputs. If all input literals are typed literals of type xsd:string, then the returned literal is also of type xsd:string
|
19
|
+
# The lexical form of the returned literal is obtained by concatenating the lexical forms of its inputs. If all input literals are typed literals of type xsd:string, then the returned literal is also of type `xsd:string`, if all input literals are plain literals with identical language tag, then the returned literal is a plain literal with the same language tag, in all other cases, the returned literal is a simple literal.
|
18
20
|
#
|
19
21
|
# @example
|
20
22
|
# concat("foo", "bar") #=> "foobar"
|
@@ -3,6 +3,8 @@ module SPARQL; module Algebra
|
|
3
3
|
##
|
4
4
|
# The SPARQL GraphPattern `construct` operator.
|
5
5
|
#
|
6
|
+
# The CONSTRUCT query form returns a single RDF graph specified by a graph template. The result is an RDF graph formed by taking each query solution in the solution sequence, substituting for the variables in the graph template, and combining the triples into a single RDF graph by set union.
|
7
|
+
#
|
6
8
|
# @example
|
7
9
|
# (prefix ((rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>)
|
8
10
|
# (foaf: <http://xmlns.com/foaf/0.1/>))
|
@@ -10,7 +12,7 @@ module SPARQL; module Algebra
|
|
10
12
|
# (project (?s ?p ?o)
|
11
13
|
# (bgp (triple ?s ?p ?o)))))
|
12
14
|
#
|
13
|
-
# @see http://www.w3.org/TR/
|
15
|
+
# @see http://www.w3.org/TR/sparql11-query/#construct
|
14
16
|
class Construct < Operator::Binary
|
15
17
|
include Query
|
16
18
|
|
@@ -20,10 +22,7 @@ module SPARQL; module Algebra
|
|
20
22
|
# Executes this query on the given {RDF::Queryable} object.
|
21
23
|
# Binds variables to the array of patterns in the first operand and returns the resulting RDF::Graph object
|
22
24
|
#
|
23
|
-
# If any such instantiation produces a triple containing an unbound variable or an illegal RDF construct,
|
24
|
-
# such as an RDF::Literal in _subject_ or _predicate_ position, then that triple is not included in the output RDF
|
25
|
-
# graph. The graph template can contain triples with no variables (known as ground or explicit triples),
|
26
|
-
# and these also appear in the output RDF graph returned by the CONSTRUCT query form.
|
25
|
+
# If any such instantiation produces a triple containing an unbound variable or an illegal RDF construct, such as a literal in subject or predicate position, then that triple is not included in the output RDF graph. The graph template can contain triples with no variables (known as ground or explicit triples), and these also appear in the output RDF graph returned by the CONSTRUCT query form.
|
27
26
|
#
|
28
27
|
# @param [RDF::Queryable] queryable
|
29
28
|
# the graph or repository to query
|
@@ -35,7 +34,7 @@ module SPARQL; module Algebra
|
|
35
34
|
# @yieldreturn [void] ignored
|
36
35
|
# @return [RDF::Queryable]
|
37
36
|
# A Queryable with constructed triples
|
38
|
-
# @see http://www.w3.org/TR/
|
37
|
+
# @see http://www.w3.org/TR/sparql11-query/#construct
|
39
38
|
def execute(queryable, options = {}, &block)
|
40
39
|
debug(options) {"Construct #{operands.first}, #{options.inspect}"}
|
41
40
|
graph = RDF::Graph.new
|
@@ -14,7 +14,7 @@ module SPARQL; module Algebra
|
|
14
14
|
NAME = :contains
|
15
15
|
|
16
16
|
##
|
17
|
-
# The CONTAINS function corresponds to the XPath fn:contains. The arguments must be argument compatible otherwise an error is raised.
|
17
|
+
# The `CONTAINS` function corresponds to the XPath fn:contains. The arguments must be argument compatible otherwise an error is raised.
|
18
18
|
#
|
19
19
|
# @example
|
20
20
|
# contains("foobar", "bar") #=> true
|
@@ -102,7 +102,7 @@ module SPARQL; module Algebra
|
|
102
102
|
# (graph ?g (bgp (triple ?s ?p ?o))))))
|
103
103
|
#
|
104
104
|
# @example Dataset with multiple named graphs
|
105
|
-
# @see http://www.w3.org/TR/
|
105
|
+
# @see http://www.w3.org/TR/sparql11-query/#specifyingDataset
|
106
106
|
class Dataset < Binary
|
107
107
|
include Query
|
108
108
|
|
@@ -125,7 +125,7 @@ module SPARQL; module Algebra
|
|
125
125
|
# @yieldreturn [void] ignored
|
126
126
|
# @return [RDF::Query::Solutions]
|
127
127
|
# the resulting solution sequence
|
128
|
-
# @see http://www.w3.org/TR/
|
128
|
+
# @see http://www.w3.org/TR/sparql11-query/#sparqlAlgebra
|
129
129
|
def execute(queryable, options = {}, &base)
|
130
130
|
debug(options) {"Dataset"}
|
131
131
|
default_datasets = []
|
@@ -11,7 +11,7 @@ module SPARQL; module Algebra
|
|
11
11
|
# (filter (= (datatype (xsd:double ?v)) xsd:double)
|
12
12
|
# (bgp (triple ?s :p ?v)))))
|
13
13
|
#
|
14
|
-
# @see http://www.w3.org/TR/
|
14
|
+
# @see http://www.w3.org/TR/sparql11-query/#func-datatype
|
15
15
|
class Datatype < Operator::Unary
|
16
16
|
include Evaluatable
|
17
17
|
|
@@ -9,7 +9,7 @@ module SPARQL; module Algebra
|
|
9
9
|
# (order ((desc ?name))
|
10
10
|
# (bgp (triple ?x foaf:name ?name)))))
|
11
11
|
#
|
12
|
-
# @see http://www.w3.org/TR/
|
12
|
+
# @see http://www.w3.org/TR/sparql11-query/#modOrderBy
|
13
13
|
class Desc < Operator::Asc
|
14
14
|
NAME = :desc
|
15
15
|
end # Desc
|
@@ -10,7 +10,7 @@ module SPARQL; module Algebra
|
|
10
10
|
# (describe (?x)
|
11
11
|
# (bgp (triple ?x exOrg:employeeId "1234"))))
|
12
12
|
#
|
13
|
-
# @see http://www.w3.org/TR/
|
13
|
+
# @see http://www.w3.org/TR/sparql11-query/#describe
|
14
14
|
class Describe < Operator::Binary
|
15
15
|
include Query
|
16
16
|
|
@@ -39,7 +39,7 @@ module SPARQL; module Algebra
|
|
39
39
|
# @yieldreturn [void] ignored
|
40
40
|
# @return [RDF::Graph]
|
41
41
|
# containing the constructed triples
|
42
|
-
# @see http://www.w3.org/TR/
|
42
|
+
# @see http://www.w3.org/TR/sparql11-query/#describe
|
43
43
|
def execute(queryable, options = {}, &block)
|
44
44
|
debug(options) {"Describe #{operands.first}, #{options.inspect}"}
|
45
45
|
|