Repository navigation
Conversation
coalesce_features() grouped features by property hash in a HashMap and emitted the groups in iteration order. std's HashMap is seeded per map, so the order of coalesced features in a tile, and therefore the archive bytes, changed from run to run. Groups now keep the order in which their first feature appears, which is the Morton order the tile was sorted in. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
5 tasks
This branch has not been deployed
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.
With
coalesce = TRUE, building the same archive twice gives different bytes.coalesce_features()grouped features by property hash in aHashMapand emitted the groups in iteration order.std'sHashMapis seeded randomly per map, so the order of the coalesced features in each tile changes between runs, and with it the archive bytes and size. Rendering is the same, but caching, checksums and output diffs break.Groups now keep the order of their first feature. Tiles are Morton-sorted before coalescing, so this is the existing spatial order. Lookups still go through the same hash, so it costs nothing extra.
coalesce.rs:merge_lines()andgroup_polygons()share agroup_by_properties()helper that returns groups in first-appearance order. Grouping is otherwise unchanged.tests/coalesce_order.rs, run as a CI step. It checks first-appearance order for lines and polygons, and repeats the call 32 times in one process. Onmainit fails on the first assertion. EachHashMaphas its own seed, so repeated calls in one process are enough to show the problem.test-coalesce.R: twofreestile(coalesce = TRUE)runs onnc.shp, with a 3-value attribute, must produce identical bytes.Validation:
main, the new R test fails (archive lengths 36,496 vs 36,512 bytes, 36,166 mismatched bytes). With this change it passes, and the rest oftest-coalesce.Rstill passes. R 4.6.1 on Windows, Rtools45, built from source with the CRAN feature set.tests/coalesce_order.rsfails onmainand passes with the fix. I ran it through a small harness crate that path-depends onfreestiler-core. On my Windows machine, the crate's dev-dependencymlt-core->fastpforcan't download CPM.cmake (TLS error), so a plaincargo testdoesn't build there. The new CI step runs the test directly.rustfmt --checkis clean on the changed files. No dependency or lockfile changes.I prepared this change with AI assistance (Claude Code) and reviewed it before submitting.