@@ -47,18 +47,17 @@ use spacetimedb_data_structures::error_stream::ErrorStream;
4747use spacetimedb_datastore:: error:: DatastoreError ;
4848use spacetimedb_datastore:: execution_context:: { Workload , WorkloadType } ;
4949use spacetimedb_datastore:: locking_tx_datastore:: { MutTxId , ViewCallInfo } ;
50- use spacetimedb_datastore:: traits:: { DatabaseTableUpdate , IsolationLevel , Program , TxData } ;
50+ use spacetimedb_datastore:: traits:: { IsolationLevel , Program , TxData } ;
5151use spacetimedb_durability:: DurableOffset ;
5252use spacetimedb_execution:: pipelined:: { PipelinedProject , ViewProject } ;
5353use spacetimedb_expr:: expr:: CollectViews ;
5454use spacetimedb_lib:: db:: raw_def:: v9:: Lifecycle ;
5555use spacetimedb_lib:: identity:: { AuthCtx , RequestId } ;
5656use spacetimedb_lib:: metrics:: ExecutionMetrics ;
57- use spacetimedb_lib:: Timestamp ;
58- use spacetimedb_lib:: { AlgebraicType , ConnectionId } ;
57+ use spacetimedb_lib:: { ConnectionId , Timestamp } ;
5958use spacetimedb_primitives:: { ArgId , ProcedureId , TableId , ViewFnPtr , ViewId } ;
6059use spacetimedb_query:: compile_subscription;
61- use spacetimedb_sats:: AlgebraicTypeRef ;
60+ use spacetimedb_sats:: { AlgebraicType , AlgebraicTypeRef , ProductValue } ;
6261use spacetimedb_schema:: auto_migrate:: { AutoMigrateError , MigrationPolicy } ;
6362use spacetimedb_schema:: def:: { ModuleDef , ProcedureDef , ReducerDef , TableDef , ViewDef } ;
6463use spacetimedb_schema:: reducer_name:: ReducerName ;
@@ -95,9 +94,14 @@ impl DatabaseUpdate {
9594 }
9695
9796 pub fn from_writes ( tx_data : & TxData ) -> Self {
98- let updates = tx_data. database_table_updates ( ) ;
99- let mut tables = SmallVec :: with_capacity ( updates. len ( ) ) ;
100- tables. extend ( updates) ;
97+ let entries = tx_data. iter_table_entries ( ) ;
98+ let mut tables = SmallVec :: with_capacity ( entries. len ( ) ) ;
99+ tables. extend ( entries. map ( |( table_id, e) | DatabaseTableUpdate {
100+ table_id,
101+ table_name : e. table_name . clone ( ) ,
102+ inserts : e. inserts . clone ( ) ,
103+ deletes : e. deletes . clone ( ) ,
104+ } ) ) ;
101105 DatabaseUpdate { tables }
102106 }
103107
@@ -107,6 +111,17 @@ impl DatabaseUpdate {
107111 }
108112}
109113
114+ #[ derive( Debug , Clone , PartialEq , Eq ) ]
115+ pub struct DatabaseTableUpdate {
116+ pub table_id : TableId ,
117+ pub table_name : TableName ,
118+ // Note: `Arc<[ProductValue]>` allows to cheaply
119+ // use the values from `TxData` without cloning the
120+ // contained `ProductValue`s.
121+ pub inserts : Arc < [ ProductValue ] > ,
122+ pub deletes : Arc < [ ProductValue ] > ,
123+ }
124+
110125#[ derive( Debug ) ]
111126pub struct DatabaseUpdateRelValue < ' a > {
112127 pub tables : Vec < DatabaseTableUpdateRelValue < ' a > > ,
0 commit comments