Skip to main content

Module scratch

Module scratch 

Source
Expand description

Compute-side evaluation of a text request over in-house terms.

The pushed-key and pinned roads of the text_scan executor receive the terms they must decide and evaluate them locally instead of draining the partition’s index. Three modes, two mechanisms:

  • FTS builds a scratch in-memory index (TextIndex::create_in_ram) over the terms and runs it through the SAME schema, analyzer registration, query builder, and collector the partition index uses. Tantivy matching is per-document boolean — nothing in the match decision depends on index-global state (document frequencies affect only scoring order) — so the scratch answer equals the index answer for the same value, and no second query implementation exists to drift.
  • PREFIX / SUFFIX are pure string tests over the bounded seeds, exactly the match the index performs on its stored fields: a document’s text_begin is crate::doc::prefix_seed of its lexical and the query seed is crate::doc::prefix_seed of the pattern, so a value matches iff its seed starts with the pattern’s seed; the suffix direction is the same test over the reversed seeds.

Direct evaluation is equivalent to index membership because these roads only run inside a plan rewritten under the trust gate: the gate injects a candidate producer only for a variable whose object-slot scans use an allowlisted predicate, and a trusted index holds every string literal under those predicates. For every value the executor is asked about, “this value matches the query” and “the index returns this value” therefore coincide. A value from outside that universe (a VALUES/BIND binding, a non-allowlisted predicate) never reaches these roads: the rewrite declines and the exact residual answers.

Functions§

evaluate_fts
Evaluate a full-text request over the in-house documents.
evaluate_seed
Evaluate a prefix / suffix request over the in-house documents as pure string tests (no index construction). The mode selects the direction; anything else is a caller bug.