sparql 3.2.3 → 3.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 853c52b99bab0b9455b25a81c8c946e5bcb1429dddadf010b66315f1dbafda51
4
- data.tar.gz: 90d89877c031476efdaa1d0b119b2a2404925186b4e0b3de99818d75ead76bff
3
+ metadata.gz: 932897287930ea7265a07628e73c13a06b02b9e0d1572b578356166d3c8fe70a
4
+ data.tar.gz: 9d17310bc07080475780c8acccbe57acb4bbeb40e3f66ab7b74a09b15ccf0863
5
5
  SHA512:
6
- metadata.gz: 98816c81664147aa0fa4ccd90ed14461eb51b652b011395f38f044934c2ff335197fbc3d2d7f447771a5b1e46fa24042aef45fd1f95356b91f52bafee48d1a72
7
- data.tar.gz: 5545d7ddd245d73382229ed6f9996b24bd66a4285ee18d6295f697202ad5901eb4221cbf2533ef1539b98ccc0c095519e531b541db3e1c4757d813ab888cb9fd
6
+ metadata.gz: e701784500aece828b2cfd41eb0af78a809bda575eed047158e962ff38678d524b179c0c3faef21fc5b5724894ada3066637b608778a1809fdc7b9bda2ffe2a2
7
+ data.tar.gz: 77c2520a5f4923a1fe27d589ea6a09b6f5a36fa9c17b564184f206971204fec6988b0941c350e10d812ccfd9b0934e6ae629b82207abfaabf8d7bcc3a380ab33
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.2.3
1
+ 3.2.4
@@ -140,7 +140,7 @@ module SPARQL; module Algebra
140
140
  logger = options[:logger]
141
141
  options.delete_if {|k, v| [:debug, :logger, :depth, :prefixes, :base_uri, :update, :validate].include?(k) }
142
142
  begin
143
- # Due to confusiong over (triple) and special-case for (qtriple)
143
+ # Due to confusion over (triple) and special-case for (qtriple)
144
144
  if operator == RDF::Query::Pattern
145
145
  options = options.merge(quoted: true) if sse.first == :qtriple
146
146
  elsif operator == Operator::Triple && PATTERN_PARENTS.include?(parent_operator)
@@ -84,6 +84,11 @@ module SPARQL; module Algebra
84
84
  debug(options) {"Extend"}
85
85
  @solutions = operand(1).execute(queryable, depth: options[:depth].to_i + 1, **options)
86
86
  @solutions.each do |solution|
87
+ # Re-bind to bindings, if defined, as they might not be found in solution
88
+ options[:bindings].each_binding do |name, value|
89
+ solution[name] = value if operands.first.variables.include?(name)
90
+ end if options[:bindings] && operands.first.respond_to?(:variables)
91
+
87
92
  debug(options) {"===> soln #{solution.to_h.inspect}"}
88
93
  operand(0).each do |(var, expr)|
89
94
  begin
@@ -49,6 +49,11 @@ module SPARQL; module Algebra
49
49
  opts = options.merge(queryable: queryable, depth: options[:depth].to_i + 1)
50
50
  @solutions = RDF::Query::Solutions()
51
51
  queryable.query(operands.last, depth: options[:depth].to_i + 1, **options) do |solution|
52
+ # Re-bind to bindings, if defined, as they might not be found in solution
53
+ options[:bindings].each_binding do |name, value|
54
+ solution[name] ||= value if operands.first.variables.include?(name)
55
+ end if options[:bindings] && operands.first.respond_to?(:variables)
56
+
52
57
  begin
53
58
  pass = boolean(operands.first.evaluate(solution, **opts)).true?
54
59
  debug(options) {"(filter) #{pass.inspect} #{solution.to_h.inspect}"}
@@ -66,6 +66,11 @@ module SPARQL; module Algebra
66
66
  load_left = true
67
67
  right.each do |s2|
68
68
  s = s2.merge(s1)
69
+ # Re-bind to bindings, if defined, as they might not be found in solution
70
+ options[:bindings].each_binding do |name, value|
71
+ s[name] = value if filter.variables.include?(name)
72
+ end if options[:bindings] && filter.respond_to?(:variables)
73
+
69
74
  expr = filter ? boolean(filter.evaluate(s)).true? : true rescue false
70
75
  debug(options) {"===>(evaluate) #{s.inspect}"} if filter
71
76
 
