Repository navigation
Consolidate query execution and rewrite pipelines - #1215
Merged
Merged
Conversation
Merged
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.
Summary
Consolidates the query-execution and pattern-rewrite code paths in
fluree-db-querybehind a single set of entry points, removes the wrapper functions that accumulated to thread varying combinations of optional context state, and replaces hand-rolled match-and-recurse blocks across four rewrite passes with a sharedPattern::map_subpatternshelper. These changes caused a net reduction of about 1000 lines of code.Motivation
The execution surface in
fluree-db-queryhad grown a family of nearly-identical wrapper functions —execute,execute_with_dataset,execute_with_dataset_and_bm25,execute_with_policy,execute_pattern_with_overlay_at, and so on — each one differing only in which optional pieces of context state (tracker, policy enforcer, dataset, R2RML providers, BM25/vector providers, binary store, dict novelty, spatial/fulltext providers, remote service executor) it threaded through. New optional state required either a new wrapper or yet another positional parameter on an existing one. Callers had to pick the wrapper that matched their exact combination, and the lib.rs surface re-exported a tangle of overlapping entry points. Likewise, the pattern-rewrite passes (rewrite.rs,geo_rewrite.rs,r2rml/rewrite.rs,rewrite_owl_ql.rs) each contained the same 8-arm match block to recurse intoPattern::Optional,Union,Minus,Exists,NotExists,Graph,Service, andSubquery— modulo the per-pass leaf logic.Key changes
executeandexecute_streaminginfluree-db-query/src/execute/runner.rsare now the canonical paths for prepared and lazy execution. Both take aContextConfig<'a, 'b>carrying every optional piece of context state.ContextConfigreplaces parameter sprawl. Callers build a config withContextConfig { tracker: Some(&t), r2rml: Some((&p, &p)), ..Default::default() }instead of selecting one of N positional-argument wrappers.Default::default()setsstrict_bind_errors: true(the de-facto default at every prior call site).execute_with_dataset,execute_with_dataset_and_bm25,execute_with_policy, and theexecute_pattern_with_overlay_atfamily are gone fromfluree-db-query/src/lib.rsandexecute.rs. Callers influree-db-api(BM25, vector, ontology imports, graph-source helpers, R2RML integration tests, transact staging) now construct aContextConfigdirectly.Pattern::map_subpatterns. New method onPattern(influree-db-query/src/ir.rs) that applies a closure to every immediateVec<Pattern>container — Optional, Minus, Exists, NotExists, Graph, Service, Subquery, and each branch of Union — and reconstructs the surrounding variant. Leaf variants pass through. Doc comment is explicit that callers intercept variants their semantics shouldn't descend into (e.g.encode_patterns_for_reasoningandgeo_rewrite::rewrite_recursiveboth carve out Service/Subquery before falling through;dedup_exact_triplesrecurses into them because triple dedup is idempotent under SPARQL set semantics).rewrite.rs,geo_rewrite.rs,r2rml/rewrite.rs, andrewrite_owl_ql.rsare replaced bypattern.map_subpatterns(&mut recurse)(or a smallmatchfor the variants that do need pass-specific carve-outs).it_graph_source_r2rml.rsconsolidates four near-identicalContextConfig { tracker: Some(&t), r2rml: Some((&p, &p)), ..Default::default() }blocks behind a small genericr2rml_test_confighelper.groupby_aggregate_tests.rs,owl2rl_property_rules_integration_tests.rs, andvalues_bind_union_tests.rsmigrate from the removed wrappers toexecute(..., ContextConfig::default()).Behavior
No semantic changes for callers. The
dedup_exact_triplesrewrite is now slightly more thorough — it descends into Service and Subquery scopes throughmap_subpatterns, where the original explicit match block stopped at the boundary. Dedup of identicalPattern::Triplenodes is idempotent in any scope under SPARQL set semantics, and the remote endpoint sees an equivalent (smaller) query, so this is a strict optimization.