Class: Locomotive::RelationalAlgebra::Numbering

Inherits:
Unary show all
Defined in:
lib/locomotive/relational_algebra/operators/ranking/basic_ranking.rb

Direct Known Subclasses

Rank, RowId, RowNum, RowRank

Instance Attribute Summary collapse

Attributes inherited from Operator

#schema

Attributes included from AstHelpers::AstNode

#kind, #left_child, #owner, #right_child, #value

Instance Method Summary collapse

Methods inherited from Operator

#bound, #free, #to_xml, #xml_kind, #xml_schema

Methods included from XML

included, #quote, #to_xml

Methods included from AstHelpers::Annotations

#method_missing, #respond_to?

Methods included from AstHelpers::AstNode

#has_left_child?, #has_right_child?, #is_leaf?, #traverse, #traverse_strategy=

Constructor Details

#initialize(op, res, sortby) ⇒ Numbering

Returns a new instance of Numbering.



28
29
30
31
32
# File 'lib/locomotive/relational_algebra/operators/ranking/basic_ranking.rb', line 28

def initialize(op, res, sortby)
  @res = res
  @sort_by = to_sort_by sortby
  super(op)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Locomotive::AstHelpers::Annotations

Instance Attribute Details

#resObject (readonly)

Returns the value of attribute res.



24
25
26
# File 'lib/locomotive/relational_algebra/operators/ranking/basic_ranking.rb', line 24

def res
  @res
end

#sort_byObject (readonly)

Returns the value of attribute sort_by.



24
25
26
# File 'lib/locomotive/relational_algebra/operators/ranking/basic_ranking.rb', line 24

def sort_by
  @sort_by
end

Instance Method Details

#child=(op) ⇒ Object



34
35
36
37
38
39
40
41
42
# File 'lib/locomotive/relational_algebra/operators/ranking/basic_ranking.rb', line 34

def child=(op)
  unless op.schema.attributes?(sort_by.attributes)
    raise CorruptedSchema,
          "Schema #{op.schema.attributes} does not " \
          "contain all attributes of #{sort_by.attributes}."
  end
  self.schema = op.schema + Schema.new({ @res => [RNat.instance] })
  super(op)
end

#cloneObject



51
52
53
54
55
# File 'lib/locomotive/relational_algebra/operators/ranking/basic_ranking.rb', line 51

def clone
  self.class.new(child.clone,
                 res.clone,
                 sort_by.clone)
end

#set(var, plan) ⇒ Object



57
58
59
60
61
62
# File 'lib/locomotive/relational_algebra/operators/ranking/basic_ranking.rb', line 57

def set(var, plan)
  self.class.new(
    child.set(var,plan),
    res.clone,
    sort_by.clone)
end

#xml_contentObject



44
45
46
47
48
49
# File 'lib/locomotive/relational_algebra/operators/ranking/basic_ranking.rb', line 44

def xml_content
  content do
    [column( :name => res.to_xml, :new => true),
     sort_by.to_xml].join
  end
end