Skip to content

[gridstore, UIO] Simplify OptionalPointer - #8945

Merged
generall merged 5 commits into
devfrom
optionalpointer-type
May 8, 2026
Merged

generall merged 5 commits into
devfrom
optionalpointer-type

Conversation

@coszio

@coszio coszio commented May 7, 2026

Copy link
Copy Markdown
Contributor

The type for interacting with optional stored pointers was Optional<ValuePointer>. But since generics can't derive bytemuck::Pod cleanly, handling this type required reading [u8] from storage, and then transmuting.

This PR simplifies implementation by making the optional type concrete: OptionalPointer. This lets the storage backend do the cast via bytemuck, and gets rid of the "legacy code" lint suppression.

Additionally, removes one layer of option from get_raw: Result<Option<Option<ValuePointer>>> to Result<Option<ValuePointer>>

@coszio
coszio requested a review from xzfc May 7, 2026 14:38
coderabbitai[bot]

This comment was marked as low quality.

@qdrant qdrant deleted a comment from coderabbitai Bot May 7, 2026
coderabbitai[bot]

This comment was marked as resolved.

Comment thread lib/gridstore/src/tracker.rs Resolved
@generall
generall self-requested a review May 8, 2026 07:39

@generall generall left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

As @xzfc mentioned here #8953 (comment)
we unfortunately can't do bytemuck that simple

@qdrant qdrant deleted a comment from coderabbitai Bot May 8, 2026
@generall

generall commented May 8, 2026

Copy link
Copy Markdown
Member

Depends on #8955

coszio and others added 4 commits May 8, 2026 12:27
…8953)

Drop the `+ UniversalRead<OptionalPointer>` / `+ UniversalWrite<OptionalPointer>`
trait bounds added in the previous two commits. Reads and writes of
`OptionalPointer` and `TrackerHeader` now go through `bytemuck::from_bytes` /
`bytemuck::bytes_of` on the existing `u8` byte slices instead.

This keeps the unsafe-transmute removal but avoids the turbofish noise
(`UniversalWrite::<u8>::flusher(&self.storage)`, `<S as UniversalRead<u8>>::open`,
…) that two `T`s on `S` forced everywhere.

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
@coszio
coszio force-pushed the optionalpointer-type branch from d979396 to 20a8a10 Compare May 8, 2026 16:42
@coderabbitai

coderabbitai Bot commented May 8, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0dbcb825-ec0e-4b19-bc20-92de77c14203

📥 Commits

Reviewing files that changed from the base of the PR and between 20a8a10 and 8011f29.

📒 Files selected for processing (1)
  • lib/gridstore/src/tracker.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • lib/gridstore/src/tracker.rs

📝 Walkthrough

Walkthrough

This change replaces the generic Optional<T> transmute-based on-disk encoding with a concrete OptionalPointer POD type containing a 32-bit discriminant and ValuePointer. Legacy transmute imports are removed and replaced with universal I/O imports. The Tracker's read paths (get_raw, get_batch) and write paths (read_header, write_header, persist_pointer) are refactored to use typed bytemuck conversions instead of unsafe byte manipulation. Tests are updated to match the new get_raw signature that returns Option<ValuePointer> directly, and layout tests validate OptionalPointer's size and discriminant encoding behavior.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title '[gridstore, UIO] Simplify OptionalPointer' directly reflects the main change: replacing generic Optional with concrete OptionalPointer type and simplifying the implementation.
Description check ✅ Passed The description clearly explains the motivation (generics can't derive bytemuck::Pod), the solution (making OptionalPointer concrete), and the benefits (removes transmute, eliminates lint suppression, simplifies get_raw return type).
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch optionalpointer-type

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@generall
generall merged commit 8aaeb96 into dev May 8, 2026
20 of 21 checks passed
@generall
generall deleted the optionalpointer-type branch May 8, 2026 18:05
generall added a commit that referenced this pull request May 22, 2026
* derive bytemuck::Pod on `OptionalPointer`, get rid of legacy transmute

* remove one layer of Option in `get_raw`

* keep `UniversalRead<u8>` bound, do bytemuck conversion at call site (#8953)

Drop the `+ UniversalRead<OptionalPointer>` / `+ UniversalWrite<OptionalPointer>`
trait bounds added in the previous two commits. Reads and writes of
`OptionalPointer` and `TrackerHeader` now go through `bytemuck::from_bytes` /
`bytemuck::bytes_of` on the existing `u8` byte slices instead.

This keeps the unsafe-transmute removal but avoids the turbofish noise
(`UniversalWrite::<u8>::flusher(&self.storage)`, `<S as UniversalRead<u8>>::open`,
…) that two `T`s on `S` forced everywhere.

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>

* extra refactoring after #8955

* explicit zeroed instantiation

---------

Co-authored-by: Andrey Vasnetsov <[email protected]>
Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
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