From 4928ce68b31b7fd5ce3fcf1d4ebc4a786fd045eb Mon Sep 17 00:00:00 2001 From: Adam Kocoloski Date: Thu, 10 Jun 2010 09:45:28 -0400 Subject: remove hash_int(), just convert hash() to int inline --- src/partitions.erl | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/partitions.erl b/src/partitions.erl index cfc1d90b..0a20d195 100644 --- a/src/partitions.erl +++ b/src/partitions.erl @@ -45,7 +45,7 @@ install_fullmap(DbName, Fullmap, FullNodes, Options) -> write_db_doc(Doc). for_key(DbName, Key) -> - HashKey = hash_int(hash(Key)), + <> = hash(Key), Head = #shard{ name = '_', node = '_', @@ -88,8 +88,7 @@ const(Const, Options) -> %% @doc hash the dbname, and return the corresponding node for seeding a ring seednode(DbName, Nodes) -> - Hash = hash(DbName), - HashInt = hash_int(Hash), + <> = hash(DbName), Size = partition_range(length(Nodes)), Factor = (HashInt div Size), lists:nth(Factor+1, Nodes). @@ -139,14 +138,6 @@ partners(DbName, N, Node, Nodes, {Beg,End}) -> name=shard_name(Beg,DbName)} end, Partners). - -%% @doc turn hash into an integer -hash_int(Hash) when is_binary(Hash) -> - <> = Hash, - IndexAsInt; -hash_int(Hash) when is_integer(Hash) -> - Hash. - %% @doc size of one partition in the ring partition_range(Q) -> trunc( ?RINGTOP / Q ). % SHA-1 space / Q -- cgit v1.2.3