Class: Mandy::Reducers::SumReducer

Inherits:
Base
  • Object
show all
Defined in:
lib/mandy/reducers/sum_reducer.rb

Constant Summary

Constants inherited from Task

Task::DEFAULT_COUNTER_GROUP, Task::KEY_VALUE_SEPERATOR, Task::NUMERIC_PADDING

Instance Attribute Summary

Attributes inherited from Task

#input_format, #output_format

Instance Method Summary collapse

Methods inherited from Base

compile, #execute

Methods included from IO::OutputFormatting

#output_serialize_key, #output_serialize_value

Methods inherited from Task

#emit, #get, #initialize, #put

Constructor Details

This class inherits a constructor from Mandy::Task

Instance Method Details

#reducer(key, values) ⇒ Object



4
5
6
# File 'lib/mandy/reducers/sum_reducer.rb', line 4

def reducer(key,values)
  emit(key, values.inject(0) {|sum,count| sum+count.to_f})
end