Repository: qdrant/qdrant
File: lib/shard/src/proxy_segment/mod.rs (Rust)

Code before:
                let segment_arc = self.write_segment.get();
                let mut write_segment = segment_arc.write();

                write_segment.upsert_point(op_num, point_id, all_vectors, hw_counter)?;
                if !payload.is_empty() {
                    write_segment.set_full_payload(op_num, point_id, &payload, hw_counter)?;
                }
            }

            (point_offset, local_version)
        };

        {
            let mut deleted_points_write = RwLockUpgradableReadGuard::upgrade(deleted_points_guard);
            let prev = deleted_points_write.insert(
                point_id,
                ProxyDeletedPoint {
                    local_version,
                    operation_version: op_num,
                },
            );
            if let Some(prev) = prev {
                debug_assert!(
                    prev.operation_version < op_num,
                    "Overriding deleted flag {:?} with older op_num:{}",
                    prev,
                    op_num
                )
            }
        }

        self.set_deleted_offset(point_offset);

        Ok(true)
    }

    fn add_deleted_points_condition_to_filter(
        filter: Option<&Filter>,
        deleted_points: impl IntoIterator<Item = PointIdType>,
    ) -> Filter {
        #[allow(clippy::from_iter_instead_of_collect)]
        let wrapper_condition = Condition::HasId(HasIdCondition::from_iter(deleted_points));
        match filter {
            None => Filter::new_must_not(wrapper_condition),
            Some(f) => {
                let mut new_filter = f.clone();
                let must_not = new_filter.must_not;

                let new_must_not = match must_not {
                    None => Some(vec![wrapper_condition]),
                    Some(mut conditions) => {

Review comment (bug):
Nit:

```suggestion
                debug_assert!(
                    prev.operation_version < op_num,
                    "Overriding deleted flag {prev:?} with older op_num:{op_num}",
                )
```

Code after:
                let segment_arc = self.write_segment.get();
                let mut write_segment = segment_arc.write();

                write_segment.upsert_point(op_num, point_id, all_vectors, hw_counter)?;
                if !payload.is_empty() {
                    write_segment.set_full_payload(op_num, point_id, &payload, hw_counter)?;
                }
            }

            (point_offset, local_version)
        };

        {
            let mut deleted_points_write = RwLockUpgradableReadGuard::upgrade(deleted_points_guard);
            let prev = deleted_points_write.insert(
                point_id,
                ProxyDeletedPoint {
                    local_version,
                    operation_version: op_num,
                },
            );
            if let Some(prev) = prev {
                debug_assert!(
                    prev.operation_version < op_num,
                    "Overriding deleted flag {prev:?} with older op_num:{op_num}",
                )
            }
        }

        self.set_deleted_offset(point_offset);

        Ok(true)
    }

    fn add_deleted_points_condition_to_filter(
        filter: Option<&Filter>,
        deleted_points: impl IntoIterator<Item = PointIdType>,
    ) -> Filter {
        #[allow(clippy::from_iter_instead_of_collect)]
        let wrapper_condition = Condition::HasId(HasIdCondition::from_iter(deleted_points));
        match filter {
            None => Filter::new_must_not(wrapper_condition),
            Some(f) => {
                let mut new_filter = f.clone();
                let must_not = new_filter.must_not;

                let new_must_not = match must_not {
                    None => Some(vec![wrapper_condition]),
                    Some(mut conditions) => {
                        conditions.push(wrapper_condition);
                        Some(conditions)