HashPartitionResolver Class

  • java.lang.Object
    • com.microsoft.azure.documentdb.HashPartitionResolver

Implements


public class HashPartitionResolver
implements PartitionResolver

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

Constructor Summary

Constructor Description
HashPartitionResolver(PartitionKeyExtractor partitionKeyExtractor, Iterable<String> collectionLinks)

HashPartitionResolver constructor taking in the PartitionKeyExtractor and collection links with default number of virtual nodes per collection(128) and default hash generator(MurmurHash3)

HashPartitionResolver(PartitionKeyExtractor partitionKeyExtractor, Iterable<String> collectionLinks, HashGenerator hashGenerator)

HashPartitionResolver constructor taking in the PartitionKeyExtractor, collection Links, hash generator with default number of virtual nodes per collection(128)

HashPartitionResolver(PartitionKeyExtractor partitionKeyExtractor, Iterable<String> collectionLinks, int numberOfVirtualNodesPerCollection)

HashPartitionResolver constructor taking in the PartitionKeyExtractor, collection Links, number of virtual nodes per collection and default hash generator(MurmurHash3)

HashPartitionResolver(PartitionKeyExtractor partitionKeyExtractor, Iterable<String> collectionLinks, int numberOfVirtualNodesPerCollection, HashGenerator hashGenerator)

HashPartitionResolver constructor taking in the PartitionKeyExtractor, collection Links, hash generator and number of virtual nodes per collection

Method Summary

Modifier and Type Method and Description
java.lang.String resolveForCreate(Object document)

Resolves the collection for creating the document based on the partition key.

java.lang.Iterable<java.lang.String> resolveForRead(Object partitionKey)

Resolves the collection for reading/querying the documents based on the partition key.

Methods inherited from java.lang.Object

java.lang.Object.clone java.lang.Object.equals java.lang.Object.finalize java.lang.Object.getClass java.lang.Object.hashCode java.lang.Object.notify java.lang.Object.notifyAll java.lang.Object.toString java.lang.Object.wait java.lang.Object.wait java.lang.Object.wait

Constructor Details

HashPartitionResolver

public HashPartitionResolver(PartitionKeyExtractor partitionKeyExtractor, Iterable collectionLinks)

HashPartitionResolver constructor taking in the PartitionKeyExtractor and collection links with default number of virtual nodes per collection(128) and default hash generator(MurmurHash3)

Parameters:

partitionKeyExtractor - an instance of class that implements PartitionKeyExtractor interface
collectionLinks - the links of collections participating in partitioning

HashPartitionResolver

public HashPartitionResolver(PartitionKeyExtractor partitionKeyExtractor, Iterable collectionLinks, HashGenerator hashGenerator)

HashPartitionResolver constructor taking in the PartitionKeyExtractor, collection Links, hash generator with default number of virtual nodes per collection(128)

Parameters:

partitionKeyExtractor - an instance of class that implements PartitionKeyExtractor interface
collectionLinks - the links of collections participating in partitioning
hashGenerator - hash generator used for hashing

HashPartitionResolver

public HashPartitionResolver(PartitionKeyExtractor partitionKeyExtractor, Iterable collectionLinks, int numberOfVirtualNodesPerCollection)

HashPartitionResolver constructor taking in the PartitionKeyExtractor, collection Links, number of virtual nodes per collection and default hash generator(MurmurHash3)

Parameters:

partitionKeyExtractor - an instance of class that implements PartitionKeyExtractor interface
collectionLinks - the links of collections participating in partitioning
numberOfVirtualNodesPerCollection - number of virtual nodes per collection

HashPartitionResolver

public HashPartitionResolver(PartitionKeyExtractor partitionKeyExtractor, Iterable collectionLinks, int numberOfVirtualNodesPerCollection, HashGenerator hashGenerator)

HashPartitionResolver constructor taking in the PartitionKeyExtractor, collection Links, hash generator and number of virtual nodes per collection

Parameters:

partitionKeyExtractor - an instance of class that implements PartitionKeyExtractor interface
collectionLinks - the links of collections participating in partitioning
numberOfVirtualNodesPerCollection - number of virtual nodes per collection
hashGenerator - hash generator used for hashing

Method Details

resolveForCreate

public String resolveForCreate(Object document)

Resolves the collection for creating the document based on the partition key.

Parameters:

document - the document to be created

Returns:

collection Self link or Name based link which should handle the Create operation.

resolveForRead

public Iterable resolveForRead(Object partitionKey)

Resolves the collection for reading/querying the documents based on the partition key.

Parameters:

partitionKey - the partition key value

Returns:

collection Self link(s) or Name based link(s) which should handle the Read operation

Applies to