Class: Locomotive::RelationalAlgebra::Operator

Inherits:
RelAlgAstNode show all
Includes:
XML
Defined in:
lib/locomotive/relational_algebra/operators/basic_operators.rb

Overview

represents a variant operator of the relational algebra

Direct Known Subclasses

Binary, Leaf, Unary

Instance Attribute Summary collapse

Attributes included from AstHelpers::AstNode

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

Instance Method Summary collapse

Methods included from XML

included, #quote

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

#initializeOperator

Returns a new instance of Operator.

Raises:



14
15
16
17
18
# File 'lib/locomotive/relational_algebra/operators/basic_operators.rb', line 14

def initialize
  raise AbstractClassError,
        "#{self.class} is an abstract class" if self.class == Operator
  self.schema = Schema.new({})
end

Dynamic Method Handling

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

Instance Attribute Details

#schemaObject

Returns the value of attribute schema.



11
12
13
# File 'lib/locomotive/relational_algebra/operators/basic_operators.rb', line 11

def schema
  @schema
end

Instance Method Details

#boundObject

returns all bound variables in this plan



56
57
58
59
60
61
62
63
# File 'lib/locomotive/relational_algebra/operators/basic_operators.rb', line 56

def bound
  # attention: for convenience we use
  #  the underlying ast framework
  bv = []
  bv += left_child.bound if has_left_child?
  bv += right_child.bound if has_right_child?
  bv
end

#freeObject

returns all free variables in this plan



46
47
48
49
50
51
52
53
# File 'lib/locomotive/relational_algebra/operators/basic_operators.rb', line 46

def free
  # attention: for convenience we use
  # the underlying ast framework
  fv = []
  fv += left_child.free if has_left_child?
  fv += right_child.free if has_right_child?
  fv
end

#to_xmlObject



32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/locomotive/relational_algebra/operators/basic_operators.rb', line 32

def to_xml
  cont_list = [ xml_schema,
                xml_content ]
  cont_list << edge(:to => left_child.ann_xml_id) if has_left_child? and 
                                                     left_child.respond_to? :ann_xml_id
  cont_list << edge(:to => right_child.ann_xml_id) if has_right_child? and
                                                      right_child.respond_to? :ann_xml_id
  node :id => ann_xml_id,
       :kind => xml_kind do
    cont_list.join
  end
end

#xml_contentObject



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

def xml_content
  content()
end

#xml_kindObject



28
29
30
# File 'lib/locomotive/relational_algebra/operators/basic_operators.rb', line 28

def xml_kind
  self.class.to_s.split("::").last.downcase.to_sym
end

#xml_schemaObject



20
21
22
# File 'lib/locomotive/relational_algebra/operators/basic_operators.rb', line 20

def xml_schema
  self.schema.to_xml
end