Truncate the memtable to `n` rows, discarding all rows beyond that point. Used by transaction rollback to restore the memtable to its pre-write state. No-op if `n >= self.row_count`.
(&mut self, n: usize)
| 140 | /// Used by transaction rollback to restore the memtable to its pre-write state. |
| 141 | /// No-op if `n >= self.row_count`. |
| 142 | pub fn truncate_to(&mut self, n: usize) { |
| 143 | if n >= self.row_count { |
| 144 | return; |
| 145 | } |
| 146 | for col in &mut self.columns { |
| 147 | col.truncate(n); |
| 148 | } |
| 149 | self.row_count = n; |
| 150 | debug_assert!( |
| 151 | self.columns.iter().all(|c| c.len() == self.row_count), |
| 152 | "column lengths misaligned after truncate_to" |
| 153 | ); |
| 154 | } |
| 155 | |
| 156 | /// Drain the memtable: return all column data and reset to empty. |
| 157 | pub fn drain(&mut self) -> (ColumnarSchema, Vec<ColumnData>, usize) { |
no test coverage detected