Skip to main content

TableLoader

Trait TableLoader 

Source
pub trait TableLoader: Send + Sync {
    // Required methods
    fn lookup<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 [u8],
    ) -> Pin<Box<dyn Future<Output = Result<LookupResult, LookupError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn name(&self) -> &str;

    // Provided methods
    fn lookup_batch<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        keys: &'life1 [&'life2 [u8]],
    ) -> Pin<Box<dyn Future<Output = Result<Vec<LookupResult>, LookupError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
    fn health_check<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn close<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<(), LookupError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

Trait for loading data from external reference tables.

Implementations of this trait provide access to external data sources for enriching streaming events with dimension data.

§Thread Safety

Implementations must be Send + Sync to allow concurrent access from multiple operator instances.

§Performance Considerations

  • Lookups may be called frequently (per-event), so implementations should be efficient
  • Consider batch lookups (TableLoader::lookup_batch) for better throughput when multiple keys need to be looked up
  • The LookupJoinOperator (in laminar-core) caches results, so implementations don’t need their own cache

Required Methods§

Source

fn lookup<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 [u8], ) -> Pin<Box<dyn Future<Output = Result<LookupResult, LookupError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Looks up a single key in the table.

§Arguments
  • key - The key to look up (typically the join column value)
§Returns
  • Ok(LookupResult::Found(batch)) if the key exists
  • Ok(LookupResult::NotFound) if the key doesn’t exist
  • Err(LookupError) if the lookup failed
Source

fn name(&self) -> &str

Returns the name of this table loader for logging/debugging.

Provided Methods§

Source

fn lookup_batch<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, keys: &'life1 [&'life2 [u8]], ) -> Pin<Box<dyn Future<Output = Result<Vec<LookupResult>, LookupError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Looks up multiple keys in a single batch operation.

Default implementation calls lookup for each key. Implementations should override this for better performance when the underlying system supports batch queries.

§Arguments
  • keys - The keys to look up
§Returns

A vector of results in the same order as the input keys.

Source

fn health_check<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Checks if the table loader is healthy and can accept requests.

Default implementation returns true. Override for loaders that need to maintain connections to external systems.

Source

fn close<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), LookupError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Closes the table loader and releases any resources.

Default implementation does nothing. Override for loaders that hold connections or other resources.

Implementors§