mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-09-20 11:46:25 +00:00
Introduce the Transform type into the indexing system
This commit is contained in:
12
src/index.rs
12
src/index.rs
@ -14,7 +14,7 @@ use crate::{
|
||||
pub const WORDS_FST_KEY: &str = "words-fst";
|
||||
pub const FIELDS_IDS_MAP_KEY: &str = "fields-ids-map";
|
||||
pub const DOCUMENTS_IDS_KEY: &str = "documents-ids";
|
||||
pub const USER_IDS_DOCUMENTS_IDS_KEY: &str = "user-ids-documents-ids";
|
||||
pub const USERS_IDS_DOCUMENTS_IDS_KEY: &str = "users-ids-documents-ids";
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Index {
|
||||
@ -51,16 +51,16 @@ impl Index {
|
||||
self.main.get::<_, Str, RoaringBitmapCodec>(rtxn, DOCUMENTS_IDS_KEY)
|
||||
}
|
||||
|
||||
/// Writes the user ids documents ids, a user id is a byte slice (i.e. `[u8]`)
|
||||
/// Writes the users ids documents ids, a user id is a byte slice (i.e. `[u8]`)
|
||||
/// and refers to an internal id (i.e. `u32`).
|
||||
pub fn put_user_ids_documents_ids<A: AsRef<[u8]>>(&self, wtxn: &mut heed::RwTxn, fst: &fst::Set<A>) -> heed::Result<()> {
|
||||
self.main.put::<_, Str, ByteSlice>(wtxn, USER_IDS_DOCUMENTS_IDS_KEY, fst.as_fst().as_bytes())
|
||||
pub fn put_users_ids_documents_ids<A: AsRef<[u8]>>(&self, wtxn: &mut heed::RwTxn, fst: &fst::Map<A>) -> heed::Result<()> {
|
||||
self.main.put::<_, Str, ByteSlice>(wtxn, USERS_IDS_DOCUMENTS_IDS_KEY, fst.as_fst().as_bytes())
|
||||
}
|
||||
|
||||
/// Returns the user ids documents ids map which associate the user ids (i.e. `[u8]`)
|
||||
/// with the internal ids (i.e. `u32`).
|
||||
pub fn user_ids_documents_ids<'t>(&self, rtxn: &'t heed::RoTxn) -> anyhow::Result<Option<fst::Map<&'t [u8]>>> {
|
||||
match self.main.get::<_, Str, ByteSlice>(rtxn, USER_IDS_DOCUMENTS_IDS_KEY)? {
|
||||
pub fn users_ids_documents_ids<'t>(&self, rtxn: &'t heed::RoTxn) -> anyhow::Result<Option<fst::Map<&'t [u8]>>> {
|
||||
match self.main.get::<_, Str, ByteSlice>(rtxn, USERS_IDS_DOCUMENTS_IDS_KEY)? {
|
||||
Some(bytes) => Ok(Some(fst::Map::new(bytes)?)),
|
||||
None => Ok(None),
|
||||
}
|
||||
|
Reference in New Issue
Block a user