Class ShardingUtils
WARNING!!! Any change to this class may lead to change in sharding distribution and render all existing data partitioning invalid. Use EXTREME care!
Inheritance
Inherited Members
Namespace: Azos.Sky.Mdb
Assembly: Azos.Sky.dll
Syntax
public static class ShardingUtils
Methods
ByteArrayToShardingID(Byte[])
Gets sharding ID for byte[], that is - computes byte[] hash as UInt64 . WARNING! Changing this function will render all existing sharding partitioning invalid. Use extreme care!
Declaration
public static ulong ByteArrayToShardingID(byte[] key)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Byte[] | key |
Returns
| Type | Description |
|---|---|
| System.UInt64 |
MakeGDIDRangePartition(GDID, Int32, Int32)
Returns GDID range partition calculated as the counter bit shift from the original ID. This function is used to organize transactions into "batches" that otherwise would have required an unnecessary lookup entity (i.e. transaction partition). With this function the partition may be derived right from the original GDID
Declaration
public static GDID MakeGDIDRangePartition(GDID id, int bitSize = 16, int bitSubShard = 4)
Parameters
| Type | Name | Description |
|---|---|---|
| GDID | id | Original ID |
| System.Int32 | bitSize | Must be between 4..24, so the partitions are caped at 16M(2^24) entries |
| System.Int32 | bitSubShard | Must be between 0 and less than bit size |
Returns
| Type | Description |
|---|---|
| GDID | Partition ID obtained id |
ObjectToShardingID(Object)
Gets sharding ID for object that can be IShardingIDProvider, string, parcel, GDID, long/ulong and int/uint. WARNING! Changing this function will render all existing sharding partitioning invalid. Use extreme care!
Declaration
public static ulong ObjectToShardingID(object key)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | key |
Returns
| Type | Description |
|---|---|
| System.UInt64 |
StringToShardingID(String)
Gets sharding ID for string, that is - computes string hash as UInt64 . WARNING! Changing this function will render all existing sharding partitioning invalid. Use extreme care!
Declaration
public static ulong StringToShardingID(string key)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | key |
Returns
| Type | Description |
|---|---|
| System.UInt64 |
TakeFirstChars(String, Int32)
Takes first X chars from a trimmed string. If a string is null returns null. If a string does not have enough chars the function returns what the string has. WARNING! Changing this function will render all existing sharding partitioning invalid. Use extreme care!
Declaration
public static string TakeFirstChars(string str, int count)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | str | |
| System.Int32 | count |
Returns
| Type | Description |
|---|---|
| System.String |