Skip to main content

Module tuple

Module tuple 

Source
Expand description

ArrayOfDoubles Tuple sketch family: cardinality estimation where each retained key also carries a fixed-width array of f64 values, summed on collision.

use apache_datasketches::tuple::ArrayOfDoublesSketchBuilder;

let mut sketch = ArrayOfDoublesSketchBuilder::new().num_values(2).build()?;
sketch.update_u64(42, &[1.0, 2.5])?;
println!("estimate: {}", sketch.get_estimate());

ArrayOfDoublesSketch and CompactArrayOfDoublesSketch can both be passed interchangeably (via the sealed ArrayOfDoublesInput trait) to every set operation in this module.

Modules§

generic
Generic Tuple sketches: cardinality estimation where each distinct key carries a summary of a type you define.

Structs§

ArrayOfDoublesAnotB
Computes the set difference (“A not B”: keys in a but not b) of two ArrayOfDoubles sketches via Self::compute. Retained entries keep a’s values unchanged. Stateless between calls — unlike super::ArrayOfDoublesUnion/super::ArrayOfDoublesIntersection, there is no accumulation across repeated calls.
ArrayOfDoublesIntersection
Computes the intersection of ArrayOfDoubles sketches fed via Self::update. Values are summed per index for keys present in every input.
ArrayOfDoublesSketch
A mutable, update-only ArrayOfDoubles Tuple sketch: estimates the number of distinct keys added via update_*, and carries a fixed-width array of f64 values per retained key, summed on collision. Build one with ArrayOfDoublesSketchBuilder.
ArrayOfDoublesSketchBuilder
Builder for crate::tuple::ArrayOfDoublesSketch, mirroring upstream’s update_array_of_doubles_sketch::builder. lg_k defaults to 12, resize_factor to ResizeFactor::X8, p to 1.0 (no sampling), and num_values to 1 (matching upstream’s default_array_tuple_update_policy default). The seed is never exposed — every sketch built by this crate uses upstream’s DEFAULT_SEED.
ArrayOfDoublesUnion
A streaming union accumulator over ArrayOfDoubles sketches. Values are summed per index when the same key appears in more than one input, using upstream’s default_array_of_doubles_union_policy.
ArrayOfDoublesUnionBuilder
Builder for ArrayOfDoublesUnion, mirroring upstream’s array_of_doubles_union::builder. lg_k defaults to 12, resize_factor to ResizeFactor::X8, p to 1.0 (no sampling), and num_values to 1. As with ArrayOfDoublesSketchBuilder, the seed is never exposed.
CompactArrayOfDoublesSketch
An immutable, serializable snapshot of an ArrayOfDoubles Tuple sketch. Produced by super::ArrayOfDoublesSketch::compact, by any set operation’s result, or by Self::deserialize.
JaccardBounds
The result of a Tuple Jaccard similarity computation — returned by both array_of_doubles_jaccard_similarity and tuple_jaccard_similarity: a confidence interval around the estimated Jaccard index of two sketches, in [0.0, 1.0].

Enums§

ResizeFactor
Controls how aggressively an ArrayOfDoubles sketch’s internal hash table grows. Mirrors upstream’s datasketches::resize_factor. Default is X8, matching theta_constants::DEFAULT_RESIZE_FACTOR (the tuple family inherits Theta’s builder defaults).

Traits§

ArrayOfDoublesInput
Either ArrayOfDoubles sketch type can be fed into any of this module’s set operations — union, intersection, a-not-b, and Jaccard similarity. This trait is sealed — it cannot be implemented outside this crate — since the set-op shims only have concrete overloads for these two exact types.

Functions§

array_of_doubles_jaccard_similarity
Estimates the Jaccard index (intersection-over-union) of two ArrayOfDoubles sketches, each of which may independently be a super::ArrayOfDoublesSketch or a super::CompactArrayOfDoublesSketch.