sparql 3.1.0 → 3.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +183 -69
  3. data/UNLICENSE +1 -1
  4. data/VERSION +1 -1
  5. data/bin/sparql +20 -9
  6. data/lib/rack/sparql/conneg.rb +2 -2
  7. data/lib/sinatra/sparql.rb +3 -3
  8. data/lib/sparql.rb +8 -6
  9. data/lib/sparql/algebra.rb +7 -15
  10. data/lib/sparql/algebra/aggregate.rb +2 -2
  11. data/lib/sparql/algebra/expression.rb +22 -8
  12. data/lib/sparql/algebra/extensions.rb +135 -3
  13. data/lib/sparql/algebra/operator.rb +37 -9
  14. data/lib/sparql/algebra/operator/abs.rb +2 -2
  15. data/lib/sparql/algebra/operator/add.rb +2 -2
  16. data/lib/sparql/algebra/operator/alt.rb +2 -2
  17. data/lib/sparql/algebra/operator/and.rb +3 -3
  18. data/lib/sparql/algebra/operator/asc.rb +1 -1
  19. data/lib/sparql/algebra/operator/ask.rb +2 -12
  20. data/lib/sparql/algebra/operator/avg.rb +1 -1
  21. data/lib/sparql/algebra/operator/base.rb +8 -8
  22. data/lib/sparql/algebra/operator/bgp.rb +1 -1
  23. data/lib/sparql/algebra/operator/bnode.rb +2 -2
  24. data/lib/sparql/algebra/operator/bound.rb +1 -1
  25. data/lib/sparql/algebra/operator/ceil.rb +2 -2
  26. data/lib/sparql/algebra/operator/clear.rb +2 -2
  27. data/lib/sparql/algebra/operator/coalesce.rb +1 -11
  28. data/lib/sparql/algebra/operator/compare.rb +8 -8
  29. data/lib/sparql/algebra/operator/concat.rb +2 -2
  30. data/lib/sparql/algebra/operator/construct.rb +2 -12
  31. data/lib/sparql/algebra/operator/contains.rb +2 -2
  32. data/lib/sparql/algebra/operator/copy.rb +2 -2
  33. data/lib/sparql/algebra/operator/count.rb +1 -1
  34. data/lib/sparql/algebra/operator/create.rb +2 -2
  35. data/lib/sparql/algebra/operator/dataset.rb +2 -13
  36. data/lib/sparql/algebra/operator/datatype.rb +1 -1
  37. data/lib/sparql/algebra/operator/day.rb +1 -1
  38. data/lib/sparql/algebra/operator/delete.rb +4 -4
  39. data/lib/sparql/algebra/operator/delete_data.rb +2 -2
  40. data/lib/sparql/algebra/operator/delete_where.rb +2 -2
  41. data/lib/sparql/algebra/operator/desc.rb +1 -1
  42. data/lib/sparql/algebra/operator/describe.rb +2 -12
  43. data/lib/sparql/algebra/operator/distinct.rb +2 -12
  44. data/lib/sparql/algebra/operator/divide.rb +1 -1
  45. data/lib/sparql/algebra/operator/drop.rb +2 -2
  46. data/lib/sparql/algebra/operator/encode_for_uri.rb +2 -2
  47. data/lib/sparql/algebra/operator/equal.rb +2 -2
  48. data/lib/sparql/algebra/operator/exists.rb +1 -1
  49. data/lib/sparql/algebra/operator/exprlist.rb +1 -11
  50. data/lib/sparql/algebra/operator/extend.rb +14 -13
  51. data/lib/sparql/algebra/operator/filter.rb +3 -13
  52. data/lib/sparql/algebra/operator/floor.rb +2 -2
  53. data/lib/sparql/algebra/operator/graph.rb +3 -14
  54. data/lib/sparql/algebra/operator/greater_than.rb +5 -5
  55. data/lib/sparql/algebra/operator/greater_than_or_equal.rb +5 -5
  56. data/lib/sparql/algebra/operator/group.rb +14 -14
  57. data/lib/sparql/algebra/operator/group_concat.rb +1 -1
  58. data/lib/sparql/algebra/operator/hours.rb +1 -1
  59. data/lib/sparql/algebra/operator/if.rb +1 -11
  60. data/lib/sparql/algebra/operator/in.rb +1 -11
  61. data/lib/sparql/algebra/operator/insert.rb +3 -3
  62. data/lib/sparql/algebra/operator/insert_data.rb +2 -2
  63. data/lib/sparql/algebra/operator/iri.rb +1 -1
  64. data/lib/sparql/algebra/operator/is_blank.rb +1 -1
  65. data/lib/sparql/algebra/operator/is_iri.rb +1 -1
  66. data/lib/sparql/algebra/operator/is_literal.rb +1 -1
  67. data/lib/sparql/algebra/operator/is_numeric.rb +1 -1
  68. data/lib/sparql/algebra/operator/join.rb +9 -7
  69. data/lib/sparql/algebra/operator/lang.rb +1 -1
  70. data/lib/sparql/algebra/operator/lang_matches.rb +3 -3
  71. data/lib/sparql/algebra/operator/lcase.rb +2 -2
  72. data/lib/sparql/algebra/operator/left_join.rb +12 -9
  73. data/lib/sparql/algebra/operator/less_than.rb +5 -5
  74. data/lib/sparql/algebra/operator/less_than_or_equal.rb +5 -5
  75. data/lib/sparql/algebra/operator/load.rb +2 -2
  76. data/lib/sparql/algebra/operator/max.rb +1 -1
  77. data/lib/sparql/algebra/operator/md5.rb +1 -1
  78. data/lib/sparql/algebra/operator/min.rb +1 -1
  79. data/lib/sparql/algebra/operator/minus.rb +9 -8
  80. data/lib/sparql/algebra/operator/minutes.rb +1 -1
  81. data/lib/sparql/algebra/operator/modify.rb +1 -1
  82. data/lib/sparql/algebra/operator/month.rb +1 -1
  83. data/lib/sparql/algebra/operator/move.rb +2 -2
  84. data/lib/sparql/algebra/operator/multiply.rb +1 -1
  85. data/lib/sparql/algebra/operator/negate.rb +1 -1
  86. data/lib/sparql/algebra/operator/not.rb +1 -1
  87. data/lib/sparql/algebra/operator/not_equal.rb +2 -2
  88. data/lib/sparql/algebra/operator/notexists.rb +2 -2
  89. data/lib/sparql/algebra/operator/notin.rb +1 -11
  90. data/lib/sparql/algebra/operator/notoneof.rb +2 -2
  91. data/lib/sparql/algebra/operator/now.rb +1 -1
  92. data/lib/sparql/algebra/operator/or.rb +3 -3
  93. data/lib/sparql/algebra/operator/order.rb +2 -12
  94. data/lib/sparql/algebra/operator/path.rb +2 -2
  95. data/lib/sparql/algebra/operator/path_opt.rb +2 -2
  96. data/lib/sparql/algebra/operator/path_plus.rb +2 -2
  97. data/lib/sparql/algebra/operator/path_star.rb +2 -2
  98. data/lib/sparql/algebra/operator/plus.rb +2 -2
  99. data/lib/sparql/algebra/operator/prefix.rb +8 -8
  100. data/lib/sparql/algebra/operator/project.rb +2 -12
  101. data/lib/sparql/algebra/operator/rand.rb +1 -1
  102. data/lib/sparql/algebra/operator/reduced.rb +2 -12
  103. data/lib/sparql/algebra/operator/regex.rb +5 -5
  104. data/lib/sparql/algebra/operator/replace.rb +3 -3
  105. data/lib/sparql/algebra/operator/reverse.rb +2 -2
  106. data/lib/sparql/algebra/operator/round.rb +2 -2
  107. data/lib/sparql/algebra/operator/same_term.rb +8 -5
  108. data/lib/sparql/algebra/operator/sample.rb +1 -1
  109. data/lib/sparql/algebra/operator/seconds.rb +1 -1
  110. data/lib/sparql/algebra/operator/seq.rb +1 -1
  111. data/lib/sparql/algebra/operator/sequence.rb +1 -1
  112. data/lib/sparql/algebra/operator/sha1.rb +1 -1
  113. data/lib/sparql/algebra/operator/sha256.rb +1 -1
  114. data/lib/sparql/algebra/operator/sha384.rb +1 -1
  115. data/lib/sparql/algebra/operator/sha512.rb +1 -1
  116. data/lib/sparql/algebra/operator/slice.rb +2 -12
  117. data/lib/sparql/algebra/operator/str.rb +1 -1
  118. data/lib/sparql/algebra/operator/strafter.rb +2 -2
  119. data/lib/sparql/algebra/operator/strbefore.rb +2 -2
  120. data/lib/sparql/algebra/operator/strdt.rb +2 -2
  121. data/lib/sparql/algebra/operator/strends.rb +2 -2
  122. data/lib/sparql/algebra/operator/strlang.rb +2 -2
  123. data/lib/sparql/algebra/operator/strlen.rb +2 -2
  124. data/lib/sparql/algebra/operator/strstarts.rb +2 -2
  125. data/lib/sparql/algebra/operator/struuid.rb +1 -1
  126. data/lib/sparql/algebra/operator/substr.rb +3 -3
  127. data/lib/sparql/algebra/operator/subtract.rb +1 -1
  128. data/lib/sparql/algebra/operator/sum.rb +1 -1
  129. data/lib/sparql/algebra/operator/table.rb +2 -2
  130. data/lib/sparql/algebra/operator/timezone.rb +1 -1
  131. data/lib/sparql/algebra/operator/tz.rb +1 -1
  132. data/lib/sparql/algebra/operator/ucase.rb +2 -2
  133. data/lib/sparql/algebra/operator/union.rb +7 -6
  134. data/lib/sparql/algebra/operator/update.rb +2 -2
  135. data/lib/sparql/algebra/operator/using.rb +2 -2
  136. data/lib/sparql/algebra/operator/uuid.rb +1 -1
  137. data/lib/sparql/algebra/operator/with.rb +2 -2
  138. data/lib/sparql/algebra/operator/year.rb +1 -1
  139. data/lib/sparql/algebra/query.rb +1 -1
  140. data/lib/sparql/algebra/update.rb +1 -1
  141. data/lib/sparql/algebra/version.rb +1 -1
  142. data/lib/sparql/extensions.rb +1 -1
  143. data/lib/sparql/grammar.rb +104 -3
  144. data/lib/sparql/grammar/meta.rb +1372 -333
  145. data/lib/sparql/grammar/parser11.rb +27 -6
  146. data/lib/sparql/grammar/terminals11.rb +1 -0
  147. data/lib/sparql/results.rb +60 -41
  148. data/lib/sparql/version.rb +1 -1
  149. metadata +14 -8
