Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Handles push-down of an insertion into a restriction operator * Creates a disjunction of the predicates for the left restriction and each right tuple, and then wraps the insertion in the new restriction. This is equivalent to the original operation, except that the insertion now wraps the original restriction operand. Also, the right hand side is materialized, which may be expensive, but it probably would've happened when the tuples were inserted into the base relation.
- Loading branch information
Showing
6 changed files
with
150 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
--- | ||
threshold: 113 | ||
total_score: 862 | ||
total_score: 858 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
.../unit/veritas/optimizer/relation/operation/insertion/restriction_left/optimizable_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# encoding: utf-8 | ||
|
||
require 'spec_helper' | ||
|
||
describe Optimizer::Relation::Operation::Insertion::RestrictionLeft, '#optimizable?' do | ||
subject { object.optimizable? } | ||
|
||
let(:object) { described_class.new(relation) } | ||
let(:relation) { left.insert(right) } | ||
let(:base_left) { Relation.new(header, [ [ 1 ] ].each) } | ||
let(:right) { Relation.new(header, [ [ 2 ] ].each) } | ||
let(:header) { Relation::Header.new([ [ :id, Integer ] ]) } | ||
|
||
before do | ||
object.operation.should be_kind_of(Relation::Operation::Insertion) | ||
end | ||
|
||
context 'when the left is a restriction' do | ||
let(:left) { base_left.restrict { |r| r.id.eq(1) } } | ||
|
||
it { should be(true) } | ||
end | ||
|
||
context 'when the left is not a rename' do | ||
let(:left) { base_left } | ||
|
||
it { should be(false) } | ||
end | ||
end |
27 changes: 27 additions & 0 deletions
27
spec/unit/veritas/optimizer/relation/operation/insertion/restriction_left/optimize_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# encoding: utf-8 | ||
|
||
require 'spec_helper' | ||
|
||
describe Optimizer::Relation::Operation::Insertion::RestrictionLeft, '#optimize' do | ||
subject { object.optimize } | ||
|
||
let(:object) { described_class.new(relation) } | ||
let(:relation) { left.insert(right) } | ||
let(:base_left) { Relation.new(header, [ [ 1 ] ].each) } | ||
let(:left) { base_left.restrict { |r| r.id.eq(1) } } | ||
let(:right) { Relation.new(header, [ [ 2 ] ].each) } | ||
let(:header) { Relation::Header.new([ attribute ]) } | ||
let(:attribute) { Attribute::Integer.new(:id) } | ||
|
||
before do | ||
object.should be_optimizable | ||
end | ||
|
||
it { should be_instance_of(Algebra::Restriction) } | ||
|
||
# the operand is unwrapped from the left, and right is materialized | ||
its(:operand) { should eql(base_left.insert(right.materialize)) } | ||
|
||
# the predicate is a disjunction of the original and each tuple predicate | ||
its(:predicate) { should eql(attribute.eq(1).or(attribute.eq(2))) } | ||
end |