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

Code before:
        // update the pointer
        let mut tracker_guard = self.tracker.write();
        let is_update = tracker_guard.has_pointer(point_offset);
        tracker_guard.set(
            point_offset,
            ValuePointer::new(start_page_id, block_offset, value_size as u32),
        );

        // return whether it was an update or not
        Ok(is_update)
    }

    /// Delete a value from the storage
    ///
    /// Returns None if the point_offset, page, or value was not found
    ///
    /// Returns the deleted value otherwise
    pub fn delete_value(&mut self, point_offset: PointOffset) -> Result<Option<V>> {
        let Some(ValuePointer {
            page_id,
            block_offset,
            length,
        }) = self.tracker.write().unset(point_offset)
        else {
            return Ok(None);
        };
        let raw = self.read_from_pages::<false>(page_id, block_offset, length)?;
        let decompressed = self.decompress(raw);
        let value = V::from_bytes(&decompressed);

        Ok(Some(value))
    }

    /// Clear the storage, going back to the initial state
    ///
    /// Completely wipes the storage, and recreates it with a single empty page.
    pub fn clear(&mut self) -> Result<()> {
        let create_options = StorageOptions::from(self.config);
        let base_path = self.base_path.clone();

        // Wait for all background flush operations to finish, abort pending flushes Below we
        // create a new Gridstore instance with a new flush lock, so flushers created on the new
        // instance work as expected
        self.is_alive_flush_lock.blocking_mark_dead();

        // Wipe
        self.pages.write().clear();
        fs::remove_dir_all(&base_path).map_err(|err| {
            GridstoreError::service_error(format!(
                "Failed to remove gridstore storage directory: {err}"
            ))

Review comment (suggestion):
```suggestion
        let Some(pointer) = self.tracker.write().unset(point_offset) else {
            return Ok(None);
        };

        let ValuePointer {
            page_id,
            block_offset,
            length,
        } = pointer;
```

Code after:

        // update the pointer
        let mut tracker_guard = self.tracker.write();
        let is_update = tracker_guard.has_pointer(point_offset);
        tracker_guard.set(
            point_offset,
            ValuePointer::new(start_page_id, block_offset, value_size as u32),
        );

        // return whether it was an update or not
        Ok(is_update)
    }

    /// Delete a value from the storage
    ///
    /// Returns None if the point_offset, page, or value was not found
    ///
    /// Returns the deleted value otherwise
    pub fn delete_value(&mut self, point_offset: PointOffset) -> Result<Option<V>> {
        let Some(pointer) = self.tracker.write().unset(point_offset) else {
            return Ok(None);
        };

        let ValuePointer {
            page_id,
            block_offset,
            length,
        } = pointer;

        let raw = self.read_from_pages::<false>(page_id, block_offset, length)?;
        let decompressed = self.decompress(raw);
        let value = V::from_bytes(&decompressed);

        Ok(Some(value))
    }

    /// Clear the storage, going back to the initial state
    ///
    /// Completely wipes the storage, and recreates it with a single empty page.
    pub fn clear(&mut self) -> Result<()> {
        let create_options = StorageOptions::from(self.config);
        let base_path = self.base_path.clone();

        // Wait for all background flush operations to finish, abort pending flushes Below we
        // create a new Gridstore instance with a new flush lock, so flushers created on the new
        // instance work as expected
        self.is_alive_flush_lock.blocking_mark_dead();

        // Wipe
        self.pages.write().clear();
        fs::remove_dir_all(&base_path).map_err(|err| {