Repository navigation
feat(segment): add ReadOnlyPayloadStorage backed by GridstoreReader - #8886
Conversation
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]>
📝 WalkthroughWalkthroughThis PR performs a semantic parameter rename from Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (3)
lib/segment/src/payload_storage/mod.rs (1)
11-12: 💤 Low valueRemove
#[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
ReadOnlyPayloadStorageis 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
ReadOnlyPayloadStorageis missing a public constructor.Both fields are private and there is no
open/new/open_or_createmethod, 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_idvariable name in closure is inconsistent with thepoint_offsetrename.The outer trait signature uses
point_offsetthroughout this PR, but the closure parameter on line 43 reverts topoint_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
📒 Files selected for processing (6)
lib/segment/src/payload_storage/mmap_payload_storage.rslib/segment/src/payload_storage/mod.rslib/segment/src/payload_storage/payload_storage_base.rslib/segment/src/payload_storage/payload_storage_enum.rslib/segment/src/payload_storage/read_only/mod.rslib/segment/src/payload_storage/read_only/payload_storage_read.rs
…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]>
Summary
ReadOnlyPayloadStorage, a read-only payload storage that wrapsGridstoreReader<Payload>and implementsPayloadStorageRead.point_idparameter topoint_offsetonPayloadStorageRead::get/get_sequential(and impls) for consistency with the underlying gridstore API.Test plan
cargo check -p segment🤖 Generated with Claude Code