axiom-optimizer 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +2 -1
- data/.rubocop.yml +6 -0
- data/.travis.yml +16 -20
- data/CONTRIBUTING.md +1 -2
- data/Gemfile +3 -1
- data/Gemfile.devtools +28 -18
- data/README.md +7 -13
- data/TODO +6 -5
- data/axiom-optimizer.gemspec +3 -3
- data/config/flay.yml +1 -1
- data/config/reek.yml +5 -29
- data/config/rubocop.yml +16 -10
- data/lib/axiom/optimizer.rb +3 -7
- data/lib/axiom/optimizer/algebra/difference.rb +2 -2
- data/lib/axiom/optimizer/algebra/extension.rb +6 -6
- data/lib/axiom/optimizer/algebra/intersection.rb +2 -2
- data/lib/axiom/optimizer/algebra/join.rb +4 -4
- data/lib/axiom/optimizer/algebra/product.rb +4 -4
- data/lib/axiom/optimizer/algebra/projection.rb +5 -5
- data/lib/axiom/optimizer/algebra/rename.rb +10 -10
- data/lib/axiom/optimizer/algebra/restriction.rb +8 -9
- data/lib/axiom/optimizer/algebra/summarization.rb +7 -7
- data/lib/axiom/optimizer/algebra/union.rb +2 -2
- data/lib/axiom/optimizer/function.rb +4 -6
- data/lib/axiom/optimizer/function/binary.rb +2 -2
- data/lib/axiom/optimizer/function/connective/binary.rb +1 -1
- data/lib/axiom/optimizer/function/connective/negation.rb +1 -1
- data/lib/axiom/optimizer/function/predicate.rb +1 -1
- data/lib/axiom/optimizer/function/predicate/comparable.rb +8 -6
- data/lib/axiom/optimizer/function/predicate/enumerable.rb +2 -2
- data/lib/axiom/optimizer/function/unary.rb +1 -1
- data/lib/axiom/optimizer/relation/operation/binary.rb +12 -12
- data/lib/axiom/optimizer/relation/operation/reverse.rb +9 -9
- data/lib/axiom/optimizer/relation/operation/{order.rb → sorted.rb} +15 -15
- data/lib/axiom/optimizer/relation/operation/unary.rb +7 -7
- data/lib/axiom/optimizer/support/predicate_partition.rb +11 -13
- data/lib/axiom/optimizer/version.rb +1 -1
- data/spec/integration/axiom/algebra/difference/optimize_spec.rb +12 -12
- data/spec/integration/axiom/algebra/intersection/optimize_spec.rb +12 -12
- data/spec/integration/axiom/algebra/join/optimize_spec.rb +6 -6
- data/spec/integration/axiom/algebra/product/optimize_spec.rb +10 -10
- data/spec/integration/axiom/algebra/projection/optimize_spec.rb +14 -14
- data/spec/integration/axiom/algebra/rename/optimize_spec.rb +38 -38
- data/spec/integration/axiom/algebra/restriction/optimize_spec.rb +12 -12
- data/spec/integration/axiom/algebra/summarization/optimize_spec.rb +2 -2
- data/spec/integration/axiom/algebra/union/optimize_spec.rb +16 -16
- data/spec/integration/axiom/function/optimize_spec.rb +1 -1
- data/spec/integration/axiom/relation/operation/limit/optimize_spec.rb +20 -20
- data/spec/integration/axiom/relation/operation/offset/optimize_spec.rb +14 -14
- data/spec/integration/axiom/relation/operation/reverse/optimize_spec.rb +15 -15
- data/spec/integration/axiom/relation/operation/{order → sorted}/optimize_spec.rb +6 -6
- data/spec/integration/axiom/relation/optimize_spec.rb +1 -1
- data/spec/shared/function_connective_binary_optimize_behavior.rb +8 -2
- data/spec/shared/optimize_method_behavior.rb +0 -11
- data/spec/spec_helper.rb +9 -9
- data/spec/support/config_alias.rb +2 -0
- data/spec/unit/axiom/optimizer/algebra/extension/{order_operand → sorted_operand}/optimizable_predicate_spec.rb +3 -3
- data/spec/unit/axiom/optimizer/algebra/extension/{order_operand → sorted_operand}/optimize_spec.rb +1 -1
- data/spec/unit/axiom/optimizer/algebra/rename/limit_operand/optimize_spec.rb +3 -3
- data/spec/unit/axiom/optimizer/algebra/rename/offset_operand/optimize_spec.rb +3 -3
- data/spec/unit/axiom/optimizer/algebra/rename/{order_operand → sorted_operand}/optimizable_predicate_spec.rb +3 -3
- data/spec/unit/axiom/optimizer/algebra/rename/{order_operand → sorted_operand}/optimize_spec.rb +2 -2
- data/spec/unit/axiom/optimizer/algebra/restriction/combination_operand/optimize_spec.rb +1 -1
- data/spec/unit/axiom/optimizer/algebra/restriction/predicate_spec.rb +5 -4
- data/spec/unit/axiom/optimizer/algebra/restriction/{order_operand → sorted_operand}/optimizable_predicate_spec.rb +3 -3
- data/spec/unit/axiom/optimizer/algebra/restriction/{order_operand → sorted_operand}/optimize_spec.rb +1 -1
- data/spec/unit/axiom/optimizer/algebra/summarization/empty_operand/class_methods/extension_default_spec.rb +1 -1
- data/spec/unit/axiom/optimizer/algebra/summarization/{order_operand → sorted_operand}/optimizable_predicate_spec.rb +3 -3
- data/spec/unit/axiom/optimizer/algebra/summarization/{order_operand → sorted_operand}/optimize_spec.rb +1 -1
- data/spec/unit/axiom/optimizer/algebra/summarization/summarize_per_spec.rb +1 -1
- data/spec/unit/axiom/optimizer/function/binary/constant_operands/optimizable_predicate_spec.rb +4 -4
- data/spec/unit/axiom/optimizer/function/connective/conjunction/contradiction/optimizable_predicate_spec.rb +2 -2
- data/spec/unit/axiom/optimizer/function/connective/disjunction/tautology/optimizable_predicate_spec.rb +2 -2
- data/spec/unit/axiom/optimizer/function/unary/constant_operand/optimizable_predicate_spec.rb +1 -1
- data/spec/unit/axiom/optimizer/function/util/class_methods/max_spec.rb +1 -1
- data/spec/unit/axiom/optimizer/function/util/class_methods/min_spec.rb +1 -1
- data/spec/unit/axiom/optimizer/optimizable/optimize_spec.rb +3 -3
- data/spec/unit/axiom/optimizer/optimizable_predicate_spec.rb +1 -5
- data/spec/unit/axiom/optimizer/optimize_spec.rb +1 -5
- data/spec/unit/axiom/optimizer/relation/operation/binary/{order_left → sorted_left}/optimizable_predicate_spec.rb +3 -3
- data/spec/unit/axiom/optimizer/relation/operation/binary/{order_left → sorted_left}/optimize_spec.rb +1 -1
- data/spec/unit/axiom/optimizer/relation/operation/binary/{order_right → sorted_right}/optimizable_predicate_spec.rb +3 -3
- data/spec/unit/axiom/optimizer/relation/operation/binary/{order_right → sorted_right}/optimize_spec.rb +1 -1
- data/spec/unit/axiom/optimizer/relation/operation/limit/equal_limit_operand/optimize_spec.rb +2 -2
- data/spec/unit/axiom/optimizer/relation/operation/limit/limit_operand/optimize_spec.rb +4 -4
- data/spec/unit/axiom/optimizer/relation/operation/limit/unoptimized_operand/optimize_spec.rb +3 -3
- data/spec/unit/axiom/optimizer/relation/operation/limit/zero_limit/optimize_spec.rb +2 -2
- data/spec/unit/axiom/optimizer/relation/operation/offset/offset_operand/optimize_spec.rb +3 -3
- data/spec/unit/axiom/optimizer/relation/operation/offset/unoptimized_operand/optimize_spec.rb +3 -3
- data/spec/unit/axiom/optimizer/relation/operation/offset/zero_offset/optimize_spec.rb +3 -3
- data/spec/unit/axiom/optimizer/relation/operation/reverse/{order_operand → sorted_operand}/optimizable_predicate_spec.rb +3 -3
- data/spec/unit/axiom/optimizer/relation/operation/reverse/{order_operand → sorted_operand}/optimize_spec.rb +2 -2
- data/spec/unit/axiom/optimizer/relation/operation/reverse/unoptimized_operand/optimize_spec.rb +4 -4
- data/spec/unit/axiom/optimizer/relation/operation/{order → sorted}/one_limit_operand/optimizable_predicate_spec.rb +2 -2
- data/spec/unit/axiom/optimizer/relation/operation/{order → sorted}/one_limit_operand/optimize_spec.rb +1 -1
- data/spec/unit/axiom/optimizer/relation/operation/{order/order_operand → sorted/sorted_operand}/optimizable_predicate_spec.rb +4 -4
- data/spec/unit/axiom/optimizer/relation/operation/{order/order_operand → sorted/sorted_operand}/optimize_spec.rb +5 -5
- data/spec/unit/axiom/optimizer/relation/operation/{order → sorted}/unoptimized_operand/optimizable_predicate_spec.rb +2 -2
- data/spec/unit/axiom/optimizer/relation/operation/{order → sorted}/unoptimized_operand/optimize_spec.rb +2 -2
- data/spec/unit/axiom/optimizer/relation/operation/unary/{order_operand → sorted_operand}/optimizable_predicate_spec.rb +4 -4
- data/spec/unit/axiom/optimizer/relation/operation/unary/{order_operand → sorted_operand}/optimize_spec.rb +2 -2
- metadata +291 -47
- data/spec/support/ice_nine_config.rb +0 -6
@@ -7,13 +7,13 @@ describe Relation::Operation::Reverse, '#optimize' do
|
|
7
7
|
|
8
8
|
let(:body) { LazyEnumerable.new([[1], [2], [3]]) }
|
9
9
|
let(:relation) { Relation.new([[:id, Integer]], body) }
|
10
|
-
let(:
|
11
|
-
let(:operand) {
|
10
|
+
let(:sorted) { relation.sort_by { |r| r.id } }
|
11
|
+
let(:operand) { sorted }
|
12
12
|
let(:object) { described_class.new(operand) }
|
13
13
|
|
14
14
|
context 'with a object operation' do
|
15
|
-
let(:limit) {
|
16
|
-
let(:operand) { limit.reverse
|
15
|
+
let(:limit) { sorted.take(2) }
|
16
|
+
let(:operand) { limit.reverse }
|
17
17
|
|
18
18
|
it 'cancels out the operations and return the contained operation' do
|
19
19
|
should be(limit)
|
@@ -24,7 +24,7 @@ describe Relation::Operation::Reverse, '#optimize' do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'does not execute body#each' do
|
27
|
-
body.
|
27
|
+
expect(body).not_to receive(:each)
|
28
28
|
subject
|
29
29
|
end
|
30
30
|
|
@@ -32,7 +32,7 @@ describe Relation::Operation::Reverse, '#optimize' do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
context 'with a object operation when optimized' do
|
35
|
-
let(:limit) {
|
35
|
+
let(:limit) { sorted.take(2) }
|
36
36
|
let(:operand) { limit.reverse.rename({}) }
|
37
37
|
|
38
38
|
it 'cancels out the operations and return the contained operation' do
|
@@ -44,14 +44,14 @@ describe Relation::Operation::Reverse, '#optimize' do
|
|
44
44
|
end
|
45
45
|
|
46
46
|
it 'does not execute body#each' do
|
47
|
-
body.
|
47
|
+
expect(body).not_to receive(:each)
|
48
48
|
subject
|
49
49
|
end
|
50
50
|
|
51
51
|
it_should_behave_like 'an optimize method'
|
52
52
|
end
|
53
53
|
|
54
|
-
context 'with
|
54
|
+
context 'with a sorted operation' do
|
55
55
|
it { should eql(relation.sort_by { object.directions }) }
|
56
56
|
|
57
57
|
it 'returns an equivalent relation to the unoptimized operation' do
|
@@ -59,15 +59,15 @@ describe Relation::Operation::Reverse, '#optimize' do
|
|
59
59
|
end
|
60
60
|
|
61
61
|
it 'does not execute body#each' do
|
62
|
-
body.
|
62
|
+
expect(body).not_to receive(:each)
|
63
63
|
subject
|
64
64
|
end
|
65
65
|
|
66
66
|
it_should_behave_like 'an optimize method'
|
67
67
|
end
|
68
68
|
|
69
|
-
context 'with
|
70
|
-
let(:operand) {
|
69
|
+
context 'with a sorted operation when optimized' do
|
70
|
+
let(:operand) { sorted.rename({}) }
|
71
71
|
|
72
72
|
it { should eql(relation.sort_by { object.directions }) }
|
73
73
|
|
@@ -76,7 +76,7 @@ describe Relation::Operation::Reverse, '#optimize' do
|
|
76
76
|
end
|
77
77
|
|
78
78
|
it 'does not execute body#each' do
|
79
|
-
body.
|
79
|
+
expect(body).not_to receive(:each)
|
80
80
|
subject
|
81
81
|
end
|
82
82
|
|
@@ -84,17 +84,17 @@ describe Relation::Operation::Reverse, '#optimize' do
|
|
84
84
|
end
|
85
85
|
|
86
86
|
context 'with an optimizable operation' do
|
87
|
-
let(:limit) {
|
87
|
+
let(:limit) { sorted.take(2) }
|
88
88
|
let(:operand) { limit.rename({}) }
|
89
89
|
|
90
|
-
it { should eql(
|
90
|
+
it { should eql(sorted.take(2).reverse) }
|
91
91
|
|
92
92
|
it 'returns an equivalent relation to the unoptimized operation' do
|
93
93
|
should == object
|
94
94
|
end
|
95
95
|
|
96
96
|
it 'does not execute body#each' do
|
97
|
-
body.
|
97
|
+
expect(body).not_to receive(:each)
|
98
98
|
subject
|
99
99
|
end
|
100
100
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
describe Relation::Operation::
|
5
|
+
describe Relation::Operation::Sorted, '#optimize' do
|
6
6
|
subject { object.optimize }
|
7
7
|
|
8
8
|
let(:body) { LazyEnumerable.new([[1], [2], [3]]) }
|
@@ -15,7 +15,7 @@ describe Relation::Operation::Order, '#optimize' do
|
|
15
15
|
it { should be(object) }
|
16
16
|
|
17
17
|
it 'does not execute body#each' do
|
18
|
-
body.
|
18
|
+
expect(body).not_to receive(:each)
|
19
19
|
subject
|
20
20
|
end
|
21
21
|
|
@@ -32,7 +32,7 @@ describe Relation::Operation::Order, '#optimize' do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'does not execute body#each' do
|
35
|
-
body.
|
35
|
+
expect(body).not_to receive(:each)
|
36
36
|
subject
|
37
37
|
end
|
38
38
|
|
@@ -49,7 +49,7 @@ describe Relation::Operation::Order, '#optimize' do
|
|
49
49
|
end
|
50
50
|
|
51
51
|
it 'does not execute body#each' do
|
52
|
-
body.
|
52
|
+
expect(body).not_to receive(:each)
|
53
53
|
subject
|
54
54
|
end
|
55
55
|
|
@@ -66,7 +66,7 @@ describe Relation::Operation::Order, '#optimize' do
|
|
66
66
|
end
|
67
67
|
|
68
68
|
it 'does not execute body#each' do
|
69
|
-
body.
|
69
|
+
expect(body).not_to receive(:each)
|
70
70
|
subject
|
71
71
|
end
|
72
72
|
|
@@ -83,7 +83,7 @@ describe Relation::Operation::Order, '#optimize' do
|
|
83
83
|
end
|
84
84
|
|
85
85
|
it 'does not execute body#each' do
|
86
|
-
body.
|
86
|
+
expect(body).not_to receive(:each)
|
87
87
|
subject
|
88
88
|
end
|
89
89
|
|
@@ -79,7 +79,10 @@ shared_examples_for 'Function::Connective::Binary#optimize' do
|
|
79
79
|
let(:right) { double('Binary', class: described_class, left: left, :optimized? => true) }
|
80
80
|
|
81
81
|
before do
|
82
|
-
right.
|
82
|
+
allow(right).to receive(:optimize).and_return(right)
|
83
|
+
allow(right).to receive(:frozen?).and_return(true)
|
84
|
+
allow(right).to receive(:memoize).and_return(right)
|
85
|
+
allow(right).to receive(:memoized).and_return(right)
|
83
86
|
end
|
84
87
|
|
85
88
|
it { should be(right) }
|
@@ -92,7 +95,10 @@ shared_examples_for 'Function::Connective::Binary#optimize' do
|
|
92
95
|
let(:right) { attribute.eq(1) }
|
93
96
|
|
94
97
|
before do
|
95
|
-
left.
|
98
|
+
allow(left).to receive(:optimize).and_return(left)
|
99
|
+
allow(left).to receive(:frozen?).and_return(true)
|
100
|
+
allow(left).to receive(:memoize).and_return(left)
|
101
|
+
allow(left).to receive(:memoized).and_return(left)
|
96
102
|
end
|
97
103
|
|
98
104
|
it { should be(left) }
|
@@ -2,15 +2,4 @@
|
|
2
2
|
|
3
3
|
shared_examples_for 'an optimize method' do
|
4
4
|
it_should_behave_like 'an idempotent method'
|
5
|
-
|
6
|
-
it 'it memoizes itself for #optimize' do
|
7
|
-
optimized = subject
|
8
|
-
expect(optimized.memoized(:optimize)).to be(optimized)
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'does not optimize further' do
|
12
|
-
optimized = subject
|
13
|
-
optimized.memoize(:optimize, nil) # clear memoized value
|
14
|
-
expect(optimized.optimize).to eql(optimized)
|
15
|
-
end
|
16
5
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
require 'devtools/spec_helper'
|
4
|
-
|
5
3
|
if ENV['COVERAGE'] == 'true'
|
6
4
|
require 'simplecov'
|
7
5
|
require 'coveralls'
|
@@ -12,21 +10,23 @@ if ENV['COVERAGE'] == 'true'
|
|
12
10
|
]
|
13
11
|
|
14
12
|
SimpleCov.start do
|
15
|
-
command_name
|
16
|
-
|
17
|
-
add_filter
|
13
|
+
command_name 'spec:unit'
|
14
|
+
|
15
|
+
add_filter 'config'
|
16
|
+
add_filter 'spec'
|
17
|
+
add_filter 'vendor'
|
18
|
+
|
18
19
|
minimum_coverage 100
|
19
20
|
end
|
20
21
|
end
|
21
22
|
|
23
|
+
require 'ice_nine'
|
24
|
+
require 'devtools/spec_helper'
|
22
25
|
require 'axiom-optimizer'
|
23
26
|
|
24
27
|
include Axiom
|
25
28
|
|
26
|
-
|
27
|
-
Dir[File.expand_path('../{support,shared}/**/*.rb', __FILE__)].each do |file|
|
28
|
-
require file.chomp('.rb')
|
29
|
-
end
|
29
|
+
Types.finalize
|
30
30
|
|
31
31
|
RSpec.configure do |config|
|
32
32
|
config.expect_with :rspec do |expect_with|
|
@@ -2,20 +2,20 @@
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
describe Optimizer::Algebra::Extension::
|
5
|
+
describe Optimizer::Algebra::Extension::SortedOperand, '#optimizable?' do
|
6
6
|
subject { object.optimizable? }
|
7
7
|
|
8
8
|
let(:base) { Relation.new([[:id, Integer]], LazyEnumerable.new) }
|
9
9
|
let(:relation) { operand.extend {} }
|
10
10
|
let(:object) { described_class.new(relation) }
|
11
11
|
|
12
|
-
context 'when operand is
|
12
|
+
context 'when operand is sorted' do
|
13
13
|
let(:operand) { base.sort_by { |r| r.id } }
|
14
14
|
|
15
15
|
it { should be(true) }
|
16
16
|
end
|
17
17
|
|
18
|
-
context 'when operand is not
|
18
|
+
context 'when operand is not sorted' do
|
19
19
|
let(:operand) { base }
|
20
20
|
|
21
21
|
it { should be(false) }
|
data/spec/unit/axiom/optimizer/algebra/extension/{order_operand → sorted_operand}/optimize_spec.rb
RENAMED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
describe Optimizer::Algebra::Extension::
|
5
|
+
describe Optimizer::Algebra::Extension::SortedOperand, '#optimize' do
|
6
6
|
subject { object.optimize }
|
7
7
|
|
8
8
|
let(:base) { Relation.new([[:id, Integer]], LazyEnumerable.new) }
|
@@ -7,8 +7,8 @@ describe Optimizer::Algebra::Rename::LimitOperand, '#optimize' do
|
|
7
7
|
|
8
8
|
let(:header) { Relation::Header.coerce([[:id, Integer]]) }
|
9
9
|
let(:base) { Relation.new(header, LazyEnumerable.new([[1]])) }
|
10
|
-
let(:
|
11
|
-
let(:relation) {
|
10
|
+
let(:sorted) { base.sort_by { |r| r.id } }
|
11
|
+
let(:relation) { sorted.take(2).rename(id: :other_id) }
|
12
12
|
let(:object) { described_class.new(relation) }
|
13
13
|
|
14
14
|
before do
|
@@ -17,7 +17,7 @@ describe Optimizer::Algebra::Rename::LimitOperand, '#optimize' do
|
|
17
17
|
|
18
18
|
it { should be_kind_of(Relation::Operation::Limit) }
|
19
19
|
|
20
|
-
its(:operand) { should eql(
|
20
|
+
its(:operand) { should eql(sorted.rename(id: :other_id)) }
|
21
21
|
|
22
22
|
its(:limit) { should == 2 }
|
23
23
|
end
|
@@ -7,8 +7,8 @@ describe Optimizer::Algebra::Rename::OffsetOperand, '#optimize' do
|
|
7
7
|
|
8
8
|
let(:header) { Relation::Header.coerce([[:id, Integer]]) }
|
9
9
|
let(:base) { Relation.new(header, LazyEnumerable.new([[1]])) }
|
10
|
-
let(:
|
11
|
-
let(:relation) {
|
10
|
+
let(:sorted) { base.sort_by { |r| r.id } }
|
11
|
+
let(:relation) { sorted.drop(1).rename(id: :other_id) }
|
12
12
|
let(:object) { described_class.new(relation) }
|
13
13
|
|
14
14
|
before do
|
@@ -17,7 +17,7 @@ describe Optimizer::Algebra::Rename::OffsetOperand, '#optimize' do
|
|
17
17
|
|
18
18
|
it { should be_kind_of(Relation::Operation::Offset) }
|
19
19
|
|
20
|
-
its(:operand) { should eql(
|
20
|
+
its(:operand) { should eql(sorted.rename(id: :other_id)) }
|
21
21
|
|
22
22
|
its(:offset) { should == 1 }
|
23
23
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
describe Optimizer::Algebra::Rename::
|
5
|
+
describe Optimizer::Algebra::Rename::SortedOperand, '#optimizable?' do
|
6
6
|
subject { object.optimizable? }
|
7
7
|
|
8
8
|
let(:base) { Relation.new([[:id, Integer]], LazyEnumerable.new([[1]])) }
|
@@ -14,13 +14,13 @@ describe Optimizer::Algebra::Rename::OrderOperand, '#optimizable?' do
|
|
14
14
|
expect(object.operation).to be_kind_of(Algebra::Rename)
|
15
15
|
end
|
16
16
|
|
17
|
-
context 'when the operand is
|
17
|
+
context 'when the operand is sorted' do
|
18
18
|
let(:operand) { base.sort_by { |r| r.id } }
|
19
19
|
|
20
20
|
it { should be(true) }
|
21
21
|
end
|
22
22
|
|
23
|
-
context 'when the operand is not
|
23
|
+
context 'when the operand is not sorted' do
|
24
24
|
let(:operand) { base }
|
25
25
|
|
26
26
|
it { should be(false) }
|
data/spec/unit/axiom/optimizer/algebra/rename/{order_operand → sorted_operand}/optimize_spec.rb
RENAMED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
describe Optimizer::Algebra::Rename::
|
5
|
+
describe Optimizer::Algebra::Rename::SortedOperand, '#optimize' do
|
6
6
|
subject { object.optimize }
|
7
7
|
|
8
8
|
let(:base) { Relation.new([[:id, Integer]], LazyEnumerable.new([[1]])) }
|
@@ -14,7 +14,7 @@ describe Optimizer::Algebra::Rename::OrderOperand, '#optimize' do
|
|
14
14
|
expect(object).to be_optimizable
|
15
15
|
end
|
16
16
|
|
17
|
-
it { should be_kind_of(Relation::Operation::
|
17
|
+
it { should be_kind_of(Relation::Operation::Sorted) }
|
18
18
|
|
19
19
|
its(:operand) { should eql(base.rename(id: :other_id)) }
|
20
20
|
|
@@ -15,7 +15,7 @@ describe Optimizer::Algebra::Restriction::CombinationOperand, '#optimize' do
|
|
15
15
|
expect(object).to be_optimizable
|
16
16
|
end
|
17
17
|
|
18
|
-
specify { expect { subject }.to raise_error(NotImplementedError, 'Axiom::Optimizer::Algebra::Restriction::CombinationOperand#relation_method
|
18
|
+
specify { expect { subject }.to raise_error(NotImplementedError, 'Axiom::Optimizer::Algebra::Restriction::CombinationOperand#relation_method is not implemented') }
|
19
19
|
|
20
20
|
context 'with a defined relation_method' do
|
21
21
|
let(:described_class) { Class.new(Optimizer::Algebra::Restriction::CombinationOperand) }
|
@@ -5,10 +5,11 @@ require 'spec_helper'
|
|
5
5
|
describe Optimizer::Algebra::Restriction, '#predicate' do
|
6
6
|
subject { object.predicate }
|
7
7
|
|
8
|
-
let(:
|
9
|
-
let(:
|
10
|
-
let(:
|
11
|
-
let(:
|
8
|
+
let(:object) { described_class.new(relation) }
|
9
|
+
let(:described_class) { Class.new(Optimizer::Algebra::Restriction) }
|
10
|
+
let(:base) { Relation.new([[:id, Integer]], [[1]]) }
|
11
|
+
let(:predicate) { base[:id].eq(1) }
|
12
|
+
let(:relation) { base.restrict { predicate } }
|
12
13
|
|
13
14
|
before do
|
14
15
|
expect(object.operation).to be_kind_of(Algebra::Restriction)
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
describe Optimizer::Algebra::Restriction::
|
5
|
+
describe Optimizer::Algebra::Restriction::SortedOperand, '#optimizable?' do
|
6
6
|
subject { object.optimizable? }
|
7
7
|
|
8
8
|
let(:base) { Relation.new([[:id, Integer]], LazyEnumerable.new([[1]])) }
|
@@ -14,13 +14,13 @@ describe Optimizer::Algebra::Restriction::OrderOperand, '#optimizable?' do
|
|
14
14
|
expect(object.operation).to be_kind_of(Algebra::Restriction)
|
15
15
|
end
|
16
16
|
|
17
|
-
context 'when the operand is
|
17
|
+
context 'when the operand is sorted' do
|
18
18
|
let(:operand) { base.sort_by { |r| r.id } }
|
19
19
|
|
20
20
|
it { should be(true) }
|
21
21
|
end
|
22
22
|
|
23
|
-
context 'when the operand is not
|
23
|
+
context 'when the operand is not sorted' do
|
24
24
|
let(:operand) { base }
|
25
25
|
|
26
26
|
it { should be(false) }
|
data/spec/unit/axiom/optimizer/algebra/restriction/{order_operand → sorted_operand}/optimize_spec.rb
RENAMED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
describe Optimizer::Algebra::Restriction::
|
5
|
+
describe Optimizer::Algebra::Restriction::SortedOperand, '#optimize' do
|
6
6
|
subject { object.optimize }
|
7
7
|
|
8
8
|
let(:base) { Relation.new([[:id, Integer]], LazyEnumerable.new([[1]])) }
|
@@ -2,20 +2,20 @@
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
describe Optimizer::Algebra::Summarization::
|
5
|
+
describe Optimizer::Algebra::Summarization::SortedOperand, '#optimizable?' do
|
6
6
|
subject { object.optimizable? }
|
7
7
|
|
8
8
|
let(:base) { Relation.new([[:id, Integer]], LazyEnumerable.new) }
|
9
9
|
let(:relation) { operand.summarize([]) {} }
|
10
10
|
let(:object) { described_class.new(relation) }
|
11
11
|
|
12
|
-
context 'when operand is
|
12
|
+
context 'when operand is sorted' do
|
13
13
|
let(:operand) { base.sort_by { |r| r.id } }
|
14
14
|
|
15
15
|
it { should be(true) }
|
16
16
|
end
|
17
17
|
|
18
|
-
context 'when operand is not
|
18
|
+
context 'when operand is not sorted' do
|
19
19
|
let(:operand) { base }
|
20
20
|
|
21
21
|
it { should be(false) }
|