node-hashring icon indicating copy to clipboard operation
node-hashring copied to clipboard

Automatically calculating weight / length

Open tcf909 opened this issue 9 years ago • 3 comments

On line 129: ", length = Math.floor(percentage * vnodes * servers.length)"

the length is automatically calculated. The problem being with 7 nodes, the length ends up being 39.999999999 (where it should actually be 40) and this then throws off the consistent aspects of calculation (wrong lookups start to occur until the 8th node is added).

tcf909 avatar Aug 10 '16 20:08 tcf909

I fixed this on my end by using Math.round instead of Math.floor

tcf909 avatar Aug 10 '16 20:08 tcf909

On vacation atm, will look at it once im back. But if its a bug, feel free to make a pr for it

On Aug 10, 2016, at 10:05 PM, T.C. Ferguson [email protected] wrote:

I fixed this on my end by using Math.round instead of Math.floor

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

3rd-Eden avatar Aug 11 '16 23:08 3rd-Eden

Posted a small PR at #45

tcf909 avatar Aug 12 '16 19:08 tcf909