Skip to content

Conversation

@PsiACE
Copy link
Member

@PsiACE PsiACE commented Jan 6, 2026

Density sketch implementation for density estimation from streaming data.

Ref https://github.com/apache/datasketches-cpp/tree/master/density

@tisonkun tisonkun changed the title feat: imple densitysketch feat: impl densitysketch Jan 7, 2026
Signed-off-by: Chojan Shang <psiace@apache.org>

/// Density sketch for streaming density estimation.
pub struct DensitySketch<T: DensityValue> {
kernel: Box<dyn DensityKernel<T>>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the any reasons not to keep the kernel as a generic argument of type K: DensityKernel<T>?

}
}

fn check_k(k: u16) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move this directly where it's called. I think having asserts inline really helps with the readability when people are exploring code.

}

thread_local! {
static RNG_STATE: Cell<u64> = Cell::new(seed_rng());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would love not to have thread local variables declared statically in the library. Is this really something we cannot store in another struct and pass it to the sketch when needed, delegating lifecycle decisions to the user?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants