use crate::data::executor::core_loop::CoreLoop;
use super::UndoEntry;
impl CoreLoop {
pub(super) fn apply_undo_spatial(
&mut self,
_entry_index: usize,
entry: UndoEntry,
) -> Result<(), (usize, String)> {
match entry {
UndoEntry::SpatialInsert { key, entry_id } => {
if let Some(rtree) = self.spatial_indexes.get_mut(&key) {
rtree.delete(entry_id);
}
self.spatial_doc_map
.remove(&(key.0, key.1, key.2, key.3, entry_id));
Ok(())
}
UndoEntry::SpatialDelete {
key,
entry_id,
bbox,
document_id,
} => {
let rtree = self.spatial_indexes.entry(key.clone()).or_default();
rtree.insert(crate::engine::spatial::RTreeEntry { id: entry_id, bbox });
self.spatial_doc_map
.insert((key.0, key.1, key.2, key.3, entry_id), document_id);
Ok(())
}
_ => unreachable!("apply_undo_spatial called with non-spatial entry"),
}
}
}