Skip to content

feat/vector-storage-read-only - #8889

Merged
dancixx merged 10 commits into
devfrom
feat/vector-storage-read-only
May 6, 2026
Merged

dancixx merged 10 commits into
devfrom
feat/vector-storage-read-only

Conversation

@dancixx

@dancixx dancixx commented May 4, 2026

Copy link
Copy Markdown
Contributor

All Submissions:

  • Contributions should target the dev branch. Did you create your branch from dev?
  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

New Feature Submissions:

  1. Does your submission pass tests?
  2. Have you formatted your code locally using cargo +nightly fmt --all command prior to submission?
  3. Have you checked your code using cargo clippy --workspace --all-features command?

Changes to Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully ran tests with your changes locally?

@dancixx
dancixx marked this pull request as ready for review May 4, 2026 14:13
@dancixx
dancixx requested a review from generall May 4, 2026 14:14
@coderabbitai

coderabbitai Bot commented May 4, 2026 •

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a read-only vector-storage layer and a universal read-backend family: a new read_only submodule exporting VectorStorageReadEnum<S: UniversalReadFamily> which wraps boxed on-disk dense vector storage variants and implements VectorStorageRead by delegating read-only operations; introduces UniversalReadFamily with concrete family types (MmapFamily, Linux-only IoUringFamily, non-Windows CachedSliceFamily) and re-exports it from universal_io. Also exposes the read_only module from lib/segment/src/vector_storage/mod.rs.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • qdrant/qdrant#8852: Introduces/refactors VectorStorageRead that VectorStorageReadEnum implements.
  • qdrant/qdrant#8915: Adds/wires read-only vector-storage abstractions similar to this change.
  • qdrant/qdrant#8702: Refactors universal read backend usage and multi-vector read paths related to UniversalReadFamily.

Suggested labels

release:1.18.0

Suggested reviewers

  • generall
  • xzfc
  • coszio
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 17.72% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The description consists only of unchecked contributor checklist items with no actual implementation details, rationale, or explanation of changes related to the vector storage read-only feature. Add a brief explanation of what the read-only vector storage feature does and why it's being added. Include details about the UniversalReadFamily abstraction and VectorStorageReadEnum enum.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat/vector-storage-read-only' is clear and specific, accurately describing the main feature being added: a read-only wrapper for vector storage with support for multiple backend families.
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 unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/vector-storage-read-only

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.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

@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.

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

📥 Commits

Reviewing files that changed from the base of the PR and between fd4e25d and a830dba.

📒 Files selected for processing (10)
  • lib/segment/src/vector_storage/dense/appendable_dense_vector_storage.rs
  • lib/segment/src/vector_storage/dense/dense_vector_storage.rs
  • lib/segment/src/vector_storage/mod.rs
  • lib/segment/src/vector_storage/multi_dense/appendable_mmap_multi_dense_vector_storage.rs
  • lib/segment/src/vector_storage/read_only/appendable_dense_vector_storage_read.rs
  • lib/segment/src/vector_storage/read_only/dense_vector_storage_read.rs
  • lib/segment/src/vector_storage/read_only/mod.rs
  • lib/segment/src/vector_storage/read_only/multi_dense_vector_storage_read.rs
  • lib/segment/src/vector_storage/read_only/sparse_vector_storage_read.rs
  • lib/segment/src/vector_storage/sparse/mmap_sparse_vector_storage.rs

Comment on lines +11 to +12
#[allow(dead_code)]
pub mod read_only;

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.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

#[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 VectorStorageReadEnum and 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.

Comment on lines +53 to +73
/// 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)
}

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.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

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.

@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.

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

📥 Commits

Reviewing files that changed from the base of the PR and between a830dba and d331c0f.

📒 Files selected for processing (5)
  • lib/segment/src/vector_storage/read_only/appendable_dense_vector_storage_read.rs
  • lib/segment/src/vector_storage/read_only/dense_vector_storage_read.rs
  • lib/segment/src/vector_storage/read_only/mod.rs
  • lib/segment/src/vector_storage/read_only/multi_dense_vector_storage_read.rs
  • lib/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

@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 (1)
lib/segment/src/vector_storage/read_only/mod.rs (1)

20-28: 💤 Low value

Commented-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 VectorStorageEnum as that enum evolves.

Do you want me to open tracking issues for each commented-out variant group, or draft the ReadOnlyAppendableDenseVectorStorage / ReadOnlyMultiDenseVectorStorage / ReadOnlySparseVectorStorage scaffolding 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

📥 Commits

Reviewing files that changed from the base of the PR and between b83f273 and 3d2e79f.

📒 Files selected for processing (3)
  • lib/common/common/src/universal_io/family.rs
  • lib/common/common/src/universal_io/mod.rs
  • lib/segment/src/vector_storage/read_only/mod.rs

@dancixx
dancixx force-pushed the feat/vector-storage-read-only branch from 3d2e79f to b67ef20 Compare May 5, 2026 15:22
@dancixx
dancixx merged commit dddc6e9 into dev May 6, 2026
20 of 21 checks passed
@dancixx
dancixx deleted the feat/vector-storage-read-only branch May 6, 2026 11:31
timvisee pushed a commit that referenced this pull request May 8, 2026
* 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]>
@coderabbitai coderabbitai Bot mentioned this pull request May 12, 2026
9 tasks
@generall generall added this to the Live-reload milestone May 30, 2026
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