Class: Spark::Command::KeyBy

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

Overview


KeyBy

Instance Method Summary collapse

Instance Method Details

#lazy_run(iterator) ⇒ Object



267
268
269
270
271
# File 'lib/spark/command/basic.rb', line 267

def lazy_run(iterator, *)
  iterator.map do |item|
    [@key_function.call(item), item]
  end
end

#run(iterator) ⇒ Object



260
261
262
263
264
265
# File 'lib/spark/command/basic.rb', line 260

def run(iterator, *)
  iterator.map! do |item|
    [@key_function.call(item), item]
  end
  iterator
end