Skip to content

feat(segment): add ReadOnlyPayloadStorage backed by GridstoreReader - #8886

Merged
generall merged 1 commit into
devfrom
feat/read-only-payload-storage
May 4, 2026
Merged

generall merged 1 commit into
devfrom
feat/read-only-payload-storage

Conversation

@generall

@generall generall commented May 4, 2026

Copy link
Copy Markdown
Member

Summary

  • Introduce ReadOnlyPayloadStorage, a read-only payload storage that wraps GridstoreReader<Payload> and implements PayloadStorageRead.
  • Rename the point_id parameter to point_offset on PayloadStorageRead::get/get_sequential (and impls) for consistency with the underlying gridstore API.

Test plan

  • cargo check -p segment
  • CI (fmt, clippy, tests)

🤖 Generated with Claude Code

Introduce a read-only payload storage that wraps `GridstoreReader<Payload>`
and implements `PayloadStorageRead`. Also rename the parameter on
`PayloadStorageRead::get`/`get_sequential` from `point_id` to `point_offset`
for consistency with the underlying storage API.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@generall
generall requested a review from dancixx May 4, 2026 12:23
@coderabbitai

coderabbitai Bot commented May 4, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

This PR performs a semantic parameter rename from point_id to point_offset across the payload storage trait and its implementations. It introduces a new ReadOnlyPayloadStorage struct and module that wraps a GridstoreReader, providing read-only payload access through a PayloadStorageRead trait implementation with methods for random/sequential reads, iteration with callbacks, and storage metrics.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • feat: split read only payload storage #8857 — Related refactoring of payload storage read operations and implementations affecting the same files (payload_storage_base.rs, payload_storage_enum.rs, mmap_payload_storage.rs)

Suggested labels

release:1.18.0

Suggested reviewers

  • coszio
  • timvisee
  • xzfc
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely describes the main change: introduction of ReadOnlyPayloadStorage backed by GridstoreReader, which aligns with the primary focus of the PR.
Description check ✅ Passed The description clearly explains the two main changes: adding ReadOnlyPayloadStorage and renaming point_id to point_offset for consistency, both of which directly relate to the changeset.
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 feat/read-only-payload-storage

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
Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (3)
lib/segment/src/payload_storage/mod.rs (1)

11-12: 💤 Low value

Remove #[allow(dead_code)] once the module is consumed.

The attribute prevents a "never used" warning on the module declaration now, but it should be removed when ReadOnlyPayloadStorage is integrated – keeping a permanent suppress-warning is a code smell.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/segment/src/payload_storage/mod.rs` around lines 11 - 12, Remove the
temporary suppression: delete the #[allow(dead_code)] attribute decorating the
mod read_only declaration and let the compiler warn until ReadOnlyPayloadStorage
(the exported type in read_only) is actually referenced/used; once
ReadOnlyPayloadStorage is integrated into the codebase, do not re-add the allow
attribute and ensure any references/imports use the
read_only::ReadOnlyPayloadStorage symbol so the module is consumed.
lib/segment/src/payload_storage/read_only/mod.rs (1)

7-10: ⚡ Quick win

ReadOnlyPayloadStorage is missing a public constructor.

Both fields are private and there is no open/new/open_or_create method, so the struct cannot be instantiated or tested outside this module. A constructor is a prerequisite for any downstream integration or unit test coverage.

🔧 Suggested minimal constructor
 mod payload_storage_read;
 
 use gridstore::GridstoreReader;
 
 use crate::types::Payload;
 
 pub struct ReadOnlyPayloadStorage {
     storage: GridstoreReader<Payload>,
     populate: bool,
 }
+
+impl ReadOnlyPayloadStorage {
+    pub fn open(storage: GridstoreReader<Payload>, populate: bool) -> Self {
+        Self { storage, populate }
+    }
+}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/segment/src/payload_storage/read_only/mod.rs` around lines 7 - 10, Add a
public constructor for ReadOnlyPayloadStorage so external code/tests can
instantiate it: implement a pub fn new (or pub fn open) on
ReadOnlyPayloadStorage that accepts a GridstoreReader<Payload> and a bool
populate (or derives populate default) and returns Self initializing the private
fields storage and populate; ensure the constructor is public (pub) and
documented so callers can create ReadOnlyPayloadStorage for integration and unit
tests.
lib/segment/src/payload_storage/read_only/payload_storage_read.rs (1)