@@ -13,7 +13,7 @@ module SPARQL; module Algebra
13
13
  # (group () ((??.0 (group_concat ?o)))
14
14
  # (bgp (triple ??.0 :p1 ?o)))))))
15
15
  #
16
- # @see http://www.w3.org/TR/sparql11-query/#defn_aggGroupConcat
16
+ # @see https://www.w3.org/TR/sparql11-query/#defn_aggGroupConcat
17
17
  class GroupConcat < Operator
18
18
  include Aggregate
19
19
 
@@ -9,7 +9,7 @@ module SPARQL; module Algebra
9
9
  # (extend ((?x (hours ?date)))
10
10
  # (bgp (triple ?s :date ?date)))))
11
11
  #
12
- # @see http://www.w3.org/TR/sparql11-query/#func-hours
12
+ # @see https://www.w3.org/TR/sparql11-query/#func-hours
13
13
  class Hours < Operator::Unary
14
14
  include Evaluatable
15
15
 
@@ -10,7 +10,7 @@ module SPARQL; module Algebra
10
10
  # (extend ((?integer (if (= (lang ?o) "ja") true false)))
11
11
  # (bgp (triple ?s ?p ?o))))))
12
12
  #
13
- # @see http://www.w3.org/TR/sparql11-query/#func-if
13
+ # @see https://www.w3.org/TR/sparql11-query/#func-if
14
14
  class If < Operator::Ternary
