@@ -8,6 +8,8 @@ use datafusion::common::Result;
88use datafusion:: error:: DataFusionError ;
99use usearch:: { Index , IndexOptions , MetricKind , ScalarKind } ;
1010
11+ use datafusion:: catalog:: TableProvider ;
12+
1113use crate :: lookup:: PointLookupProvider ;
1214
1315// ── USearchIndexConfig ────────────────────────────────────────────────────────
@@ -177,7 +179,10 @@ impl Default for USearchTableConfig {
177179
178180pub struct RegisteredTable {
179181 pub index : Arc < Index > ,
180- pub provider : Arc < dyn PointLookupProvider > ,
182+ /// Scan provider for WHERE evaluation and low-selectivity Parquet-native path.
183+ pub scan_provider : Arc < dyn TableProvider > ,
184+ /// Lookup provider for efficient key-based row fetch (e.g. SQLite).
185+ pub lookup_provider : Arc < dyn PointLookupProvider > ,
181186 pub key_col : String ,
182187 pub metric : MetricKind ,
183188 /// Native scalar type of the vector column. Determines which typed search
@@ -213,31 +218,36 @@ impl USearchRegistry {
213218 /// [`USearchTableConfig::default()`] (ef_search=64, threshold=5%).
214219 ///
215220 /// - `index` — must already be loaded / populated.
216- /// - `provider` — must implement [`PointLookupProvider`].
221+ /// - `scan_provider` — [`TableProvider`] used for WHERE evaluation and
222+ /// low-selectivity Parquet-native scanning.
223+ /// - `lookup_provider` — [`PointLookupProvider`] for O(k) key-based fetch.
217224 /// [`HashKeyProvider`] is the bundled in-memory implementation.
218- /// For production, implement the trait on your storage engine's table type.
219- /// - `key_col` — column in `provider.schema()` that stores the USearch key
220- /// (`u64`). Supported Arrow types: `UInt64`, `Int64`, `UInt32`, `Int32`.
225+ /// - `key_col` — column in `lookup_provider.schema()` that stores the
226+ /// USearch key (`u64`). Supported Arrow types: `UInt64`, `Int64`,
227+ /// `UInt32`, `Int32`.
221228 /// - `metric` — must match how the index was built. The optimizer rule
222229 /// validates this and refuses to rewrite on mismatch.
223230 /// - `scalar_kind` — native element type of the vector column (`F32` or
224231 /// `F64`). Controls which typed search method the planner dispatches to.
225232 ///
226233 /// [`add_with_config`]: USearchRegistry::add_with_config
227234 /// [`HashKeyProvider`]: crate::lookup::HashKeyProvider
235+ #[ allow( clippy:: too_many_arguments) ]
228236 pub fn add (
229237 & self ,
230238 name : & str ,
231239 index : Arc < Index > ,
232- provider : Arc < dyn PointLookupProvider > ,
240+ scan_provider : Arc < dyn TableProvider > ,
241+ lookup_provider : Arc < dyn PointLookupProvider > ,
233242 key_col : & str ,
234243 metric : MetricKind ,
235244 scalar_kind : ScalarKind ,
236245 ) -> Result < ( ) > {
237246 self . add_with_config (
238247 name,
239248 index,
240- provider,
249+ scan_provider,
250+ lookup_provider,
241251 key_col,
242252 metric,
243253 scalar_kind,
@@ -254,7 +264,8 @@ impl USearchRegistry {
254264 & self ,
255265 name : & str ,
256266 index : Arc < Index > ,
257- provider : Arc < dyn PointLookupProvider > ,
267+ scan_provider : Arc < dyn TableProvider > ,
268+ lookup_provider : Arc < dyn PointLookupProvider > ,
258269 key_col : & str ,
259270 metric : MetricKind ,
260271 scalar_kind : ScalarKind ,
@@ -263,7 +274,7 @@ impl USearchRegistry {
263274 // Set ef_search once, here, before any query touches the index.
264275 index. change_expansion_search ( config. expansion_search ) ;
265276
266- let data_schema = provider . schema ( ) ;
277+ let data_schema = lookup_provider . schema ( ) ;
267278
268279 let _ = data_schema. index_of ( key_col) . map_err ( |_| {
269280 DataFusionError :: Execution ( format ! (
@@ -286,7 +297,8 @@ impl USearchRegistry {
286297 name. to_string ( ) ,
287298 Arc :: new ( RegisteredTable {
288299 index,
289- provider,
300+ scan_provider,
301+ lookup_provider,
290302 key_col : key_col. to_string ( ) ,
291303 metric,
292304 scalar_kind,
0 commit comments