Skip to content

refactor(segment): split ChunkedVectors into read-only core + write wrapper - #8915

Merged
generall merged 1 commit into
devfrom
feat/chunked-vectors-read-only
May 5, 2026
Merged

generall merged 1 commit into
devfrom
feat/chunked-vectors-read-only

Conversation

@generall

@generall generall commented May 5, 2026

Copy link
Copy Markdown
Member

Summary

  • Extract ChunkedVectorsRead<T, S: UniversalRead<T>> containing all read-side state (config, chunks, snapshot len, directory) and read-side API (get, iter, for_each_in_batch, files, populate, clear_cache, ...). Read-only consumers can now use the storage without an UniversalWrite bound.
  • Rebuild existing ChunkedVectors<T, S: UniversalWrite<T>> on top via composition + Deref<Target = ChunkedVectorsRead<T, S>>. Mutating methods (insert, insert_many, push, flusher) live on the wrapper; writes update both the live MmapType<Status> and the inner snapshot len in lockstep.
  • Reorganize the previous flat file into a chunked_vectors/ module: config.rs (constants, ChunkedVectorsConfig, Status), chunks.rs (read_chunks/create_chunk helpers), read.rs (ChunkedVectorsRead), write.rs (ChunkedVectors), mod.rs (wiring + tests).
  • read_chunks is generalized to S: UniversalRead<T> with a writeable: bool flag so both open paths share it. Two UFCS callers in quantized_chunked_mmap_storage switched to method-call syntax to go through Deref.

ChunkedVectorsRead::open is wired and tested but currently #[allow(dead_code)] — it's the entry point for the upcoming read-only vector storage enum.

Test plan

  • cargo check -p segment — clean, no warnings
  • cargo test -p segment --lib vector_storage::chunked_vectors::tests::test_chunked_mmap — passes
  • Full segment test suite in CI

🤖 Generated with Claude Code

…rapper

Extract the read-side API into ChunkedVectorsRead<T, S: UniversalRead<T>>
and rebuild the existing ChunkedVectors<T, S: UniversalWrite<T>> on top of
it via composition + Deref. Lets read-only consumers use the storage
without pulling in UniversalWrite, and avoids method duplication.

Reorganizes the file into a chunked_vectors/ module: config (constants,
ChunkedVectorsConfig, Status), chunks (read_chunks/create_chunk helpers),
read (ChunkedVectorsRead), write (ChunkedVectors wrapper). read_chunks
now takes a writeable flag so both open paths share it.

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

coderabbitai Bot commented May 5, 2026 •

Copy link
Copy Markdown
Contributor

Caution

Review failed

Failed to post review comments

📝 Walkthrough

Walkthrough

The chunked vector storage module was refactored from a single monolithic file into a modular structure with separate concerns. The original chunked_vectors.rs (~617 lines) containing ChunkedVectors struct, configuration, chunk utilities, and both read/write logic was decomposed into config.rs (configuration and status), chunks.rs (chunk file utilities), read.rs (read-only interface), and write.rs (write interface), orchestrated through mod.rs. Public APIs are preserved via re-exports. A minor update in quantized_chunked_mmap_storage.rs changed associated function calls to method delegation syntax.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • qdrant/qdrant#8685: Introduces UniversalKind and io_uring fast-path specialization in for_each_in_batch, directly related to the refactored batch read implementation.
  • qdrant/qdrant#8601: Updates UniversalRead and UniversalWrite API signatures with metadata parameters, directly affecting the chunked vectors read/write method calls.
  • qdrant/qdrant#7116: Implements chunked mmap-based quantized storage that depends on the refactored ChunkedVectors read/write and utility APIs.

Suggested reviewers

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

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 45.24% 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 clearly summarizes the main refactoring: splitting ChunkedVectors into a read-only core (ChunkedVectorsRead) and a write wrapper (ChunkedVectors), which matches the primary structural change in the changeset.
Description check ✅ Passed The description is comprehensive and directly related to the changeset, detailing the extraction of ChunkedVectorsRead, the rebuilding of ChunkedVectors via composition, module reorganization, and test plans.
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/chunked-vectors-read-only

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 1822f10 into dev May 5, 2026
12 checks passed
@generall
generall deleted the feat/chunked-vectors-read-only branch May 5, 2026 14:57
timvisee pushed a commit that referenced this pull request May 8, 2026
…rapper (#8915)

Extract the read-side API into ChunkedVectorsRead<T, S: UniversalRead<T>>
and rebuild the existing ChunkedVectors<T, S: UniversalWrite<T>> on top of
it via composition + Deref. Lets read-only consumers use the storage
without pulling in UniversalWrite, and avoids method duplication.

Reorganizes the file into a chunked_vectors/ module: config (constants,
ChunkedVectorsConfig, Status), chunks (read_chunks/create_chunk helpers),
read (ChunkedVectorsRead), write (ChunkedVectors wrapper). read_chunks
now takes a writeable flag so both open paths share it.

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