@@ -105,10 +105,7 @@ pub struct Warehouse {
105105 pub w_ytd_cents : i64 ,
106106}
107107
108- #[ table(
109- accessor = district,
110- index( accessor = by_w_d, btree( columns = [ d_w_id, d_id] ) )
111- ) ]
108+ #[ table( accessor = district) ]
112109#[ derive( Clone , Debug ) ]
113110pub struct District {
114111 #[ primary_key]
@@ -128,7 +125,6 @@ pub struct District {
128125
129126#[ table(
130127 accessor = customer,
131- index( accessor = by_w_d_c_id, btree( columns = [ c_w_id, c_d_id, c_id] ) ) ,
132128 index( accessor = by_w_d_last_first_id, btree( columns = [ c_w_id, c_d_id, c_last, c_first, c_id] ) )
133129) ]
134130#[ derive( Clone , Debug ) ]
@@ -185,10 +181,7 @@ pub struct Item {
185181 pub i_data : String ,
186182}
187183
188- #[ table(
189- accessor = stock,
190- index( accessor = by_w_i, btree( columns = [ s_w_id, s_i_id] ) )
191- ) ]
184+ #[ table( accessor = stock) ]
192185#[ derive( Clone , Debug ) ]
193186pub struct Stock {
194187 #[ primary_key]
@@ -776,29 +769,29 @@ fn ensure_warehouse_exists(tx: &ReducerContext, w_id: WarehouseId) -> Result<(),
776769}
777770
778771fn find_district ( tx : & ReducerContext , w_id : WarehouseId , d_id : u8 ) -> Result < District , String > {
772+ let district_key = pack_district_key ( w_id, d_id) ;
779773 tx. db
780774 . district ( )
781- . by_w_d ( )
782- . filter ( ( w_id, d_id) )
783- . next ( )
775+ . district_key ( )
776+ . find ( district_key)
784777 . ok_or_else ( || format ! ( "district ({w_id}, {d_id}) not found" ) )
785778}
786779
787780fn find_customer_by_id ( tx : & ReducerContext , w_id : WarehouseId , d_id : u8 , c_id : u32 ) -> Result < Customer , String > {
781+ let customer_key = pack_customer_key ( w_id, d_id, c_id) ;
788782 tx. db
789783 . customer ( )
790- . by_w_d_c_id ( )
791- . filter ( ( w_id, d_id, c_id) )
792- . next ( )
784+ . customer_key ( )
785+ . find ( customer_key)
793786 . ok_or_else ( || format ! ( "customer ({w_id}, {d_id}, {c_id}) not found" ) )
794787}
795788
796789fn find_stock ( tx : & ReducerContext , w_id : WarehouseId , item_id : u32 ) -> Result < Stock , String > {
790+ let stock_key = pack_stock_key ( w_id, item_id) ;
797791 tx. db
798792 . stock ( )
799- . by_w_i ( )
800- . filter ( ( w_id, item_id) )
801- . next ( )
793+ . stock_key ( )
794+ . find ( stock_key)
802795 . ok_or_else ( || format ! ( "stock ({w_id}, {item_id}) not found" ) )
803796}
804797
0 commit comments