Class: MapContext

Inherits:
Object
  • Object
show all
Defined in:
lib/learn_mapreduce.rb

Overview

The context within the mapper Used to give a custom ‘emit’ function

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMapContext

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

#emittedObject

Returns the value of attribute emitted.



47
48
49
# File 'lib/learn_mapreduce.rb', line 47

def emitted
  @emitted
end

#shuffledObject

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