Sha256: 01b5068939c33b5a274ae2e5fd79a0bc10545e6e65771ab4684e9a82638b5c28
Contents?: true
Size: 736 Bytes
Versions: 12
Compression:
Stored size: 736 Bytes
Contents
class MapreduceTest include SkynetDebugger def self.run job = Skynet::Job.new( :mappers => 2, :reducers => 1, :map_reduce_class => self, :map_data => [OpenStruct.new({:created_by => 2}),OpenStruct.new({:created_by => 2}),OpenStruct.new({:created_by => 3})] ) results = job.run end def self.map(profiles) result = Array.new profiles.each do |profile| result << [profile.created_by, 1] if profile.created_by end result end def self.reduce(pairs) totals = Hash.new pairs.each do |pair| created_by, count = pair[0], pair[1] totals[created_by] ||= 0 totals[created_by] += count end totals end end
Version data entries
12 entries across 12 versions & 3 rubygems