Skip to main content

apache_datasketches/cpc/
mod.rs

1//! CPC (Compressed Probabilistic Counting) sketch family: cardinality
2//! estimation with a more compact serialized form than HLL or Theta.
3//!
4//! Unlike the `theta` module, CPC has no set operations beyond union — no
5//! intersection, a-not-b, or Jaccard similarity.
6//!
7//! ```
8//! # fn main() -> Result<(), apache_datasketches::SketchError> {
9//! use apache_datasketches::cpc::CpcSketchBuilder;
10//!
11//! let mut sketch = CpcSketchBuilder::new().lg_k(11).build()?;
12//! sketch.update_u64(42);
13//! println!("estimate: {}", sketch.get_estimate());
14//! # Ok(())
15//! # }
16//! ```
17//!
18//! - [`CpcSketch`] / [`CpcSketchBuilder`] — the sketch; build with
19//!   `CpcSketchBuilder::new().lg_k(..).build()`.
20//! - [`CpcUnion`] / [`CpcUnionBuilder`] — merges multiple sketches.
21//! - [`get_max_serialized_size_bytes`] — the estimated maximum compressed
22//!   serialized size, in bytes, for a given `lg_k`.
23//! - [`init`] — eagerly initializes CPC's global decompression tables, as
24//!   a one-time latency optimization; see its own doc comment for details.
25
26mod builder;
27mod init;
28mod sketch;
29mod union;
30
31pub use builder::{CpcSketchBuilder, CpcUnionBuilder};
32pub use init::init;
33pub use sketch::{get_max_serialized_size_bytes, CpcSketch};
34pub use union::CpcUnion;