sparql 1.1.3 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CREDITS +1 -0
- data/VERSION +1 -1
- data/lib/sparql/algebra/extensions.rb +10 -0
- data/lib/sparql/algebra/operator.rb +2 -0
- data/lib/sparql/algebra/operator/asc.rb +1 -1
- data/lib/sparql/algebra/operator/compare.rb +13 -3
- data/lib/sparql/algebra/operator/order.rb +8 -14
- data/lib/sparql/algebra/operator/project.rb +1 -1
- data/lib/sparql/algebra/operator/table.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ed52de8b3772ffc718813e0a7c9445fd37d27ec
|
4
|
+
data.tar.gz: b7aa4ec3157690796c0e12fc74bcf9328c740c2a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 007315130ab3bc5f734e47c96d74f501460feb5e22229106b16c32dad35f24c59e35a47654fff1cc9f88610a8628bb43a33773cd812503800d954e52f3a3e1da
|
7
|
+
data.tar.gz: 697a8dde03ef5b117820d585f7e30d58c9f1e17eb8baa139f77d4f7260d6417dd6673e0d1e1bea181d2dd60f66ce8bc176dd7575d6caa056faeff03d103ed2ce
|
data/CREDITS
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.4
|
@@ -289,6 +289,8 @@ module SPARQL; module Algebra
|
|
289
289
|
operand
|
290
290
|
when TrueClass, FalseClass, Numeric, String, DateTime, Date, Time
|
291
291
|
RDF::Literal(operand)
|
292
|
+
when NilClass
|
293
|
+
nil
|
292
294
|
else raise TypeError, "invalid SPARQL::Algebra::Operator operand: #{operand.inspect}"
|
293
295
|
end
|
294
296
|
end
|
@@ -16,7 +16,7 @@ module SPARQL; module Algebra
|
|
16
16
|
NAME = :asc
|
17
17
|
|
18
18
|
##
|
19
|
-
# Returns the evaluation of
|
19
|
+
# Returns the evaluation of its operand. Default comparison is in
|
20
20
|
# ascending order. Ordering is applied in {Order}.
|
21
21
|
#
|
22
22
|
# @param [RDF::Query::Solution] bindings
|
@@ -52,7 +52,8 @@ module SPARQL; module Algebra
|
|
52
52
|
when right.simple? && left.datatype == RDF::XSD.string && right.value == left.value
|
53
53
|
RDF::Literal(-1)
|
54
54
|
|
55
|
-
else
|
55
|
+
else
|
56
|
+
left <=> right
|
56
57
|
end
|
57
58
|
|
58
59
|
when left.is_a?(RDF::URI) && right.is_a?(RDF::URI)
|
@@ -65,13 +66,22 @@ module SPARQL; module Algebra
|
|
65
66
|
RDF::Literal(0)
|
66
67
|
|
67
68
|
# SPARQL also fixes an order between some kinds of RDF terms that would not otherwise be ordered:
|
68
|
-
|
69
|
+
|
70
|
+
when left.nil? && !right.nil?
|
71
|
+
RDF::Literal(-1)
|
72
|
+
when right.nil?
|
73
|
+
RDF::Literal(1)
|
74
|
+
|
69
75
|
when left.is_a?(RDF::Node) && right.is_a?(RDF::Term)
|
70
76
|
RDF::Literal(-1)
|
71
77
|
when right.is_a?(RDF::Node) && left.is_a?(RDF::Term)
|
72
78
|
RDF::Literal(1)
|
73
79
|
|
74
|
-
|
80
|
+
when left.is_a?(RDF::Node) && right.is_a?(RDF::URI)
|
81
|
+
RDF::Literal(-1)
|
82
|
+
when right.is_a?(RDF::Node) && left.is_a?(RDF::URI)
|
83
|
+
RDF::Literal(1)
|
84
|
+
|
75
85
|
when left.is_a?(RDF::URI) && right.is_a?(RDF::Term)
|
76
86
|
RDF::Literal(-1)
|
77
87
|
when right.is_a?(RDF::URI) && left.is_a?(RDF::Term)
|
@@ -32,26 +32,20 @@ module SPARQL; module Algebra
|
|
32
32
|
# the resulting solution sequence
|
33
33
|
# @see http://www.w3.org/TR/rdf-sparql-query/#sparqlAlgebra
|
34
34
|
def execute(queryable, options = {}, &block)
|
35
|
+
|
35
36
|
debug(options) {"Order"}
|
36
37
|
@solutions = queryable.query(operands.last, options.merge(:depth => options[:depth].to_i + 1)).order do |a, b|
|
37
|
-
operand(0).inject(
|
38
|
+
operand(0).inject(0) do |memo, op|
|
38
39
|
debug(options) {"(order) #{op.inspect}"}
|
39
|
-
memo
|
40
|
+
memo = begin
|
40
41
|
a_eval = op.evaluate(a, options.merge(:queryable => queryable, :depth => options[:depth].to_i + 1)) rescue nil
|
41
42
|
b_eval = op.evaluate(b, options.merge(:queryable => queryable, :depth => options[:depth].to_i + 1)) rescue nil
|
42
|
-
comp =
|
43
|
-
RDF::Literal(-1)
|
44
|
-
elsif b_eval.nil?
|
45
|
-
RDF::Literal(1)
|
46
|
-
elsif op.is_a?(RDF::Query::Variable)
|
47
|
-
a_eval <=> b_eval
|
48
|
-
else
|
49
|
-
Operator::Compare.evaluate(a_eval, b_eval)
|
50
|
-
end
|
43
|
+
comp = Operator::Compare.evaluate(a_eval, b_eval).to_i
|
51
44
|
comp = -comp if op.is_a?(Operator::Desc)
|
52
|
-
comp
|
53
|
-
end
|
54
|
-
|
45
|
+
comp
|
46
|
+
end if memo == 0
|
47
|
+
memo
|
48
|
+
end
|
55
49
|
end
|
56
50
|
@solutions.each(&block) if block_given?
|
57
51
|
@solutions
|
@@ -36,7 +36,7 @@ module SPARQL; module Algebra
|
|
36
36
|
operands[1..-1].each do |row|
|
37
37
|
next unless row.is_a?(Array)
|
38
38
|
bindings = row[1..-1].inject({}) do |memo, (var, value)|
|
39
|
-
memo[var.to_sym] = value
|
39
|
+
memo[var.to_sym] = value unless value == :undef
|
40
40
|
memo
|
41
41
|
end
|
42
42
|
@solutions << RDF::Query::Solution.new(bindings)
|
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: 1.1.
|
4
|
+
version: 1.1.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: 2014-
|
12
|
+
date: 2014-07-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rdf
|