feat: introduce preloaded index cache and thread-safe progress tracker
Introduce `PreloadedIndex` to cache partition indices and eliminate redundant I/O during repeated queries. Refactor the query pipeline to route through this pre-loaded index, and expose it publicly in `obikpartitionner`. Additionally, add a thread-safe, lazily-initialized `MultiProgress` singleton for improved progress tracking.
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
use std::sync::OnceLock;
|
||||
|
||||
use indicatif::MultiProgress;
|
||||
|
||||
static MULTI: OnceLock<MultiProgress> = OnceLock::new();
|
||||
|
||||
/// Initialise the shared progress display. Call once from the binary before
|
||||
/// any index operation. Subsequent calls are silently ignored.
|
||||
pub fn init(multi: MultiProgress) {
|
||||
let _ = MULTI.set(multi);
|
||||
}
|
||||
|
||||
/// Return the shared `MultiProgress`, creating a plain default one if the
|
||||
/// binary never called [`init`].
|
||||
pub fn get() -> &'static MultiProgress {
|
||||
MULTI.get_or_init(MultiProgress::new)
|
||||
}
|
||||
|
||||
pub(crate) fn multi() -> &'static MultiProgress {
|
||||
get()
|
||||
}
|
||||
Reference in New Issue
Block a user