fn estimate_nfa_states(pattern: &MatchRecognizePattern) -> u64Expand description
Upper bound on the number of NFA states Nfa::compile will allocate for pattern.
Mirrors the construction in nfa.rs (Nfa::build): a variable is 2 states; an alternation adds a
start and an accept state; *, ? and each optional copy of a range add 2; + builds the inner
pattern twice; PERMUTE of n variables becomes an alternation of n! concatenations. Saturating
throughout, so an over-large pattern reports a saturated estimate rather than wrapping.
This is a model of code in another crate, so it cannot be checked by a test: risingwave_stream
depends on risingwave_frontend’s protos, not the reverse, and nothing can observe both. If the
state count of any construct in nfa.rs changes, this must change with it, or the guard above
silently becomes an under-estimate. The construction sites in nfa.rs carry a comment pointing
back here.