fix: directory offset encoding#111
Conversation
| let offset_to_write = if entry.offset == last_offset + u64::from(entry.length) { | ||
| let mut last_length = 0; | ||
| for (i, entry) in self.entries.iter().enumerate() { | ||
| let offset_to_write = if i > 0 && entry.offset == last_offset + u64::from(last_length) { |
There was a problem hiding this comment.
| #[cfg(feature = "write")] | ||
| fn directory_roundtrip_gzip() { | ||
| let entries = vec![ | ||
| DirEntry { |
There was a problem hiding this comment.
please add a helper for instantiating DirEntry, or maybe a new() fn, possibly with pub(crate) to not expose it -- so that all this becomes readable oneliners
There was a problem hiding this comment.
if you really want this readable by humans, you may instead make a test-only helper like fn entry_id_off_len_rl(...) ... but totally up to you
There was a problem hiding this comment.
or DirEntry::from_id_off_len_rl(...) ?
There was a problem hiding this comment.
It would result in fewer lines of code, but I disagree that this would be a readability improvement. I admit it's subjective though. Is this a blocker for getting this bug fix merged?
There was a problem hiding this comment.
I would agree for the regular code, but the tests are already fairly verbose. I am ok to fix it myself if you want - up to you
There was a problem hiding this comment.
Yes, thanks! Please fix up the test phrasing as you see fit.
There was a problem hiding this comment.
@nyurik - I'd like to see this bugfix merged. Can you apply your preferred test styling?
There was a problem hiding this comment.
Pull request overview
Fixes PMTiles directory offset varint encoding and expands directory-related unit tests to better align with upstream go-pmtiles behavior.
Changes:
- Correct offset “same-as-previous+length” encoding to use the previous entry’s length (and avoid emitting
0for the first entry). - Derive
PartialEqforDirEntryto support equality assertions in tests. - Add multiple directory roundtrip and
find_tile_idbehavior tests (ported from go-pmtiles).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| // Ported from go-pmtiles/pmtiles/directory_test.go:TestDirectoryRoundtrip (line 10) | ||
| #[test] | ||
| #[cfg(feature = "write")] | ||
| fn directory_roundtrip_gzip() { | ||
| let entries = vec
- 2026-04-18
### Fixed
- directory offset encoding
([#111](#111))
### Other
- update object_store dependency and fix build
([#119](#119))
- Configurable compression parameters via Compressor trait
([#112](#112))
</blockquote>
</p></details>
---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).
Note: I used an LLM to port the tests, but I visually inspected them and they appear equivalent.