15
15
  include Evaluatable
16
16
 
@@ -40,16 +40,6 @@ module SPARQL; module Algebra
40
40
  rescue
41
41
  raise TypeError
42
42
  end
43
-
44
- ##
45
- # Returns an optimized version of this query.
46
- #
47
- # Return optimized query
48
- #
49
- # @return [Union, RDF::Query] `self`
50
- def optimize
51
- operands = operands.map(&:optimize)
52
- end
53
43
  end # If
54
44
  end # Operator
55
45
  end; end # SPARQL::Algebra
@@ -6,7 +6,7 @@ module SPARQL; module Algebra
6
6
  # @example
7
7
  # (ask (filter (in 2 1 2 3) (bgp)))
8
8
  #
9
- # @see http://www.w3.org/TR/sparql11-query/#func-in
9
+ # @see https://www.w3.org/TR/sparql11-query/#func-in
10
10
  class In < Operator
11
11
  include Evaluatable
12
12
 
@@ -54,16 +54,6 @@ module SPARQL; module Algebra
54
54
  else RDF::Literal::FALSE
55
55
  end
56
56
  end
57
-
58
- ##
59
- # Returns an optimized version of this query.
60
- #
61
- # Return optimized query
62
- #
63
- # @return [Union, RDF::Query] `self`
64
- def optimize
65
- operands = operands.map(&:optimize)
66
- end
67
57
  end # In
