Repository navigation
feat/vector-storage-read-only - #8889
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds a read-only vector-storage layer and a universal read-backend family: a new Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@lib/segment/src/vector_storage/mod.rs`:
- Around line 11-12: The new pub mod read_only is annotated with
#[allow(dead_code)], which hides missing-use diagnostics; remove or narrow that
attribute and either wire up the read-only types so the compiler detects usage
(connect VectorStorageReadEnum and the wrapper types into the public
API/dispatch paths) or, if this is intentionally staged, replace the blanket
allow with a scoped suppression and add a TODO pointing to a follow-up issue
(e.g., “// TODO: wire up VectorStorageReadEnum and wrapper types in ISSUE-123”)
so future contributors know to finish integration; reference the read_only
module, VectorStorageReadEnum, and the wrapper types when making the change.
In `@lib/segment/src/vector_storage/sparse/mmap_sparse_vector_storage.rs`:
- Around line 53-73: The directory existence checks in open_read_only currently
use exists(), which returns true for non-directory filesystem entries; change
both checks to use is_dir() instead (for storage_dir and deleted_dir) so regular
files or symlinks won't pass the check and cause confusing downstream errors;
update the error messages if needed but keep the same
OperationError::service_error path and then call Self::open(path) as before to
remain consistent with open_or_create's behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 8c8c2b14-d207-40b6-a89f-0c2b1bdbed6d
📒 Files selected for processing (10)
lib/segment/src/vector_storage/dense/appendable_dense_vector_storage.rslib/segment/src/vector_storage/dense/dense_vector_storage.rslib/segment/src/vector_storage/mod.rslib/segment/src/vector_storage/multi_dense/appendable_mmap_multi_dense_vector_storage.rslib/segment/src/vector_storage/read_only/appendable_dense_vector_storage_read.rslib/segment/src/vector_storage/read_only/dense_vector_storage_read.rslib/segment/src/vector_storage/read_only/mod.rslib/segment/src/vector_storage/read_only/multi_dense_vector_storage_read.rslib/segment/src/vector_storage/read_only/sparse_vector_storage_read.rslib/segment/src/vector_storage/sparse/mmap_sparse_vector_storage.rs
| #[allow(dead_code)] | ||
| pub mod read_only; |
There was a problem hiding this comment.
#[allow(dead_code)] on a new pub mod signals that the module is unintegrated.
Applying this attribute to the entire read_only module blanket-suppresses dead code diagnostics for every item inside it—public and private alike—meaning future contributors can add broken or stale code without any compiler feedback.
Either:
- Wire up
VectorStorageReadEnumand the wrapper types so the lint fires cleanly without the attribute, or - If this is intentionally a staging PR, add an explicit
// TODO: wire up in <follow-up issue>comment and scope the suppression as narrowly as possible.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@lib/segment/src/vector_storage/mod.rs` around lines 11 - 12, The new pub mod
read_only is annotated with #[allow(dead_code)], which hides missing-use
diagnostics; remove or narrow that attribute and either wire up the read-only
types so the compiler detects usage (connect VectorStorageReadEnum and the
wrapper types into the public API/dispatch paths) or, if this is intentionally
staged, replace the blanket allow with a scoped suppression and add a TODO
pointing to a follow-up issue (e.g., “// TODO: wire up VectorStorageReadEnum and
wrapper types in ISSUE-123”) so future contributors know to finish integration;
reference the read_only module, VectorStorageReadEnum, and the wrapper types
when making the change.
| /// Open an existing mmap sparse vector storage without creating any files | ||
| /// or directories. Fails if the storage layout is missing. | ||
| pub fn open_read_only(path: &Path) -> OperationResult<Self> { | ||
| let storage_dir = path.join(STORAGE_DIRNAME); | ||
| let deleted_dir = path.join(DELETED_DIRNAME); | ||
|
|
||
| if !storage_dir.exists() { | ||
| return Err(OperationError::service_error(format!( | ||
| "Sparse vector storage dir not found at {}", | ||
| storage_dir.display(), | ||
| ))); | ||
| } | ||
| if !deleted_dir.exists() { | ||
| return Err(OperationError::service_error(format!( | ||
| "Sparse vector storage 'deleted' dir not found at {}", | ||
| deleted_dir.display(), | ||
| ))); | ||
| } | ||
|
|
||
| Self::open(path) | ||
| } |
There was a problem hiding this comment.
Use is_dir() instead of exists() for directory presence checks.
exists() returns true for any filesystem entry (file, symlink, device node). If either path happens to be a regular file, the check passes but Self::open will fail with a confusing error from the underlying Gridstore/DynamicMmapFlags. The existing open_or_create already uses is_dir() for the same deleted_dir — keep them consistent.
🐛 Proposed fix
- if !storage_dir.exists() {
+ if !storage_dir.is_dir() {
return Err(OperationError::service_error(format!(
"Sparse vector storage dir not found at {}",
storage_dir.display(),
)));
}
- if !deleted_dir.exists() {
+ if !deleted_dir.is_dir() {
return Err(OperationError::service_error(format!(
"Sparse vector storage 'deleted' dir not found at {}",
deleted_dir.display(),
)));
}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@lib/segment/src/vector_storage/sparse/mmap_sparse_vector_storage.rs` around
lines 53 - 73, The directory existence checks in open_read_only currently use
exists(), which returns true for non-directory filesystem entries; change both
checks to use is_dir() instead (for storage_dir and deleted_dir) so regular
files or symlinks won't pass the check and cause confusing downstream errors;
update the error messages if needed but keep the same
OperationError::service_error path and then call Self::open(path) as before to
remain consistent with open_or_create's behavior.
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@lib/segment/src/vector_storage/read_only/appendable_dense_vector_storage_read.rs`:
- Around line 16-18: The tuple struct ReadOnlyAppendableDenseVectorStorage has a
private inner field AppendableMmapDenseVectorStorage which prevents construction
from the parent module (used by VectorStorageReadEnum in mod.rs); add a public
constructor or conversion to allow creation: implement pub fn new(inner:
AppendableMmapDenseVectorStorage<T>) -> Self or impl
From<AppendableMmapDenseVectorStorage<T>> for
ReadOnlyAppendableDenseVectorStorage<T>, or alternatively make the tuple field
pub(super) so the parent module can construct instances.
In `@lib/segment/src/vector_storage/read_only/dense_vector_storage_read.rs`:
- Around line 6-7: The unused #[cfg(target_os = "linux")] import IoUringFile
should be removed or properly used; delete the standalone use
common::universal_io::IoUringFile import from dense_vector_storage_read.rs to
satisfy clippy's unused-imports rule, or if a Linux-specific storage variant is
intended, gate a type alias or S-parameter usage (e.g., a #[cfg(target_os =
"linux")] type alias for ReadOnlyDenseVectorStorage that uses IoUringFile as the
S generic) so the symbol is actually referenced.
- Around line 19-22: ReadOnlyDenseVectorStorage currently has a private tuple
field (DenseVectorStorageImpl<T, S>) so it cannot be constructed outside its
module; add a public constructor or conversion to expose it: implement either
pub fn new(inner: DenseVectorStorageImpl<T, S>) -> Self for
ReadOnlyDenseVectorStorage or impl From<DenseVectorStorageImpl<T, S>> for
ReadOnlyDenseVectorStorage so callers (and the VectorStorageReadEnum variants)
can be created; ensure the signature keeps the generic bounds (T:
PrimitiveVectorElement, S: UniversalRead<T>) and make the constructor/From
implementation public.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 0c0e1c3a-29b6-414a-8f1c-57cc4e5981d9
📒 Files selected for processing (5)
lib/segment/src/vector_storage/read_only/appendable_dense_vector_storage_read.rslib/segment/src/vector_storage/read_only/dense_vector_storage_read.rslib/segment/src/vector_storage/read_only/mod.rslib/segment/src/vector_storage/read_only/multi_dense_vector_storage_read.rslib/segment/src/vector_storage/read_only/sparse_vector_storage_read.rs
🚧 Files skipped from review as they are similar to previous changes (1)
- lib/segment/src/vector_storage/read_only/mod.rs
There was a problem hiding this comment.
🧹 Nitpick comments (1)
lib/segment/src/vector_storage/read_only/mod.rs (1)
20-28: 💤 Low valueCommented-out future variants — consider tracking as follow-up issues.
Lines 20–28 document planned (but currently absent) variants for appendable dense, multi-dense, and sparse storage. Leaving them as inline comments risks them being forgotten or diverging from the real
VectorStorageEnumas that enum evolves.Do you want me to open tracking issues for each commented-out variant group, or draft the
ReadOnlyAppendableDenseVectorStorage/ReadOnlyMultiDenseVectorStorage/ReadOnlySparseVectorStoragescaffolding so they can be uncommented incrementally?🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@lib/segment/src/vector_storage/read_only/mod.rs` around lines 20 - 28, The commented-out variants for DenseAppendable, MultiDense and Sparse (DenseAppendable / DenseAppendableByte / DenseAppendableHalf / MultiDense / MultiDenseByte / MultiDenseHalf / Sparse and the referenced types ReadOnlyAppendableDenseVectorStorage, ReadOnlyMultiDenseVectorStorage, ReadOnlySparseVectorStorage) should not live only as inline comments; create tracking issues for each variant group and replace the inline comment block with short TODO markers that reference the new issue IDs (e.g., "TODO: implement ReadOnlyAppendableDenseVectorStorage - issue `#123`"). Alternatively, if you prefer scaffolding, add minimal stub modules/types for ReadOnlyAppendableDenseVectorStorage, ReadOnlyMultiDenseVectorStorage and ReadOnlySparseVectorStorage (public structs/enums with empty impls and TODO comments) so the variants can be uncommented safely later; pick one approach and apply it consistently to all listed variants.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@lib/segment/src/vector_storage/read_only/mod.rs`:
- Around line 20-28: The commented-out variants for DenseAppendable, MultiDense
and Sparse (DenseAppendable / DenseAppendableByte / DenseAppendableHalf /
MultiDense / MultiDenseByte / MultiDenseHalf / Sparse and the referenced types
ReadOnlyAppendableDenseVectorStorage, ReadOnlyMultiDenseVectorStorage,
ReadOnlySparseVectorStorage) should not live only as inline comments; create
tracking issues for each variant group and replace the inline comment block with
short TODO markers that reference the new issue IDs (e.g., "TODO: implement
ReadOnlyAppendableDenseVectorStorage - issue `#123`"). Alternatively, if you
prefer scaffolding, add minimal stub modules/types for
ReadOnlyAppendableDenseVectorStorage, ReadOnlyMultiDenseVectorStorage and
ReadOnlySparseVectorStorage (public structs/enums with empty impls and TODO
comments) so the variants can be uncommented safely later; pick one approach and
apply it consistently to all listed variants.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: a6cf878f-7eb7-4d47-9118-5db7805d7eb6
📒 Files selected for processing (3)
lib/common/common/src/universal_io/family.rslib/common/common/src/universal_io/mod.rslib/segment/src/vector_storage/read_only/mod.rs
…, implement 1st part of VectorStorageReadEnum
3d2e79f to
b67ef20
Compare
* feat: add vector storage read enum * fix: linter * chore: remove open functions * fix: compiler error * review fix 1: remove constructiors (for now), use UniversalReadFamily, implement 1st part of VectorStorageReadEnum * fmt * read only chucked_vector_storage * fnt * feat: add dense chunked variants to vector storage read enum (#8916) * feat: add multi dense chunked (#8918) --------- Co-authored-by: generall <[email protected]>
All Submissions:
devbranch. Did you create your branch fromdev?New Feature Submissions:
cargo +nightly fmt --allcommand prior to submission?cargo clippy --workspace --all-featurescommand?Changes to Core Features: