aboutsummaryrefslogtreecommitdiffstats
path: root/lib/mnesia/src
diff options
context:
space:
mode:
authorHenrik Nord <[email protected]>2011-11-18 11:19:37 +0100
committerHenrik Nord <[email protected]>2011-11-18 11:19:41 +0100
commit6e74b5800d5870d5fc98d90a6e377a0301f75d4c (patch)
tree38e3a54e11042e59ed918936232ac1984c24ed35 /lib/mnesia/src
parent2e6181a106f0dfd1b588b9aeb408e5883a662c76 (diff)
parent1d6762d162560197facb263e03e0cd4958b2418d (diff)
downloadotp-6e74b5800d5870d5fc98d90a6e377a0301f75d4c.tar.gz
otp-6e74b5800d5870d5fc98d90a6e377a0301f75d4c.tar.bz2
otp-6e74b5800d5870d5fc98d90a6e377a0301f75d4c.zip
Merge branch 'pr/mnesia_frag_hash'
* pr/mnesia_frag_hash: add mnesia_frag_hash test Reduce calls to phash in key_to_frag_number OTP-9722
Diffstat (limited to 'lib/mnesia/src')
-rw-r--r--lib/mnesia/src/mnesia_frag_hash.erl18
1 files changed, 8 insertions, 10 deletions
diff --git a/lib/mnesia/src/mnesia_frag_hash.erl b/lib/mnesia/src/mnesia_frag_hash.erl
index 610ba2535c..d70579c3b3 100644
--- a/lib/mnesia/src/mnesia_frag_hash.erl
+++ b/lib/mnesia/src/mnesia_frag_hash.erl
@@ -101,21 +101,19 @@ del_frag(OldState) ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-key_to_frag_number(#hash_state{function = phash, next_n_to_split = SplitN, n_doubles = L}, Key) ->
- P = SplitN,
- A = erlang:phash(Key, power2(L)),
+key_to_frag_number(#hash_state{function = phash, n_fragments = N, n_doubles = L}, Key) ->
+ A = erlang:phash(Key, power2(L + 1)),
if
- A < P ->
- erlang:phash(Key, power2(L + 1));
+ A > N ->
+ A - power2(L);
true ->
A
end;
-key_to_frag_number(#hash_state{function = phash2, next_n_to_split = SplitN, n_doubles = L}, Key) ->
- P = SplitN,
- A = erlang:phash2(Key, power2(L)) + 1,
+key_to_frag_number(#hash_state{function = phash2, n_fragments = N, n_doubles = L}, Key) ->
+ A = erlang:phash2(Key, power2(L + 1)) + 1,
if
- A < P ->
- erlang:phash2(Key, power2(L + 1)) + 1;
+ A > N ->
+ A - power2(L);
true ->
A
end;