68
58
  end # Operator
69
59
  end; end # SPARQL::Algebra
@@ -9,7 +9,7 @@ module SPARQL; module Algebra
9
9
  # @example
10
10
  # (insert ((triple ?s ?p "q")))
11
11
  #
12
- # @see http://www.w3.org/TR/sparql11-update/#insert
12
+ # @see https://www.w3.org/TR/sparql11-update/#insert
13
13
  class Insert < Operator::Unary
14
14
  include SPARQL::Algebra::Update
15
15
 
@@ -20,7 +20,7 @@ module SPARQL; module Algebra
20
20
  #
21
21
  # @param [RDF::Queryable] queryable
22
22
  # the graph or repository to write
23
- # @param [RDF::Query::Solution] :solutions
23
+ # @param [RDF::Query::Solutions] solutions
24
24
  # Solution to map to patterns for this operation
25
25
  # @param [Hash{Symbol => Object}] options
26
26
  # any additional keyword options
@@ -30,7 +30,7 @@ module SPARQL; module Algebra
30
30
  # Returns queryable.
31
31
  # @raise [IOError]
32
32
  # If `from` does not exist, unless the `silent` operator is present
33
- # @see http://www.w3.org/TR/sparql11-update/
33
+ # @see https://www.w3.org/TR/sparql11-update/
34
34
  def execute(queryable, solutions: nil, **options)
35
35
  # Only binds the first solution
36
36
  solution = solutions.is_a?(RDF::Query::Solutions) ? solutions.first : solutions
@@ -9,7 +9,7 @@ module SPARQL; module Algebra
9
9
  # @example
10
10
  # (insertData ((graph <http://example.org/g1> ((triple :s :p :o)))))
11
11
  #
12
- # @see http://www.w3.org/TR/sparql11-update/#insertData
12
+ # @see https://www.w3.org/TR/sparql11-update/#insertData
13
13
  class InsertData < Operator::Unary
14
14
  include SPARQL::Algebra::Update
15
15
 
@@ -28,7 +28,7 @@ module SPARQL; module Algebra
28
28
  # Returns queryable.
29
29
  # @raise [IOError]
30
30
  # If `from` does not exist, unless the `silent` operator is present
31
- # @see http://www.w3.org/TR/sparql11-update/
31
+ # @see https://www.w3.org/TR/sparql11-update/
32
32
  def execute(queryable, **options)
33
33
  operand.each do |op|
34
34
  debug(options) {"InsertData #{op.to_sxp}"}
@@ -8,7 +8,7 @@ module SPARQL; module Algebra
8
8
  # (extend ((?uri (uri "uri")) (?iri (iri "iri")))
9
9
  # (bgp))))
10
10
  #
11
- # @see http://www.w3.org/TR/sparql11-query/#func-iri
11
+ # @see https://www.w3.org/TR/sparql11-query/#func-iri
12
12
  class IRI < Operator::Unary
13
13
  include Evaluatable
14
14
 
@@ -10,7 +10,7 @@ module SPARQL; module Algebra
10
10
  # (filter (isBlank ?v)
11
11
  # (bgp (triple ?x :p ?v)))))
12
12
  #
13
- # @see http://www.w3.org/TR/sparql11-query/#func-isBlank
13
+ # @see https://www.w3.org/TR/sparql11-query/#func-isBlank
14
14
  class IsBlank < Operator::Unary
15
15
  include Evaluatable
16
16
 
@@ -10,7 +10,7 @@ module SPARQL; module Algebra
10
10
  # (filter (isIRI ?v)
11
11
  # (bgp (triple ?x :p ?v)))))
12
12
  #
13
- # @see http://www.w3.org/TR/sparql11-query/#func-isIRI
13
+ # @see https://www.w3.org/TR/sparql11-query/#func-isIRI
14
14
  class IsIRI < Operator::Unary
15
15
  include Evaluatable
16
16
 
@@ -10,7 +10,7 @@ module SPARQL; module Algebra
10
10
  # (filter (isLiteral ?v)
11
11
  # (bgp (triple ?x :p ?v)))))
12
12
  #
13
- # @see http://www.w3.org/TR/sparql11-query/#func-isLiteral
13
+ # @see https://www.w3.org/TR/sparql11-query/#func-isLiteral
14
14
  class IsLiteral < Operator::Unary
15
15
  include Evaluatable
16
16
 
@@ -12,7 +12,7 @@ module SPARQL; module Algebra
12
12
  # (filter (isNumeric ?v)
13
13
  # (bgp (triple ?x :p ?v)))))
14
14
  #
15
- # @see http://www.w3.org/TR/sparql11-query/#func-isNumeric
15
+ # @see https://www.w3.org/TR/sparql11-query/#func-isNumeric
16
16
  class IsNumeric < Operator::Unary
17
17
  include Evaluatable
18
18
 
@@ -10,7 +10,7 @@ module SPARQL; module Algebra
10
10
  # (graph ?g
11
11
  # (bgp (triple ?s ?q ?v)))))
12
12
  #
13
- # @see http://www.w3.org/TR/sparql11-query/#sparqlAlgebra
13
+ # @see https://www.w3.org/TR/sparql11-query/#sparqlAlgebra
14
14
  class Join < Operator::Binary
15
15
  include Query
16
16
 
@@ -31,9 +31,9 @@ module SPARQL; module Algebra
31
31
  # @yieldreturn [void] ignored
32
32
  # @return [RDF::Query::Solutions]
33
33
  # the resulting solution sequence
34
- # @see http://www.w3.org/TR/sparql11-query/#sparqlAlgebra
35
- # @see http://www.rubydoc.info/github/ruby-rdf/rdf/RDF/Query/Solution#merge-instance_method
36
- # @see http://www.rubydoc.info/github/ruby-rdf/rdf/RDF/Query/Solution#compatible%3F-instance_method
34
+ # @see https://www.w3.org/TR/sparql11-query/#sparqlAlgebra
35
+ # @see https://www.rubydoc.info/github/ruby-rdf/rdf/RDF/Query/Solution#merge-instance_method
36
+ # @see https://www.rubydoc.info/github/ruby-rdf/rdf/RDF/Query/Solution#compatible%3F-instance_method
37
37
  def execute(queryable, **options, &block)
38
38
  # Join(Ω1, Ω2) = { merge(μ1, μ2) | μ1 in Ω1 and μ2 in Ω2, and μ1 and μ2 are compatible }
39
39
  # eval(D(G), Join(P1, P2)) = Join(eval(D(G), P1), eval(D(G), P2))
@@ -67,7 +67,7 @@ module SPARQL; module Algebra
67
67
  end
68
68
 
69
69
  ##
70
- # Returns an optimized version of this query.
70
+ # Optimizes this query.
71
71
  #
72
72
  # Groups of one graph pattern (not a filter) become join(Z, A) and can be replaced by A.
73
73
  # The empty graph pattern Z is the identity for join:
@@ -75,8 +75,10 @@ module SPARQL; module Algebra
75
75
  # Replace join(A, Z) by A
76
76
  #
77
77
  # @return [Join, RDF::Query] `self`
78
- def optimize
79
- ops = operands.map {|o| o.optimize }.select {|o| o.respond_to?(:empty?) && !o.empty?}
78
+ # @return [self]
79
+ # @see SPARQL::Algebra::Expression#optimize!
80
+ def optimize!(**options)
81
+ ops = operands.map {|o| o.optimize(**options) }.select {|o| o.respond_to?(:empty?) && !o.empty?}
80
82
  @operands = ops
