Logical-to-Physical Extent Map With Overwrite Splitting
Last updated: November 29, 2026
Quick Overview
Implement a volume extent map where write(start, length, segment, offset) maps a logical block range to a location in a log-structured segment, splitting and replacing any overlapping extents, and read(start, length) returns the ordered pieces including holes, merging extents that become physically contiguous.
Pure Storage
November 29, 20260
0
0 solved
Implement a volume extent map where write(start, length, segment, offset) maps a logical block range to a location in a log-structured segment, splitting and replacing any overlapping extents, and read(start, length) returns the ordered pieces including holes, merging extents that become physically contiguous.
Purity is log structured: overwrites land in new segments and the volume's metadata points logical ranges at their latest physical location. This tests whether you can keep sorted interval metadata consistent through partial overwrites, which is the bread and butter of the data path team.
What the Interviewer Expects
- Keeps extents non-overlapping and sorted by logical start
- Splits extents at both ends of a new write and carries the physical offset correctly
- Removes fully covered extents in one slice operation
- Merges neighbours only when both logical and physical ranges are contiguous
- Returns holes for unmapped ranges in reads
- Discusses a B-tree or skip list for the production version
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
- How would you make this a persistent copy-on-write B-tree so snapshots can share it?
- How would garbage collection find which extents still reference a segment?
- What changes if writes are compressed and the physical length differs from the logical one?
- How would you bound metadata size for a workload of random 4 KB overwrites?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Logical space is a range of blocks. Each extent is (logical start, length, segment id, segment offset). After write, the new range maps entirely to the new location; parts of old extents outside the...
High-Level Design
A sorted list of starts plus a dict of extent info, standing in for a balanced tree. The key helper _split(pos) guarantees an extent boundary at pos by cutting the extent containing it into two, t...