Skip to main content

Module codegen_batch

Module codegen_batch 

Source
Expand description

Batch classes: a function run over many items that stay on the Rust side.

bridge --batch fuzzyScore:text gives the crate a FuzzyScoreBatch class: the constructor takes the items (the text values) once; run(query) applies the port to every item on all cores and returns the results as one typed array; rank(query, min) returns the indexes of the items whose result is at least min, best first. One call does what a loop of per-item calls did, so the crossing is paid once instead of per item.

The default index calls the port per item. A port can do better by defining pub struct FuzzyScoreIndex in port.rs with pub fn new(items: Vec<T>) -> Self and pub fn run(&self, <other params>) -> Result<Vec<R>, String>: it can prepare the items once (lowercase them, build masks) and the class uses it instead.

Structs§

Batch
--batch function:param: run function over many values of param.

Functions§

index_cjs
The index.cjs part that sends and receives the values of [fast_batches] in bulk.
js_rs
Batch classes for a napi-rs or wasm-bindgen lib.rs.
needs_rayon
Whether the crate depends on rayon: every crate with batches. Wasm gets it too, so a port.rs index using it builds for both kinds: without threads, rayon runs on the calling thread.
pascal
py_rs
Batch classes for a PyO3 lib.rs, and the names to register.