Skip to content

Instantly share code, notes, and snippets.

@Jxck
Created May 26, 2011 15:55
Show Gist options
  • Save Jxck/993406 to your computer and use it in GitHub Desktop.
Save Jxck/993406 to your computer and use it in GitHub Desktop.
Hadoop Streaming with Ruby
#!/usr/bin/env ruby
ARGF.each do |line|
line.chomp!
words = line.split(' ')
printf("%s,1\n", words[8])
end
#!/usr/bin/env ruby
counter = Hash.new
ARGF.each do |line|
line.chomp!
words = line.split(',')
word = words[0]
count = words[1].to_i
if !counter.key?(word)
counter[word] = 1
else
counter[word]+=count
end
end
counter.each do |k, v|
printf("%s:%d\n", k, v)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment