Class: Spark::Command::CombineByKey::CombineWithZero

Inherits:
Base
  • Object
show all
Defined in:
lib/spark/command/pair.rb

Overview


Constant Summary

Constants inherited from Base

Base::DEFAULT_VARIABLE_OPTIONS

Instance Attribute Summary

Attributes inherited from Base

#__objects__

Instance Method Summary collapse

Methods inherited from Base

#lazy_run, #run

Methods inherited from Base

#before_run, error, #error, #execute, init_settings, #initialize, #log, #method_missing, #prepare, #prepared?, #settings, settings, #to_s, variable

Constructor Details

This class inherits a constructor from Spark::Command::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Spark::Command::Base

Instance Method Details

#_run(iterator) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/spark/command/pair.rb', line 65

def _run(iterator)
  # Not use combiners[key] ||= ..
  # it tests nil and not has_key?
  combiners = {}
  iterator.each do |key, value|
    unless combiners.has_key?(key)
      combiners[key] = @zero_value
    end

    combiners[key] = @merge_value.call(combiners[key], value)
  end
  combiners
end