fix the del items thing

This commit is contained in:
Tamo 2024-09-24 10:52:05 +02:00
parent f2d187ba3e
commit fd8447c521
2 changed files with 9 additions and 10 deletions

View File

@ -680,7 +680,7 @@ pub(crate) fn write_typed_chunk_into_index(
let mut iter = merger.into_stream_merger_iter()?;
while let Some((key, _)) = iter.next()? {
let docid = key.try_into().map(DocumentId::from_be_bytes).unwrap();
writer.del_item_raw(wtxn, expected_dimension, docid)?;
writer.del_items(wtxn, expected_dimension, docid)?;
}
// add generated embeddings

View File

@ -170,29 +170,28 @@ impl ArroyWrapper {
Ok(())
}
/// Delete an item from the index. It **does not** take care of fixing the hole
/// made after deleting the item.
pub fn del_item_raw(
/// Delete all embeddings from a specific `item_id`
pub fn del_items(
&self,
wtxn: &mut RwTxn,
dimension: usize,
item_id: arroy::ItemId,
) -> Result<bool, arroy::Error> {
) -> Result<(), arroy::Error> {
for index in arroy_db_range_for_embedder(self.embedder_index) {
if self.quantized {
let writer = arroy::Writer::new(self.quantized_db(), index, dimension);
if writer.del_item(wtxn, item_id)? {
return Ok(true);
if !writer.del_item(wtxn, item_id)? {
break;
}
} else {
let writer = arroy::Writer::new(self.angular_db(), index, dimension);
if writer.del_item(wtxn, item_id)? {
return Ok(true);
if !writer.del_item(wtxn, item_id)? {
break;
}
}
}
Ok(false)
Ok(())
}
/// Delete one item.