Skip to content

Instantly share code, notes, and snippets.

@TylerBrock
Created June 6, 2012 20:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TylerBrock/2884708 to your computer and use it in GitHub Desktop.
Save TylerBrock/2884708 to your computer and use it in GitHub Desktop.
#!/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