class Bmg::Operator::Autosummarize
Autosummarize
operator.
Autosummarize
helps structuring the results of a big flat join.
This operator is still largely experimental and should be used with careā¦
Attributes
by[R]
sums[R]
Public Class Methods
group(*args)
click to toggle source
# File lib/bmg/operator/autosummarize.rb, line 31 def self.group(*args) Group.new(*args) end
new(type, operand, by, sums)
click to toggle source
# 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
same(*args)
click to toggle source
# File lib/bmg/operator/autosummarize.rb, line 27 def self.same(*args) Same.new(*args) end
y_by_x(*args)
click to toggle source
# File lib/bmg/operator/autosummarize.rb, line 35 def self.y_by_x(*args) YByX.new(*args) end
ys_by_x(*args)
click to toggle source
# File lib/bmg/operator/autosummarize.rb, line 39 def self.ys_by_x(*args) YsByX.new(*args) end
Public Instance Methods
each(&bl)
click to toggle source
# 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()
click to toggle source
# File lib/bmg/operator/autosummarize.rb, line 57 def to_ast [:autosummarize, operand.to_ast, by.dup, sums.dup] end