Skip to content

feat: expose estimated_size for countmin and frequencies sketches - #174

Merged
tisonkun merged 5 commits into
apache:mainfrom
Renkai:feat/estimated-size-countmin-frequencies
Aug 1, 2026
Merged

feat: expose estimated_size for countmin and frequencies sketches#174
tisonkun merged 5 commits into
apache:mainfrom
Renkai:feat/estimated-size-countmin-frequencies

Conversation

@Renkai

@Renkai Renkai commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

This is a follow-up of #136, addressing part of #137.

Add estimated_size() to the remaining sketches that don't report their memory footprint yet:

  • CountMinSketch: size_of::<Self>() plus the capacity of the counts and hash_seeds backing vectors
  • FrequentItemsSketch: size_of::<Self>() plus the heap allocations of the internal ReversePurgeItemHashMap (keys/values/states arrays)

The implementation follows the pattern established in #136: heap usage is measured by allocation capacity, and nested storage types expose their own estimated_size() helper.

Tests: added one case per sketch (countmin_test, frequencies_test). Verified with cargo x check, cargo x test, and cargo x lint.

Follow the pattern from PR apache#136: report size_of::<Self>() plus the
heap allocations of the backing tables, using capacity rather than
length.

Addresses apache#137
@Renkai
Renkai force-pushed the feat/estimated-size-countmin-frequencies branch from 3b6881f to 1e3df46 Compare August 1, 2026 03:20
@Renkai
Renkai marked this pull request as ready for review August 1, 2026 03:22
Signed-off-by: tison <wander4096@gmail.com>
Signed-off-by: tison <wander4096@gmail.com>
Signed-off-by: tison <wander4096@gmail.com>

@tisonkun tisonkun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for your contribution!

@tisonkun
tisonkun enabled auto-merge (squash) August 1, 2026 06:26
@tisonkun
tisonkun merged commit fa704e2 into apache:main Aug 1, 2026
10 checks passed
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.

2 participants