Permalink
Browse files

Add a few decent size data set map egs

  • Loading branch information...
1 parent 89a38b9 commit 362096c1cf7670af8cde667fa79756d34e9d3c30 @lstoll committed Feb 18, 2010
@@ -0,0 +1,22 @@
+require 'riak'
+require '../lib/utils.rb'
+
+# Connect and get a bucket instance
+client = Riak::Client.new
+bucket = client.bucket("test4", :keys => false) # we don't want to load all the keys!
+
+time "Simple map - Select 10 by batch" do
+ puts Riak::MapReduce.new(client).add(bucket.name).
+ map("function(v) {
+ // Load the items data, and parse it
+ obj = JSON.parse(v.values[0].data);
+ if (obj.batch && obj.batch == '513') {
+ return [obj];
+ }
+ else {
+ return [];
+ }
+ }", :keep => true).run
+end
+
+
@@ -0,0 +1,12 @@
+{"item"=>"one", "batch"=>513}
+{"item"=>"one", "batch"=>513}
+{"item"=>"one", "batch"=>513}
+{"item"=>"one", "batch"=>513}
+{"item"=>"one", "batch"=>513}
+{"item"=>"one", "batch"=>513}
+{"item"=>"one", "batch"=>513}
+{"item"=>"one", "batch"=>513}
+{"item"=>"one", "batch"=>513}
+{"item"=>"one", "batch"=>513}
+Simple map - Select 10 by batch execution time: 10.798442s
+
View
@@ -0,0 +1,10 @@
+function FourSixCachedTest(v) {
+ // Load the items data, and parse it
+ obj = JSON.parse(v.values[0].data);
+ if (obj.batch && obj.batch == '513') {
+ return [obj];
+ }
+ else {
+ return [];
+ }
+}
@@ -0,0 +1,24 @@
+###
+# This one requires some setup! You need a line like
+#
+# {js_source_dir, "/usr/local/var/lib/riak-js"}
+#
+# in
+#
+# /usr/local/Cellar/riak/0.8/etc/app.config
+#
+# You will then need to copy 5_cached.js into that dir.
+
+require 'riak'
+require '../lib/utils.rb'
+
+# Connect and get a bucket instance
+client = Riak::Client.new
+bucket = client.bucket("test4", :keys => false) # we don't want to load all the keys!
+
+time "Simple map - Select 10 by batch (Server function)" do
+ puts Riak::MapReduce.new(client).add(bucket.name).
+ map(:function => "FourFiveCachedTest", :keep => true).run
+end
+
+
@@ -0,0 +1,25 @@
+lstoll@linc ~/dev/riak/playground/4_perf_tests <master⚡> $ ruby 5_cached_map_test.rb
+{"item"=>"one", "batch"=>513}
+{"item"=>"one", "batch"=>513}
+{"item"=>"one", "batch"=>513}
+{"item"=>"one", "batch"=>513}
+{"item"=>"one", "batch"=>513}
+{"item"=>"one", "batch"=>513}
+{"item"=>"one", "batch"=>513}
+{"item"=>"one", "batch"=>513}
+{"item"=>"one", "batch"=>513}
+{"item"=>"one", "batch"=>513}
+Simple map - Select 10 by batch execution time: 11.826533s
+lstoll@linc ~/dev/riak/playground/4_perf_tests <master⚡> $ ruby 5_cached_map_test.rb
+{"item"=>"one", "batch"=>513}
+{"item"=>"one", "batch"=>513}
+{"item"=>"one", "batch"=>513}
+{"item"=>"one", "batch"=>513}
+{"item"=>"one", "batch"=>513}
+{"item"=>"one", "batch"=>513}
+{"item"=>"one", "batch"=>513}
+{"item"=>"one", "batch"=>513}
+{"item"=>"one", "batch"=>513}
+{"item"=>"one", "batch"=>513}
+Simple map - Select 10 by batch execution time: 4.837789s
+

0 comments on commit 362096c

Please sign in to comment.