JYKetamaHash 1.0.0

dotnet add package JYKetamaHash --version 1.0.0                
NuGet\Install-Package JYKetamaHash -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="JYKetamaHash" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add JYKetamaHash --version 1.0.0                
#r "nuget: JYKetamaHash, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install JYKetamaHash as a Cake Addin
#addin nuget:?package=JYKetamaHash&version=1.0.0

// Install JYKetamaHash as a Cake Tool
#tool nuget:?package=JYKetamaHash&version=1.0.0                

JYKetamaHash

Hash一致实现负载均衡 已经上传nuget(JYKetamaHash)

使用方法:
1.直接将数据发网服务端
hashRing.GetCurrent();
2.将字符串Key映射到服务端
hashRing.GetStoreNode(key)
3.将其它类型Key映射到服务端
byte[]k=你的转换方式(k)
hashRing.GetStoreNode(key)
需要将Key转换(序列化为byte[])

使用前需要将真实节点插入 ConsistencyRing hashRing = new ConsistencyRing(); hashRing.AddNode();

1.保持以前的代码,主要是网上找到的
2.优化算法,结合MurmurHash以及红黑树存储,专门的接口。
3.经测试,在小集合中,使用sortedlist更加高速。
4.使用了网友的红黑树,但是测试没有意义,红黑树需要遍历返回比当前key大的最近一个,很慢
5.经整合,在红黑树上添加了sortedlist维持数据,更加高效合理。
6.当前数据量百万级分片没有意义,源码中有说明。
7.已经尽可能优化,基本符合功能。所以采用Murmur算法能够加快速度。但是底层集合还是网上的sortedlist合理。 8.底层sortedlist返回比当前大的key,不能用网上的方法,而是自己写一个二分法查找,网上直接用linq不合理,用plinq也无意义

2018-12-21整合升级

1.首先是歉意.
2.我没有真正理解红黑树的算法含义,所以在使用期满足Hash一致时,没有找到合适的方法返回大于Key并且是最近的那个节点。
3.最近一天测试,发现有合理快速的办法返回最近的Key(也就是Hash环右侧的Key).很快速,因此恢复了使用红黑树,没有再使用sortedlist。
4.虽然我提供了TailMap方法,但是测试很慢(不影响Hash一致算法),不知道是不是我还是没有理解红黑树,没有找到最合适的方法返回。该功能是返回大于Key的所有数据节点。 5.总体说就是除了上次的第4嗲是错误的,其余还是支持的。

说明:如果有谁理解红黑树,请帮我完善TialMap方法。当前我的办法是找到第一个比当前Key大的节点,然后以此节点为基础,遍历其下面的所有节点,找到符合的节点。但是真的蛮。


2018-12-22
添加了java的实现方法,但是没有使用,只是当做参阅

2018-12-19 扩展了2个方法方便使用,更加符合c#方式

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 657 2/17/2019