You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(render): preserve @row_number across streamed layer chunks - #3312
When a layer is read from its source in chunks, each chunk was evaluated with row indices starting from 0, causing @row_number to restart at 1 in every chunk for definition queries, display filters, styling expressions, labels, and legends.
Added row_offset: usize (default 0) and Env::at_row_offset to rustgis_data::query::Env (preserved by Env::at_scale), initialized Eval::row_offset from env.row_offset, and combined it with explicit offsets in matches_at and value_or_fault_at.
Tracked the running feature count across chunks in crates/render/src/lib.rs (render_frame -> draw_rows -> draw_chunk) and passed the offset environment to drawn_rows_with, styler_with, LabelExprs::with_env, and LabelMatcher::with_env.
Tracked the running feature count across chunks in crates/render/src/layout/legend.rs (read_whole) and passed env.at_row_offset(offset) to both complete_counted_legends and complete_shown_legends (which now reuses count_for_legend / legend_of_count without retaining per-class sample features).
Added regression tests covering definition queries and display filters using @row_number <= 3 across multi-chunk streamed rendering and legends.
Applies to all surfaces that render maps or layout legends from chunked sources (desktop, browser, CLI, Python, and mobile); no new commands, UI controls, or saved-project changes.
cargo test -p rustgis-render --lib -- stream_tests:: layout::legend:: — 58 passed, 0 failed (including new regression tests stream_tests::streamed_row_number_keeps_layer_position_across_chunks and layout::legend::count_tests::streamed_legends_keep_row_number_across_chunks).
cargo clippy -p rustgis-data --all-targets --no-deps -- -D warnings -A clippy::needless_bool — passed (crates/data/src/source/shp/cache.rs:233 has a pre-existing Windows-only clippy::needless_bool due to a #[cfg(unix)] block in that function).
Fixed row-number-based filters and queries so they identify the correct rows when data is processed in chunks.
Corrected streamed rendering, labels, and legends to match results from processing the full dataset at once. This keeps row-based styling and filtering consistent across different ways of loading and displaying data.
No actionable comments were generated in the recent review.
Walkthrough
The change adds source-row offsets to query evaluation and applies them during streamed rendering and legend counting. Regression tests compare streamed and loaded results for @row_number filters.
Env now stores a row offset and provides at_row_offset. Evaluation combines environment and explicit offsets with saturating addition. The test helper’s environment initialization is reformatted without a behavior change.
Rendering passes cumulative source-row offsets to filtering, styling, and label evaluation for streamed chunks. Cached chunks and non-streamed layers use offset zero. A regression test compares streamed and whole-layer pixels for @row_number <= 3.
Complete-source legend traversal counts chunks using their source-row offsets and builds entries from the accumulated counts. Streamed feature counts also use offsets. Tests compare streamed and loaded counts and classes.
opengeos/RustGIS issue 3238: This change updates streamed legend class counting across the full source.
opengeos/RustGIS issue 3237: This change uses streamed feature counts when building legend entries.
Suggested reviewers:jgregoriorincon, mavrick-f
Merge Risk: Minimal · up to b9ca2
@row_number now keeps its layer-wide position when a layer is read in chunks, for rendering, labels and legends. No concrete defect was found, and the added regression tests cover the changed behavior. The merge risk is minimal.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: @row_number is preserved across streamed layer chunks. It is specific, uses a conventional type(scope) prefix, and matches the changes in the query, render, and legend…
Description check
The description follows the repository template. It has Summary, Testing, UI evidence, and Related issue sections. The UI section keeps the 'No visible UI change.' line as the template requires. The S…
Linked Issues check
Issue #3271 requires @row_number to give the feature's position in the layer when a layer is read in chunks. Confirmed at the reviewed head: Env in crates/data/src/query.rs has a public `row_off…
Out of Scope Changes check
All listed changes relate to propagating the chunk row offset to row-dependent evaluation: the Env offset field and method (query.rs), the test-only Env struct literal update (query/tests.rs),…
Full details: Title check
Explanation
The title names the main change: @row_number is preserved across streamed layer chunks. It is specific, uses a conventional type(scope) prefix, and matches the changes in the query, render, and legend code and the regression tests.
Full details: Description check
Explanation
The description follows the repository template. It has Summary, Testing, UI evidence, and Related issue sections. The UI section keeps the 'No visible UI change.' line as the template requires. The Summary explains the root cause and the code changes. The Testing section lists commands and results. The Related issue section cites #3271. The description is complete and specific.
Full details: Linked Issues check
Explanation
Issue #3271 requires @row_number to give the feature's position in the layer when a layer is read in chunks. Confirmed at the reviewed head: Env in crates/data/src/query.rs has a public row_offset: usize field (default 0), and Env::at_row_offset sets it. The PR summary states that matches_at and value_or_fault_at add the explicit offset to the environment offset, and that Eval::new initializes from env.row_offset. In crates/render/src/lib.rs, the streamed path passes a per-chunk cumulative offset to definition queries, display filters, symbol styling, and label expressions/matchers. In crates/render/src/layout/legend.rs, read_whole accumulates chunk offsets and passes env.at_row_offset(offset) to the legend counting functions. Regression tests cover @row_number <= 3 for definition queries and display filters across streamed chunks and legends. Limits: the diff of query.rs could not be read because changed blobs were missing from the checkout, so the matches_at and value_or_fault_at logic and the test results (author-reported) are not independently verified. The Env field and method were confirmed at head.
Full details: Out of Scope Changes check
Explanation
All listed changes relate to propagating the chunk row offset to row-dependent evaluation: the Env offset field and method (query.rs), the test-only Env struct literal update (query/tests.rs), offset tracking in render/src/lib.rs (render_frame, draw_rows, draw_chunk), offset-aware legend counting in layout/legend.rs (which replaces per-class sample retention with direct counting; this change is needed for counting across chunks with offsets), and the regression tests (stream_tests.rs, legend/count_tests.rs). The PR description states that no new commands, UI, or saved-project changes exist. No unrelated change was identified in the summary. The unverified diff of query.rs limits this conclusion to the summary and the visible Env declarations.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
A rabbit counts each row in line, Through chunks that cross the field, The first three keep their places true, In maps and legends yield. Soft paws hop from row to row, No chunk resets the trail.
Recent review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: ASSERTIVE
Plan: Advanced
Run ID: 3441cb43-97d1-4d74-8c05-f2e19ae003f6
Commits
Reviewing files that changed from the base of the PR and between b01ebec and b9ca273.
Files selected for processing: 6
crates/data/src/query.rs
crates/data/src/query/tests.rs
crates/render/src/layout/legend.rs
crates/render/src/layout/legend/count_tests.rs
crates/render/src/lib.rs
crates/render/src/stream_tests.rs
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
GitHub Pages takes a minute or two to publish a new commit. Newer commits from the fork aren't published until a maintainer adds the preview label (once per commit).
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
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.
Summary
When a layer is read from its source in chunks, each chunk was evaluated with row indices starting from 0, causing
@row_numberto restart at 1 in every chunk for definition queries, display filters, styling expressions, labels, and legends.row_offset: usize(default0) andEnv::at_row_offsettorustgis_data::query::Env(preserved byEnv::at_scale), initializedEval::row_offsetfromenv.row_offset, and combined it with explicit offsets inmatches_atandvalue_or_fault_at.crates/render/src/lib.rs(render_frame->draw_rows->draw_chunk) and passed the offset environment todrawn_rows_with,styler_with,LabelExprs::with_env, andLabelMatcher::with_env.crates/render/src/layout/legend.rs(read_whole) and passedenv.at_row_offset(offset)to bothcomplete_counted_legendsandcomplete_shown_legends(which now reusescount_for_legend/legend_of_countwithout retaining per-class sample features).@row_number <= 3across multi-chunk streamed rendering and legends.Applies to all surfaces that render maps or layout legends from chunked sources (desktop, browser, CLI, Python, and mobile); no new commands, UI controls, or saved-project changes.
Testing
cargo fmt --check— passed.cargo test -p rustgis-data --lib query::tests::— 27 passed, 0 failed.cargo test -p rustgis-render --lib -- stream_tests:: layout::legend::— 58 passed, 0 failed (including new regression testsstream_tests::streamed_row_number_keeps_layer_position_across_chunksandlayout::legend::count_tests::streamed_legends_keep_row_number_across_chunks).cargo clippy -p rustgis-data --all-targets --no-deps -- -D warnings -A clippy::needless_bool— passed (crates/data/src/source/shp/cache.rs:233has a pre-existing Windows-onlyclippy::needless_booldue to a#[cfg(unix)]block in that function).cargo clippy -p rustgis-render --all-targets --no-deps -- -D warnings— passed.cargo xtask test-hygiene— passed (test-hygiene: ok).cargo xtask layers— passed (layers: ok).cargo xtask rows— passed (rows: ok, 757 direct uses vs 764 allowed; full workspace--lib --binschecked cleanly).UI evidence
No visible UI change.
Related issue
Closes #3271
Summary by CodeRabbit