Remove with comprehensive error handling
(&mut self, key: &K)
| 78 | |
| 79 | /// Remove with comprehensive error handling |
| 80 | pub fn try_remove(&mut self, key: &K) -> ModifyResult<V> { |
| 81 | // Validate tree state before removal |
| 82 | if let Err(e) = self.check_invariants_detailed() { |
| 83 | return Err(BPlusTreeError::DataIntegrityError(e)); |
| 84 | } |
| 85 | |
| 86 | let value = self.remove(key).ok_or(BPlusTreeError::KeyNotFound)?; |
| 87 | |
| 88 | // Validate tree state after removal |
| 89 | if let Err(e) = self.check_invariants_detailed() { |
| 90 | return Err(BPlusTreeError::DataIntegrityError(e)); |
| 91 | } |
| 92 | |
| 93 | Ok(value) |
| 94 | } |
| 95 | |
| 96 | /// Batch insert operations with rollback on any failure |
| 97 | pub fn batch_insert(&mut self, items: Vec<(K, V)>) -> ModifyResult<Vec<Option<V>>> |