81
83
  self
82
84
  end
@@ -3,7 +3,7 @@ module SPARQL; module Algebra
3
3
  ##
4
4
  # The SPARQL `lang` operator.
5
5
  #
6
- # @see http://www.w3.org/TR/sparql11-query/#func-lang
6
+ # @see https://www.w3.org/TR/sparql11-query/#func-lang
7
7
  class Lang < Operator::Unary
8
8
  include Evaluatable
9
9
 
@@ -8,8 +8,8 @@ module SPARQL; module Algebra
8
8
  # (filter (langMatches (lang ?v) "en-GB")
9
9
  # (bgp (triple :x ?p ?v))))
10
10
  #
11
- # @see http://www.w3.org/TR/sparql11-query/#func-langMatches
12
- # @see http://tools.ietf.org/html/rfc4647#section-3.3.1
11
+ # @see https://www.w3.org/TR/sparql11-query/#func-langMatches
12
+ # @see https://tools.ietf.org/html/rfc4647#section-3.3.1
13
13
  class LangMatches < Operator::Binary
14
14
  include Evaluatable
15
15
 
@@ -23,7 +23,7 @@ module SPARQL; module Algebra
23
23
  # a simple literal containing a language tag
24
24
  # @param [RDF::Literal] language_range
25
25
  # a simple literal containing a language range, per
26
- # [RFC 4647 section 2.1](http://tools.ietf.org/html/rfc4647#section-2.1)
26
+ # [RFC 4647 section 2.1](https://tools.ietf.org/html/rfc4647#section-2.1)
27
27
  # @return [RDF::Literal::Boolean] `true` or `false`
28
28
  # @raise [TypeError] if either operand is unbound
29
29
  # @raise [TypeError] if either operand is not a simple literal
@@ -6,8 +6,8 @@ module SPARQL; module Algebra
6
6
  # @example
7
7
  # (lcase ?x)
8
8
  #
9
- # @see http://www.w3.org/TR/sparql11-query/#func-lcase
10
- # @see http://www.w3.org/TR/xpath-functions/#func-lcase
9
+ # @see https://www.w3.org/TR/sparql11-query/#func-lcase
10
+ # @see https://www.w3.org/TR/xpath-functions/#func-lcase
11
11
  class LCase < Operator::Unary
12
12
  include Evaluatable
13
13
 
@@ -10,7 +10,7 @@ module SPARQL; module Algebra
10
10
  # (bgp (triple ?y :q ?w))
11
11
  # (= ?v 2)))
12
12
  #
13
- # @see http://www.w3.org/TR/sparql11-query/#sparqlAlgebra
13
+ # @see https://www.w3.org/TR/sparql11-query/#sparqlAlgebra
14
14
  class LeftJoin < Operator
15
15
  include Query
16
16
 
@@ -31,9 +31,9 @@ module SPARQL; module Algebra
31
31
  # @yieldreturn [void] ignored
32
32
  # @return [RDF::Query::Solutions]
33
33
  # the resulting solution sequence
34
- # @see http://www.w3.org/TR/sparql11-query/#sparqlAlgebra
35
- # @see http://www.rubydoc.info/github/ruby-rdf/rdf/RDF/Query/Solution#merge-instance_method
36
- # @see http://www.rubydoc.info/github/ruby-rdf/rdf/RDF/Query/Solution#compatible%3F-instance_method
34
+ # @see https://www.w3.org/TR/sparql11-query/#sparqlAlgebra
35
+ # @see https://www.rubydoc.info/github/ruby-rdf/rdf/RDF/Query/Solution#merge-instance_method
36
+ # @see https://www.rubydoc.info/github/ruby-rdf/rdf/RDF/Query/Solution#compatible%3F-instance_method
37
37
  def execute(queryable, **options, &block)
38
38
  filter = operand(2)
39
39
 
@@ -83,14 +83,17 @@ module SPARQL; module Algebra
83
83
  end
84
84
 
85
85
  ##
86
- # Returns an optimized version of this query.
86
+ # Optimizes this query.
87
87
  #
88
88
  # If optimize operands, and if the first two operands are both Queries, replace
89
89
  # with the unique sum of the query elements
90
90
  #