@@ -0,0 +1,86 @@
1
+ module SPARQL; module Algebra
2
+ class Operator
3
+ ##
4
+ # The SPARQL Service operator.
5
+ #
6
+ # [59] ServiceGraphPattern ::= 'SERVICE' 'SILENT'? VarOrIri GroupGraphPattern
7
+ #
8
+ # @example SPARQL Grammar
9
+ # PREFIX : <http://example.org/>
10
+ #
11
+ # SELECT ?s ?o1 ?o2 {
12
+ # ?s ?p1 ?o1 .
13
+ # SERVICE <http://example.org/sparql> {
14
+ # ?s ?p2 ?o2
15
+ # }
16
+ # }
17
+ #
18
+ # @example SSE
19
+ # (prefix ((: <http://example.org/>))
20
+ # (project (?s ?o1 ?o2)
21
+ # (join
22
+ # (bgp (triple ?s ?p1 ?o1))
23
+ # (service :sparql
24
+ # (bgp (triple ?s ?p2 ?o2))))))
25
+ #
26
+ # @see https://www.w3.org/TR/sparql11-query/#QSynIRI
27
+ class Service < Operator
28
+ include Query
29
+
30
+ NAME = [:service]
31
+
32
+ ##
33
+ # Executes this query on the given `queryable` graph or repository.
34
+ # Really a pass-through, as this is a syntactic object used for providing
35
+ # graph_name for URIs.
36
+ #
37
+ # @param [RDF::Queryable] queryable
38
+ # the graph or repository to query
39
+ # @param [Hash{Symbol => Object}] options
40
+ # any additional keyword options
41
+ # @yield [solution]
42
+ # each matching solution, statement or boolean
43
+ # @yieldparam [RDF::Statement, RDF::Query::Solution, Boolean] solution
44
+ # @yieldreturn [void] ignored
45
+ # @return [RDF::Query::Solutions]
46
+ # the resulting solution sequence
47
+ # @see https://www.w3.org/TR/sparql11-query/#sparqlAlgebra
48
+ def execute(queryable, **options, &block)
49
+ debug(options) {"Service"}
50
+ silent = operands.first == :silent
51
+ location, query = operands
52
+ query_sparql = query.to_sparql
53
+ debug(options) {"query: #{query_sparql}"}
54
+ raise NotImplementedError, "SERVICE operator not implemented"
55
+ end
56
+
57
+ ##
58
+ # Returns an optimized version of this query.
59
+ #
60
+ # Replace with the query with URIs having their lexical shortcut removed
61
+ #
62
+ # @return [Prefix] a copy of `self`
63
+ # @see SPARQL::Algebra::Expression#optimize
64
+ def optimize(**options)
65
+ operands.last.optimize(**options)
66
+ end
67
+
68
+ ##
69
+ #
70
+ # Returns a partial SPARQL grammar for this term.
71
+ #
72
+ # @return [String]
73
+ def to_sparql(**options)
74
+ silent = operands.first == :silent
75
+ ops = silent ? operands[1..-1] : operands
76
+ location, query = ops
77
+
78
+
79
+ str = "SERVICE "
80
+ str << "SILENT " if silent
81
+ str << location.to_sparql(**options) + " {" + query.to_sparql(**options) + "}"
82
+ str
83
+ end
84
+ end # Service
85
+ end # Operator
86
+ end; end # SPARQL::Algebra
@@ -134,6 +134,7 @@ module SPARQL; module Algebra
134
134
  autoload :Prefix, 'sparql/algebra/operator/prefix'
135
135
  autoload :Project, 'sparql/algebra/operator/project'
136
136
  autoload :Reduced, 'sparql/algebra/operator/reduced'
137
+ autoload :Service, 'sparql/algebra/operator/service'
137
138
  autoload :Slice, 'sparql/algebra/operator/slice'
138
139
  autoload :Table, 'sparql/algebra/operator/table'
139
140
  autoload :Union, 'sparql/algebra/operator/union'
@@ -236,6 +237,7 @@ module SPARQL; module Algebra
236
237
  when :seconds then Seconds
237
238
  when :seq then Seq
238
239
  when :sequence then Sequence
240
+ when :service then Service
239
241
  when :sha1 then SHA1
240
242
  when :sha256 then SHA256
241
243
  when :sha384 then SHA384
@@ -916,6 +916,19 @@ module SPARQL::Grammar
916
916
  end
917
917
  end
918
918
 
919
+ # [59] ServiceGraphPattern ::= 'SERVICE' 'SILENT'? VarOrIri GroupGraphPattern
920
+ #
921
+ # Input from `data` is TODO.
922
+ # Output to prod_data is TODO.
923
+ production(:ServiceGraphPattern) do |input, data, callback|
924
+ args = []
925
+ args << :silent if data[:silent]
926
+ args << (data[:VarOrIri]).last
927
+ args << data.fetch(:query, [SPARQL::Algebra::Operator::BGP.new]).first
928
+ service = SPARQL::Algebra::Expression.for(:service, *args)
929
+ add_prod_data(:query, service)
930
+ end
931
+
919
932
  # [60] Bind ::= 'BIND' '(' Expression 'AS' Var ')'
920
933
  #
921
934
  # Input from `data` is TODO.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sparql
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.3
4
+ version: 3.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregg Kellogg
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-05-05 00:00:00.000000000 Z
12
+ date: 2022-06-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rdf
@@ -20,7 +20,7 @@ dependencies:
20
20
  version: '3.2'
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 3.2.7
23
+ version: 3.2.8
24
24
  type: :runtime
25
25
  prerelease: false
26
26
  version_requirements: !ruby/object:Gem::Requirement
@@ -30,7 +30,7 @@ dependencies:
30
30
  version: '3.2'
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 3.2.7
33
+ version: 3.2.8
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: rdf-aggregate-repo
36
36
  requirement: !ruby/object:Gem::Requirement
@@ -389,6 +389,7 @@ files:
389
389
  - lib/sparql/algebra/operator/seconds.rb
390
390
  - lib/sparql/algebra/operator/seq.rb
391
391
  - lib/sparql/algebra/operator/sequence.rb
392
+ - lib/sparql/algebra/operator/service.rb
392
393
  - lib/sparql/algebra/operator/sha1.rb
393
394
  - lib/sparql/algebra/operator/sha256.rb
394
395
  - lib/sparql/algebra/operator/sha384.rb