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

Method delete

nodedb-columnar/src/mutation/write.rs:169–195  ·  view source on GitHub ↗

Delete a row by PK value. Returns WAL record to persist. Looks up PK in the index to find the segment + row, then marks the row in the segment's delete bitmap.

(&mut self, pk_value: &Value)

Source from the content-addressed store, hash-verified

167 /// Looks up PK in the index to find the segment + row, then marks
168 /// the row in the segment's delete bitmap.
169 pub fn delete(&mut self, pk_value: &Value) -> Result<MutationResult, ColumnarError> {
170 let pk_bytes = encode_pk(pk_value);
171
172 let location = self
173 .pk_index
174 .get(&pk_bytes)
175 .copied()
176 .ok_or(ColumnarError::PrimaryKeyNotFound)?;
177
178 // Generate WAL record BEFORE applying.
179 let wal = ColumnarWalRecord::DeleteRows {
180 collection: self.collection.clone(),
181 segment_id: location.segment_id,
182 row_indices: vec![location.row_index],
183 };
184
185 // Mark in delete bitmap.
186 let bitmap = self.delete_bitmaps.entry(location.segment_id).or_default();
187 bitmap.mark_deleted(location.row_index);
188
189 // Remove from PK index.
190 self.pk_index.remove(&pk_bytes);
191
192 Ok(MutationResult {
193 wal_records: vec![wal],
194 })
195 }
196
197 /// Update a row by PK: DELETE old + INSERT new.
198 ///

Callers 5

updateMethod · 0.45
delete_by_pkFunction · 0.45
delete_nonexistent_pkFunction · 0.45
should_compact_thresholdFunction · 0.45

Calls 6

encode_pkFunction · 0.85
entryMethod · 0.80
getMethod · 0.45
cloneMethod · 0.45
mark_deletedMethod · 0.45
removeMethod · 0.45

Tested by 4

delete_by_pkFunction · 0.36
delete_nonexistent_pkFunction · 0.36
should_compact_thresholdFunction · 0.36