Sha256: 7ebb25507aae9ca885c4bca61098685e73430fac34d697ff37e4f5f5151dfcbe

Contents?: true

Size: 1.75 KB

Versions: 1

Compression:

Stored size: 1.75 KB

Contents

# encoding: utf-8

module Veritas
  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 = self.left
            left.header.empty? && !left.kind_of?(Veritas::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 = self.right
            right.header.empty? && !right.kind_of?(Veritas::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

        Veritas::Algebra::Product.optimizer = chain(
          TableDeeLeft,
          TableDeeRight,
          EmptyLeft,
          EmptyRight,
          LeftOrderOperand,
          RightOrderOperand,
          MaterializedOperands,
          UnoptimizedOperands
        )

      end # class Product
    end # module Algebra
  end # class Optimizer
end # module Veritas

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
veritas-optimizer-0.0.5 lib/veritas/optimizer/algebra/product.rb