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

Method add_column

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

Add a new column to the schema, backfilling existing rows with nulls/defaults.

(&mut self, name: String, column_type: ColumnType, nullable: bool)

Source from the content-addressed store, hash-verified

199
200 /// Add a new column to the schema, backfilling existing rows with nulls/defaults.
201 pub fn add_column(&mut self, name: String, column_type: ColumnType, nullable: bool) {
202 if self.schema.columns.iter().any(|c| c.name == name) {
203 return;
204 }
205
206 let existing_rows = self.row_count;
207 let mut col = ColumnData::new(&column_type, nullable);
208 if existing_rows > 0 {
209 col.backfill_nulls(existing_rows);
210 }
211
212 self.columns.push(col);
213 let col_def = if nullable {
214 ColumnDef::nullable(name, column_type)
215 } else {
216 ColumnDef::required(name, column_type)
217 };
218 self.schema.columns.push(col_def);
219 }
220}
221
222/// Borrowed value for zero-copy ingest into the columnar memtable.

Callers

nothing calls this directly

Calls 4

requiredFunction · 0.85
iterMethod · 0.45
backfill_nullsMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected