Class: Alf::Algebra::Project

Inherits:
Object
  • Object
show all
Includes:
Operator, Relational, Unary
Defined in:
lib/alf-algebra/alf/algebra/operator/project.rb

Instance Attribute Summary

Attributes included from Operator

#operands

Attributes included from Support::Bindable

#connection

Instance Method Summary collapse

Methods included from Operator

#==, #bind, #dup, included, #initialize, #signature, #to_lispy, #to_relvar, #with_operands

Methods included from Support::Registry

#each, #listen, #listeners, #register, #registered

Methods included from Operand

#attr_list, coerce, #to_cog, #to_dot, #to_relation

Methods included from Support::Bindable

#bind, #bound?, #connection!

Methods included from Relational

included

Methods included from Unary

included, #operand, #with_operand

Instance Method Details

#headingObject



11
12
13
# File 'lib/alf-algebra/alf/algebra/operator/project.rb', line 11

def heading
  @heading ||= operand.heading.project(attributes, allbut)
end

#key_preserving?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/alf-algebra/alf/algebra/operator/project.rb', line 26

def key_preserving?
  keys.any?{|k| operand.keys.any?{|op_k| k.subset?(op_k) } }
end

#keysObject



15
16
17
18
19
20
21
22
23
24
# File 'lib/alf-algebra/alf/algebra/operator/project.rb', line 15

def keys
  @keys ||= begin
    keys = operand.keys.project(attributes, allbut).compact
    if keys.empty?
      has_empty = operand.keys.include?(AttrList::EMPTY)
      keys = Keys[ has_empty ? AttrList::EMPTY : heading.to_attr_list ]
    end
    keys
  end
end

#stay_attributesObject



30
31
32
# File 'lib/alf-algebra/alf/algebra/operator/project.rb', line 30

def stay_attributes
  allbut ? heading.to_attr_list : attributes
end