Skip to main content

Module compile

Module compile 

Source
Expand description

AST → compiled execution plan. Each AND group gets a driver — the most selective positive literal, executed as a single SIMD sweep over the name pool — plus residual matchers ordered by evaluation cost (numeric filters → memmem → regex → path).

Structs§

CTerm 🔒
CompiledGroup 🔒
CompiledQuery
An executable plan: one compiled AND group per OR clause, plus the path pools the sweep must materialize to evaluate them.

Enums§

CaseMode
How the query is matched against names (FmfQueryOptions.case_mode).
CompileError
Why a query failed to compile into an executable plan.
Driver 🔒
Candidate generator for one AND group — a single sweep over the folded name pool (the only contiguous one) instead of a per-entry matcher call. Needles are always folded; a case-exact source term makes the sweep a superset and its exact comparison runs as a residual (CompiledGroup::driver_exact).
Matcher 🔒
RegexScope
Which haystack a whole-query regex runs against (FmfQueryOptions.regex_mode bit1; ADR-0023).
WildShape 🔒
lit* / *lit / *lit* style patterns collapse to anchored byte comparisons; everything else stays a regex.

Constants§

REGEX_DFA_SIZE_LIMIT 🔒
REGEX_SIZE_LIMIT 🔒
Compile-time bounds on a user regex (ADR-0023). The regex crate matches in guaranteed linear time (finite automata, no backtracking) — so there is no ReDoS execution blowup — but a pathological pattern can still demand a large program/DFA at build time. We index file names only (p99 ≈110 B), so a legitimate name regex never approaches 1 MiB; capping there turns a memory-DoS pattern into a clean CompiledTooBigFMF_E_QUERY_SYNTAX rejection (it flows through CompileError::Regex unchanged), instead of letting the elevated service compile it. Both default higher (10/2 MiB).

Functions§

build_regex 🔒
classify_wildcard 🔒
compile
Compile a parsed Ast into an executable CompiledQuery.
compile_term 🔒
compile_whole_regex
Compile the entire query text as one regex (whole-query regex mode).
driver_for 🔒
Build the sweep driver from a term, leaving the term intact (kept as CompiledGroup::driver_term). Returns the driver and whether it fully checks the term — false for a case-exact term: the sweep folds its needle (sound: an original-case match always implies the folded match) and the exact comparison runs as a residual.
driver_score 🔒
Driver candidate score — longer literals are more selective. Returns None for matchers that cannot drive a pool sweep.
fold_exact_needle 🔒
Fold a case-exact needle for the superset sweep. Needles always originate from the query &str, so the bytes are valid UTF-8; the fold’s length preservation keeps prefix/suffix anchors sound.
fold_needle 🔒
insensitive 🔒
Smart-case decision for one needle.
regex_name_prefilter 🔒
Extract a required literal factor from a name regex and turn it into a folded-pool substring sweep — the same linear sweep every literal query uses (ADR-0002), so regex stays off the full scan without any standing index (ADR-0023).
regex_prefilter_driver 🔒
When a group has no literal driver, try to drive it from a positive name regex’s required literal. The regex matcher stays in terms as the residual that confirms each candidate, so driver_term is None.
regex_prefilter_enabled 🔒
Kill switch for the regex literal prefilter (FMF_REGEX_PREFILTER=0) — forces literal-less and literal-bearing regex groups onto the chunked full scan. A field escape hatch if a prefilter soundness bug ever surfaces (the same shape as FMF_QUERY_CACHE, ADR-0023).
substring_finder 🔒
wildcard_to_regex_body 🔒
Translate a */? pattern into a regex body (no anchors).