Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors OSM data parsing to use streaming deserialization and reduce memory usage by minimizing cloning. The key changes include:
- Streaming deserialization of OSM data directly into typed structures instead of building intermediate JSON trees
- Wrapping ProcessedWay in Arc to enable sharing across relations without cloning large node vectors
- Explicit memory cleanup by dropping large temporary maps after relation processing
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/test_utilities.rs | Updated to work with new OsmData return type instead of serde_json::Value |
| src/retrieve_data.rs | Modified fetch functions to stream-deserialize directly into OsmData struct, eliminating intermediate JSON tree construction |
| src/osm_parser.rs | Made OsmData public with typed fields, changed way storage to use Arc<ProcessedWay> for zero-copy sharing in relations, and added explicit cleanup of temporary maps |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Description
serde_json::Deserializer::from_reader(...)directly intoOsmDatainsrc/retrieve_data.rsand returnOsmDatainstead ofValue.OsmDataa public typed struct (includingremark) and updateparse_osm_datato acceptOsmDatainsrc/osm_parser.rs.ways_mapstorage withHashMap<u64, Arc<ProcessedWay>>and changeProcessedMemberto holdArc<ProcessedWay>to avoid cloning way node vectors repeatedly.nodes_mapandways_mapafter processing relations to release memory earlier and update call sites (src/test_utilities.rs) to use the new typed fetch return.Testing
cargo fmtto apply formatting changes and ensure code style is consistent, which completed successfully.Codex Task