Class: MapContext
- Inherits:
-
Object
- Object
- MapContext
- Defined in:
- lib/learn_mapreduce.rb
Overview
The context within the mapper Used to give a custom ‘emit’ function
Instance Attribute Summary collapse
-
#emitted ⇒ Object
Returns the value of attribute emitted.
-
#shuffled ⇒ Object
Returns the value of attribute shuffled.
Instance Method Summary collapse
- #emit(key, value) ⇒ Object
-
#initialize ⇒ MapContext
constructor
A new instance of MapContext.
Constructor Details
#initialize ⇒ MapContext
Returns a new instance of MapContext.
49 50 51 52 |
# File 'lib/learn_mapreduce.rb', line 49 def initialize @emitted = [] @shuffled = {} end |
Instance Attribute Details
#emitted ⇒ Object
Returns the value of attribute emitted.
47 48 49 |
# File 'lib/learn_mapreduce.rb', line 47 def emitted @emitted end |
#shuffled ⇒ Object
Returns the value of attribute shuffled.
47 48 49 |
# File 'lib/learn_mapreduce.rb', line 47 def shuffled @shuffled end |
Instance Method Details
#emit(key, value) ⇒ Object
54 55 56 57 |
# File 'lib/learn_mapreduce.rb', line 54 def emit key, value @emitted.push([key, value]) (@shuffled[key] ||= []).push(value) end |