Skip to content

fix(render): preserve @row_number across streamed layer chunks - #3312

Merged
Mavrick-F merged 1 commit into
opengeos:mainfrom
rvyyv-n:fix/issue-3271
Nov 29, 2026
Merged

Mavrick-F merged 1 commit into
opengeos:mainfrom
rvyyv-n:fix/issue-3271

Conversation

@rvyyv-n

@rvyyv-n rvyyv-n commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

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.

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 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).
  • 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 --bins checked cleanly).

UI evidence

No visible UI change.

Related issue

Closes #3271

Summary by CodeRabbit

  • Bug Fixes
    • 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.

@coderabbitai

coderabbitai Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

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.

Changes: Streamed row positions

Layer / File(s) Summary
Row-offset evaluation
crates/data/src/query.rs, crates/data/src/query/tests.rs
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.
Offset-aware rendering
crates/render/src/lib.rs, crates/render/src/stream_tests.rs
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.
Offset-aware legend counting
crates/render/src/layout/legend.rs, crates/render/src/layout/legend/count_tests.rs
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.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Possibly related issues

  • 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: Passed 4

Check name Status Explanation
Title check Passed 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 Passed 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 Passed 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 Passed 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 &lt;= 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.

Share

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-actions

Copy link
Copy Markdown
Contributor

📖 Docs preview

Item Value
Preview https://preview.rustgis.app/pr-3312/
Web app https://preview.rustgis.app/pr-3312/app/
Commit b9ca273

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).

@Mavrick-F
Mavrick-F added this pull request to the merge queue Nov 29, 2026
Merged via the queue into opengeos:main with commit 29d89e7 Nov 29, 2026
28 checks passed
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.

[Bug]: @row_number restarts in each chunk of a layer read in place

2 participants