Skip to content

[quantization] Add as_raw_ptr.#774

Open
hildebrandmw wants to merge 2 commits intomainfrom
mhildebr/as_raw_ptr
Open

[quantization] Add as_raw_ptr.#774
hildebrandmw wants to merge 2 commits intomainfrom
mhildebr/as_raw_ptr

Conversation

@hildebrandmw
Copy link
Contributor

Add publicly exported as_raw_ptr for retrieving the base pointer of Mat, MatRef, and MatMut.

The term "raw" is meant to denote that this is the byte pointer - not necessarily the pointer to the actual element type stored in these containers.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds a new public method as_raw_ptr() to the Mat, MatRef, and MatMut types in the quantization module. The method provides safe access to the underlying byte-level pointer (*const u8) for these matrix types. The "raw" naming convention clearly distinguishes this byte-pointer accessor from potential typed-pointer accessors, following established codebase patterns.

Changes:

  • Added as_raw_ptr() method to Mat, MatRef, and MatMut that returns the base byte pointer (*const u8)
  • Removed the previous test-only as_ptr() method from Mat and replaced all its usages with the new public as_raw_ptr()
  • Updated all test code to use the new method name

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov-commenter
Copy link

codecov-commenter commented Feb 13, 2026

Codecov Report

❌ Patch coverage is 91.30435% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.99%. Comparing base (e093583) to head (a84331d).

Files with missing lines Patch % Lines
diskann-quantization/src/multi_vector/matrix.rs 91.30% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #774      +/-   ##
==========================================
- Coverage   88.99%   88.99%   -0.01%     
==========================================
  Files         428      428              
  Lines       78415    78431      +16     
==========================================
+ Hits        69784    69798      +14     
- Misses       8631     8633       +2     
Flag Coverage Δ
miri 88.99% <91.30%> (-0.01%) ⬇️
unittests 88.99% <91.30%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
diskann-quantization/src/multi_vector/matrix.rs 97.28% <91.30%> (-0.25%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

/// Return the base pointer for the [`Mat`].
pub fn as_raw_ptr(&self) -> *const u8 {
self.ptr.as_ptr()
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious - why expose these publicly?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this a footgun for unsafe reads?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants