Class: Locomotive::RelationalAlgebra::Aggr
- Inherits:
-
Unary
- Object
- RelAlgAstNode
- Operator
- Unary
- Locomotive::RelationalAlgebra::Aggr
- Defined in:
- lib/locomotive/relational_algebra/operators/aggregation/aggregation.rb
Instance Attribute Summary collapse
-
#aggr_kind ⇒ Object
Returns the value of attribute aggr_kind.
-
#item ⇒ Object
Returns the value of attribute item.
-
#over ⇒ Object
Returns the value of attribute over.
-
#part_list ⇒ Object
Returns the value of attribute part_list.
Attributes inherited from Operator
Attributes included from AstHelpers::AstNode
#kind, #left_child, #owner, #right_child, #value
Instance Method Summary collapse
- #child=(op) ⇒ Object
- #clone ⇒ Object
-
#initialize(op, aggr_kind, item, over, part) ⇒ Aggr
constructor
A new instance of Aggr.
- #set(var, plan) ⇒ Object
- #xml_content ⇒ Object
Methods inherited from Operator
#bound, #free, #to_xml, #xml_kind, #xml_schema
Methods included from XML
Methods included from AstHelpers::Annotations
Methods included from AstHelpers::AstNode
#has_left_child?, #has_right_child?, #is_leaf?, #traverse, #traverse_strategy=
Constructor Details
#initialize(op, aggr_kind, item, over, part) ⇒ Aggr
Returns a new instance of Aggr.
14 15 16 17 18 19 20 |
# File 'lib/locomotive/relational_algebra/operators/aggregation/aggregation.rb', line 14 def initialize(op, aggr_kind, item, over, part) self.item = item self.aggr_kind = aggr_kind self.over = over self.part_list = part 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
#aggr_kind ⇒ Object
Returns the value of attribute aggr_kind.
8 9 10 |
# File 'lib/locomotive/relational_algebra/operators/aggregation/aggregation.rb', line 8 def aggr_kind @aggr_kind end |
#item ⇒ Object
Returns the value of attribute item.
8 9 10 |
# File 'lib/locomotive/relational_algebra/operators/aggregation/aggregation.rb', line 8 def item @item end |
#over ⇒ Object
Returns the value of attribute over.
8 9 10 |
# File 'lib/locomotive/relational_algebra/operators/aggregation/aggregation.rb', line 8 def over @over end |
#part_list ⇒ Object
Returns the value of attribute part_list.
8 9 10 |
# File 'lib/locomotive/relational_algebra/operators/aggregation/aggregation.rb', line 8 def part_list @part_list end |
Instance Method Details
#child=(op) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/locomotive/relational_algebra/operators/aggregation/aggregation.rb', line 22 def child=(op) unless op.schema.attributes?(part_list) raise CorruptedSchema, "Schema #{op.schema.attributes} does not " \ "contain all attributes of #{part_list}." end unless op.schema.attributes?(over) raise CorruptedSchema, "Schema #{op.schema.attributes} does not " \ "contain all attributes of #{item}." end self.schema = Schema.new( { self.item => [RNat.instance] }.merge( Hash[*part_list.collect do |p| [p, op.schema[p]] end.flatten_once])) super(op) end |
#clone ⇒ Object
55 56 57 58 59 60 61 62 |
# File 'lib/locomotive/relational_algebra/operators/aggregation/aggregation.rb', line 55 def clone Aggr.new( child.clone, aggr_kind.clone, over.clone, item.clone, part_list.clone) end |
#set(var, plan) ⇒ Object
64 65 66 67 68 69 70 71 |
# File 'lib/locomotive/relational_algebra/operators/aggregation/aggregation.rb', line 64 def set(var,plan) Aggr.new( child.set(var,plan), aggr_kind.clone, item.clone, over.clone, part_list.clone) end |
#xml_content ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/locomotive/relational_algebra/operators/aggregation/aggregation.rb', line 41 def xml_content content do part_list.collect do |part| column :name => part.to_xml, :function => :partition, :new => false end.join + (aggregate :kind => aggr_kind.to_xml do ([column(:name => item.to_xml, :new => true)] + over.map do |c| column(:name => c.to_xml, :new => false, :function => :item) end).join end) end end |