@@ -3,7 +3,9 @@ use crate::errors::DatabaseError;
3
3
use crate :: expression:: range_detacher:: Range ;
4
4
use crate :: optimizer:: core:: statistics_meta:: { StatisticMetaLoader , StatisticsMeta } ;
5
5
use 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
+ } ;
7
9
use crate :: types:: index:: { Index , IndexId , IndexMetaRef , IndexType } ;
8
10
use crate :: types:: tuple:: { Tuple , TupleId } ;
9
11
use crate :: types:: { ColumnId , LogicalType } ;
@@ -118,6 +120,8 @@ impl Transaction for KipTransaction {
118
120
let table = self
119
121
. table ( table_name. clone ( ) )
120
122
. ok_or ( DatabaseError :: TableNotFound ) ?;
123
+ let table_types = table. types ( ) ;
124
+ let table_name = table. name . as_str ( ) ;
121
125
let offset = offset_option. unwrap_or ( 0 ) ;
122
126
123
127
let mut tuple_columns = Vec :: with_capacity ( columns. len ( ) ) ;
@@ -126,18 +130,22 @@ impl Transaction for KipTransaction {
126
130
tuple_columns. push ( column) ;
127
131
projections. push ( projection) ;
128
132
}
133
+ let inner = IndexImplEnum :: instance ( index_meta. ty ) ;
129
134
130
135
Ok ( IndexIter {
131
136
offset,
132
137
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,
137
147
ranges : VecDeque :: from ( ranges) ,
138
- tx : & self . tx ,
139
148
scope_iter : None ,
140
- projections,
141
149
} )
142
150
}
143
151
@@ -565,7 +573,9 @@ mod test {
565
573
use crate :: errors:: DatabaseError ;
566
574
use crate :: expression:: range_detacher:: Range ;
567
575
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
+ } ;
569
579
use crate :: types:: index:: { IndexMeta , IndexType } ;
570
580
use crate :: types:: tuple:: Tuple ;
571
581
use crate :: types:: value:: DataValue ;
@@ -671,27 +681,30 @@ mod test {
671
681
let mut iter = IndexIter {
672
682
offset : 0 ,
673
683
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
+ } ,
684
699
ranges : VecDeque :: from ( vec ! [
685
700
Range :: Eq ( Arc :: new( DataValue :: Int32 ( Some ( 0 ) ) ) ) ,
686
701
Range :: Scope {
687
702
min: Bound :: Included ( Arc :: new( DataValue :: Int32 ( Some ( 2 ) ) ) ) ,
688
703
max: Bound :: Included ( Arc :: new( DataValue :: Int32 ( Some ( 4 ) ) ) ) ,
689
704
} ,
690
705
] ) ,
691
- index_values : VecDeque :: new ( ) ,
692
- tx : & transaction. tx ,
693
706
scope_iter : None ,
694
- projections : vec ! [ 0 ] ,
707
+ inner : IndexImplEnum :: PrimaryKey ( PrimaryKeyIndexImpl ) ,
695
708
} ;
696
709
let mut result = Vec :: new ( ) ;
697
710
0 commit comments