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

Code before:
        let mut applied_points: AHashSet<PointIdType> = Default::default();

        let _applied_points_count = self.apply_points(
            ids,
            update_nonappendable,
            |point_id, idx, write_segment, &update_nonappendable| {
                if let Some(point_version) = write_segment.point_version(point_id)
                    && point_version >= op_num
                {
                    applied_points.insert(point_id);
                    return Ok(false);
                }

                let can_apply_operation = !write_segment.is_proxy()
                    && (update_nonappendable || write_segment.is_appendable());

                let is_applied = if can_apply_operation {
                    point_operation(point_id, write_segment)?
                } else {
                    self.aloha_random_write(
                        &appendable_segments,
                        |appendable_idx, appendable_write_segment| {
                            // If we are moving point from one segment to another,
                            // we must guarantee, that data in new segment will be persister before
                            // deleting point from old segment.
                            // Do ensure that, we add flush
                            self.flush_dependency.lock().add_dependency(
                                idx,
                                appendable_idx,
                                op_num,
                            );

                            let mut all_vectors =
                                write_segment.all_vectors(point_id, hw_counter)?;
                            let mut payload = write_segment.payload(point_id, hw_counter)?;

                            point_cow_operation(point_id, &mut all_vectors, &mut payload);

                            appendable_write_segment.upsert_point(
                                op_num,
                                point_id,
                                all_vectors,
                                hw_counter,
                            )?;
                            appendable_write_segment
                                .set_full_payload(op_num, point_id, &payload, hw_counter)?;

                            write_segment.delete_point(op_num, point_id, hw_counter)?;

                            Ok(true)
                        },

Review comment (suggestion):
```suggestion
                            // Do ensure that, we add a flush dependency
```

Code after:
        let mut applied_points: AHashSet<PointIdType> = Default::default();

        let _applied_points_count = self.apply_points(
            ids,
            update_nonappendable,
            |point_id, idx, write_segment, &update_nonappendable| {
                if let Some(point_version) = write_segment.point_version(point_id)
                    && point_version >= op_num
                {
                    applied_points.insert(point_id);
                    return Ok(false);
                }

                let can_apply_operation = !write_segment.is_proxy()
                    && (update_nonappendable || write_segment.is_appendable());

                let is_applied = if can_apply_operation {
                    point_operation(point_id, write_segment)?
                } else {
                    self.aloha_random_write(
                        &appendable_segments,
                        |appendable_idx, appendable_write_segment| {
                            // If we are moving point from one segment to another,
                            // we must guarantee, that data in new segment will be persisted before
                            // deleting point from old segment.
                            // Do ensure that, we add a flush dependency
                            self.flush_dependency.lock().add_dependency(
                                idx,
                                appendable_idx,
                                op_num,
                            );

                            let mut all_vectors =
                                write_segment.all_vectors(point_id, hw_counter)?;
                            let mut payload = write_segment.payload(point_id, hw_counter)?;

                            point_cow_operation(point_id, &mut all_vectors, &mut payload);

                            appendable_write_segment.upsert_point(
                                op_num,
                                point_id,
                                all_vectors,
                                hw_counter,
                            )?;
                            appendable_write_segment
                                .set_full_payload(op_num, point_id, &payload, hw_counter)?;

                            write_segment.delete_point(op_num, point_id, hw_counter)?;

                            Ok(true)
                        },