@@ -3,7 +3,9 @@ use crate::errors::DatabaseError;
33use crate :: expression:: range_detacher:: Range ;
44use crate :: optimizer:: core:: statistics_meta:: { StatisticMetaLoader , StatisticsMeta } ;
55use crate :: storage:: table_codec:: TableCodec ;
6- use crate :: storage:: { Bounds , IndexIter , Iter , Storage , Transaction } ;
6+ use crate :: storage:: {
7+ Bounds , IndexImplEnum , IndexImplParams , IndexIter , Iter , Storage , Transaction ,
8+ } ;
79use crate :: types:: index:: { Index , IndexId , IndexMetaRef , IndexType } ;
810use crate :: types:: tuple:: { Tuple , TupleId } ;
911use crate :: types:: { ColumnId , LogicalType } ;
@@ -118,6 +120,8 @@ impl Transaction for KipTransaction {
118120 let table = self
119121 . table ( table_name. clone ( ) )
120122 . ok_or ( DatabaseError :: TableNotFound ) ?;
123+ let table_types = table. types ( ) ;
124+ let table_name = table. name . as_str ( ) ;
121125 let offset = offset_option. unwrap_or ( 0 ) ;
122126
123127 let mut tuple_columns = Vec :: with_capacity ( columns. len ( ) ) ;
@@ -126,18 +130,22 @@ impl Transaction for KipTransaction {
126130 tuple_columns. push ( column) ;
127131 projections. push ( projection) ;
128132 }
133+ let inner = IndexImplEnum :: instance ( index_meta. ty ) ;
129134
130135 Ok ( IndexIter {
131136 offset,
132137 limit : limit_option,
133- tuple_schema_ref : Arc :: new ( tuple_columns) ,
134- index_meta,
135- table,
136- index_values : VecDeque :: new ( ) ,
138+ params : IndexImplParams {
139+ tuple_schema_ref : Arc :: new ( tuple_columns) ,
140+ projections,
141+ index_meta,
142+ table_name,
143+ table_types,
144+ tx : & self . tx ,
145+ } ,
146+ inner,
137147 ranges : VecDeque :: from ( ranges) ,
138- tx : & self . tx ,
139148 scope_iter : None ,
140- projections,
141149 } )
142150 }
143151
@@ -565,7 +573,9 @@ mod test {
565573 use crate :: errors:: DatabaseError ;
566574 use crate :: expression:: range_detacher:: Range ;
567575 use crate :: storage:: kip:: KipStorage ;
568- use crate :: storage:: { IndexIter , Iter , Storage , Transaction } ;
576+ use crate :: storage:: {
577+ IndexImplEnum , IndexImplParams , IndexIter , Iter , PrimaryKeyIndexImpl , Storage , Transaction ,
578+ } ;
569579 use crate :: types:: index:: { IndexMeta , IndexType } ;
570580 use crate :: types:: tuple:: Tuple ;
571581 use crate :: types:: value:: DataValue ;
@@ -671,27 +681,30 @@ mod test {
671681 let mut iter = IndexIter {
672682 offset : 0 ,
673683 limit : None ,
674- tuple_schema_ref : table. schema_ref ( ) . clone ( ) ,
675- index_meta : Arc :: new ( IndexMeta {
676- id : 0 ,
677- column_ids : vec ! [ 0 ] ,
678- table_name,
679- pk_ty : LogicalType :: Integer ,
680- name : "pk_a" . to_string ( ) ,
681- ty : IndexType :: PrimaryKey ,
682- } ) ,
683- table : & table,
684+ params : IndexImplParams {
685+ tuple_schema_ref : table. schema_ref ( ) . clone ( ) ,
686+ projections : vec ! [ 0 ] ,
687+ index_meta : Arc :: new ( IndexMeta {
688+ id : 0 ,
689+ column_ids : vec ! [ 0 ] ,
690+ table_name,
691+ pk_ty : LogicalType :: Integer ,
692+ name : "pk_a" . to_string ( ) ,
693+ ty : IndexType :: PrimaryKey ,
694+ } ) ,
695+ table_name : & table. name ,
696+ table_types : table. types ( ) ,
697+ tx : & transaction. tx ,
698+ } ,
684699 ranges : VecDeque :: from ( vec ! [
685700 Range :: Eq ( Arc :: new( DataValue :: Int32 ( Some ( 0 ) ) ) ) ,
686701 Range :: Scope {
687702 min: Bound :: Included ( Arc :: new( DataValue :: Int32 ( Some ( 2 ) ) ) ) ,
688703 max: Bound :: Included ( Arc :: new( DataValue :: Int32 ( Some ( 4 ) ) ) ) ,
689704 } ,
690705 ] ) ,
691- index_values : VecDeque :: new ( ) ,
692- tx : & transaction. tx ,
693706 scope_iter : None ,
694- projections : vec ! [ 0 ] ,
707+ inner : IndexImplEnum :: PrimaryKey ( PrimaryKeyIndexImpl ) ,
695708 } ;
696709 let mut result = Vec :: new ( ) ;
697710
0 commit comments