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.
74 75 76 77 |
# File 'lib/learn_mapreduce.rb', line 74 def initialize @emitted = [] @shuffled = {} end |
Instance Attribute Details
#emitted ⇒ Object
Returns the value of attribute emitted.
72 73 74 |
# File 'lib/learn_mapreduce.rb', line 72 def emitted @emitted end |
#shuffled ⇒ Object
Returns the value of attribute shuffled.
72 73 74 |
# File 'lib/learn_mapreduce.rb', line 72 def shuffled @shuffled end |
Instance Method Details
#emit(key, value) ⇒ Object
79 80 81 82 |
# File 'lib/learn_mapreduce.rb', line 79 def emit key, value @emitted.push([key, value]) (@shuffled[key] ||= []).push(value) end |