Sha256: 101e20a94e3b5b299f404c786086799d9323183ef0d43280471c6e95e5371157

Contents?: true

Size: 1.6 KB

Versions: 2

Compression:

Stored size: 1.6 KB

Contents

module Veritas
  class Optimizer
    module Algebra

      # Abstract base class representing Difference optimizations
      class Difference < Relation::Operation::Binary

        # Optimize when operands are equal
        class EqualOperands < self
          include Relation::Operation::Binary::EqualOperands

          # A Difference with equal operands is empty
          #
          # @return [Relation::Empty]
          #
          # @api private
          def optimize
            Veritas::Relation::Empty.new(operation.header)
          end

        end # class EqualOperands

        # Optimize when the left operand is empty
        class EmptyLeft < self
          include Relation::Operation::Binary::EmptyLeft

          # A Difference with an empty left operand is empty
          #
          # @return [Relation::Empty]
          #
          # @api private
          def optimize
            left
          end

        end # class EmptyLeft

        # Optimize when the right operand is empty
        class EmptyRight < self
          include Relation::Operation::Binary::EmptyRight

          # A Difference with an empty right operand is equivalent to the left
          #
          # @return [Relation]
          #
          # @api private
          def optimize
            left
          end

        end # class EmptyRight

        Veritas::Algebra::Difference.optimizer = chain(
          EqualOperands,
          EmptyLeft,
          EmptyRight,
          MaterializedOperand,
          UnoptimizedOperand
        )

      end # class Difference
    end # module Algebra
  end # class Optimizer
end # module Veritas

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
veritas-0.0.2 lib/veritas/optimizer/algebra/difference.rb
veritas-0.0.1 lib/veritas/optimizer/algebra/difference.rb