mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-22 18:17:39 +08:00
Fix the prefix deletion
This commit is contained in:
parent
1e81d72b5f
commit
9a0e1dc375
@ -204,32 +204,3 @@ fn rhaimap_to_object(map: rhai::Map) -> Object {
|
|||||||
}
|
}
|
||||||
output
|
output
|
||||||
}
|
}
|
||||||
|
|
||||||
fn rhaimap_to_obkv(
|
|
||||||
map: rhai::Map,
|
|
||||||
global_fields_ids_map: &mut GlobalFieldsIdsMap,
|
|
||||||
buffer: &mut Vec<u8>,
|
|
||||||
) -> Result<Box<KvReaderFieldId>> {
|
|
||||||
let result: Result<BTreeMap<_, _>> = map
|
|
||||||
.keys()
|
|
||||||
.map(|key| {
|
|
||||||
global_fields_ids_map
|
|
||||||
.id_or_insert(key)
|
|
||||||
.ok_or(UserError::AttributeLimitReached)
|
|
||||||
.map_err(Error::from)
|
|
||||||
.map(|fid| (fid, key))
|
|
||||||
})
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
let ordered_fields = result?;
|
|
||||||
let mut writer = KvWriterFieldId::memory();
|
|
||||||
for (fid, key) in ordered_fields {
|
|
||||||
let value = map.get(key).unwrap();
|
|
||||||
let value = serde_json::to_value(value).unwrap();
|
|
||||||
buffer.clear();
|
|
||||||
serde_json::to_writer(&mut *buffer, &value).unwrap();
|
|
||||||
writer.insert(fid, &buffer)?;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(writer.into_boxed())
|
|
||||||
}
|
|
||||||
|
@ -128,9 +128,10 @@ fn delete_prefixes(
|
|||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
// We remove all the entries that are no more required in this word prefix docids database.
|
// We remove all the entries that are no more required in this word prefix docids database.
|
||||||
for prefix in prefixes {
|
for prefix in prefixes {
|
||||||
let prefix = prefix.as_bytes();
|
let mut iter = prefix_database.prefix_iter_mut(wtxn, prefix.as_bytes())?;
|
||||||
if !prefix_database.delete(wtxn, prefix)? {
|
while iter.next().transpose()?.is_some() {
|
||||||
unreachable!("We tried to delete an unknown key")
|
// safety: we do not keep a reference on database entries.
|
||||||
|
unsafe { iter.del_current()? };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user