Struct elipdotter::index::DocumentMap
source · pub struct DocumentMap { /* private fields */ }
Expand description
Map of documents and their Id
s to quickly get name from id and vice versa.
Implementations§
source§impl DocumentMap
impl DocumentMap
pub fn new() -> Self
pub fn reserve_id(&mut self, name: impl Into<String> + AsRef<str>) -> Id
sourcepub fn insert<'a>(
&mut self,
name: impl Into<String> + AsRef<str>,
content: &str,
provider: &mut impl Provider<'a>
)
pub fn insert<'a>( &mut self, name: impl Into<String> + AsRef<str>, content: &str, provider: &mut impl Provider<'a> )
Alternatively, Self::reserve_id
and then drop the lock, go to a different thread, and
make a new Simple
. Simple::digest_document
, then Simple::ingest
the
second index into the first.
sourcepub fn get_name(&self, id: Id) -> Option<&str>
pub fn get_name(&self, id: Id) -> Option<&str>
O(log n)
But since this is a BTree, this is often faster than O(1) in a hash map, if we assume you have < 10_000 documents.