Implement lazy file replay reader and integrate with Repo::open_file()#1
Implement lazy file replay reader and integrate with Repo::open_file()#1
Conversation
Co-authored-by: danhab99 <13894263+danhab99@users.noreply.github.com>
Co-authored-by: danhab99 <13894263+danhab99@users.noreply.github.com>
Co-authored-by: danhab99 <13894263+danhab99@users.noreply.github.com>
Co-authored-by: danhab99 <13894263+danhab99@users.noreply.github.com>
danhab99
left a comment
There was a problem hiding this comment.
confirm that the replayer is capable of seeking forward and backward, prove it in a unit test
Co-authored-by: danhab99 <13894263+danhab99@users.noreply.github.com>
danhab99
left a comment
There was a problem hiding this comment.
implement the replayer in the repo open file function
Added comprehensive unit test The test validates:
Test uses a simple file structure (A's, B's, C's) with DELETED fragments to demonstrate that seeking works correctly even when fragments are skipped. Commit: f150d94 |
Co-authored-by: danhab99 <13894263+danhab99@users.noreply.github.com>
Integrated LazyFileReplay into The function now returns a lazy reader that:
Files opened via Key changes:
Commit: 2e787fb |
Adds
LazyFileReplayreader for on-demand file reconstruction from fragment sequences without loading entire files into memory. Addresses the need to replay UNCHANGED/ADDED/DELETED fragments lazily while supporting bidirectional seeking. The reader is now integrated intoRepo::open_file()to provide lazy file access throughout the system.Implementation
LazyFileReplaystruct implementingRead + Seektraitsfind_fragment_at_position()maps logical→(fragment_idx, offset, old_pos)Box<dyn ReadSeek>Fragment Handling
UNCHANGED{len}ADDED{body,len}DELETED{len}Seeking Behavior
DELETED fragments don't exist in output—they only shift the old file position mapping. Seeking to logical position N calculates which fragment contains N and determines the corresponding old file offset accounting for all preceding DELETED fragments.
Example:
Integration with Repo::open_file()
The
Repo::open_file()function now returns aLazyFileReplayreader instead of eagerly reconstructing files into memory:Key changes:
open_file()Box<dyn ReadSeek>wrappingLazyFileReplayAPI
Testing
test_seeking_forward_and_backward) validates:SeekFrom::StartSeekFrom::Current(both directions)SeekFrom::EndFiles Changed
lib/src/replay.rs- Core LazyFileReplay implementation with comprehensive testslib/src/repo.rs- Integrated LazyFileReplay intoopen_file(), exposedget_object_path()for fragment loadinglib/examples/lazy_replay_demo.rs- Usage exampleOriginal prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.