mirror of
https://github.com/elicpeter/nyx.git
synced 2026-06-24 20:28:06 +02:00
Add vacuum method to Indexer for database maintenance
- Added a `vacuum` method in `database.rs` to optimize database file size and performance. - Integrated `vacuum` calls into `scan.rs` and `index.rs` to ensure regular maintenance during operations.
This commit is contained in:
parent
0a62b6f40c
commit
eedfc5dbe8
3 changed files with 17 additions and 1 deletions
|
|
@ -81,5 +81,11 @@ pub fn build_index(
|
||||||
idx.replace_issues(file_id, rows).unwrap();
|
idx.replace_issues(file_id, rows).unwrap();
|
||||||
Ok(())
|
Ok(())
|
||||||
}).unwrap();
|
}).unwrap();
|
||||||
|
|
||||||
|
{
|
||||||
|
let idx = Indexer::from_pool(&project_name, &pool)?;
|
||||||
|
idx.vacuum()?;
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
@ -139,6 +139,11 @@ fn scan_with_index_parallel(
|
||||||
Ok(())
|
Ok(())
|
||||||
}).unwrap();
|
}).unwrap();
|
||||||
|
|
||||||
|
{
|
||||||
|
let idx = Indexer::from_pool(project, &pool)?;
|
||||||
|
idx.vacuum()?;
|
||||||
|
}
|
||||||
|
|
||||||
Ok(acc.into_inner().unwrap())
|
Ok(acc.into_inner().unwrap())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -211,10 +211,15 @@ pub mod index {
|
||||||
VACUUM;
|
VACUUM;
|
||||||
"#,
|
"#,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
self.c().execute_batch(SCHEMA)?;
|
self.c().execute_batch(SCHEMA)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn vacuum(&self) -> rusqlite::Result<()> {
|
||||||
|
self.c().execute("VACUUM;", [])?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
fn digest_file(path: &Path) -> Result<Vec<u8>, Box<dyn std::error::Error>> {
|
fn digest_file(path: &Path) -> Result<Vec<u8>, Box<dyn std::error::Error>> {
|
||||||
let mut hasher = blake3::Hasher::new();
|
let mut hasher = blake3::Hasher::new();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue