That is correct -- that is, you can choose what chash_keyfun to use. 

Hashing the key to the vnode is separate from the backend storage, so you can 
still store the same key in different buckets.

Sean Cribbs <[email protected]>
Developer Advocate
Basho Technologies, Inc.
http://basho.com/

On Jan 10, 2011, at 12:07 PM, 吴磊 wrote:

> Thanks. I checked the source code. It looks I ?CAN? use my own
> chash_keyfun to replace the default riak_core_util:chash_std_keyfun.
> Mine  only hash the Key, (not including Bucket. But bitcask still use
> {Bucket,Key} as hash key to store).
> 
> By this way, I make the objects, which have the same key but in
> different buckets, stored in the same vnode. Am I break something?
> 
> 
> On 1/10/11, Sean Cribbs <[email protected]> wrote:
>> To clear up this confusion, let me spell it out. The hash value of any
>> bucket/key pair is the SHA1 of the serialized tuple of {Bucket, Key}. That
>> is, {Bucket, Key} -> term_to_binary -> sha1.
>> 
>> The actual function that does the hashing:
>> 
>> https://github.com/basho/riak_core/blob/master/src/chash.erl#L140
>> 
>> The helper function that most riak_core applications use:
>> 
>> https://github.com/basho/riak_core/blob/master/src/riak_core_util.erl#L160
>> 
>> An example of usage in the Get FSM:
>> 
>> https://github.com/basho/riak_kv/blob/master/src/riak_kv_get_fsm.erl#L70
>> 
>> Sean Cribbs <[email protected]>
>> Developer Advocate
>> Basho Technologies, Inc.
>> http://basho.com/
>> 
>> On Jan 10, 2011, at 7:36 AM, Jeremiah Peschka wrote:
>> 
>>> I believe that keys hare hashed using a combination of bucket name and key
>>> name. The bucket+key string is then run through SHA1. Don't take that as
>>> gospel, though. I searched my mailing list archive and couldn't find it,
>>> but this also could have happened on the IRC channel. Hopefully someone
>>> who knows the source can point you in the right direction.
>>> 
>>> Until then, you can safely assume that the hashed key is the result of
>>> SHA1(bucket_name + key_name). You should be able to determine if they're
>>> on the same node by hashing both bucket/key combos and then looking at the
>>> ring. Take a look at
>>> http://wiki.basho.com/Replication.html#Routing-an-object-to-a-set-of-partitions
>>> for more info on looking at the state of the ring.
>>> 
>>> Jeremiah Peschka
>>> Microsoft SQL Server MVP
>>> MCITP: Database Developer, DBA
>>> 
>>> 
>>> On Mon, Jan 10, 2011 at 3:42 AM, 吴磊 <[email protected]> wrote:
>>> Hi, guys
>>> 
>>> I'm a newbie to Riak,  I have the question. Will the objects, which in
>>> different buckets but have the same key, be stored in the same vnode
>>> and be managed by this vnode?
>>> 
>>> Best regards,
>>> 
>>> _______________________________________________
>>> riak-users mailing list
>>> [email protected]
>>> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
>>> 
>>> _______________________________________________
>>> riak-users mailing list
>>> [email protected]
>>> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
>> 
>> 


_______________________________________________
riak-users mailing list
[email protected]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com

Reply via email to