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

Code before:
            block_offset = 0;
            length = unread_bytes as u32;
        }

        Ok(raw_sections)
    }

    /// Get the value for a given point offset
    ///
    /// # Arguments
    /// - point_offset: The ID of the value.
    /// - hw_counter: The hardware counter cell.
    /// - READ_SEQUENTIAL: Whether to read mmap pages ahead to optimize sequential access
    pub fn get_value<const READ_SEQUENTIAL: bool>(
        &self,
        point_offset: PointOffset,
        hw_counter: &HardwareCounterCell,
    ) -> Result<Option<V>> {
        let Some(ValuePointer {
            page_id,
            block_offset,
            length,
        }) = self.get_pointer(point_offset)
        else {
            return Ok(None);
        };

        let raw = self.read_from_pages::<READ_SEQUENTIAL>(page_id, block_offset, length)?;
        hw_counter.payload_io_read_counter().incr_delta(raw.len());

        let decompressed = self.decompress(raw);
        let value = V::from_bytes(&decompressed);

        Ok(Some(value))
    }

    /// Create a new page and return its id.
    /// If size is None, the page will have the default size
    ///
    /// Returns the new page id
    #[allow(clippy::needless_pass_by_ref_mut)]
    fn create_new_page(&mut self) -> Result<u32> {
        let new_page_id = self.next_page_id();
        let path = self.page_path(new_page_id);
        let page = Page::<MmapUniversal<u8>>::new(&path, self.config.page_size_bytes)?;
        self.pages.write().push(page);

        self.bitmask.write().cover_new_page()?;

        Ok(new_page_id)
    }

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

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

Code after:
            block_offset = 0;
            length = unread_bytes as u32;
        }

        Ok(raw_sections)
    }

    /// Get the value for a given point offset
    ///
    /// # Arguments
    /// - point_offset: The ID of the value.
    /// - hw_counter: The hardware counter cell.
    /// - READ_SEQUENTIAL: Whether to read mmap pages ahead to optimize sequential access
    pub fn get_value<const READ_SEQUENTIAL: bool>(
        &self,
        point_offset: PointOffset,
        hw_counter: &HardwareCounterCell,
    ) -> Result<Option<V>> {
        let Some(pointer) = self.get_pointer(point_offset) else {
            return Ok(None);
        };

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

        let raw = self.read_from_pages::<READ_SEQUENTIAL>(page_id, block_offset, length)?;
        hw_counter.payload_io_read_counter().incr_delta(raw.len());

        let decompressed = self.decompress(raw);
        let value = V::from_bytes(&decompressed);

        Ok(Some(value))
    }

    /// Create a new page and return its id.
    /// If size is None, the page will have the default size
    ///
    /// Returns the new page id
    #[allow(clippy::needless_pass_by_ref_mut)]
    fn create_new_page(&mut self) -> Result<u32> {
        let new_page_id = self.next_page_id();
        let path = self.page_path(new_page_id);
        let page = Page::<MmapUniversal<u8>>::new(&path, self.config.page_size_bytes)?;
        self.pages.write().push(page);

        self.bitmask.write().cover_new_page()?;

        Ok(new_page_id)