Skip to content

fix(map): a streamed layer counts unread dates, <Null> and non-UTF-8 text once for a window read twice (#2615) - #2672

Merged
giswqs merged 2 commits into
opengeos:mainfrom
choupeanut:fix/2615-window-counts
Nov 22, 2026
Merged

giswqs merged 2 commits into
opengeos:mainfrom
choupeanut:fix/2615-window-counts

Conversation

@choupeanut

@choupeanut choupeanut commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A view that read the same window twice before the notice pass (after a reset, or a definition query change) added that window's unread dates, rounded date-times, <Null> text values and non-UTF-8 text values to the layer's pending counts twice, so the "so far" count in the notice could be higher than the values the layer holds.

The four pending counts are now kept per window read (Tally in crates/map/src/source.rs): a window read again replaces its counts, and different windows still add up. Both view-read call sites in crates/map/src/lib.rs pass the window's extent. The notice wording, and each kind being said once for the opening, are unchanged.

Two ceilings remain, both inside the notice's "so far" (it points to Load All Features for the full count):

  • two different windows that overlap still count their shared rows twice: telling rows apart would need row identity in a batch;
  • at most 64 windows are kept between notice passes (bounded memory under endless panning); past that, counts add into one overflow total, so a window already in it that is read again counts twice, as before.

Memory: a few counters per window read, no layer data. No schema change (the counts aren't saved).

Testing

  • a_window_read_twice_before_the_notice_pass_counts_once (engine): fails on main (2 text values counted where the layer holds 1); passes now.
  • a_window_read_again_replaces_its_counts (map): every counted kind (non-UTF-8, <Null> text, unread and rounded dates) read twice in one window counts once, other windows add up, an all-zero re-read clears its window, and the 64-window cap (NaN extents) adds into the overflow. It doesn't compile on main, as the saw_* methods take the window now.
  • cargo test -p rustgis-map --lib (451 passed), cargo test -p rustgis-engine streamed and hostile_params, clippy with -D warnings on map and engine.
  • Local gate on origin/main (fb77d77) with this branch and three other branches of mine (fix/2614-dbf-multibyte-notice, fix/2447-terrain-block-keys and fix/2620-qgis-style-read-thread) merged: pre-commit on every file, cargo fmt --check, clippy with -D warnings, cargo test --workspace (8721 passed, 0 failed), cargo xtask layers, cargo xtask schema --check with the fixtures checked against the schema and test hygiene, cargo xtask rows, and the Python package's tests (maturin + pytest, 44 passed). Not run here: the wasm32 build (no clang on this machine; CI's Web app job checks it), macOS and Windows.

UI evidence

No visible UI change.

Related issue

Closes #2615

Summary by CodeRabbit

  • Bug Fixes
    • Data-quality notices for unread or rounded dates, null text, and invalid text encoding now reflect the affected read areas more accurately.
    • Re-reading the same area replaces its previous counts instead of duplicating them, and clean reads clear prior counts for that area.
    • Repeated invalid-text reads no longer cause the same notice to appear more than once.

@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Streamed-read diagnostic counts now track read-window extents. Re-reading an extent replaces its pending counts, and completed reads pass their extents to the notice handlers. Tests cover tally behavior and repeated reads before notice collection.

Changes: Streamed-read notice counts

Layer / File(s) Summary
Per-window tally model
crates/map/src/source.rs
Diagnostic tallies retain counts for up to 64 distinct extents. Re-reading an extent replaces its counts, zero counts remove it, and further distinct extents add to a fallback total.
Notice recording and collection
crates/map/src/source.rs, crates/map/src/lib.rs
Notice handlers accept read extents and aggregate per-window counts. Completed-read paths pass the window extent, and reopening resets the tallies.
Notice count tests
crates/map/src/source.rs, crates/engine/src/tests.rs
Tests cover count replacement, aggregation, clearing, the 64-extent limit, and repeated streamed reads before notices are collected.

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

Change: Bug fix · Severity of issue fixed: Low

Possibly related issues

Possibly related PRs

  • opengeos/RustGIS#2325 — Adds the streamed invalid UTF-8 notice count that this PR tracks per window.
  • opengeos/RustGIS#2426 — Changes streamed view-read notice handling in the same crates and retains once-per-layer notice reporting.
  • opengeos/RustGIS#2303 — Adds <Null> marker counts to read notices, which this PR tracks per window.

Suggested reviewers: mavrick-f, giswqs

Merge Risk: Minimal · up to 7327c

Streamed-layer "so far" notices stop double-counting when the same window is read twice before the notice pass. The change is local to diagnostic counting and has no schema or data effect. Documented limits remain for overlapping windows and for more than 64 windows. Merge-readiness risk is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the fix (a streamed layer counting unread dates, and non-UTF-8 text once for a window read twice) and matches the changeset, which keys the pending counts per window extent. It …
Description check Passed The description follows the template's sections: Summary, Testing, UI evidence, and Related issue. The Summary explains the bug, the per-window fix, and the two stated limits. Testing lists the new te…
Linked Issues check Passed Issue #2615 requires that the unread-date, -text and non-UTF-8-text accumulators stop counting a window twice when it is read again before the notice pass. The reviewed head's crates/map/src/sou…
Out of Scope Changes check Passed The changes match the issue. The Tally type and per-window replacement in crates/map/src/source.rs implement #2615. The signature changes to saw_unread_dates, saw_null_text and saw_not_utf8 add the wi…
Full details: Title check

Explanation

The title names the fix (a streamed layer counting unread dates, <Null> and non-UTF-8 text once for a window read twice) and matches the changeset, which keys the pending counts per window extent. It is specific and does not mention files. The title is long at 110 characters, but it still conveys the main change.

Full details: Description check

Explanation

The description follows the template's sections: Summary, Testing, UI evidence, and Related issue. The Summary explains the bug, the per-window fix, and the two stated limits. Testing lists the new tests, the commands run, and what was not run. UI evidence states 'No visible UI change.' as the template requires. Related issue reads 'Closes #2615'. The description is complete. It does not use the template's comment placeholders, but the sections are all filled in.

Full details: Linked Issues check

Explanation

Issue #2615 requires that the unread-date, <Null>-text and non-UTF-8-text accumulators stop counting a window twice when it is read again before the notice pass. The reviewed head's crates/map/src/source.rs keeps these counts in a per-window Tally, so a window read again replaces its counts. The PR applies this to all three accumulators together, as the issue asks. It also applies it to rounded date-times, which share saw_unread_dates. Both view-read call sites in crates/map/src/lib.rs pass window.extent, per the raw summary. The issue allows keeping the latest batch per window, so this approach matches a permitted option. Two limits remain and are disclosed: overlapping distinct windows can still count shared rows twice, and past 64 retained windows, a re-read window in the overflow total counts twice. The issue does not require either case, so they do not fail the requirement. Evidence limit: the whole-PR diff tool was unavailable, so the call-site and test claims rest on the supplied summary. The head source.rs file was read in part.

Full details: Out of Scope Changes check

Explanation

The changes match the issue. The Tally type and per-window replacement in crates/map/src/source.rs implement #2615. The signature changes to saw_unread_dates, saw_null_text and saw_not_utf8 add the window extent, which the fix needs. The lib.rs edits only pass window.extent at the two view-read call sites. The 64-window cap is a bounded-memory design choice that the PR description discloses; it supports the per-window tracking. The rounded date-time handling sits in the same method as unread dates. The tests cover the fixed behavior and the cap. The engine test covers the reported double count. No unrelated functional change appears in the supplied evidence. The whole-PR diff tool was unavailable, so this verdict relies on the summary and the partial file read.

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 reads each window twice,
Yet counts one view, not counted thrice.
The tallies change when extents return,
And gather notices when they’re due.
I nibble clover, pleased and bright.

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: b51c9831-7c3b-4e19-bac9-fe82d7d22f15
Commits

Reviewing files that changed from the base of the PR and between 4bbe5be and 7327c52.

Files selected for processing: 3

  • crates/engine/src/tests.rs
  • crates/map/src/lib.rs
  • crates/map/src/source.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.

/// A window read twice before the notice pass (after a reset) counts its non-UTF-8 text once, not
/// twice: the notice's "so far" count is what the layer holds.
#[test]
fn a_window_read_twice_before_the_notice_pass_counts_once() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This test repeats the setup of a_streamed_shapefile_says_text_that_isnt_utf8_once_and_in_its_exports above (the temp dir and Dir guard, the shapefile write, the .cpg removal, the DBF language byte and AAAAAAA patch, and the layer.addData stream). Pulling that setup into a helper that takes the text to write and returns the session and layer id would keep the two cases from drifting apart. The two tests differ only in when the second read happens relative to the notice pass.

Category: quality

@github-actions

Copy link
Copy Markdown
Contributor

Code review

Bugs

  • None found. I checked the window-keying logic, the zero-count removal, the cap and overflow path, the take_* ordering, and the Option→Tally migration (no leftover Option-shape uses, including in source/window.rs). Confidence: high.

Security

  • None found.

Performance

  • None found. Tally::saw scans at most 64 windows per read, and take_not_utf8 returns early when empty. Confidence: high.

Quality

  • crates/engine/src/tests.rs:1807: the new test repeats the setup of the test at line 1735 (temp dir, shapefile write, .cpg removal, DBF patch, layer.addData). Extracting a helper would prevent drift. Left as a quality point for the release quality pass. Confidence: high.
  • crates/map/src/source.rs:778: the // ponytail: marker is used nowhere else in the repo. A plain Known limit: comment would read better. Confidence: medium.
  • The PR body says "a few counters per window read", but each window stores one count per field (a 100-field layer holds 100 counters per kind). This is still tiny next to layer data, so no cargo xtask memory requirement applies. Confidence: high.

AGENTS.md

  • The PR body does not state which surfaces the change reaches (desktop, CLI, Python, browser, phone, Assistant/MCP). The fix goes through Session::notify, so it probably reaches all of them, but the PR should say so. Confidence: medium; it is a documentation gap, not a code defect.

Known limits, not re-raised

  • The PR already discloses two ceilings: overlapping but different windows still double-count shared rows, and past 64 windows between notice passes, re-reads of an overflow window add up again. I did not raise these again. In the UI the notice pass runs each frame and consumes the tally on its first non-zero pass, so these limits are narrow in practice.

Reviewed: the full diff (3 files), pr-context/AGENTS.md, and the call sites in crates/map/src/lib.rs and crates/engine/src/lib.rs. I could not compile or run the tests here, so the PR's claimed test results are unverified.

Prior reviews: none existed on this PR, so no earlier concerns were left alone.

Change size

Compared with main (merge base 442ccde to PR head 7327c52).

Measure Value
Files changed 3 (0 added, 3 modified, 0 removed, 0 renamed)
Size before 3.74 MB
Size after 3.75 MB
Total size change +6.2 KB
Path Before After Change
crates/map/src/source.rs 110.6 KB 114.4 KB +3.8 KB
crates/engine/src/tests.rs 3.31 MB 3.31 MB +2.3 KB
crates/map/src/lib.rs 233.6 KB 233.7 KB +106 B

@github-actions

Copy link
Copy Markdown
Contributor

📖 Docs preview

Commit 7327c52 from a fork built, but isn't published until a maintainer adds the preview label (once per commit).

@giswqs
giswqs added this pull request to the merge queue Nov 22, 2026
Merged via the queue into opengeos:main with commit f4ed17b Nov 22, 2026
26 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.

Streamed layers count unread dates, <Null> text and non-UTF-8 text twice when a window is read again before the notice pass

2 participants