Introduce indexer level bumpalo

This commit is contained in:
Louis Dureuil
2024-10-03 18:08:09 +02:00
parent 39b27e42be
commit 68a2502388
26 changed files with 1984 additions and 721 deletions

View File

@ -1,6 +1,8 @@
use std::collections::BTreeMap;
use std::sync::RwLock;
use super::MutFieldIdMapper;
use crate::documents::FieldIdMapper;
use crate::{FieldId, FieldsIdsMap};
/// A fields ids map that can be globally updated to add fields
@ -11,11 +13,21 @@ pub struct GlobalFieldsIdsMap<'indexing> {
}
#[derive(Debug, Clone)]
struct LocalFieldsIdsMap {
pub struct LocalFieldsIdsMap {
names_ids: BTreeMap<String, FieldId>,
ids_names: BTreeMap<FieldId, String>,
}
impl FieldIdMapper for LocalFieldsIdsMap {
fn id(&self, name: &str) -> Option<FieldId> {
self.id(name)
}
fn name(&self, id: FieldId) -> Option<&str> {
self.name(id)
}
}
impl LocalFieldsIdsMap {
fn new(global: &RwLock<FieldsIdsMap>) -> Self {
let global = global.read().unwrap();
@ -83,4 +95,14 @@ impl<'indexing> GlobalFieldsIdsMap<'indexing> {
self.local.name(id)
}
pub fn local_map(&self) -> &LocalFieldsIdsMap {
&self.local
}
}
impl<'indexing> MutFieldIdMapper for GlobalFieldsIdsMap<'indexing> {
fn insert(&mut self, name: &str) -> Option<FieldId> {
self.id_or_insert(name)
}
}