pub struct JetroEngine { /* private fields */ }Expand description
Long-lived multi-document query engine with an explicit plan cache. Use when the same process evaluates many expressions over many documents — parse/lower/compile work is amortised by this object, not hidden in thread-local state.
Implementations§
Source§impl JetroEngine
impl JetroEngine
Sourcepub fn with_plan_cache_limit(plan_cache_limit: usize) -> Self
pub fn with_plan_cache_limit(plan_cache_limit: usize) -> Self
Create a JetroEngine with an explicit plan-cache capacity.
Set plan_cache_limit to 0 to disable caching entirely.
Sourcepub fn clear_cache(&self)
pub fn clear_cache(&self)
Discard all cached query plans and the engine’s key-intern cache, forcing re-compilation and re-interning on the next call.
Sourcepub fn parse_value(&self, document: Value) -> Jetro
pub fn parse_value(&self, document: Value) -> Jetro
Build a Jetro document from a serde_json::Value with object keys
interned into this engine’s key cache. Use this in place of
Jetro::from(...) / the From<serde_json::Value> impl when
per-engine key isolation is required.
Sourcepub fn parse_bytes(&self, bytes: Vec<u8>) -> Result<Jetro, JetroEngineError>
pub fn parse_bytes(&self, bytes: Vec<u8>) -> Result<Jetro, JetroEngineError>
Parse raw JSON bytes into a Jetro document with object keys
interned into this engine’s key cache. With simd-json, the tape
is materialised eagerly so interning happens once at parse time
(subsequent collect calls reuse the cached Val tree).
Sourcepub fn collect<S: AsRef<str>>(
&self,
document: &Jetro,
expr: S,
) -> Result<Value, EvalError>
pub fn collect<S: AsRef<str>>( &self, document: &Jetro, expr: S, ) -> Result<Value, EvalError>
Evaluate a Jetro expression against an already-constructed Jetro document,
using the engine’s shared plan cache and VM.
Sourcepub fn collect_value<S: AsRef<str>>(
&self,
document: Value,
expr: S,
) -> Result<Value, EvalError>
pub fn collect_value<S: AsRef<str>>( &self, document: Value, expr: S, ) -> Result<Value, EvalError>
Convenience wrapper: wrap a serde_json::Value in a Jetro and evaluate expr.
Routes through JetroEngine::parse_value so the document’s object keys are
interned into this engine’s key cache.
Sourcepub fn collect_bytes<S: AsRef<str>>(
&self,
bytes: Vec<u8>,
expr: S,
) -> Result<Value, JetroEngineError>
pub fn collect_bytes<S: AsRef<str>>( &self, bytes: Vec<u8>, expr: S, ) -> Result<Value, JetroEngineError>
Parse raw JSON bytes into a Jetro document and evaluate expr,
returning a JetroEngineError on either parse or evaluation failure.
Routes through JetroEngine::parse_bytes so the document’s object keys
are interned into this engine’s key cache.