Repository navigation
Conversation
…until provider impl) R2rmlTableProvider gains table_row_count (default Ok(None) — opt-in), and the fused aggregate answers a bare COUNT (one CountRows fold, no GROUP BY, no FILTER) from it when the provider can prove manifest count == full scan. The non-null proof columns are parsed from the subject template STRING (template_columns is loader-only; a with_subject_template mapping would otherwise pass the null guard vacuously). With no provider impl yet every call falls back to today's scan — corpus and suites unchanged.
…R-1 provider side) FlureeR2rmlProvider implements table_row_count: resolve the SAME per-query pinned table context the scan uses (new load_table_context helper, shared verbatim loadTable resolution incl. the IcebergCatalogSession snapshot pin), read only the manifest-list/manifest Avro (never a data file), and return the record_count sum when sound_manifest_row_count proves it equals a full scan: no delete manifests, and every subject/object non-null column provably zero-null (absent/partial stats are unknown, never zero; unknown column or would-be-negative total declines). Constant-subject mappings need no null proof. Declines fall back to the always-correct scan. Scan-only concerns (scan-start log, Parquet disk cache) stay in scan_table_inner — a COUNT emits no phantom scan log and builds no cache. Live SF01: fact COUNTs q036/q037/q039 DNF@180s -> 2.8-4.4s with exact counts hash-equal to the native oracle; the residual is entirely the cold REST floor (oauth+loadTable). Fused-scan sentinel and GROUP-BY negative control unaffected; FLUREE_FUSED_R2RML_AGG=0 restores the scan path. Native corpus 54/54, 0 hash mismatches across three runs.
This was referenced Jul 12, 2026
cargo fmt --all --check fails on three hunks of this PR's own delta (fluree-db-api/src/graph_source/r2rml.rs, fused_aggregate.rs import + manifest-shortcut block) with rustfmt from stable 1.97.0 — what CI's dtolnay/rust-toolchain@stable resolves. CI never ran here (ci.yml triggers only on base=main), flagged by the #1476 review stack-wide note.
…m, as-of breadcrumbs The four optional items from the #1478 review (the blocking fmt item was already fixed in f8f5206): - table_row_count is instrumented as r2rml.count_manifest (the same .instrument split as scan_table), recording fired=answered|declined. Allowlisted in fluree-bench-virtual with a rename-guard citation, so the vbench pathway counters show the shortcut directly instead of inferring it from files_selected=0 + scan-span absence. The must-fire invariant becomes a group — scan_table OR count_manifest — because a fired COUNT(*) legitimately never scans; spans_missing would otherwise false-flag the very pathway PR-1 added. - sound_manifest_row_count re-sums record_count with per-file checked u64 arithmetic instead of trusting agg.row_count: a corrupt manifest with a negative per-file count, or a total that overflows, declines instead of wrapping past the sign check in release builds (test: three i64::MAX files wrap i64 to a positive total the old guard would have served as an "exact" count). aggregate_column_stats' advisory totals now saturate instead of wrapping (or overflow-panicking in debug builds). - GREP: r2rml-as-of-t breadcrumbs in table_row_count_inner and scan_table_inner so time-travel semantics cannot land on one without the other — a COUNT and a scan in one query must read one snapshot. - ROADMAP PR-8 residual: the decline-path double manifest read (the shortcut reads manifests, then the fallback scan's planner re-reads them; a first cold COUNT on a delete-bearing table pays twice) folds into the catalog round-trip caching program. Gates: fmt clean; scoped clippy adds no lints; fluree-bench-virtual 33/33 (incl. the allowlist rename guard); fluree-db-iceberg --all-features green; fluree-db-api --lib --all-features 845 passed (count_shortcut 7/7).
Contributor
Author
|
Consolidating at maintainer request. #1478 (PR-1 — the |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Roadmap PR-1 (
docs/audit/2026-07-virtual-dataset-perf/ROADMAP.md). A bare, unfilteredCOUNT(*)over one class of a virtual (R2RML/Iceberg) dataset now answers from the Iceberg manifestrecord_countsum instead of decoding every Parquet data file. On the SF01 corpus this turns the three fact COUNTs from DNF@180s into sub-5s exact counts:Query-side detection shipped in the parent commit (
271c8b7a6, behavior-neutral until this provider impl); this commit is the provider side.Soundness contract
table_row_countreturnsSome(n)only when the manifest count provably equals a full-scanCOUNT(*)(puresound_manifest_row_count, unit-tested without I/O):aggregate_column_stats' coverage gate yieldsSome(0)only when every data file reported the stat and they sum to zero; absent/partial stats are unknown ⇒ decline (never treated as zero); unknown column or would-be-negative total likewise declines.non_null_cols= constant-subject mapping ⇒ sound with no null proof.Any decline ⇒
Ok(None)⇒ the caller runs today's delete/null-correct scan. Trait default isOk(None), so non-Iceberg providers always scan. Kill switch: existingFLUREE_FUSED_R2RML_AGG(off ⇒ full-scan path, verified live).Extraction + snapshot-pin preservation
The loadTable front-half of
scan_table_inneris extracted intoload_table_context, shared by scan and count. The per-query snapshot pin (IcebergCatalogSession::cached_load_table/pinned_metadata_location/store_load_table, via the query-scopedself.session) moved verbatim, so a COUNT and a scan in one query read the same pinnedmetadata_location⇒ one snapshot. Scan-only concerns (the scan-start log, the Parquet disk cache) stay inscan_table_inner— a COUNT emits no phantom scan log and builds no unused cache.Gates (all six pass)
fluree-db-queryfull suite — green.fluree-db-api --features icebergfull suite — green; 6 newcount_shortcut_*tests (delete-manifest DoD centerpiece, nullable, stats-absent, unknown-column, constant-subject, clean-table exact).fluree-db-iceberg --lib --tests— green (180). Barecargo test -p fluree-db-icebergfails only on the pre-existing aws-gatedexamples/smoke_minio.rscompile issue (proven pre-existing by stash-to-base; suggest a tiny follow-up gating the example on#[cfg(feature="aws")]).cargo test→ 4 idle → 10 under another build) and the violator set shuffles run-to-run; native never enters this provider.result_hash == native oracleon all three; fused-scan sentinel q022 unaffected (took the scan path, shortcut correctly declined —files_selected=1+ scan span present); GROUP-BY negative control q014 unaffected. Fire-vs-decline proven by span counters (fired ⇒files_selected=0+ no scan spans), stronger than log greps.FLUREE_FUSED_R2RML_AGG=0restores the scan path on q036 (DNF vs 4.43s on).Note
q036's residual 4.4s is entirely
oauth_token(0.52s) +r2rml.load_table(3.52s): PR-1 reduces fact COUNT to the cold-catalog REST floor — exactly roadmap PR-8's target.Stacks on #1476 (PR-0 correctness) ← #1475 (bench harness) ← #1450.