Skip to content

Defined in: packages/scalar-sketch/src/hyperloglog.ts:93

A HyperLogLog specialized for unsigned 32-bit numbers.

readonly kind: "hyperloglog"

Defined in: packages/scalar-sketch/src/hyperloglog.ts:13

HyperLogLogMetadata.kind


readonly precision: number

Defined in: packages/scalar-sketch/src/hyperloglog.ts:16

Effective register precision. The register count is 2 ** precision.

HyperLogLogMetadata.precision


readonly registerCount: number

Defined in: packages/scalar-sketch/src/hyperloglog.ts:18

Number of one-byte maximum-rank registers.

HyperLogLogMetadata.registerCount


readonly stateByteLength: number

Defined in: packages/scalar-sketch/src/hyperloglog.ts:20

Bytes occupied by the mutable register state, excluding object overhead.

HyperLogLogMetadata.stateByteLength


readonly estimator: "ertl-improved-raw"

Defined in: packages/scalar-sketch/src/hyperloglog.ts:22

The cardinality estimator applied by estimate.

HyperLogLogMetadata.estimator


readonly relativeStandardError: number

Defined in: packages/scalar-sketch/src/hyperloglog.ts:24

Approximate one-standard-deviation relative error, 1.04 / sqrt(registerCount).

HyperLogLogMetadata.relativeStandardError


readonly seed: bigint

Defined in: packages/scalar-sketch/src/hyperloglog.ts:26

XXH64 seed that participates in merge compatibility.

HyperLogLogMetadata.seed


estimate: () => number

Defined in: packages/scalar-sketch/src/hyperloglog.ts:39

Estimate the number of distinct updates. O(registerCount) after an update or merge that changes a register, O(1) for repeated or no-op reads; does not change the sketch’s registers.

Uses Otmar Ertl’s improved raw estimator without empirical lookup tables. The estimator is monotone, returns exactly zero for an empty sketch, and remains a floating-point query result rather than persisted state. The statistical error is described by relativeStandardError; it is not a hard bound.

number

New cardinality estimation algorithms for HyperLogLog sketches

HyperLogLogMetadata.estimate


readonly scalarKind: "uint32"

Defined in: packages/scalar-sketch/src/hyperloglog.ts:94

HyperLogLogMetadata.scalarKind


update: (value) => void

Defined in: packages/scalar-sketch/src/hyperloglog.ts:100

Add one unsigned 32-bit number to the distinct-count sketch. O(1); mutates the sketch.

number

void

From knotkit/hash when the value is outside the unsigned 32-bit domain.


merge: (other) => void

Defined in: packages/scalar-sketch/src/hyperloglog.ts:107

Merge a compatible sketch by register maximum. O(registerCount); mutates only this sketch.

Uint32HyperLogLog

void

With FOREIGN_STRUCTURE, WRONG_FAMILY, or INCOMPATIBLE_SKETCH.


reduce: (targetPrecision) => Uint32HyperLogLog

Defined in: packages/scalar-sketch/src/hyperloglog.ts:114

Return an exact reconstructed copy at a precision no larger than this one. O(registerCount). Top digest bits remain the index; discarded index bits become the target rank prefix.

number

Uint32HyperLogLog

With INVALID_REDUCTION for an unsupported target.