PgHash
Namespace: Ankus
Assembly: Ankus.Runtime.dll
Computes stable PostgreSQL hash support values from an explicitly chosen value representation.
public static class PgHashUses the SeaHash v4 byte-buffer algorithm and pgrx’s frozen seeds, returning the signed low 32 bits of the finished hash. The algorithm, seeds and overload encodings are stable across processes and architectures. They do not reproduce Rust’s type-specific Hash value encoding. Callers must normalize values that compare equal to identical input, including case, Unicode, floating-point zero or other distinctions ignored by their equality contract. Persist that normalization contract; changing hash results requires rebuilding dependent PostgreSQL indexes.
Inheritance: object
Methods
Section titled “Methods”Compute(ReadOnlySpan<byte>)
Section titled “Compute(ReadOnlySpan<byte>)”Hashes the exact bytes using SeaHash v4 with fixed seeds and little-endian block interpretation.
public static int Compute(ReadOnlySpan<byte> value)Parameters:
value — ReadOnlySpan<byte>
The caller’s equality-normalized byte representation, including any zero bytes.
Returns: int
The signed low 32 bits of the finished SeaHash value.
Compute(string)
Section titled “Compute(string)”Hashes strict UTF-8 bytes without adding a byte-order mark or normalizing the text.
public static int Compute(string value)Parameters:
value — string
The caller’s equality-normalized text; embedded zero characters are retained.
Returns: int
The signed low 32 bits of the finished SeaHash value.
Exceptions:
- ArgumentNullException: The value is null.
- EncoderFallbackException: The value contains an unpaired UTF-16 surrogate.
Compute(ulong)
Section titled “Compute(ulong)”Hashes an unsigned integer encoded as exactly eight little-endian bytes on every architecture.
public static int Compute(ulong value)Parameters:
value — ulong
The caller’s equality-normalized unsigned value.
Returns: int
The signed low 32 bits of the finished SeaHash value.