HashPartitionResolver Class

Definition

Caution

Support for IPartitionResolver based classes is now obsolete. It's recommended that you use partitioned collections for higher storage and throughput.

HashPartitionResolver implements partitioning based on the value of a hash function, allowing you to evenly distribute requests and data across a number of partitions in the Azure Cosmos DB service.

[System.Obsolete("Support for IPartitionResolver based classes is now obsolete. It's recommended that you use partitioned collections for higher storage and throughput.")]
public class HashPartitionResolver : IDisposable, Microsoft.Azure.Documents.Client.IPartitionResolver
[<System.Obsolete("Support for IPartitionResolver based classes is now obsolete. It's recommended that you use partitioned collections for higher storage and throughput.")>]
type HashPartitionResolver = class
    interface IPartitionResolver
    interface IDisposable
Public Class HashPartitionResolver
Implements IDisposable, IPartitionResolver
Inheritance
HashPartitionResolver
Attributes
Implements

Remarks

Support for IPartitionResolver based classes is now obsolete. It's recommended that you use Partitioned Collections for higher storage and throughput.

The HashPartitionResolver class internally implements a consistent hash ring over the hash function specified in the IHashGenerator interface. By default, the HashPartitionResolver provides an MD5 hash function, but this can be swapped out with a different hashing implementation. The consistent hash ring creates 16 replicas for each collection in order to achieve a more uniform distribution of documents across collections.

The hash partitioning is most suitable for partitioning when the partition key has a high cardinality because it will distribute the data evenly across collections. Typically hash partitioning uses the id property. A common use cases for hash partitioning is data produced or consumed from a large number of distinct clients or for storing user profiles, catalog items, and telemetry data.

Constructors

HashPartitionResolver(Func<Object,String>, IEnumerable<String>, Int32, IHashGenerator)

Initializes a new instance of the HashPartitionResolver in the Azure Cosmos DB service using the specified partitionKeyExtractor value.

HashPartitionResolver(String, IEnumerable<String>, Int32, IHashGenerator)

Initializes a new instance of the HashPartitionResolver in the Azure Cosmos DB service using the specified partitionKeyPropertyName value.

Properties

CollectionLinks

Gets the IEnumerable of collection links used for hashing in the Azure Cosmos DB service.

HashGenerator

Gets the HashGenerator used in consistent hashing.

NumberOfVirtualNodesPerCollection

The number of virtual nodes per collection in the conisistent hash ring in the Azure Cosmos DB service. This controls the compromise of skewness of documents accross collections vs the consistent hashing latency.

PartitionKeyExtractor

Gets the function to extract the partition key from an object in the Azure Cosmos DB service.

PartitionKeyPropertyName

Gets the name of the property in the document to execute the hashing on in the Azure Cosmos DB service.

Methods

Dispose()

Disposes the resolver in the Azure Cosmos DB service.

GetPartitionKey(Object)

Extracts the partition key from the specified document using the specified PartitionKeyPropertyName property or PartitionKeyExtractor function in order of preference in the Azure Cosmos DB service.

ResolveForCreate(Object)

Given a partition key, returns the collection self-link for creating a document in the Azure Cosmos DB service.

ResolveForRead(Object)

Given a partition key, returns a list of collection links to read from using its hash in the Azure Cosmos DB service.

Applies to