Skip to main content

LookupSource

Trait LookupSource 

Source
pub trait LookupSource: Send + Sync {
    // Required methods
    fn query(
        &self,
        keys: &[&[u8]],
        predicates: &[Predicate],
        projection: &[ColumnId],
    ) -> impl Future<Output = Result<Vec<Option<RecordBatch>>, LookupError>> + Send;
    fn capabilities(&self) -> LookupSourceCapabilities;
    fn source_name(&self) -> &str;
    fn schema(&self) -> SchemaRef;

    // Provided methods
    fn estimated_row_count(&self) -> Option<u64> { ... }
    fn health_check(
        &self,
    ) -> impl Future<Output = Result<(), LookupError>> + Send { ... }
}
Expand description

Async data source for lookup table refresh and query.

This trait uses RPITIT (return-position impl Trait in traits, stabilized in Rust 1.75) for zero-overhead async dispatch.

§Implementing

Sources that support predicate/projection pushdown should set the corresponding flags in capabilities() and handle filtered queries in query(). Sources that do not support pushdown can be wrapped in PushdownAdapter to get automatic local evaluation.

Required Methods§

Source

fn query( &self, keys: &[&[u8]], predicates: &[Predicate], projection: &[ColumnId], ) -> impl Future<Output = Result<Vec<Option<RecordBatch>>, LookupError>> + Send

Query the source by keys, predicates, and/or projection.

Returns a Vec<Option<RecordBatch>> aligned with the input keys:

  • Some(batch) — key found, value is a single-row RecordBatch
  • None — key not found
Source

fn capabilities(&self) -> LookupSourceCapabilities

Capabilities this source advertises.

Source

fn source_name(&self) -> &str

Source name for logging and metrics.

Source

fn schema(&self) -> SchemaRef

Arrow schema of the data this source returns.

Provided Methods§

Source

fn estimated_row_count(&self) -> Option<u64>

Optional row count estimate for query planning.

Source

fn health_check(&self) -> impl Future<Output = Result<(), LookupError>> + Send

Health check. Default: always healthy.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§