Skip to content

Instantly share code, notes, and snippets.

{"inputs":"bucket",
"query":[
{"map":{"language":"javascript", "name":"Riak.mapValuesJson"}},
{"reduce":{"language":"javascript", "source":"function(values){ return values.slice(0,20); }"}}
]
}
@seancribbs
seancribbs / inputs.json
Created April 5, 2010 12:52
Code samples for Practical Map-Reduce: Forwarding and Collecting
{"inputs":[["users","seancribbs"]],
@seancribbs
seancribbs / links.rb
Created April 14, 2010 13:01
Code samples from my demos at Boston.rb - "Introducing Riak and Ripple"
$ curl --raw http://localhost:8098/riak/goog?keys=stream
13a
{"props":{"name":"goog","n_val":3,"allow_mult":false,"last_write_wins":false,"precommit":[],"postcommit":[],"chash_keyfun":{"mod":"riak_core_util","fun":"chash_std_keyfun"},"linkfun":{"mod":"riak_kv_wm_link_walker","fun":"mapreduce_linkfun"},"old_vclock":86400,"young_vclock":20,"big_vclock":50,"small_vclock":10}}
3cc
{"keys":["2010-03-29","2010-02-12","2010-02-09","2009-12-30","2009-12-03","2009-11-19","2009-10-23","2009-09-04","2009-08-17","2009-07-20","2009-06-17","2009-06-15","2009-04-07","2009-03-04","2009-03-03","2009-02-11","2009-01-09","2008-12-19","2008-11-26","2008-10-01","2008-07-16","2008-07-07","2008-06-20","2008-04-29","2008-03-27","2008-03-10","2008-02-04","2008-01-24","2008-01-07","2007-12-24","2007-12-12","2007-12-10","2007-11-27","2007-11-14","2007-11-13","2007-10-29","2007-10-17","2007-09-21","2007-09-04","2007-08-03","2007-07-13","2007-04-10","2007-02-05","2007-01-31","2006-11-30","2006-11-29","2006-11-15","2006-10-26","2006-10-25
PGError: ERROR: column "Riak" does not exist LINE 1: ...eta_tag_id = meta_tags.id AND (meta_tags.name IN ("Riak")) G... ^ : SELECT pages.* FROM pages, meta_tags, taggings WHERE pages.id = taggings.taggable_id AND taggings.taggable_type = 'Page' AND taggings.meta_tag_id = meta_tags.id AND (meta_tags.name IN ("Riak")) GROUP BY pages.id, pages.title, pages.slug, pages.breadcrumb, pages.class_name, pages.status_id, pages.parent_id, pages.layout_id, pages.created_at, pages.updated_at, pages.published_at, pages.created_by_id, pages.updated_by_id, pages.virtual, pages.lock_version, pages.description, pages.keywords HAVING COUNT(taggings.meta_tag_id) = 1
-module(test_helper).
-export([riak_test/1]).
riak_test(Fun) ->
start_riak(),
{ok, Riak} = riak:local_client(),
Ret = (catch Fun(Riak)),
stop_riak(),
case Ret of
%% Based on Okasaki 6.2.2
-module(binomial_heap).
-export([insert/2, insert/3, merge/2, delete/1, to_list/1, take/2,esize/1]).
-record(node,{rank,key,value,children=[]}).
% Inserts a new pair into the heap (or creates a new heap)
insert(Key,Value) ->
insert(Key,Value,[]).
insert(Key,Value,Forest) ->
Ripple.config = YAML.load_file(::File.expand_path("../../config/ripple.yml", __FILE__))[ENV['RACK_ENV']]
@seancribbs
seancribbs / application.rb
Created August 5, 2010 20:14
Code from the "Riak with Rails" webinar
# Add this line to your config/application.rb to enable
# initialization of Ripple, after the other framework railties
require 'ripple/railtie'
# To use the Riak cache store, place this line inside the
# Application class
config.cache_store = :riak_store
diff --git a/bin/mapreduce b/bin/mapreduce
index c661dda..ee7321a 100755
--- a/bin/mapreduce
+++ b/bin/mapreduce
@@ -25,9 +25,9 @@ map_func_word_count_per_tweet = <<-JAVASCRIPT
try {
tweet = Riak.mapValuesJson(value)[0];
word_count = tweet["text"] ? tweet["text"].split(" ").length : 0;
- return [ { word_count: word_count } ];
+ return [ word_count ];