Skip to content

PgHash

Namespace: Ankus

Assembly: Ankus.Runtime.dll

Computes stable PostgreSQL hash support values from an explicitly chosen value representation.

public static class PgHash

Uses 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

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.

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:

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.