66use crate :: {
77 SearchResults ,
88 garnet:: { Context , GarnetId } ,
9- labels:: GarnetQueryLabelProvider ,
109 provider:: { DynamicQuantization , GarnetProvider } ,
1110} ;
1211use diskann:: {
@@ -15,10 +14,7 @@ use diskann::{
1514 provider:: DataProvider ,
1615 utils:: VectorRepr ,
1716} ;
18- use diskann_providers:: {
19- index:: wrapped_async:: DiskANNIndex , model:: graph:: provider:: layers:: BetaFilter ,
20- } ;
21- use std:: sync:: Arc ;
17+ use diskann_providers:: index:: wrapped_async:: DiskANNIndex ;
2218
2319/// Type-erased version of `DiskANNIndex<GarnetProvider>`.
2420/// All vector data is passed as untyped byte slices.
@@ -31,17 +27,31 @@ pub(crate) trait DynIndex: Send + Sync {
3127 & self ,
3228 context : & Context ,
3329 data : & [ u8 ] ,
34- params : & search:: Knn ,
35- filter : Option < ( & GarnetQueryLabelProvider , f32 ) > ,
30+ params : search:: Knn ,
3631 output : & mut SearchResults < ' _ > ,
3732 ) -> ANNResult < SearchStats > ;
3833
3934 fn search_element (
4035 & self ,
4136 context : & Context ,
4237 id : & GarnetId ,
43- params : & search:: Knn ,
44- filter : Option < ( & GarnetQueryLabelProvider , f32 ) > ,
38+ params : search:: Knn ,
39+ output : & mut SearchResults < ' _ > ,
40+ ) -> ANNResult < SearchStats > ;
41+
42+ fn filtered_search_vector (
43+ & self ,
44+ context : & Context ,
45+ data : & [ u8 ] ,
46+ params : search:: InlineFilterSearch ,
47+ output : & mut SearchResults < ' _ > ,
48+ ) -> ANNResult < SearchStats > ;
49+
50+ fn filtered_search_element (
51+ & self ,
52+ context : & Context ,
53+ id : & GarnetId ,
54+ params : search:: InlineFilterSearch ,
4555 output : & mut SearchResults < ' _ > ,
4656 ) -> ANNResult < SearchStats > ;
4757
@@ -84,32 +94,50 @@ impl<T: VectorRepr> DynIndex for DiskANNIndex<GarnetProvider<T>> {
8494 & self ,
8595 context : & Context ,
8696 data : & [ u8 ] ,
87- params : & search:: Knn ,
88- filter : Option < ( & GarnetQueryLabelProvider , f32 ) > ,
97+ params : search:: Knn ,
8998 output : & mut SearchResults < ' _ > ,
9099 ) -> ANNResult < SearchStats > {
91100 let query = bytemuck:: cast_slice :: < u8 , T > ( data) ;
92- if let Some ( ( labels, beta) ) = filter {
93- let beta_filter = BetaFilter :: new ( DynamicQuantization , Arc :: new ( labels. clone ( ) ) , beta) ;
94- self . search ( * params, & beta_filter, context, query, output)
95- } else {
96- self . search ( * params, & DynamicQuantization , context, query, output)
97- }
101+ self . search ( params, & DynamicQuantization , context, query, output)
98102 }
99103
100104 fn search_element (
101105 & self ,
102106 context : & Context ,
103107 id : & GarnetId ,
104- params : & search:: Knn ,
105- filter : Option < ( & GarnetQueryLabelProvider , f32 ) > ,
108+ params : search:: Knn ,
109+ output : & mut SearchResults < ' _ > ,
110+ ) -> ANNResult < SearchStats > {
111+ // Look up internal ID
112+ let iid = self . inner . provider ( ) . to_internal_id ( context, id) ?;
113+ let data = self . inner . provider ( ) . get_full_vector ( context, iid) ?;
114+ let data_bytes = bytemuck:: cast_slice :: < T , u8 > ( & data) ;
115+ self . search_vector ( context, data_bytes, params, output)
116+ }
117+
118+ fn filtered_search_vector (
119+ & self ,
120+ context : & Context ,
121+ data : & [ u8 ] ,
122+ params : search:: InlineFilterSearch ,
123+ output : & mut SearchResults < ' _ > ,
124+ ) -> ANNResult < SearchStats > {
125+ let query = bytemuck:: cast_slice :: < u8 , T > ( data) ;
126+ self . search ( params, & DynamicQuantization , context, query, output)
127+ }
128+
129+ fn filtered_search_element (
130+ & self ,
131+ context : & Context ,
132+ id : & GarnetId ,
133+ params : search:: InlineFilterSearch ,
106134 output : & mut SearchResults < ' _ > ,
107135 ) -> ANNResult < SearchStats > {
108136 // Look up internal ID
109137 let iid = self . inner . provider ( ) . to_internal_id ( context, id) ?;
110138 let data = self . inner . provider ( ) . get_full_vector ( context, iid) ?;
111139 let data_bytes = bytemuck:: cast_slice :: < T , u8 > ( & data) ;
112- self . search_vector ( context, data_bytes, params, filter , output)
140+ self . filtered_search_vector ( context, data_bytes, params, output)
113141 }
114142
115143 fn remove ( & self , context : & Context , id : & GarnetId ) -> ANNResult < ( ) > {
0 commit comments