dracoooooo commented on code in PR #1566:
URL: https://github.com/apache/horaedb/pull/1566#discussion_r1757289636
##########
src/wal/src/local_storage_impl/segment.rs:
##########
@@ -454,6 +516,89 @@ impl SegmentManager {
}
Ok(())
}
+
+ pub fn mark_delete_entries_up_to(
+ &self,
+ location: WalLocation,
+ sequence_num: SequenceNumber,
+ ) -> Result<()> {
+ let current_segment_id =
self.current_segment.lock().unwrap().lock().unwrap().id;
+ let mut all_segments = self.all_segments.lock().unwrap();
+ let mut segments_to_remove = Vec::new();
+
+ for (_, segment) in all_segments.iter() {
+ let mut guard = segment.lock().unwrap();
+
+ guard.mark_deleted(location.table_id, sequence_num);
+
+ // Delete this segment if it is empty
+ if guard.is_empty() && guard.id != current_segment_id {
+ let mut cache = self.cache.lock().unwrap();
+
+ // Check if segment is already in cache
+ if let Some(index) = cache.iter().position(|(id, _)| *id ==
guard.id) {
+ cache.remove(index);
+ }
+
+ segments_to_remove.push((guard.id, segment.clone()));
+ }
+ }
+
+ // Delete segments in all_segments
+ for (segment_id, _) in segments_to_remove.iter() {
Review Comment:
`segments_to_remove` is `Vec<(u64, Arc<...>)>`, so there is no `keys()` for
this type. Do I need to change it to a hashmap?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]