class Axiom::Optimizer::Algebra::Projection::ExtensionOperand

Optimize when the operand is an Extension

Public Instance Methods

optimizable?() click to toggle source

Test if the operand is an Extension

@return [Boolean]

@api private

# File lib/axiom/optimizer/algebra/projection.rb, line 52
def optimizable?
  operand.kind_of?(Axiom::Algebra::Extension) &&
  operand.extensions != new_extensions
end
optimize() click to toggle source

Extend the operand with the attributes not projected away

This avoid performing an extension when the new attributes are immediately removed.

@return [Projection]

@api private

# File lib/axiom/optimizer/algebra/projection.rb, line 65
def optimize
  extend_operand.project(operation.header)
end

Private Instance Methods

extend_operand() click to toggle source

Extend the operand with only the new extensions

@return [Extension]

@api private

# File lib/axiom/optimizer/algebra/projection.rb, line 76
def extend_operand
  unwrap_operand.extend(new_extensions)
end
new_extensions() click to toggle source

Extensions minus the removed attributes

@return [Hash{Attribute => Function}]

@api private

# File lib/axiom/optimizer/algebra/projection.rb, line 94
def new_extensions
  extensions = operand.extensions
  attributes = extensions.keys - removed_attributes
  Hash[attributes.zip(extensions.values_at(*attributes))]
end
removed_attributes() click to toggle source

Attributes removed by the projection

@return [Header]

@api private

# File lib/axiom/optimizer/algebra/projection.rb, line 105
def removed_attributes
  operand.header - operation.header
end
unwrap_operand() click to toggle source

Unwrap the operand from the Extension

@return [Relation]

@api private

# File lib/axiom/optimizer/algebra/projection.rb, line 85
def unwrap_operand
  operand.operand
end