Implement garbage collection without indexes
This commit is contained in:
parent
3a50328e51
commit
2357ea8230
1 changed files with 25 additions and 6 deletions
|
|
@ -518,18 +518,37 @@ impl <'cursor, T> WriteCursor<'cursor, T>
|
|||
where T: Send + Decode + Encode
|
||||
{
|
||||
let mut cursor_to_intermediate = self.spawn_cursor_to_intermediate_file().await?;
|
||||
|
||||
// This will be a vector of such BTree maps...
|
||||
let in_memory_index: BTreeMap<T, HashSet<FilePosition>> = BTreeMap::new();
|
||||
|
||||
// We'll dump all alive entries into a new file.
|
||||
while let Some(live_entry) = self.next_alive().await? {
|
||||
let file_position = cursor_to_intermediate.append_entry(&live_entry.forget()).await?;
|
||||
// TODO: Start indexing all of the indexable columns from scratch.
|
||||
let mut entries_deleted = 0;
|
||||
{
|
||||
while let Some(live_entry) = self.next_alive().await? {
|
||||
entries_deleted += 1;
|
||||
let file_position = cursor_to_intermediate.append_entry(&live_entry.forget()).await?;
|
||||
// TODO: Start indexing all of the indexable columns from scratch.
|
||||
}
|
||||
}
|
||||
|
||||
// In it there will be only the alive rows.
|
||||
// TODO: Create a new indexes from in_memory_index.
|
||||
|
||||
// Afterwards we swap the files, and delete the garbage.
|
||||
todo!()
|
||||
// TODO:
|
||||
// What needs to be done?
|
||||
// 1. We take self cursor and mutate it
|
||||
|
||||
// swapping headers
|
||||
self.header.deleted_count = 0;
|
||||
self.header.total_count = cursor_to_intermediate.header.total_count;
|
||||
|
||||
// TODO: We'll actually have to iterate through all the indexes and swap each of them.
|
||||
self.indexes = todo!();
|
||||
self.file = cursor_to_intermediate.file;
|
||||
|
||||
self.eof_file_position = cursor_to_intermediate.eof_file_position;
|
||||
|
||||
Ok(entries_deleted)
|
||||
}
|
||||
|
||||
async fn spawn_cursor_to_intermediate_file(&self) -> Result<AppendOnlyCursor<T>>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue