Class: Locomotive::RelationalAlgebra::RowNum

Inherits:
Numbering show all
Defined in:
lib/locomotive/relational_algebra/operators/ranking/row_number.rb

Instance Attribute Summary collapse

Attributes inherited from Numbering

#res, #sort_by

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, part, sortby) ⇒ RowNum

Returns a new instance of RowNum.



11
12
13
14
# File 'lib/locomotive/relational_algebra/operators/ranking/row_number.rb', line 11

def initialize(op, res, part, sortby)
  self.part = part
  super(op,res,sortby)
end

Dynamic Method Handling

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

Instance Attribute Details

#partObject

Returns the value of attribute part.



8
9
10
# File 'lib/locomotive/relational_algebra/operators/ranking/row_number.rb', line 8

def part
  @part
end

Instance Method Details

#child=(op) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/locomotive/relational_algebra/operators/ranking/row_number.rb', line 16

def child=(op)
  unless op.schema.attributes?(part)
    raise CorruptedSchema,
          "Schema #{op.schema.attributes} does not " \
          "contain all attributes of #{part}."
  end
  super(op)
end

#cloneObject



39
40
41
42
43
44
# File 'lib/locomotive/relational_algebra/operators/ranking/row_number.rb', line 39

def clone
  RowNum.new(child.clone,
             res.clone,
             part.clone,
             sort_by.clone)
end

#set(var, plan) ⇒ Object



46
47
48
49
50
# File 'lib/locomotive/relational_algebra/operators/ranking/row_number.rb', line 46

def set(var,plan)
  RowNum.new(
    child.set(var,plan),
    res.clone, part.clone, sort_by.clone)
end

#xml_contentObject



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/locomotive/relational_algebra/operators/ranking/row_number.rb', line 25

def xml_content
  pos = -1
  content do
    [column(:name => res.to_xml, :new => true),
     sort_by.to_xml,
     part.collect do |p|
       column :name => p.to_xml,
              :function => :partition,
              :position => pos += 1,
              :new => false
     end.join].join
  end
end