Sha256: 06085f5b8d3a6b1f87e7ea7124ddf2629090822e0ab161ebd031772df91c33ef

Contents?: true

Size: 1.67 KB

Versions: 2

Compression:

Stored size: 1.67 KB

Contents

# encoding: utf-8

module Axiom
  class Optimizer
    module Algebra

      # Abstract base class representing Product optimizations
      class Product < Relation::Operation::Combination

        # Optimize when left operand is a TABLE DEE
        class TableDeeLeft < self

          # Test if the left operand is a TABLE DEE
          #
          # @return [Boolean]
          #
          # @api private
          def optimizable?
            left.header.empty? && ! left.kind_of?(Axiom::Relation::Empty)
          end

          # A Product with a left TABLE DEE is equivalent to the right operand
          #
          # @return [Relation]
          #
          # @api private
          def optimize
            right
          end

        end # class TableDeeLeft

        # Optimize when right operand is a TABLE DEE
        class TableDeeRight < self

          # Test if the right operand is a TABLE DEE
          #
          # @return [Boolean]
          #
          # @api private
          def optimizable?
            right.header.empty? && ! right.kind_of?(Axiom::Relation::Empty)
          end

          # A Product with a right TABLE DEE is equivalent to the left operand
          #
          # @return [Relation]
          #
          # @api private
          def optimize
            left
          end

        end # class TableDeeRight

        Axiom::Algebra::Product.optimizer = chain(
          TableDeeLeft,
          TableDeeRight,
          EmptyLeft,
          EmptyRight,
          OrderLeft,
          OrderRight,
          MaterializedOperands,
          UnoptimizedOperands
        )

      end # class Product
    end # module Algebra
  end # class Optimizer
end # module Axiom

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
axiom-optimizer-0.1.1 lib/axiom/optimizer/algebra/product.rb
axiom-optimizer-0.1.0 lib/axiom/optimizer/algebra/product.rb