ruve-db 0.1.0

A hybrid vector and full-text search database with HNSW approximate nearest-neighbour indexing and BM25
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use std::collections::HashMap;
use std::fs;

pub type Index = HashMap<String, u64>;

pub fn load_index(path: &str) -> Index {
    fs::read_to_string(&path)
        .ok()
        .and_then(|data| serde_json::from_str::<Index>(&data).ok())
        .unwrap_or_default()
}

pub fn save_index(path: &str, index: &Index) {
    let data = serde_json::to_string_pretty(index).unwrap();
    fs::write(path, data).unwrap();
}