Skip to main content

LookupTable

Trait LookupTable 

Source
pub trait LookupTable: Send + Sync {
    // Required methods
    fn get_cached(&self, key: &[u8]) -> LookupResult;
    fn get(&self, key: &[u8]) -> LookupResult;
    fn insert(&self, key: &[u8], value: RecordBatch);
    fn invalidate(&self, key: &[u8]);
    fn len(&self) -> usize;

    // Provided method
    fn is_empty(&self) -> bool { ... }
}
Expand description

Synchronous lookup table interface for Ring 0 operators.

Implementations must be Send + Sync to allow sharing across threads in the thread-per-core runtime. The hot-path method is get_cached which should be < 500ns.

Writes (insert/invalidate) come from the Ring 1 CDC adapter or bulk-load path, not from the hot path.

Required Methods§

Source

fn get_cached(&self, key: &[u8]) -> LookupResult

Look up a key in the in-memory cache only (Ring 0).

This is the fast path — must not block or perform I/O. Returns LookupResult::NotFound on cache miss; callers should then try get for a deeper lookup.

§Performance

Target: < 500ns

Source

fn get(&self, key: &[u8]) -> LookupResult

Look up a key, potentially checking slower storage tiers.

May check a disk cache, remote cache, or trigger an async source query. Returns LookupResult::Pending if the lookup requires an async fetch that hasn’t completed yet.

Source

fn insert(&self, key: &[u8], value: RecordBatch)

Insert or update a cached entry.

Called by the CDC adapter or bulk-load path when new data arrives from the source. This is NOT on the hot path.

Source

fn invalidate(&self, key: &[u8])

Invalidate a cached entry.

Called when the source signals a delete or the TTL expires.

Source

fn len(&self) -> usize

Number of entries currently in the cache.

Provided Methods§

Source

fn is_empty(&self) -> bool

Whether the cache is empty.

Implementors§