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.



74
75
76
77
# File 'lib/learn_mapreduce.rb', line 74

def initialize
   @emitted = []
   @shuffled = {}
end

Instance Attribute Details

#emittedObject

Returns the value of attribute emitted.



72
73
74
# File 'lib/learn_mapreduce.rb', line 72

def emitted
  @emitted
end

#shuffledObject

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