pub fn batch_delete(
index: &mut VectorIndex,
cids: &[Cid],
) -> Result<BatchDeletionResult>Expand description
Delete multiple CIDs from a vector index in batch
This function efficiently deletes multiple CIDs and provides detailed statistics about the operation.
§Arguments
index- The vector index to delete fromcids- List of CIDs to delete
§Returns
Statistics about the deletion operation
§Example
use ipfrs_semantic::{VectorIndex, utils::batch_delete};
use ipfrs_core::Cid;
let mut index = VectorIndex::with_defaults(768)?;
// Add some vectors
let cid1: Cid = "bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi".parse()?;
let cid2: Cid = "bafybeihpjhkeuiq3k6nqa3fkgeigeri7iebtrsuyuey5y6vy36n345xmbi".parse()?;
index.insert(&cid1, &vec![0.1; 768])?;
index.insert(&cid2, &vec![0.2; 768])?;
// Delete them in batch
let result = batch_delete(&mut index, &[cid1, cid2])?;
assert_eq!(result.deleted, 2);
assert_eq!(result.not_found, 0);