MCPcopy Create free account
hub / github.com/Permify/permify / GetPartitionID

Method GetPartitionID

pkg/consistent/consistent.go:367–373  ·  view source on GitHub ↗

GetPartitionID calculates and returns the partition ID for a given key. The partition ID is determined by hashing the key and applying modulo operation with the partition count.

(key []byte)

Source from the content-addressed store, hash-verified

365// GetPartitionID calculates and returns the partition ID for a given key.
366// The partition ID is determined by hashing the key and applying modulo operation with the partition count.
367func (c *Consistent) GetPartitionID(key []byte) int {
368 // Generate a hash value for the given key using the configured hasher.
369 hashValue := c.hasher(key)
370
371 // Calculate the partition ID by taking the modulus of the hash value with the partition count.
372 return int(hashValue % c.partitionCount)
373}
374
375// GetPartitionOwner retrieves the owner of the specified partition in a thread-safe manner.
376// It ensures that the access to shared resources is synchronized.

Callers 2

LocateKeyMethod · 0.95
ClosestNMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected