Skip to content

#290: live viewport/cross-filtered counts for the Material facet tree#292

Merged
rdhyee merged 1 commit into
isamplesorg:mainfrom
rdhyee:feat/290-live-material-counts
Jun 18, 2026
Merged

#290: live viewport/cross-filtered counts for the Material facet tree#292
rdhyee merged 1 commit into
isamplesorg:mainfrom
rdhyee:feat/290-live-material-counts

Conversation

@rdhyee

@rdhyee rdhyee commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

#290 — live viewport / cross-filtered counts for the Material facet tree

Follow-up to the shipped Material hierarchy (#281/#282). The tree shipped with static global baseline counts; this makes the legend numbers live when you zoom in. (Map/table filtering was already live + correct — this is just the counts.)

What

  • Zoomed views: each tree node's count = COUNT(DISTINCT pid) from sample_facet_membership, scoped to the viewport (bbox via lite JOIN) + the other active facets (a facets_v3 pid-subquery) + search. Parent ≥ child holds; legend == table for a node selection (explorer: facet counts use padded viewport, matching the table (#234) #245 coherence).
  • Cross-filter both ways: a source/context/object selection narrows Material counts; a Material node selection narrows the others (via the membership subtree subquery, not facets_v3's flat value).
  • Cube disabled in tree mode (it has no tree nodes).

Global-view gate (perf — important)

The membership COUNT(DISTINCT pid) is a near-full scan at global/large views and starved the single DuckDB-WASM connection (the samples-table query timed out). At true-global the baseline IS the correct global count, so we use it (instant). Live counts engage when zoomed, where the bbox prunes the scan (verified fast). Net: the global view is unchanged/instant; zoomed views get live counts.

Verified (202608)

  • earthmaterial 4,091,133 global → 25,988 at Cyprus (viewport-scoped)
  • legend(earthmaterial) == table = 26,310 when it's the filter (coherence)
  • parent ≥ child in-viewport; source⇄material cross-filter both directions
  • 8 facet-tree specs + smoke green; render clean
  • Codex: no blocking findings (it independently verified the cross-filter with direct DuckDB queries)

Accepted residual (documented)

At global view with another active filter/search, Material counts show the global baseline (instant, slightly stale — not cross-filtered). A precomputed facet_tree_cross_filter cube is the follow-up if live global cross-filtered Material counts are wanted. (Closes the first half of #290; the cube is the optional remainder.)

🤖 Generated with Claude Code

… facet tree

The Material tree shipped with STATIC global baseline counts; this makes them live
when the user zooms in. Map/table filtering was already live — this is the legend.

- describeCrossFilters: Material participates via materialSelection() (minimal nodes)
  ONLY when zoomed (!isGlobalView); at/near global it stays baseline.
- buildCrossFilterWhere: Material cross-filters OTHER dims via a membership
  pid-subquery (concept_uri IN selected) — a selected parent matches its subtree.
- updateCrossFilteredCounts: cube disabled in tree mode (no tree nodes in the cube);
  Material own-counts at global → baseline (instant); zoomed → membership query
  COUNT(DISTINCT pid) per concept_uri, scoped by bbox (lite JOIN) + other dims
  (facets_v3 pid-subquery) + search.

GLOBAL GATE (perf): the membership COUNT(DISTINCT) is a near-full scan at global/
large views and starved the single DuckDB-WASM connection (samples-table query
timed out). At true-global the baseline IS the correct global count, so we use it
(instant); live counts engage when zoomed, where the bbox prunes the scan.

Verified (202608): earthmaterial 4,091,133 global → 25,988 at Cyprus; legend(node)
== table(node filter) = 26,310 (coherence isamplesorg#245); parent>=child in-viewport; source⇄
material cross-filter both directions. 8 facet-tree specs + smoke green; render clean.
Codex: no blocking findings (verified cross-filter via direct DuckDB queries).

Accepted residual (documented): at global view WITH another filter/search, Material
counts show baseline (instant, slightly stale) — a precomputed facet_tree_cross_filter
cube is the follow-up if live global cross-filtered material counts are wanted.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@rdhyee rdhyee merged commit 85e8cc7 into isamplesorg:main Jun 18, 2026
2 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.

1 participant