Repository: qdrant/qdrant
File: lib/segment/src/segment/segment_ops.rs (Rust)

Code before:
    /// - `segment.restore_snapshot("foo/bar/segment-id")`      (directory)
    pub fn restore_snapshot_in_place(snapshot_path: &Path) -> OperationResult<()> {
        restore_snapshot_in_place(snapshot_path).map_err(|err| {
            OperationError::service_error(format!(
                "Failed to restore snapshot from {snapshot_path:?}: {err}",
            ))
        })
    }

    /// Check consistency of the segment's data and repair it if possible.
    /// Removes partially persisted points.
    pub fn check_consistency_and_repair(&mut self) -> OperationResult<()> {
        // Get rid of versionless points.
        let ids_to_clean = self.fix_id_tracker_inconsistencies()?;

        // There are some leftovers to clean from segment.
        // After that we need to set internal version to 0, so that
        // we won't need to clean them again.

        // This is internal operation, no hw measurement needed
        let disposable_hw_counter = HardwareCounterCell::disposable();
        if !ids_to_clean.is_empty() {
            log::debug!("cleaning up {} points without version", ids_to_clean.len());

            for internal_id in ids_to_clean {
                self.delete_point_internal(internal_id, &disposable_hw_counter)?;
            }

            self.flush(true)?;

            // We do not drop version here, because it is already not loaded into memory.
            // There are no explicit mapping between internal ID and version, so all dangling
            // versions will be ignored automatically.
            // Those versions could be overwritten by new points, but it is not a problem.
            // They will also be deleted by the next optimization.
        }

        Ok(())
    }

    /// Update all payload/field indices to match `desired_schemas`
    ///
    /// Missing payload indices are created. Incorrectly configured payload indices are recreated.
    /// Extra payload indices are NOT deleted.
    ///
    /// This does nothing if the current payload indices state matches `desired_schemas` exactly.
    pub fn update_all_field_indices(
        &mut self,
        desired_schemas: &HashMap<PayloadKeyType, PayloadFieldSchema>,
    ) -> OperationResult<()> {
        let schema_applied = self.payload_index.borrow().indexed_fields();

Review comment (suggestion):
```suggestion
                self.data_path(),
```

🤡 

Code after:
    /// - `segment.restore_snapshot("foo/bar/segment-id")`      (directory)
    pub fn restore_snapshot_in_place(snapshot_path: &Path) -> OperationResult<()> {
        restore_snapshot_in_place(snapshot_path).map_err(|err| {
            OperationError::service_error(format!(
                "Failed to restore snapshot from {snapshot_path:?}: {err}",
            ))
        })
    }

    /// Check consistency of the segment's data and repair it if possible.
    /// Removes partially persisted points.
    pub fn check_consistency_and_repair(&mut self) -> OperationResult<()> {
        // Get rid of mappingless points.
        let ids_to_clean = self.fix_id_tracker_inconsistencies()?;

        // There are some leftovers to clean from segment.
        // After that we need to set internal version to 0, so that
        // we won't need to clean them again.

        // This is internal operation, no hw measurement needed
        let disposable_hw_counter = HardwareCounterCell::disposable();
        if !ids_to_clean.is_empty() {
            log::debug!(
                "Cleaning up {} points with version but no mapping in segment {:?}",
                ids_to_clean.len(),
                self.data_path()
            );

            for internal_id in ids_to_clean {
                self.delete_point_internal(internal_id, &disposable_hw_counter)?;
            }

            self.flush(true)?;

            // We do not drop version here, because it is already not loaded into memory.
            // There are no explicit mapping between internal ID and version, so all dangling
            // versions will be ignored automatically.
            // Those versions could be overwritten by new points, but it is not a problem.
            // They will also be deleted by the next optimization.
        }

        Ok(())
    }

    /// Update all payload/field indices to match `desired_schemas`
    ///
    /// Missing payload indices are created. Incorrectly configured payload indices are recreated.
    /// Extra payload indices are NOT deleted.
    ///
    /// This does nothing if the current payload indices state matches `desired_schemas` exactly.
    pub fn update_all_field_indices(