Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions datasketches/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ frequencies = []
hll = []
tdigest = []
theta = []
tuple = ["theta"]

[dev-dependencies]
googletest = { workspace = true }
Expand Down
10 changes: 10 additions & 0 deletions datasketches/src/codec/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ impl SketchSlice<'_> {
self.slice.set_position(pos + n);
}

/// Returns the not-yet-read portion of the underlying slice.
///
/// Useful for handing the remaining bytes to a variable-length decoder that reports how many
/// bytes it consumed; pair it with [`advance`](Self::advance).
pub fn remaining(&self) -> &[u8] {
let buf = self.slice.get_ref();
let pos = (self.slice.position() as usize).min(buf.len());
&buf[pos..]
}

/// Reads exactly `buf.len()` bytes from the slice into `buf`.
pub fn read_exact(&mut self, buf: &mut [u8]) -> io::Result<()> {
self.slice.read_exact(buf)
Expand Down
9 changes: 9 additions & 0 deletions datasketches/src/codec/family.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ impl Family {
max_pre_longs: 1,
};

/// Tuple Sketch for cardinality estimation with per-key summaries.
#[cfg(feature = "tuple")]
pub const TUPLE: Family = Family {
id: 9,
name: "TUPLE",
min_pre_longs: 1,
max_pre_longs: 3,
};

/// The Frequency family of sketches.
#[cfg(feature = "frequencies")]
pub const FREQUENCY: Family = Family {
Expand Down
2 changes: 2 additions & 0 deletions datasketches/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ pub mod hll;
pub mod tdigest;
#[cfg(feature = "theta")]
pub mod theta;
#[cfg(feature = "tuple")]
pub mod tuple;

// common modules
pub mod codec;
Expand Down
Loading