Class: Spark::Command::FlatMapValues

Inherits:
Object
  • Object
show all
Defined in:
lib/spark/command/pair.rb

Overview


FlatMapValues

Instance Method Summary collapse

Instance Method Details

#run(iterator) ⇒ Object



113
114
115
116
117
118
119
120
121
122
123
# File 'lib/spark/command/pair.rb', line 113

def run(iterator, *)
  iterator.map! do |(key, values)|
    values = @map_function.call(values)
    values.flatten!(1)
    values.map! do |value|
      [key, value]
    end
  end
  iterator.flatten!(1)
  iterator
end