perf: completely remove disk I/O from memory access paths, optimize Tantivy indexing, and fix MemoryIndex commits
This commit is contained in:
1 parent
a5011048b1
commit
686fea683d
3 files changed
+110
-64
No files matched your search
+10
-7
@@ -49,7 +49,7 @@ impl MemoryIndex {
|
||||
}
|
||||
|
||||
pub fn index_entity(&self, e: &Entity) -> tantivy::Result<()> {
|
||||
let mut writer = self.writer.lock().unwrap();
|
||||
let writer = self.writer.lock().unwrap();
|
||||
writer.add_document(doc!(
|
||||
self.id_field => e.name.clone(),
|
||||
self.title_field => e.name.clone(),
|
||||
@@ -57,12 +57,11 @@ impl MemoryIndex {
|
||||
self.type_field => "entity",
|
||||
self.namespace_field => e.namespace.clone()
|
||||
))?;
|
||||
writer.commit()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn index_task(&self, t: &Task) -> tantivy::Result<()> {
|
||||
let mut writer = self.writer.lock().unwrap();
|
||||
let writer = self.writer.lock().unwrap();
|
||||
writer.add_document(doc!(
|
||||
self.id_field => t.id.clone(),
|
||||
self.title_field => t.title.clone(),
|
||||
@@ -70,6 +69,12 @@ impl MemoryIndex {
|
||||
self.type_field => "task",
|
||||
self.namespace_field => "global"
|
||||
))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
pub fn commit(&self) -> tantivy::Result<()> {
|
||||
let mut writer = self.writer.lock().unwrap();
|
||||
writer.commit()?;
|
||||
Ok(())
|
||||
}
|
||||
@@ -117,7 +122,7 @@ impl MemoryIndex {
|
||||
}
|
||||
|
||||
pub fn index_snippet(&self, s: &Snippet) -> tantivy::Result<()> {
|
||||
let mut writer = self.writer.lock().unwrap();
|
||||
let writer = self.writer.lock().unwrap();
|
||||
writer.add_document(doc!(
|
||||
self.id_field => s.name.clone(),
|
||||
self.title_field => s.name.clone(),
|
||||
@@ -125,12 +130,11 @@ impl MemoryIndex {
|
||||
self.type_field => "snippet",
|
||||
self.namespace_field => "global"
|
||||
))?;
|
||||
writer.commit()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn index_adr(&self, a: &Adr) -> tantivy::Result<()> {
|
||||
let mut writer = self.writer.lock().unwrap();
|
||||
let writer = self.writer.lock().unwrap();
|
||||
writer.add_document(doc!(
|
||||
self.id_field => a.id.clone(),
|
||||
self.title_field => a.title.clone(),
|
||||
@@ -138,7 +142,6 @@ impl MemoryIndex {
|
||||
self.type_field => "adr",
|
||||
self.namespace_field => "global"
|
||||
))?;
|
||||
writer.commit()?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user