91
- # @return [Union, RDF::Query] `self`
92
- def optimize
93
- ops = operands.map {|o| o.optimize }.select {|o| o.respond_to?(:empty?) && !o.empty?}
91
+ # @return [Object] a copy of `self`
92
+ # @see SPARQL::Algebra::Expression#optimize
93
+ # FIXME
94
+ def optimize!(**options)
95
+ return self
96
+ ops = operands.map {|o| o.optimize(**options) }.select {|o| o.respond_to?(:empty?) && !o.empty?}
94
97
  expr = ops.pop unless ops.last.executable?
95
98
  expr = nil if expr.respond_to?(:true?) && expr.true?
96
99
 
@@ -102,7 +105,7 @@ module SPARQL; module Algebra
102
105
  when 1
103
106
  expr ? Filter.new(expr, ops.first) : ops.first
104
107
  else
105
- expr ? LeftJoin(ops[0], ops[1], expr) : LeftJoin(ops[0], ops[1])
108
+ expr ? LeftJoin.new(ops[0], ops[1], expr) : LeftJoin.new(ops[0], ops[1])
106
109
  end
107
110
  end
108
111
  end # LeftJoin
@@ -6,11 +6,11 @@ module SPARQL; module Algebra
6
6
  # @example
7
7
  # (< ?x ?y)
8
8
  #
9
- # @see http://www.w3.org/TR/sparql11-query/#OperatorMapping
10
- # @see http://www.w3.org/TR/xpath-functions/#func-compare
11
- # @see http://www.w3.org/TR/xpath-functions/#func-numeric-less-than
12
- # @see http://www.w3.org/TR/xpath-functions/#func-boolean-less-than
13
- # @see http://www.w3.org/TR/xpath-functions/#func-dateTime-less-than
9
+ # @see https://www.w3.org/TR/sparql11-query/#OperatorMapping
10
+ # @see https://www.w3.org/TR/xpath-functions/#func-compare
11
+ # @see https://www.w3.org/TR/xpath-functions/#func-numeric-less-than
12
+ # @see https://www.w3.org/TR/xpath-functions/#func-boolean-less-than
13
+ # @see https://www.w3.org/TR/xpath-functions/#func-dateTime-less-than
14
14
  class LessThan < Compare
15
15
  NAME = :<
16
16
 
@@ -6,11 +6,11 @@ module SPARQL; module Algebra
6
6
  # @example
7
7
  # (<= ?x ?y)
8
8
  #
9
- # @see http://www.w3.org/TR/sparql11-query/#OperatorMapping
10
- # @see http://www.w3.org/TR/xpath-functions/#func-compare
11
- # @see http://www.w3.org/TR/xpath-functions/#func-numeric-less-than
12
- # @see http://www.w3.org/TR/xpath-functions/#func-boolean-less-than
13
- # @see http://www.w3.org/TR/xpath-functions/#func-dateTime-less-than
9
+ # @see https://www.w3.org/TR/sparql11-query/#OperatorMapping
10
+ # @see https://www.w3.org/TR/xpath-functions/#func-compare
11
+ # @see https://www.w3.org/TR/xpath-functions/#func-numeric-less-than
12
+ # @see https://www.w3.org/TR/xpath-functions/#func-boolean-less-than
13
+ # @see https://www.w3.org/TR/xpath-functions/#func-dateTime-less-than
14
14
  class LessThanOrEqual < Compare
15
15
  NAME = :<=
16
16
 
@@ -9,7 +9,7 @@ module SPARQL; module Algebra
9
9
  # @example
10
10
  # (load <remote> <g>)
11
11
  #
12
- # @see http://www.w3.org/TR/sparql11-update/#load
12
+ # @see https://www.w3.org/TR/sparql11-update/#load
13
13
  class Load < Operator
14
14
  include SPARQL::Algebra::Update
15
15
 
@@ -28,7 +28,7 @@ module SPARQL; module Algebra
28
28
  # Returns queryable.
29
29
  # @raise [IOError]
30
30
  # If `from` does not exist, unless the `silent` operator is present
31
- # @see http://www.w3.org/TR/sparql11-update/
31
+ # @see https://www.w3.org/TR/sparql11-update/
32
32
  def execute(queryable, **options)
33
33
  debug(options) {"Load"}
34
34
  silent = operands.first == :silent
