Class VBucketMapper
Provides services to apply hash algorithms and map a key to a vBucket ID.
Inherited Members
Namespace: Couchbase.Core.Sharding
Assembly: Couchbase.NetClient.dll
Syntax
[InterfaceStability(Level.Volatile)]
public static class VBucketMapper
Methods
| Edit this page View SourceGetMask(int)
Calculate the mask used to calculate vBucket IDs based on the number of vBuckets in the cluster. This is primarily a performance optimization, since this can be calculated once and stored.
Declaration
public static short GetMask(int vBucketCount)
Parameters
| Type | Name | Description |
|---|---|---|
| int | vBucketCount | The number of vBuckets in the cluster. |
Returns
| Type | Description |
|---|---|
| short | The mask to use when calculating the vBucket ID. |
GetVBucketId(ReadOnlySpan<byte>, short)
Get the vBucketID for a given key.
Declaration
public static short GetVBucketId(ReadOnlySpan<byte> keyBytes, short mask)
Parameters
| Type | Name | Description |
|---|---|---|
| ReadOnlySpan<byte> | keyBytes | The key encoded as UTF-8. |
| short | mask | The previously calculated mask from a call to GetMask(int). |
Returns
| Type | Description |
|---|---|
| short | The vBucketID for the key. |
GetVBucketId(ReadOnlySpan<byte>, int)
Get the vBucketID for a given key.
Declaration
public static short GetVBucketId(ReadOnlySpan<byte> keyBytes, int vBucketCount)
Parameters
| Type | Name | Description |
|---|---|---|
| ReadOnlySpan<byte> | keyBytes | The key encoded as UTF-8. |
| int | vBucketCount | The number of vBuckets in the cluster. |
Returns
| Type | Description |
|---|---|
| short | The vBucketID for the key. |
GetVBucketId(string, short)
Get the vBucketID for a given key.
Declaration
public static short GetVBucketId(string key, short mask)
Parameters
| Type | Name | Description |
|---|---|---|
| string | key | The key. |
| short | mask | The previously calculated mask from a call to GetMask(int). |
Returns
| Type | Description |
|---|---|
| short | The vBucketID for the key. |