bmg 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/bmg/algebra.rb +11 -1
- data/lib/bmg/operator/constants.rb +5 -3
- data/lib/bmg/operator/image.rb +26 -5
- data/lib/bmg/version.rb +1 -1
- metadata +3 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b43a1cda1c1650f7678db8e4a9213e7065d26a5
|
4
|
+
data.tar.gz: 6f130fa599d6d24b4eaa0450883cfef539b95e6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ac9c79f0c348dbd7685a5c922a28a315192a72ce6b42da708b3233f1fb53da1b64da97659ddb3935aad39a4bdf3141d06be24ff102d202be0e7d8677fbb9f8a
|
7
|
+
data.tar.gz: 40aea311e6e4d372ca07ffd91fd5c6ad102f3dd67da5443287121233848e3470ccded49eea97ef4e1f9d4a01afebeb4b43425e7426081ee2472cb0b8a95833ed
|
data/lib/bmg/algebra.rb
CHANGED
@@ -74,7 +74,17 @@ module Bmg
|
|
74
74
|
protected :_rename
|
75
75
|
|
76
76
|
def restrict(predicate)
|
77
|
-
|
77
|
+
predicate = Predicate.coerce(predicate)
|
78
|
+
if predicate.tautology?
|
79
|
+
self
|
80
|
+
else
|
81
|
+
type = self.type.restrict(predicate)
|
82
|
+
if predicate.contradiction?
|
83
|
+
Relation.empty(type)
|
84
|
+
else
|
85
|
+
_restrict type, predicate
|
86
|
+
end
|
87
|
+
end
|
78
88
|
end
|
79
89
|
|
80
90
|
def _restrict(type, predicate)
|
@@ -36,18 +36,20 @@ module Bmg
|
|
36
36
|
protected ### optimization
|
37
37
|
|
38
38
|
def _restrict(type, predicate)
|
39
|
+
# bottom_p makes no reference to constants, top_p possibly
|
40
|
+
# does...
|
39
41
|
top_p, bottom_p = predicate.and_split(constants.keys)
|
40
42
|
if top_p.tautology?
|
41
|
-
# push all situation
|
43
|
+
# push all situation: predicate made no reference to constants
|
42
44
|
result = operand
|
43
|
-
result = result.restrict(bottom_p)
|
45
|
+
result = result.restrict(bottom_p)
|
44
46
|
result = result.constants(constants)
|
45
47
|
result
|
46
48
|
elsif (top_p.free_variables - constants.keys).empty?
|
47
49
|
# top_p applies to constants only
|
48
50
|
if eval = top_p.evaluate(constants)
|
49
51
|
result = operand
|
50
|
-
result = result.restrict(bottom_p)
|
52
|
+
result = result.restrict(bottom_p)
|
51
53
|
result = result.constants(constants)
|
52
54
|
result
|
53
55
|
else
|
data/lib/bmg/operator/image.rb
CHANGED
@@ -58,14 +58,35 @@ module Bmg
|
|
58
58
|
|
59
59
|
def _restrict(type, predicate)
|
60
60
|
on_as, rest = predicate.and_split([as])
|
61
|
-
if
|
61
|
+
if rest.tautology?
|
62
|
+
# push none situation: on_as is still the full predicate
|
62
63
|
super
|
63
64
|
else
|
64
|
-
|
65
|
-
|
66
|
-
|
65
|
+
# rest makes no reference to `as` and can be pushed
|
66
|
+
# down...
|
67
|
+
new_left = left.restrict(rest)
|
68
|
+
|
69
|
+
# regarding right... rest possibly makes references to the
|
70
|
+
# join key, but also to left attributes... let split again
|
71
|
+
# on the join key attributes, to try to remove spurious
|
72
|
+
# attributes for right...
|
73
|
+
on_on_and_more, left_only = rest.and_split(on)
|
74
|
+
|
75
|
+
# it's not guaranteed! let now check whether the split led
|
76
|
+
# to a situation where the predicate on `on` attributes
|
77
|
+
# actually refers to no other ones...
|
78
|
+
if !on_on_and_more.tautology? and (on_on_and_more.free_variables - on).empty?
|
79
|
+
new_right = right.restrict(on_on_and_more)
|
80
|
+
else
|
81
|
+
new_right = right
|
82
|
+
end
|
83
|
+
|
84
|
+
# This is the image itself
|
67
85
|
opt = new_left.image(new_right, as, on, options)
|
68
|
-
|
86
|
+
|
87
|
+
# finaly, it still needs to be kept on the final node
|
88
|
+
opt = opt.restrict(on_as)
|
89
|
+
|
69
90
|
opt
|
70
91
|
end
|
71
92
|
rescue Predicate::NotSupportedError
|
data/lib/bmg/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bmg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bernard Lambeau
|
@@ -16,20 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
20
|
-
- - ">="
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: 1.1.1
|
19
|
+
version: '1.2'
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
24
|
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: '1.
|
30
|
-
- - ">="
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: 1.1.1
|
26
|
+
version: '1.2'
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: rake
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|