MCPcopy Create free account
hub / github.com/GraphLite-AI/GraphLite / apply_undo_operation

Method apply_undo_operation

graphlite/src/session/transaction_state.rs:226–529  ·  view source on GitHub ↗

Apply a single undo operation to rollback changes

(
        &self,
        operation: &crate::txn::UndoOperation,
        storage: &Arc<crate::storage::StorageManager>,
    )

Source from the content-addressed store, hash-verified

224
225 /// Apply a single undo operation to rollback changes
226 fn apply_undo_operation(
227 &self,
228 operation: &crate::txn::UndoOperation,
229 storage: &Arc<crate::storage::StorageManager>,
230 ) -> Result<(), ExecutionError> {
231 use crate::txn::UndoOperation;
232
233 match operation {
234 UndoOperation::Batch { operations } => {
235 // Handle batch operations - undo all operations in the batch atomically
236 log::info!(
237 "ROLLBACK: Processing batch with {} operations",
238 operations.len()
239 );
240 for (i, op) in operations.iter().enumerate() {
241 log::debug!(
242 "ROLLBACK: Applying batch operation {}/{}",
243 i + 1,
244 operations.len()
245 );
246 self.apply_undo_operation(op, storage)?;
247 }
248 log::info!(
249 "ROLLBACK: Successfully processed batch of {} operations",
250 operations.len()
251 );
252 }
253 UndoOperation::InsertNode {
254 graph_path,
255 node_id,
256 } => {
257 log::info!(
258 "ROLLBACK: Undoing InsertNode: graph={}, node={}",
259 graph_path,
260 node_id
261 );
262
263 // Load the graph
264 let mut graph = storage
265 .get_graph(graph_path)
266 .map_err(|e| {
267 ExecutionError::StorageError(format!(
268 "Failed to load graph for rollback: {}",
269 e
270 ))
271 })?
272 .ok_or_else(|| {
273 ExecutionError::StorageError(format!(
274 "Graph not found for rollback: {}",
275 graph_path
276 ))
277 })?;
278
279 log::info!(
280 "ROLLBACK: Graph loaded, current node count: {}",
281 graph.node_count().unwrap_or(0)
282 );
283

Callers 1

Calls 11

StorageErrorEnum · 0.85
remove_nodeMethod · 0.80
save_graphMethod · 0.80
add_nodeMethod · 0.80
cloneMethod · 0.80
get_node_mutMethod · 0.80
remove_edgeMethod · 0.80
add_edgeMethod · 0.80
get_edge_mutMethod · 0.80
iterMethod · 0.45
get_graphMethod · 0.45

Tested by

no test coverage detected