@@ -10,7 +10,7 @@ module SPARQL; module Algebra
10
10
  # (group () ((??.0 (max ?o)))
11
11
  # (bgp (triple ?s ?p ?o))))))
12
12
  #
13
- # @see http://www.w3.org/TR/sparql11-query/#defn_aggMax
13
+ # @see https://www.w3.org/TR/sparql11-query/#defn_aggMax
14
14
  class Max < Operator
15
15
  include Aggregate
16
16
 
@@ -13,7 +13,7 @@ module SPARQL; module Algebra
13
13
  # (extend ((?hash (md5 ?l)))
14
14
  # (bgp (triple :s1 :str ?l)))))
15
15
  #
16
- # @see http://www.w3.org/TR/sparql11-query/#func-md5
16
+ # @see https://www.w3.org/TR/sparql11-query/#func-md5
17
17
  class MD5 < Operator::Unary
18
18
  include Evaluatable
19
19
 
@@ -10,7 +10,7 @@ module SPARQL; module Algebra
10
10
  # (group () ((??.0 (min ?o)))
11
11
  # (bgp (triple ?s ?p ?o))))))
12
12
  #
13
- # @see http://www.w3.org/TR/sparql11-query/#defn_aggMin
13
+ # @see https://www.w3.org/TR/sparql11-query/#defn_aggMin
14
14
  class Min < Operator
15
15
  include Aggregate
16
16
 
@@ -11,8 +11,8 @@ module SPARQL; module Algebra
11
11
  # (filter (|| (= ?type ex:Reptile) (= ?type ex:Insect))
12
12
  # (bgp (triple ?animal <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?type))))))
13
13
  #
14
- # @see http://www.w3.org/TR/xpath-functions/#func-numeric-unary-minus
15
- # @see http://www.w3.org/TR/sparql11-query/#sparqlAlgebra
14
+ # @see https://www.w3.org/TR/xpath-functions/#func-numeric-unary-minus
15
+ # @see https://www.w3.org/TR/sparql11-query/#sparqlAlgebra
16
16
  class Minus < Operator::Binary
17
17
  include Query
18
18
 
@@ -33,8 +33,8 @@ module SPARQL; module Algebra
33
33
  # @yieldreturn [void] ignored
34
34
  # @return [RDF::Query::Solutions]
35
35
  # the resulting solution sequence
36
- # @see http://www.w3.org/TR/2013/REC-sparql11-query-20130321/#defn_algMinus
37
- # @see http://www.w3.org/TR/2013/REC-sparql11-query-20130321/#negation
36
+ # @see https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#defn_algMinus
37
+ # @see https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#negation
38
38
  def execute(queryable, **options, &block)
39
39
  # Let Ω1 and Ω2 be multisets of solution mappings. We define:
40
40
  #
@@ -52,16 +52,17 @@ module SPARQL; module Algebra
52
52
  end
53
53
 
54
54
  ##
55
- # Returns an optimized version of this query.
55
+ # Optimizes this query.
56
56
  #
57
57
  # Groups of one graph pattern (not a filter) become join(Z, A) and can be replaced by A.
58
58
  # The empty graph pattern Z is the identity for join:
59
59
  # Replace join(Z, A) by A
60
60
  # Replace join(A, Z) by A
61
61
  #
62
- # @return [Join, RDF::Query] `self`
63
- def optimize
64
- ops = operands.map {|o| o.optimize }.select {|o| o.respond_to?(:empty?) && !o.empty?}
62
+ # @return [self]
63
+ # @see SPARQL::Algebra::Expression#optimize!
64
+ def optimize!(**options)
65
+ ops = operands.map {|o| o.optimize(**options) }.select {|o| o.respond_to?(:empty?) && !o.empty?}
65
66
  @operands = ops
66
67
  self
67
68
  end
@@ -11,7 +11,7 @@ module SPARQL; module Algebra
11
11
  # (extend ((?x (minutes ?date)))
12
12
  # (bgp (triple ?s :date ?date)))))
13
13
  #
14
- # @see http://www.w3.org/TR/sparql11-query/#func-minutes
14
+ # @see https://www.w3.org/TR/sparql11-query/#func-minutes
15
15
  class Minutes < Operator::Unary
16
16
  include Evaluatable
17
17