Class: Jrf::Stage::MapReducer
- Inherits:
-
Object
- Object
- Jrf::Stage::MapReducer
- Defined in:
- lib/jrf/stage.rb
Defined Under Namespace
Classes: SlotState
Instance Attribute Summary collapse
-
#slots ⇒ Object
readonly
Returns the value of attribute slots.
Instance Method Summary collapse
- #array_input? ⇒ Boolean
- #finish ⇒ Object
-
#initialize(builtin, array_input) ⇒ MapReducer
constructor
A new instance of MapReducer.
- #slot(key) ⇒ Object
Constructor Details
#initialize(builtin, array_input) ⇒ MapReducer
Returns a new instance of MapReducer.
238 239 240 241 242 |
# File 'lib/jrf/stage.rb', line 238 def initialize(builtin, array_input) @builtin = builtin @array_input = array_input @slots = {} end |
Instance Attribute Details
#slots ⇒ Object (readonly)
Returns the value of attribute slots.
236 237 238 |
# File 'lib/jrf/stage.rb', line 236 def slots @slots end |
Instance Method Details
#array_input? ⇒ Boolean
244 245 246 |
# File 'lib/jrf/stage.rb', line 244 def array_input? @array_input end |
#finish ⇒ Object
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 |
# File 'lib/jrf/stage.rb', line 252 def finish if @array_input keys = @slots.keys.sort [keys.map { |k| Stage.resolve_template(@slots[k].template, @slots[k].reducers) }] else case @builtin when :map [@slots.map { |_k, s| Stage.resolve_template(s.template, s.reducers) }] when :map_values, :group_by result = {} @slots.each { |k, s| result[k] = Stage.resolve_template(s.template, s.reducers) } [result] else raise ArgumentError, "unexpected builtin: #{@builtin}" end end end |