feat: add debug outputs for index writing and reading
This commit is contained in:
parent
19c471249e
commit
3d1e7527d2
@ -248,6 +248,7 @@ impl SearchEngine {
|
|||||||
|
|
||||||
let mut file = BufWriter::new(File::create("/tmp/search.db").unwrap());
|
let mut file = BufWriter::new(File::create("/tmp/search.db").unwrap());
|
||||||
serialize_into(&mut file, &data).unwrap();
|
serialize_into(&mut file, &data).unwrap();
|
||||||
|
log::debug!("Wrote Index as BTreeMap to Disk");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Prints the current state of the search engine's index and document collection for debugging purposes.
|
/// Prints the current state of the search engine's index and document collection for debugging purposes.
|
||||||
@ -259,11 +260,15 @@ impl SearchEngine {
|
|||||||
|
|
||||||
fn get_index_from_disk() -> SavedIndex {
|
fn get_index_from_disk() -> SavedIndex {
|
||||||
let file = File::open("/tmp/search.db");
|
let file = File::open("/tmp/search.db");
|
||||||
let mut data = SavedIndex{ documents_btree_map: BTreeMap::new(), index_btree_map: BTreeMap::new()};
|
let mut data = SavedIndex {
|
||||||
|
documents_btree_map: BTreeMap::new(),
|
||||||
|
index_btree_map: BTreeMap::new(),
|
||||||
|
};
|
||||||
|
|
||||||
if file.is_ok() {
|
if file.is_ok() {
|
||||||
let reader = BufReader::new(file.unwrap());
|
let reader = BufReader::new(file.unwrap());
|
||||||
data = deserialize_from(reader).unwrap();
|
data = deserialize_from(reader).unwrap();
|
||||||
|
log::debug!("Got BTreeMap Index from Disk");
|
||||||
}
|
}
|
||||||
|
|
||||||
data
|
data
|
||||||
|
Loading…
x
Reference in New Issue
Block a user