- Remove unused jpx::JpxDecoder import from stream.rs (code uses fully qualified paths)
- Add notes/pdftract-36glh.md with acceptance criteria verification
The JPXDecode passthrough implementation was already complete in commit 4ba4687.
This change is minor cleanup only.
References: pdftract-36glh
2.2 KiB
2.2 KiB
pdftract-1uhee: MmapSource Implementation
Summary
The MmapSource implementation was already complete in crates/pdftract-core/src/source/mmap.rs. This task verified the implementation and fixed two incorrect test assertions.
Changes Made
Test Fixes (commit: ba5d101)
-
test_open_valid_file: Fixed assertion from 20 to 22 bytes
- The byte string
b"%PDF-1.4\ntest content\n"is 22 bytes %PDF-1.4(8) +\n(1) +test content(12) +\n(1) = 22
- The byte string
-
test_seek_from_end: Fixed expected result from
b"el"tob"lo"- Content:
b"Hello"(indices 0='H', 1='e', 2='l', 3='l', 4='o') SeekFrom::End(-2)puts position at index 3- Reading 2 bytes from position 3 gives
b"lo"
- Content:
Acceptance Criteria Status
| Criterion | Status | Test |
|---|---|---|
| MmapSource::open(/path/to/file.pdf) returns Ok for valid file | PASS | test_open_valid_file |
| MmapSource::open(/nonexistent) returns Err | PASS | test_open_nonexistent_file |
| read_range(0, 10) returns first 10 bytes | PASS | test_read_range |
| read_range past EOF returns Err | PASS | test_read_range_past_eof |
| len() matches file size | PASS | test_len_matches_file_size |
| Read+Seek trait usage works | PASS | test_read_trait, test_seek_trait |
| Send + Sync: can send across threads | PASS | test_send_sync, test_sync_multiple_threads |
| MADV_SEQUENTIAL compiles and runs | PASS | test_advise_sequential, test_prefetch |
Implementation Details (Already Complete)
MmapSource Structure
pub struct MmapSource {
mmap: Mmap,
cursor: Cursor<u64>,
}
Key Methods
open(path): Creates memory-mapped file usingmemmap2::MmapOptionsread_range(offset, length): Zero-copy read viaBytes::copy_from_sliceadvise_sequential(offset, length): AppliesMADV_SEQUENTIALfor content streamsprefetch(offset, length): Wrapper foradvise_sequential
Thread Safety
unsafe impl Send for MmapSourceunsafe impl Sync for MmapSource- Verified by
test_send_syncandtest_sync_multiple_threads
Files
- Implementation:
crates/pdftract-core/src/source/mmap.rs(460 lines) - Module:
crates/pdftract-core/src/source/mod.rs(exports MmapSource)