Class: Bmg::Operator::Autosummarize
- Inherits:
-
Object
- Object
- Bmg::Operator::Autosummarize
- Includes:
- Unary
- Defined in:
- lib/bmg/operator/autosummarize.rb
Overview
Autosummarize operator.
Autosummarize helps structuring the results of a big flat join.
This operator is still largely experimental and should be used with care…
Defined Under Namespace
Classes: DistinctList, Same, YByX, YsByX
Instance Attribute Summary
Attributes included from Bmg::Operator
Class Method Summary collapse
Instance Method Summary collapse
- #_count ⇒ Object
- #each(&bl) ⇒ Object
-
#initialize(type, operand, by, sums) ⇒ Autosummarize
constructor
A new instance of Autosummarize.
- #to_ast ⇒ Object
Methods included from Unary
Methods included from Bmg::Operator
Methods included from Relation
#bind, #count, #debug, #delete, empty, #empty?, #insert, new, #one, #one_or_nil, #to_csv, #to_json, #to_xlsx, #type, #update, #visit, #with_type, #with_type_attrlist, #with_typecheck, #without_typecheck, #y_by_x, #ys_by_x
Methods included from Algebra
#allbut, #autosummarize, #autowrap, #constants, #extend, #group, #image, #join, #left_join, #matching, #materialize, #not_matching, #page, #project, #rename, #restrict, #spied, #summarize, #transform, #union, #unspied
Methods included from Algebra::Shortcuts
#exclude, #image, #images, #join, #left_join, #matching, #not_matching, #prefix, #rxmatch, #suffix, #where
Constructor Details
#initialize(type, operand, by, sums) ⇒ Autosummarize
Returns a new instance of Autosummarize.
14 15 16 17 18 19 |
# File 'lib/bmg/operator/autosummarize.rb', line 14 def initialize(type, operand, by, sums) @type = type @operand = operand @by = by @sums = sums.each_with_object({}){|(k,v),h| h[k] = to_summarizer(v) } end |
Class Method Details
.group(*args) ⇒ Object
31 32 33 |
# File 'lib/bmg/operator/autosummarize.rb', line 31 def self.group(*args) Group.new(*args) end |
.same(*args) ⇒ Object
27 28 29 |
# File 'lib/bmg/operator/autosummarize.rb', line 27 def self.same(*args) Same.new(*args) end |
Instance Method Details
#_count ⇒ Object
63 64 65 |
# File 'lib/bmg/operator/autosummarize.rb', line 63 def _count operand._count end |
#each(&bl) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/bmg/operator/autosummarize.rb', line 43 def each(&bl) return to_enum unless block_given? h = {} @operand.each do |tuple| key = key(tuple) h[key] ||= init(key, tuple) h[key] = sum(h[key], tuple) end h.each_pair do |k,v| h[k] = term(v) end h.values.each(&bl) end |
#to_ast ⇒ Object
57 58 59 |
# File 'lib/bmg/operator/autosummarize.rb', line 57 def to_ast [:autosummarize, operand.to_ast, by.dup, sums.dup] end |