Add support for performing a magic hash on a binary
Ignore unnecessray term_to_binary if already binary. This will be useful when we use magic_hash in tictac_trees we wish to be exportable.
This commit is contained in:
parent
f50a2a19d3
commit
2f9afa1469
1 changed files with 4 additions and 2 deletions
|
@ -87,10 +87,12 @@ magic_hash({?RIAK_TAG, Bucket, Key, _SubKey}) ->
|
|||
magic_hash({Bucket, Key});
|
||||
magic_hash({?STD_TAG, Bucket, Key, _SubKey}) ->
|
||||
magic_hash({Bucket, Key});
|
||||
magic_hash({binary, BinaryKey}) ->
|
||||
H = 5381,
|
||||
hash1(H, BinaryKey) band 16#FFFFFFFF;
|
||||
magic_hash(AnyKey) ->
|
||||
BK = term_to_binary(AnyKey),
|
||||
H = 5381,
|
||||
hash1(H, BK) band 16#FFFFFFFF.
|
||||
magic_hash({binary, BK}).
|
||||
|
||||
hash1(H, <<>>) ->
|
||||
H;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue