class Axiom::Optimizer::Algebra::Rename::ProjectionOperand

Optimize when the operand is a Projection

Public Instance Methods

optimizable?() click to toggle source

Test if the operand is a Projection

@return [Boolean]

@api private

# File lib/axiom/optimizer/algebra/rename.rb, line 105
def optimizable?
  operand.kind_of?(Axiom::Algebra::Projection) && distributive?
end
optimize() click to toggle source

Wrap the Rename in a Projection

@return [Projection]

@api private

# File lib/axiom/optimizer/algebra/rename.rb, line 114
def optimize
  wrap_operand.project(header)
end

Private Instance Methods

alias_names() click to toggle source

Return the aliases as an inverted Hash

@return [Hash]

@api private

# File lib/axiom/optimizer/algebra/rename.rb, line 137
def alias_names
  aliases.to_hash.values.map(&:name)
end
distributive?() click to toggle source

Test if the rename can be distributed over the projection

@return [Boolean]

@api private

# File lib/axiom/optimizer/algebra/rename.rb, line 125
def distributive?
  names = alias_names
  removed_attributes.none? do |attribute|
    names.include?(attribute.name)
  end
end
removed_attributes() click to toggle source

Returns the attributes removed from the projection

@return [#all?]

@api private

# File lib/axiom/optimizer/algebra/rename.rb, line 146
def removed_attributes
  operand.operand.header - operand.header
end