Skip to main content

MemoizeCache

Struct MemoizeCache 

Source
pub struct MemoizeCache {
    pub group_maps: BTreeMap<String, Option<Rc<GroupMap>>>,
    pub expr_plans: BTreeMap<usize, ExprPlan>,
    pub in_sets: BTreeMap<usize, Option<InListSetEntry>>,
    pub has_subquery: BTreeMap<usize, bool>,
    pub hit_count: u64,
    pub miss_count: u64,
    /* private fields */
}

Fields§

§group_maps: BTreeMap<String, Option<Rc<GroupMap>>>

v7.29 (round-22 phase 3) - batch-evaluated correlated scalar subqueries: subquery repr -> Some((outer column, key -> value map built in ONE pass)) or None when the shape can’t batch (so we don’t re-analyse it per row). Turns 23.5k per-group executions into one grouped scan + 23.5k lookups.

§expr_plans: BTreeMap<usize, ExprPlan>

v7.29 (3c) - host-expression ptr -> (subquery count, plan).

§in_sets: BTreeMap<usize, Option<InListSetEntry>>

v7.30.2 (mailrs round-25) - InList node ptr -> membership set for large all-literal IN lists, built once per row loop. Turns the O(rows × list) membership scan into O(rows × log list). None = analysed, not eligible.

§has_subquery: BTreeMap<usize, bool>

v7.30.2 (mailrs round-25) - host-expression ptr -> “contains a subquery node”. The walk is O(tree) and a materialised IN list makes the tree huge — caching it makes the per-row dispatch O(log n) instead of O(24k list elements).

§hit_count: u64§miss_count: u64

Implementations§

Source§

impl MemoizeCache

Source

pub fn new() -> Self

Source

pub const fn with_max_entries(self, n: usize) -> Self

Source

pub const fn with_max_bytes(self, b: usize) -> Self

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn get(&mut self, key: &CacheKey) -> Option<Value>

Look up a cached scalar value. On hit, re-promotes the entry to the LRU front and bumps hit_count. On miss, returns None (caller runs the subquery + inserts).

Source

pub fn insert(&mut self, key: CacheKey, value: Value)

Insert a freshly-computed scalar value. Caller must have get-missed first (the cache doesn’t dedupe inserts). Evicts LRU entries until both caps are satisfied.

Trait Implementations§

Source§

impl Clone for MemoizeCache

Source§

fn clone(&self) -> MemoizeCache

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MemoizeCache

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for MemoizeCache

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.