MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / truncate_to

Method truncate_to

nodedb-columnar/src/memtable/mod.rs:142–154  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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) {

Callers 1

Calls 1

truncateMethod · 0.45

Tested by

no test coverage detected