diff options
Diffstat (limited to 'base/src/database.rs')
-rw-r--r-- | base/src/database.rs | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/base/src/database.rs b/base/src/database.rs index 2fabf1c..3971c62 100644 --- a/base/src/database.rs +++ b/base/src/database.rs @@ -33,15 +33,16 @@ pub const T_NODE_IMPORT: TableDefinition<&str, Ser<Vec<(Vec<usize>, Node)>>> = pub struct DataAcid { pub inner: redb::Database, - pub node_index: NodeFulltextIndex, + pub node_index: NodeIndex, } impl DataAcid { pub fn open(path: &Path) -> Result<Self, anyhow::Error> { - info!("database"); - create_dir_all(path)?; - let db = redb::Database::create(path.join("data"))?; - let ft_node = NodeFulltextIndex::new(path)?; + create_dir_all(path).context("creating database directory")?; + info!("opening kv store..."); + let db = redb::Database::create(path.join("data")).context("opening kv store")?; + info!("opening node index..."); + let ft_node = NodeIndex::new(path).context("in node index")?; let r = Self { inner: db, node_index: ft_node, @@ -71,7 +72,7 @@ impl Deref for DataAcid { } } -pub struct NodeFulltextIndex { +pub struct NodeIndex { pub schema: Schema, pub reader: IndexReader, pub writer: RwLock<IndexWriter>, @@ -82,7 +83,7 @@ pub struct NodeFulltextIndex { pub description: Field, pub f_index: Field, } -impl NodeFulltextIndex { +impl NodeIndex { fn new(path: &Path) -> anyhow::Result<Self> { let mut schema = Schema::builder(); let id = schema.add_text_field("id", TEXT | STORED | FAST); |