Content-Defined Chunking With a Rolling Hash for Dedupe
Last updated: November 29, 2026
Quick Overview
Split a byte stream into variable-size chunks whose boundaries depend on content (using a rolling hash with min and max sizes), then store each unique chunk once so a shifted copy of a file mostly deduplicates.
Rubrik
November 29, 20260
0
0 solved
Split a byte stream into variable-size chunks whose boundaries depend on content (using a rolling hash with min and max sizes), then store each unique chunk once so a shifted copy of a file mostly deduplicates.
Deduplication drives storage cost on Rubrik clusters and in cloud archives, and fixed-size blocks fail when bytes are inserted near the start of a file. The interviewer wants a correct O(1)-per-byte rolling hash, sensible min/max chunk guards, and an explanation of why boundaries resynchronize after an insertion.
What the Interviewer Expects
- Explain why fixed-size chunking breaks on insertions
- Implement a rolling hash with O(1) update per byte
- Enforce minimum and maximum chunk sizes
- Store chunks by strong digest and build a recipe
- Show that a shifted copy writes few new bytes
- Analyze expected chunk size from the mask
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- Why use a weak rolling hash for boundaries but SHA-256 for identity?
- How would you choose average chunk size for VM disk images versus database files?
- How does compression interact with dedupe, and in which order would you apply them?
- Encryption at the source would kill dedupe. What options exist?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input: bytes. Output: chunk ranges, plus a dedupe step that maps each chunk to a digest and stores new ones. An insertion of k bytes should change only the chunks around it, not every chunk after it....
High-Level Design
Keep a polynomial hash of the last window bytes. After each byte, if the low mask_bits bits are zero and the chunk is at least min_size, cut. Also cut at max_size so random data cannot make gi...