@@ -73,6 +73,51 @@ impl Iterator for MigrationTableIterator {
7373 }
7474}
7575
76+ pub struct MigrationTableRowView < ' a > {
77+ table : & ' a MigrationTable ,
78+ pub id : MigrationId ,
79+ pub left : Position ,
80+ pub right : Position ,
81+ pub node : NodeId ,
82+ pub source : PopulationId ,
83+ pub dest : PopulationId ,
84+ pub time : Time ,
85+ pub metadata : Option < & ' a [ u8 ] > ,
86+ }
87+
88+ impl < ' a > MigrationTableRowView < ' a > {
89+ fn new ( table : & ' a MigrationTable ) -> Self {
90+ Self {
91+ table,
92+ id : MigrationId :: NULL ,
93+ left : Position :: from ( f64:: NAN ) ,
94+ right : Position :: from ( f64:: NAN ) ,
95+ node : NodeId :: NULL ,
96+ source : PopulationId :: NULL ,
97+ dest : PopulationId :: NULL ,
98+ time : Time :: from ( f64:: NAN ) ,
99+ metadata : None ,
100+ }
101+ }
102+ }
103+
104+ impl < ' a > streaming_iterator:: StreamingIterator for MigrationTableRowView < ' a > {
105+ type Item = Self ;
106+
107+ row_lending_iterator_get ! ( ) ;
108+
109+ fn advance ( & mut self ) {
110+ self . id = ( i32:: from ( self . id ) + 1 ) . into ( ) ;
111+ self . left = self . table . left ( self . id ) . unwrap_or_else ( || f64:: NAN . into ( ) ) ;
112+ self . right = self . table . right ( self . id ) . unwrap_or_else ( || f64:: NAN . into ( ) ) ;
113+ self . node = self . table . node ( self . id ) . unwrap_or ( NodeId :: NULL ) ;
114+ self . source = self . table . source ( self . id ) . unwrap_or ( PopulationId :: NULL ) ;
115+ self . dest = self . table . dest ( self . id ) . unwrap_or ( PopulationId :: NULL ) ;
116+ self . time = self . table . time ( self . id ) . unwrap_or_else ( || f64:: NAN . into ( ) ) ;
117+ self . metadata = self . table . raw_metadata ( self . id ) ;
118+ }
119+ }
120+
76121/// An immutable view of a migration table.
77122///
78123/// These are not created directly but are accessed
@@ -102,6 +147,8 @@ impl MigrationTable {
102147 self . as_ref ( ) . num_rows . into ( )
103148 }
104149
150+ raw_metadata_getter_for_tables ! ( MigrationId ) ;
151+
105152 /// Return the left coordinate for a given row.
106153 ///
107154 /// # Returns
@@ -232,6 +279,10 @@ impl MigrationTable {
232279 crate :: table_iterator:: make_table_iterator :: < & MigrationTable > ( self )
233280 }
234281
282+ pub fn lending_iter ( & self ) -> MigrationTableRowView {
283+ MigrationTableRowView :: new ( self )
284+ }
285+
235286 /// Return row `r` of the table.
236287 ///
237288 /// # Parameters
0 commit comments