Class: Jrf::Stage::MapReducer

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

Defined Under Namespace

Classes: SlotState

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type) ⇒ MapReducer

Returns a new instance of MapReducer.



198
199
200
201
# File 'lib/jrf/stage.rb', line 198

def initialize(type)
  @type = type
  @slots = {}
end

Instance Attribute Details

#slotsObject (readonly)

Returns the value of attribute slots.



196
197
198
# File 'lib/jrf/stage.rb', line 196

def slots
  @slots
end

Instance Method Details

#finishObject



207
208
209
210
211
212
213
214
215
216
217
# File 'lib/jrf/stage.rb', line 207

def finish
  case @type
  when :array
    keys = @slots.keys.sort
    [keys.map { |k| Stage.resolve_template(@slots[k].template, @slots[k].reducers) }]
  when :hash
    result = {}
    @slots.each { |k, s| result[k] = Stage.resolve_template(s.template, s.reducers) }
    [result]
  end
end

#slot(key) ⇒ Object



203
204
205
# File 'lib/jrf/stage.rb', line 203

def slot(key)
  @slots[key] ||= SlotState.new
end