EdgeAIG's picture
download
raw
820 Bytes
/**
* Internal hashing helpers used by cluster routing to map entity identifiers to
* shard numbers. The hash is intentionally small and deterministic for
* JavaScript strings so every node that sees the same entity id and sharding
* configuration derives the same destination shard.
*
* **Gotchas**
*
* - Changing this implementation changes entity-to-shard assignment.
* - Strings are hashed as UTF-16 code units; normalize ids before routing if
* callers may produce equivalent text in different Unicode forms.
*/
/** @internal */
export const hashOptimize = (n: number): number => (n & 0xbfffffff) | ((n >>> 1) & 0x40000000)
/** @internal */
export const hashString = (str: string) => {
let h = 5381, i = str.length
while (i) {
h = (h * 33) ^ str.charCodeAt(--i)
}
return hashOptimize(h)
}

Xet Storage Details

Size:
820 Bytes
·
Xet hash:
14da2834326d4f72de74d4fa3fa13e31db50eed60ff5474930edf9845c3f86a6

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.