Installing a custom hash function

Simon Fell sfell at
Wed Apr 24 13:52:53 EDT 2013

I'm following the instructions at to setup a custom hash function, how safe or not is it to assume its the same process ?

Currently when i try and PUT the bucket config to specify the new function i get back


My .beam file is in /tmp/riak_fun, and i added {add_paths, ["/tmp/riak_fun"]}, to the riak_kv section in the app.config, and the .beam file is world readable.

I'm running this to set the properties
curl -v --data-binary @props.json -H Content-Type:application/json http://riak1.local:8098/riak/ex -X PUT

props.json contains
{"props": { "chash_keyfun":{"mod":"sfdc_hash","fun":"kv_hash_fun"} } }

Is there a more detailed log somewhere? is there an easy way to see if riak can actually load my .beam file?

the source for the module is very straighforward (we just want to hash on part of the key)

-export([extract_id/1, kv_hash_fun/1]).

extract_id(Key) ->
	case binary:match(Key,<<",">>) of
		{Pos, 1} -> binary:part(Key, 0, Pos);
		_ -> Key

kv_hash_fun({Bucket,Key}) ->
	chash:key_of({Bucket, extract_id(Key)}).

This is with riak 1.2.0 on Unbuntu.


More information about the riak-users mailing list