Repository navigation
feat: selective B+Tree lookup in filter_facts_for_query (#208) - #246
Merged
Merged
Conversation
) Move get_facts_by_entity, get_facts_by_attribute, and get_facts_by_entity_attribute from #[cfg(test)] to a production impl block so they can be called from the query executor. Also promote the resolve_fact_ref and next_string_prefix helper functions to production scope. The five remaining test-only helpers stay in #[cfg(test)]. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add `selective_fact_fetch` to `DatalogExecutor` and wire it into the `(None, None)` arm of `filter_facts_for_query`. For rule-free queries with ≤4 distinct bound entities/attributes, this skips the full `get_all_facts()` scan in favour of targeted index lookups. Patterns inside `not`/`not-join`/`or`/`or-join` bodies are included via `collect_all_patterns` so the snapshot is always complete. Rule queries continue to use the full scan since rules require the entire fact base. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
4 tasks done
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
get_facts_by_entityandget_facts_by_attributefrom#[cfg(test)]to production code ingraph/storage.rsselective_fact_fetchhelper onDatalogExecutorthat inspects query patterns for bound entity literals and attribute names, unions index-driven results (up to a threshold of 4 total lookups), and falls back toget_all_facts()when the threshold is exceeded or no bound values exist(None, None)arm offilter_facts_for_query;as_ofarms always use the full log for correctnessbtree_lookup/entity_pointandbtree_lookup/attribute_scanbenchmark groups at 1k/10k/100k scale — baseline for Benchmark SIMD vectorization gains vs current scalar implementation #229 SIMD workTest Plan
cargo test— all 795+ tests pass, zero failurescargo clippy— cleancargo fmt --check— cleanas_ofqueries still take full-scan path and return correct resultsCloses #208. Prerequisite for #229.
🤖 Generated with Claude Code