Class: Size::Reducer
- Inherits:
-
Wukong::Streamer::Base
- Object
- Wukong::Streamer::Base
- Size::Reducer
- Defined in:
- examples/size.rb
Overview
Sums the numeric value of each column in its input
Instance Attribute Summary (collapse)
-
- (Object) sums
Returns the value of attribute sums.
Attributes inherited from Wukong::Streamer::Base
Instance Method Summary (collapse)
-
- (Object) process(*vals)
add each corresponding column in the input.
-
- (Object) recordize(line)
The unix wc command uses whitespace, not tabs, so we'll recordize accordingly.
-
- (Object) stream(*args)
run through the whole reduction input and then output the total.
Methods inherited from Wukong::Streamer::Base
#after_stream, #bad_record!, #before_stream, #each_record, #emit, #initialize, #mapper, mapper, #monitor, #options, #run, run, #track
Constructor Details
This class inherits a constructor from Wukong::Streamer::Base
Instance Attribute Details
- (Object) sums
Returns the value of attribute sums
29 30 31 |
# File 'examples/size.rb', line 29 def sums @sums end |
Instance Method Details
- (Object) process(*vals)
add each corresponding column in the input
42 43 44 |
# File 'examples/size.rb', line 42 def process *vals self.sums = vals.zip( sums || [] ).map{|val,sum| val.to_i + sum.to_i } end |
- (Object) recordize(line)
The unix wc command uses whitespace, not tabs, so we'll recordize accordingly.
35 36 37 |
# File 'examples/size.rb', line 35 def recordize line line.strip.split(/\s+/) end |
- (Object) stream(*args)
run through the whole reduction input and then output the total
49 50 51 52 |
# File 'examples/size.rb', line 49 def stream *args super *args emit sums end |