Commit a2347c6
Document why MapChunks doesn't allocate a trailing zero-length sentinel
Upstream Java's MMapDirectory.map allocates nrBuffers = floor + 1 and
tolerates a final 0-byte ByteBuffer at `buffers[N]`. That sentinel
exists because ByteBufferIndexInput's read loop unconditionally
advances its buffer cursor past the end of each buffer, so indexing
`buffers[N]` must remain valid after reading the last byte of a file
whose length is a whole multiple of chunkSize.
Our ReadInternal bounds-checks `pos + len` before indexing and only
advances `chunkIdx` while `len > 0`, so no sentinel is needed. Also,
MemoryMappedFile.CreateViewAccessor rejects a zero-length view, which
would force a special-case code path anyway.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 3da3c56 commit a2347c6
1 file changed
Lines changed: 12 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
808 | 808 | | |
809 | 809 | | |
810 | 810 | | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
811 | 823 | | |
812 | 824 | | |
813 | 825 | | |
| |||
0 commit comments