Skip to content

fix(layout): list only what the definition query keeps in tables and charts - #3555

Merged
jgregoriorincon merged 4 commits into
opengeos:mainfrom
jgregoriorincon:fix/3478-layout-table-definition-query
Dec 1, 2026
Merged

jgregoriorincon merged 4 commits into
opengeos:mainfrom
jgregoriorincon:fix/3478-layout-table-definition-query

Conversation

@jgregoriorincon

@jgregoriorincon jgregoriorincon commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A layout's table and chart listed every feature of their layer, including those its definition query hides on the map frame.

  • Both now read the query the way the map frame does (Layer::query_rows_with), at the frame's scale and on the series page shown, so a query on @page_number or @page_feature_id lists the page's features.
  • The chart is fixed too: it had the same cause as the table.
  • The notices follow: rows a table's box cannot hold, and bars a chart leaves out, count only the features the query keeps. A table of the selected features lists the selected ones the query keeps.
  • Without a query, or with one that does not read, nothing changes. A saved layout with a query and a table or chart now draws fewer rows or bars.
  • Display filters and the time window, which the map frame also applies, are not applied: layer figures in layout texts follow the definition query alone as well.
  • Memory: the query's answer, one byte per feature, while a table or chart is read. Nothing is kept between draws. No project format, command or parameter changes.

Reach: desktop, browser, phone, command line, Python, the Assistant and MCP draw through the same path. Undo and reopening need nothing new. No new interface strings.

Testing

  • New tests, written first: engine/src/tests/layout_definition_query.rs (the drawn page of a table and of ungrouped, grouped and stacked charts equals that of a layer holding only the kept features; selected rows; a series page; undo; the notices). A unit test in rustgis-map covers the query read on a page, and a line in the streamed @row_number test covers a layer read in place. A review round added one_tables_cut_is_its_own_of_the_pages in rustgis-render.
  • Full run at e364531b: fmt, clippy -D warnings, doctests, layers and schema check pass; nextest 11930 passed, 8 failed, all outside this diff on this machine (7 in rustgis-geolibre and line_strokes_editor_edits_one_class).
  • Since then, at c4063cb5: fmt, clippy -D warnings on rustgis-map, rustgis-render and rustgis-engine, and their layout, chart, table and guide tests without the DuckDB one (1161 passed). The wasm32 web build with -D warnings passed at 869a3380; only comments and the user guide changed after it.
  • ui_shot before and after.

UI evidence

Table and chart with the definition query name IN ('Tokyo','Lima','Cairo'), before and after:

compare.png

Related issue

Closes #3478.

Summary by CodeRabbit

  • New Features
    • Table and chart frames now honor the layer’s definition query, including page-specific queries. Rows and chart bars excluded by the query are omitted.
    • Exported table counts reflect only rows kept by the query.
  • Documentation
    • Clarified that display filters and the time window do not affect which rows or features appear in table and chart frames.

@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Layout tables and charts now use layer definition queries to determine displayed features. Table rendering receives the frame’s page environment, so page-specific query values are available. Tests cover filtering, selection, sorting, export notices, and blank or invalid queries.

Changes: Layout Definition Query Filtering

Layer / File(s) Summary
Filter table and chart data
crates/map/src/layout/elements.rs, crates/map/src/layout/tests.rs, crates/map/src/lib.rs
Table listings and chart scans exclude rows not kept by the layer definition query. Tests cover page context, selection, sorting, cancellation, and streamed reads.
Pass page context to table rendering
crates/render/src/layout.rs, crates/render/src/layout/table.rs, crates/render/src/layout/tests.rs, crates/engine/src/cmd/layout/elements.rs, crates/engine/src/cmd/layout/chart.rs, docs/user-guide/layouts.md
Table rendering passes the frame page environment to table listings. table_cut evaluates a specified table element, and the engine uses it for table notices. Documentation describes definition-query filtering for table and chart frames.
Verify layout query behavior
crates/engine/src/tests.rs, crates/engine/src/tests/layout_definition_query.rs, crates/render/src/layout/tests.rs, crates/map/src/layout/chart.rs, crates/map/src/layout/elements.rs, crates/render/src/layout/chart.rs
Engine tests compare queried tables and charts with filtered layers and check page-specific queries, undo, and export notices. Chart tests use layer-based data extraction, and chart documentation references the updated entry point.

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

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant Layout
  participant Frame
  participant TableListing
  Layout->>Frame: Resolve the table layer and frame page environment
  Frame-->>Layout: Return the layer and environment
  Layout->>TableListing: List rows using the environment
Loading

Possibly related issues

Suggested reviewers: elpidioassinaturas, giswqs

Merge Risk: Minimal · up to c4063

Layout tables and charts now follow the layer definition query, including on series pages, and unqueried or unreadable-query layers behave as before. No concrete merge-blocking risk remains in the supplied evidence.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: layout tables and charts now list only the features that the layer's definition query keeps. The title matches the linked issue #3478 and the description. The fix(layo…
Description check Passed The description covers the summary of the change, the reason for it, and the testing done. It also includes a UI evidence section with a before and after screenshot, and it links the issue with Closes…
Linked Issues check Passed [#3478] requires that a layout table list only the features kept by the layer's definition query, matching the map frame. The whole-PR summary shows this implemented. In crates/map/src/layout/elements…
Out of Scope Changes check Passed The changes stay within the scope of #3478. The chart filtering follows the issue title. The table_listing signature change and the Env plumbing in crates/render are needed to evaluate the query a…
Full details: Title check

Explanation

The title names the main change: layout tables and charts now list only the features that the layer's definition query keeps. The title matches the linked issue #3478 and the description. The fix(layout) prefix is a conventional-commit style that fits the change.

Full details: Description check

Explanation

The description covers the summary of the change, the reason for it, and the testing done. It also includes a UI evidence section with a before and after screenshot, and it links the issue with Closes #3478. It does not follow the template's exact structure, but it contains every required section and the required information.

Full details: Linked Issues check

Explanation

[#3478] requires that a layout table list only the features kept by the layer's definition query, matching the map frame. The whole-PR summary shows this implemented. In crates/map/src/layout/elements.rs, table_listing takes an Env, evaluates the layer query, and limits unselected counts and rows, and selected rows, to query-kept rows. In crates/render/src/layout.rs and crates/render/src/layout/table.rs, each table receives its layer with a frame-derived Env, so @page_number and @page_feature_id queries resolve at the frame scale and series page. The issue title also names charts. chart_data_of evaluates the same query and passes a keep mask into grouped and ungrouped scans, so charts drop excluded bars, and the tests cover ungrouped, grouped, and stacked charts. Tests in engine/src/tests/layout_definition_query.rs compare drawn output with an equivalent layer holding only the kept features. Display filters and the time window are excluded by design. The issue names only the definition query, so this exclusion does not leave a required behavior unmet. Basis: PR summary, file-level summaries, and the incremental change since the prior review (c4063cb). I did not read the full diff or run the tests.

Full details: Out of Scope Changes check

Explanation

The changes stay within the scope of #3478. The chart filtering follows the issue title. The table_listing signature change and the Env plumbing in crates/render are needed to evaluate the query at the frame scale and series page. Notice counts and selected-row filtering apply the same query rule to table output. chart_data becomes test-only, and the docs and tests are changed to match the new call shapes. The table_cut entry point supports the notice path in crates/engine/src/cmd/layout/elements.rs. The lib.rs @row_number assertion checks the in-place layer read that the query path touches. The docs/user-guide/layouts.md edits describe the new definition-query rule. The no-format-change, memory, and cross-surface statements are descriptive and add no code scope. No unrelated behavior change appears in the summaries. Basis: PR summary and file-level summaries; the full diff was not 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 checks each row in view
And finds the query’s kept ones true
The charts count bars that pass the gate
Page numbers shape the table’s fate
Blank queries leave the rows in place
Then exports list the trimmed-down space

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: e76f4742-25e1-4cf8-b719-a7708619f995
Commits

Reviewing files that changed from the base of the PR and between 744d7ca and c4063cb.

Files selected for processing: 9

  • crates/engine/src/cmd/layout/chart.rs
  • crates/engine/src/cmd/layout/elements.rs
  • crates/map/src/layout/chart.rs
  • crates/map/src/layout/elements.rs
  • crates/render/src/layout.rs
  • crates/render/src/layout/chart.rs
  • crates/render/src/layout/table.rs
  • crates/render/src/layout/tests.rs
  • docs/user-guide/layouts.md

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 4 remain after this review.

Comment thread crates/render/src/layout/table.rs Resolved
Comment thread crates/map/src/layout/elements.rs Resolved
@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Code review

I reviewed the whole diff (9 files) against pr-context/AGENTS.md. I could not compile or run the tests, because this environment has no shell. Everything below comes from reading the code. The prior-review file had no threads, so nothing was left out as already raised.

Bugs: None found. I traced the table and chart paths. The kept mask is applied before every grouped and ungrouped tally, the stacked cells, the colour reads and the left_out and no_number counts. Selection, sorting, the heap, and the count()/first() pairing are also consistent. The render table path and the chart path use the same frame camera and series env as tables_cut and frame_page_env.

Security: None found. The change does not touch inputs, I/O or secrets.

Performance:

  • crates/render/src/layout/table.rs:89: tables_cut now runs a full, uncached query pass for every table on the page. engine/src/cmd/layout/elements.rs:323 (say_table_cut) calls it for the whole page on each table-fit edit and then keeps one table's notice. Export and report add more passes. Confidence: medium-high. Inline comment posted.
  • The query pass has no Cancel check. The doc comment says so, which AGENTS allows, so I am not raising it as a finding.

Quality:

  • crates/map/src/layout/elements.rs:1029: the public chart_data ignores the definition query and is now test-only. It is a trap for future callers. Inline comment posted.
  • Nits, not commented: table() takes a (layer, env) tuple parameter, which reads less clearly than two parameters. The exported test helper unwraps before its cleanup, so a failed export leaves its temp dir behind.

AGENTS.md: No breaks found. Checked: no unwrap in non-test code, no new commands (so command-surface.txt is unchanged), no project-format change (so no schema update is needed), the docs are updated, there are no new interface strings, and the Size for real data multiple is stated in the PR body. The Cancel gap is documented as AGENTS requires.

Twins checked: chart_data_of callers (engine/src/cmd/layout/chart.rs:473, ui-egui/src/layoutview/format/chart.rs:229, and the render draw path) all pass the page env. say_chart warns on a series error, and tables_cut silently skips it, but the page draw fails on the same error. svg.rs and report.rs do not draw table or chart elements, so there is nothing to change there. The definitionQuery setter validates the query, but qgis.rs:846 imports one without validating it. That is pre-existing and the map behaves the same, so I left it alone.

Confidence: High that the logic is correct on reading. Not verified by compiling or running tests.

Change size

Compared with the base branch: the whole PR against main (merge base e11b061 to PR head 744d7ca).

Measure Value
Files changed 9 (1 added, 8 modified, 0 removed, 0 renamed)
Size before 4.98 MB
Size after 4.99 MB
Total size change +12.1 KB
Path Before After Change
crates/engine/src/tests/layout_definition_query.rs 0 B 7.4 KB +7.4 KB
crates/map/src/layout/tests.rs 134.3 KB 136.3 KB +2.0 KB
crates/map/src/layout/elements.rs 65.9 KB 67.5 KB +1.7 KB
crates/render/src/layout.rs 64.6 KB 64.9 KB +272 B
docs/user-guide/layouts.md 105.4 KB 105.6 KB +224 B
crates/map/src/lib.rs 295.1 KB 295.3 KB +210 B
crates/render/src/layout/tests.rs 489.6 KB 489.8 KB +198 B
crates/engine/src/tests.rs 3.84 MB 3.84 MB +75 B
crates/render/src/layout/table.rs 11.2 KB 11.2 KB +34 B

@jgregoriorincon
jgregoriorincon marked this pull request as draft December 1, 2026 18:08
Comment thread crates/map/src/layout/elements.rs Resolved
@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Code review

I reviewed the full diff against pr-context/AGENTS.md, the prior review threads, and the call sites of every changed function. I found no correctness bugs. The grouped, ungrouped and stacked chart loops all skip non-kept rows before they create groups or pairs. count(), first(), the draw path and the cut path all read the same query through table_listing/chart_data_of with the same frame environment. The engine tests exercise the command path, and the map and render tests call the functions directly.

Bugs

  • None found.

Security

  • None found.

Performance

  • Medium confidence: say_table_cut (crates/engine/src/cmd/layout/elements.rs:323) now runs table_listing, which does a full definition-query pass over the edited table's layer. It runs on the UI thread from layout.addElement and layout.update, with no Cancel look and no note in its doc comment. This is the remaining part of the earlier all-tables thread. The cost only appears when a query is set. Inline comment posted.

Quality

  • Low-medium confidence: an uncompilable definition query makes query_rows_with return None, so the table or chart lists every row with no notice. The map does the same, and the tests lock it in. Under "Never silent" this may need a notice or a comment. Inline comment posted (crates/map/src/layout/elements.rs:504).
  • Low confidence: cut_of (crates/render/src/layout/table.rs:98) uses frame_page_env(...).ok()??, which drops a refused series index without a notice. say_chart warns for the same error. The export still fails on that page, so the impact is small.

AGENTS.md

  • No rule break found. The command surface, row-use counts, memory limits and the saved-file schema are unchanged, and no new check list was added.
  • The changed chart_data is now #[cfg(test)], so the earlier public-API thread is handled by the code. I did not repost it.
  • The Reach section and the doc updates match the code. Undo is covered by undo_gives_the_hidden_rows_back.

Checked for twins

  • Tables: draw (draw_page), tables_cut, table_cut, say_table_cut, and export and report callers all go through table_listing with a frame environment. None reads rows directly.
  • Charts: chart_data_of callers in engine/cmd/layout/chart.rs:473, ui-egui/layoutview/format/chart.rs:229 and render/layout.rs:768 all pass the frame's environment.
  • wasm branches: none changed.
  • Read routes and overlay tools: not affected by this diff.

Prior reviews

  • 2 threads reviewed. 1 is already handled by the diff (chart_data is now test-only), and I did not repost it.
  • The all-tables tables_cut thread was fixed in 6d23ac6. Its remaining one-table cost is the new performance comment above.
  • 1 concern was left alone, and 1 was narrowed and raised again with what is new.

Change size

Compared: the whole PR against main (merge base e11b061 to PR head 6d23ac6).

Files changed Added Modified Removed Renamed Size before Size after Total change
12 1 11 0 0 5.11 MB 5.12 MB +14.1 KB
File Size before Size after Change
crates/engine/src/tests/layout_definition_query.rs 0 B 7.4 KB +7.4 KB
crates/map/src/layout/tests.rs 134.3 KB 136.3 KB +2.0 KB
crates/render/src/layout/tests.rs 489.6 KB 491.4 KB +1.8 KB
crates/map/src/layout/elements.rs 65.9 KB 67.4 KB +1.5 KB
crates/render/src/layout/table.rs 11.2 KB 11.8 KB +0.6 KB
crates/render/src/layout.rs 64.6 KB 64.9 KB +0.3 KB
docs/user-guide/layouts.md 105.4 KB 105.6 KB +0.2 KB
crates/map/src/lib.rs 295.1 KB 295.3 KB +0.2 KB
crates/engine/src/tests.rs 3.76 MB 3.76 MB +75 B
crates/engine/src/cmd/layout/elements.rs 83.4 KB 83.4 KB −23 B
crates/map/src/layout/chart.rs 17.6 KB 17.6 KB +9 B
crates/render/src/layout/chart.rs 25.6 KB 25.6 KB +3 B

@github-actions

github-actions Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

📖 Docs preview

Item Value
Preview https://preview.rustgis.app/pr-3555/
Web app https://preview.rustgis.app/pr-3555/app/
Commit c4063cb

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

Comment thread crates/map/src/layout/elements.rs Resolved
@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Code review

Reviewed the full PR (12 files) against pr-context/AGENTS.md. I did not run the build or tests, since I have no shell here, so the findings below come from reading the diff and the surrounding source.

Bugs

  • None found. I checked the grouped, ungrouped and stacked chart loops (every row read is preceded by the is_kept check), the sorted and unsorted paths of TableListing::first, the count() consistency with is_kept on the kept bytes, the frame_page_env and frame_style_env pairing between draw and cut, and the .ok()?? unwrapping in cut_of. Confidence the logic is right: high.

Security

  • None found.

Performance

  • Draw path now does a full query pass for unsorted tables (inline on crates/map/src/layout/elements.rs:505). Before this PR, an unsorted, unselected table with a query did O(limit) work per draw. Now each draw of such a table runs a whole-layer query_rows_with on the UI thread, uncached, with no Cancel look. The map frame already pays the same kind of pass per draw, so this is consistent with it, but it is new for tables. Confidence: medium.
  • Minor: cut_of recomputes page_geometry and series_env for each table, so an export with many tables repeats that work. The doc comment already describes what an export pays. Confidence: medium-low that it matters.

Quality

  • table() takes its layer and environment as a tuple (&Layer, &Env), which reads awkwardly. A small struct or two arguments would be clearer.
  • TableListing::count() rescans the kept bytes on every call. Storing the count in table_listing would avoid that.
  • The exported helper in the new test filters notices by the substrings "Table" and "Chart". That is fragile if the wording changes.
  • These are nits for the release quality pass; I did not post them inline.

AGENTS.md

  • No violations found.
  • No unwrap, expect or unsafe in non-test code.
  • No command, parameter or project-format change, so command-surface.txt and schema/ need no update.
  • The UI-thread cost of say_table_cut and table_cut is stated in the doc comments.
  • The one-byte-per-feature memory cost is stated in the PR body.
  • Twins checked: the table draw (render/src/layout.rs:748), the table cut (render/src/layout/table.rs cut_of), the chart draw (render/src/layout.rs:766), the chart properties panel (ui-egui/src/layoutview/format/chart.rs:229), and the chart losses notice (engine/src/cmd/layout/chart.rs:473). All of them read through frame_page_env or frame_style_env and chart_data_of, so they agree. render_region keeps table and chart frames drawn. None of the changed code is wasm32-specific.

Prior review threads

  • 4 earlier threads were on this PR. I did not repeat any of them.
  • Left alone, still open: the silent fallback when a definition query fails to compile, which lists every row with no notice (elements.rs:505, raised as quality, unanswered).
  • Verified fixed in code: the say_table_cut cost (now table_cut counts one table), the tables_cut cost (the same change, plus a doc comment), and the chart_data trap (now #[cfg(test)] and pub(super)).

Change size

Compared with the base branch: merge base e11b061 to head 869a338.

Measure Value
Files changed 12 (added 1, modified 11, removed 0, renamed 0)
Size before 5.1 MB (5,354,661 B)
Size after 5.1 MB (5,369,543 B)
Total size change +14.5 KB (+14,882 B)
File Before After Change
crates/engine/src/tests/layout_definition_query.rs 0 B 7.4 KB +7.4 KB
crates/map/src/layout/tests.rs 134.3 KB 136.3 KB +2.0 KB
crates/render/src/layout/tests.rs 489.6 KB 491.4 KB +1.8 KB
crates/map/src/layout/elements.rs 65.9 KB 67.6 KB +1.7 KB
crates/render/src/layout/table.rs 11.2 KB 11.8 KB +633 B
crates/render/src/layout.rs 64.6 KB 64.9 KB +283 B
docs/user-guide/layouts.md 105.4 KB 105.6 KB +224 B
crates/map/src/lib.rs 295.1 KB 295.3 KB +210 B
crates/engine/src/cmd/layout/elements.rs 83.4 KB 83.6 KB +183 B
crates/engine/src/tests.rs 3.8 MB 3.8 MB +75 B
crates/map/src/layout/chart.rs 17.6 KB 17.6 KB +9 B
crates/render/src/layout/chart.rs 25.6 KB 25.6 KB +3 B

Comment thread crates/render/src/layout/table.rs Resolved
@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Code review

This PR makes layout tables and charts list only the rows their layer's definition query keeps, at the frame's scale and on the series page shown. I traced every reader of the new path: the page draw, the table cut and notices (say_table_cut, tables_cut, export and report), the chart notices (say_chart), and the Layout view's chart preview. All of them now go through frame_page_env or frame_style_env, so the readers agree. I found no crash, data-loss or security defect in the changed code. I could not compile or run the tests here, so compile and test results are unverified.

Bugs

  • None found. I checked the grouped, ungrouped and stacked chart loops, the sorted and unsorted table paths, the selected-rows path, the is_kept boundaries and the Cancel checks. They are consistent with the query's answer.

Security

  • None found.

Performance

  • Already raised and answered in earlier threads: a full query pass on the UI thread per table draw and per table cut. The doc comments now say so. Left alone (5 earlier concerns in total, see below).
  • New, not raised before, low severity: each draw of a table or chart with a query allocates a Vec<bool> of one byte per feature and frees it on return. The PR states this. Nothing is kept between draws, so this is transient, not a second copy of the layer.

Quality

  • crates/render/src/layout/table.rs:98: .ok() drops the series-index error. A table on a series page whose index can't be read gets no cut notice, while say_chart reports the same error. Confidence: low-medium. Inline comment posted.
  • Test gap, grouped as a nit: no test covers the add-time notice (say_table_cut via layout.addElement) with a definition query. what_is_said_to_be_left_out_counts_the_kept_rows_alone only goes through export. Confidence: medium that it's untested, low that it's a real bug.
  • Nit: the cut notices for a table or chart are not re-said when layer.definitionQuery changes. They are said on element change and on export. Confidence: low. This may be intended.

AGENTS.md

  • None found that I could verify. Checked:
    • No unwrap, expect or panic in new non-test code.
    • Cancel and cost are documented in the doc comments of table_listing and chart_data_of.
    • No new command or parameter, so the command snapshot and schema are unaffected.
    • No new interface strings.
    • chart_data is now #[cfg(test)], so production code cannot reach the unfiltered chart path.

Already raised, left alone

Five earlier threads are on this PR. I did not post new comments on them:

  • elements.rs:325: per-edit query cost (answered, doc updated).
  • elements.rs:507: silent fallback for a query that doesn't compile (answered by the author).
  • elements.rs:507: per-draw cost (answered by the author).
  • table.rs:89: tables_cut cost (outdated; fixed with table_cut, and tables_cut documents its cost).
  • elements.rs:1029: public chart_data trap (fixed with #[cfg(test)]).

Change size

Compared with the base branch (merge base e11b061 to PR head c4063cb). The size figures are file bytes from stats.json, not diff line counts.

Measure Value
Files changed 13 (1 added, 12 modified, 0 removed, 0 renamed)
Size before 5.13 MB
Size after 5.15 MB
Total size change +14.9 KB
File Before After Change
crates/engine/src/tests/layout_definition_query.rs 0 B 7.4 KB +7.4 KB
crates/map/src/layout/tests.rs 134.3 KB 136.3 KB +2.0 KB
crates/map/src/layout/elements.rs 65.9 KB 67.7 KB +1.9 KB
crates/render/src/layout/tests.rs 489.6 KB 491.4 KB +1.8 KB
crates/render/src/layout/table.rs 11.2 KB 11.9 KB +0.7 KB
crates/render/src/layout.rs 64.6 KB 64.9 KB +0.3 KB
docs/user-guide/layouts.md 105.4 KB 105.7 KB +0.2 KB
crates/map/src/lib.rs 295.1 KB 295.3 KB +0.2 KB
crates/engine/src/cmd/layout/elements.rs 83.4 KB 83.6 KB +0.2 KB
crates/engine/src/tests.rs 3.8 MB 3.8 MB +75 B
crates/engine/src/cmd/layout/chart.rs 26.8 KB 26.9 KB +51 B
crates/map/src/layout/chart.rs 17.6 KB 17.6 KB +9 B
crates/render/src/layout/chart.rs 25.6 KB 25.6 KB +3 B

@jgregoriorincon
jgregoriorincon marked this pull request as ready for review December 1, 2026 19:01
/// count, and no table is counted while the series index can't be read, as the page isn't drawn
/// then. Each table's layer has its definition query read over it, once a call, besides the read
/// that draws it: what an export or a report pays to say them (#3478).
pub fn tables_cut(layout: &Layout, maps: &[Map], dpi: f64) -> Vec<TableCut> {

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.

New per-page cost on the export paths. tables_cut now runs table_listing(...).count() for every visible table of the layout, and each call reads that table's definition query over its whole layer. Its callers repeat that work per page:

  • crates/engine/src/cmd/layout/export.rs:322 calls it inside the per-page loop of the PNG/PDF export (progress::step per page), so an N-page series export does N full query passes per query-filtered table on the layout.
  • crates/engine/src/cmd/report.rs:1420 (keep_tables) does the same per page of a report.

Before this change an unsorted, unselected table counted in O(1), so this cost is new. The series index differs per page, so the count can't simply be reused across pages, and the pass has no look at Cancel. A layer of tens of millions of rows makes each page's cut seconds of work that Cancel only sees between pages.

The doc above notes the cost for one call, but not that the export and report loops multiply it. Either state that multiplication in the doc of tables_cut and at those two call sites, or skip tables whose layer has no query before anything else, or keep the page's kept rows for the cut and the draw so the read happens once per page.

Confidence: high on the code path, medium on the magnitude (not measured).

Category: performance

@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Code review

Bugs

  • None confirmed. I checked that the table count, the table draw and the chart bars read the same query at the same frame scale (frame_style_env / frame_page_env), that is_kept matches the map's query_rows_with fallback, that the two chart row loops (grouped and ungrouped, which feed stacked charts) are the only per-row loops and both skip unkept rows, and that TableListing::count and first agree for the selected, sorted and plain cases. Confidence: medium-high. I could not compile or run the tests here, so this rests on reading.

Security

  • None found.

Performance

  • crates/render/src/layout/table.rs:77 (inline comment posted): tables_cut now does a full definition-query pass per query-filtered table, and the export loop (crates/engine/src/cmd/layout/export.rs:322) and report (crates/engine/src/cmd/report.rs:1420) call it once per page. A series export therefore pays N passes per table, with no Cancel look inside a pass. Confidence: high on the code path, medium on the magnitude (not measured). This is new, not the per-draw or per-edit cost the earlier threads raised.

Quality (nits, left for the release quality pass)

  • one_tables_cut_is_its_own_of_the_pages is an unclear test name.
  • TableListing builds the kept-rows vector even for a selected_only table with no selection, where it isn't needed. Minor.
  • In layout_definition_query.rs, exported calls remove_dir_all(...).unwrap() before the assertions run, so a failed export also leaves the temp directory behind.

AGENTS.md

  • crates/engine/src/cmd/layout/elements.rs (say_table_cut): the doc says the count runs "on the command's thread" and reads the query without a look at Cancel, but it doesn't say why it must stay on the UI thread. "Never hold the window" asks for that reason when a command's work grows with its input, and a table's count now does. The earlier reply covers the cost but not this rule, so this is a gap the reply doesn't close. Confidence: medium-low. Not posted inline, since the earlier thread already sits on that line.

Earlier concerns left alone: 6 threads already on this PR (query-pass cost on the UI thread, the silent fallback for a query that doesn't compile, the silence when the series index can't be read, the per-table count in tables_cut, and the public chart_data). Each has a reply that addresses it, and I found nothing new in them beyond the export-loop multiplication above.

Change size

Compared with the base branch: the whole PR against main (merge base e11b061 to PR head c4063cb).

Measure Value
Files changed 13 (1 added, 12 modified, 0 removed, 0 renamed)
Size before 5.13 MB
Size after 5.15 MB
Total size change +14.9 KB
File Before After Change
crates/engine/src/tests/layout_definition_query.rs 0 B 7.4 KB +7.4 KB
crates/map/src/layout/tests.rs 134.3 KB 136.3 KB +2.0 KB
crates/map/src/layout/elements.rs 65.9 KB 67.7 KB +1.9 KB
crates/render/src/layout/tests.rs 489.6 KB 491.5 KB +1.8 KB
crates/render/src/layout/table.rs 11.2 KB 11.9 KB +743 B
crates/render/src/layout.rs 64.6 KB 64.9 KB +283 B
docs/user-guide/layouts.md 105.4 KB 105.7 KB +245 B
crates/map/src/lib.rs 295.1 KB 295.3 KB +210 B
crates/engine/src/cmd/layout/elements.rs 83.4 KB 83.6 KB +183 B
crates/engine/src/tests.rs 3.84 MB 3.84 MB +75 B
crates/engine/src/cmd/layout/chart.rs 26.8 KB 26.9 KB +51 B
crates/map/src/layout/chart.rs 17.6 KB 17.6 KB +9 B
crates/render/src/layout/chart.rs 25.6 KB 25.6 KB +3 B

@jgregoriorincon
jgregoriorincon added this pull request to the merge queue Dec 1, 2026
Merged via the queue into opengeos:main with commit eaf74c0 Dec 1, 2026
31 checks passed
@jgregoriorincon
jgregoriorincon deleted the fix/3478-layout-table-definition-query branch December 1, 2026 20:10
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]: A layout table or chart lists features the layer's definition query hides

1 participant