Skip to content

Instantly share code, notes, and snippets.

@TylerBrock
Created June 6, 2012 20:55
Show Gist options
  • Select an option

  • Save TylerBrock/2884708 to your computer and use it in GitHub Desktop.

Select an option

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