Skip to main content

Crate apache_datasketches

Crate apache_datasketches 

Source
Expand description

Safe, idiomatic Rust bindings for Apache DataSketches, built via the cxx crate over the raw apache-datasketches-sys bridge.

All four sketch families are enabled by default. To compile only the ones you need, disable default features and name them:

apache-datasketches = { version = "0.2", default-features = false, features = ["hll"] }

Unused families cost nothing at runtime — the linker drops what you do not call — so opting out buys C++ compile time, not a smaller binary.

The families:

  • hll (feature hll) — HyperLogLog cardinality estimation (sketch + union).
  • theta (feature theta) — cardinality estimation plus set operations: union, intersection, a-not-b, and Jaccard similarity.
  • cpc (feature cpc) — Compressed Probabilistic Counting cardinality estimation with a more compact serialized form (sketch + union only; no set operations beyond union).
  • tuple (feature tuple) — Tuple sketches, in two shapes. The ArrayOfDoubles form carries a fixed-width array of f64 per distinct key (summed on collision); the generic form in tuple::generic carries a summary type you define in Rust. Both support union, intersection, a-not-b, and Jaccard similarity.

(Module-level docs for each feature are only linked above when built with that feature enabled — see hll/theta/cpc/tuple in the sidebar.)

See each module’s documentation for usage examples, or the crate’s examples/ directory for complete runnable demos.

Re-exports§

pub use error::SketchError;

Modules§

cpc
CPC (Compressed Probabilistic Counting) sketch family: cardinality estimation with a more compact serialized form than HLL or Theta.
error
The single error type shared across every sketch family in this crate.
hll
HyperLogLog (HLL) cardinality estimation.
theta
Theta sketch family: cardinality estimation plus set operations (union, intersection, a-not-b) and Jaccard similarity.
tuple
ArrayOfDoubles Tuple sketch family: cardinality estimation where each retained key also carries a fixed-width array of f64 values, summed on collision.