43-43: 💤 Low value

point_id variable name in closure is inconsistent with the point_offset rename.

The outer trait signature uses point_offset throughout this PR, but the closure parameter on line 43 reverts to point_id. While functionally harmless, it's inconsistent with the rename intent.

🔧 Suggested fix
-        |point_id, payload| callback(point_id, &payload),
+        |point_offset, payload| callback(point_offset, &payload),
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/segment/src/payload_storage/read_only/payload_storage_read.rs` at line
43, Rename the closure parameter from point_id to point_offset to match the
surrounding trait signature and the rename intent: update the closure at the
call site where you currently have |point_id, payload| callback(point_id,
&payload) to use |point_offset, payload| and pass point_offset into callback;
ensure any matching parameter names in the surrounding method/trait (e.g.,
callback signature and callers) remain consistent with point_offset to avoid
mismatches.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@lib/segment/src/payload_storage/mod.rs`:
- Around line 11-12: Remove the temporary suppression: delete the
#[allow(dead_code)] attribute decorating the mod read_only declaration and let
the compiler warn until ReadOnlyPayloadStorage (the exported type in read_only)
is actually referenced/used; once ReadOnlyPayloadStorage is integrated into the
codebase, do not re-add the allow attribute and ensure any references/imports
use the read_only::ReadOnlyPayloadStorage symbol so the module is consumed.

In `@lib/segment/src/payload_storage/read_only/mod.rs`:
- Around line 7-10: Add a public constructor for ReadOnlyPayloadStorage so
external code/tests can instantiate it: implement a pub fn new (or pub fn open)
on ReadOnlyPayloadStorage that accepts a GridstoreReader<Payload> and a bool
populate (or derives populate default) and returns Self initializing the private
fields storage and populate; ensure the constructor is public (pub) and
documented so callers can create ReadOnlyPayloadStorage for integration and unit
tests.

In `@lib/segment/src/payload_storage/read_only/payload_storage_read.rs`:
- Line 43: Rename the closure parameter from point_id to point_offset to match
the surrounding trait signature and the rename intent: update the closure at the
call site where you currently have |point_id, payload| callback(point_id,
&payload) to use |point_offset, payload| and pass point_offset into callback;
ensure any matching parameter names in the surrounding method/trait (e.g.,
callback signature and callers) remain consistent with point_offset to avoid
mismatches.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 660eec59-fad4-4acc-a54a-ba0446f145f1

📥 Commits

Reviewing files that changed from the base of the PR and between 81ea504 and 38bfb2a.

📒 Files selected for processing (6)
  • lib/segment/src/payload_storage/mmap_payload_storage.rs
  • lib/segment/src/payload_storage/mod.rs
  • lib/segment/src/payload_storage/payload_storage_base.rs
  • lib/segment/src/payload_storage/payload_storage_enum.rs
  • lib/segment/src/payload_storage/read_only/mod.rs
  • lib/segment/src/payload_storage/read_only/payload_storage_read.rs

@generall
generall merged commit deb21b4 into dev May 4, 2026
15 checks passed
@generall
generall deleted the feat/read-only-payload-storage branch May 4, 2026 13:00
timvisee pushed a commit that referenced this pull request May 8, 2026
…8886)

Introduce a read-only payload storage that wraps `GridstoreReader<Payload>`
and implements `PayloadStorageRead`. Also rename the parameter on
`PayloadStorageRead::get`/`get_sequential` from `point_id` to `point_offset`
for consistency with the underlying storage API.

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
@coderabbitai coderabbitai Bot mentioned this pull request Jul 14, 2026
9 tasks done
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.

2 participants