Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor to cleanup and prepare for directory caching #23

Merged
merged 1 commit into from
Nov 10, 2023

Conversation

nyurik
Copy link
Collaborator

@nyurik nyurik commented Nov 8, 2023

  • there is no point in returning type and compression with every get_tile -- PMTiles keeps this data in the header, so it is constant, and if the user needs it, they can get it directly. Returns bytes now.
  • add Entry::is_leaf helper
  • add Header::get_bounds and Header::get_center (tilejson structs)
  • no need for AsyncPmTilesReader<B: ...> type - it has to be specified in the impl anyway
  • no need for the backend::read_initial_bytes - it is only used once, has default implementation anyway. Inlined.
  • inlined read_directory_with_backend - used once and tiny
  • split up the find_tile_entry into two functions - I will need this later to add caching -- the root entry is permanently cached as part of the main struct, but the other ones are not, so needs a different code path.
  • added cargo test for default features

@nyurik nyurik force-pushed the refactor-for-cache branch 2 times, most recently from 970fed0 to 2cb2cfe Compare November 8, 2023 04:19
@nyurik nyurik mentioned this pull request Nov 8, 2023
* there is no point in returning type and compression with every `get_tile` -- PMTiles keeps this data in the header, so it is constant, and if the user needs it, they can get it directly. Returns `bytes` now.
* add `Entry::is_leaf` helper
* add `Header::get_bounds` and `Header::get_center` (tilejson structs)
* no need for `AsyncPmTilesReader<B: ...>` type - it has to be specified in the impl anyway
* no need for the `backend::read_initial_bytes` - it is only used once, has default implementation anyway. Inlined.
* inlined `read_directory_with_backend` - used once and tiny
* split up the `find_tile_entry` into two functions - I will need this later to add caching -- the root entry is permanently cached as part of the main struct, but the other ones are not, so needs a different code path.
* added `cargo test` for default features
Copy link
Member

@lseelenbinder lseelenbinder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Could simplify one function, but it's not strictly necessary.

Thanks @nyurik!

src/async_reader.rs Show resolved Hide resolved
@nyurik nyurik force-pushed the refactor-for-cache branch 2 times, most recently from 84cdfd0 to eb0a896 Compare November 10, 2023 08:50
@nyurik nyurik merged commit 2de5837 into stadiamaps:main Nov 10, 2023
2 checks passed
@nyurik nyurik deleted the refactor-for-cache branch November 10, 2023 08:51
@nyurik
Copy link
Collaborator Author

nyurik commented Nov 10, 2023

it ended up being more complicated because I would have to re-wrap entry as an option

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants