Skip to content

Instantly share code, notes, and snippets.

@flazz
Created July 7, 2011 18:30
Show Gist options
  • Save flazz/1070198 to your computer and use it in GitHub Desktop.
Save flazz/1070198 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'riak'
require 'json'
require 'benchmark'
require 'pp'
$client = Riak::Client.new :protocol => :pbc
def keys_in_range
end_time = 1310135095305
start_time = end_time - 86400000
puts (start_time..end_time)
mr = Riak::MapReduce.new($client).
filter("events") {
tokenize '-', 2
string_to_int
between start_time, end_time
}.
map(<<-MAP, :keep => true)
function(v) { return [v.key]; }
MAP
results = mr.run
puts results
end
puts Benchmark.measure { keys_in_range }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment