Create a gist now

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
require 'mongo-hadoop'
MongoHadoop.reduce do |key, values|
count = sum = 0
values.each do |value|
count += 1
sum += value['num']
end
{ :_id => key, :average => sum / count }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment