class Axiom::Optimizer::Algebra::Restriction::CombinationOperand
Optimize when the operand is a combine operation
Public Instance Methods
Test if the restriction is commutative
@return [Boolean]
@api private
# File lib/axiom/optimizer/algebra/restriction.rb, line 149 def optimizable? restriction_commutative? end
Distribute the restriction across the operation and apply to the operands
@return [Restriction]
@api private
# File lib/axiom/optimizer/algebra/restriction.rb, line 158 def optimize left_restriction.send(relation_method, right_restriction).restrict(partition.remainder) end
Private Instance Methods
Restrict the left operand with the left predicate partition
@return [Restriction]
@api private
# File lib/axiom/optimizer/algebra/restriction.rb, line 217 def left_restriction operand.left.restrict(partition.left) end
Return a predicate partition for the restriction and operand headers
@return [PredicatePartition]
@api private
# File lib/axiom/optimizer/algebra/restriction.rb, line 169 def partition PredicatePartition.new(predicate, operand.left.header, operand.right.header) end
Test if the predicate for the left operand would match everything
@return [Boolean]
@api private
# File lib/axiom/optimizer/algebra/restriction.rb, line 191 def partition_left_tautology? partition.left.equal?(Axiom::Function::Proposition::Tautology.instance) end
Test if the predicate for the right operand would match everything
@return [Boolean]
@api private
# File lib/axiom/optimizer/algebra/restriction.rb, line 200 def partition_right_tautology? partition.right.equal?(Axiom::Function::Proposition::Tautology.instance) end
Test if the restriction can be distributed over the operation
If the predicates for the left and right operands would match everything, there is no point in distributing the restriction across the operation, since it will not affect the result.
@return [Boolean]
@api private
# File lib/axiom/optimizer/algebra/restriction.rb, line 182 def restriction_commutative? ! (partition_left_tautology? && partition_right_tautology?) end
Restrict the right operand with the right predicate partition
@return [Restriction]
@api private
# File lib/axiom/optimizer/algebra/restriction.rb, line 226 def right_restriction operand.right.restrict(partition.right) end