Skip to main content

JetroEngine

Struct JetroEngine 

Source
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

Source

pub fn new() -> Self

Create a JetroEngine with the default plan-cache limit of 256 entries.

Source

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.

Source

pub fn keys(&self) -> &Arc<KeyCache>

Borrow this engine’s JSON key-intern cache.

Source

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.

Source

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.

Source

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).

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Default for JetroEngine

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.