Repository navigation
Сreate and load TQ - #8701
Сreate and load TQ#8701
Conversation
📝 WalkthroughWalkthroughThis PR implements Turbo Quant support in the quantized vectors storage by replacing Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
lib/segment/src/vector_storage/quantized/quantized_vectors.rs (1)
2214-2219: Prefer an exhaustive match over the_arm.Per coding guidelines, catch-all
_arms should be avoided in non-test code.Option<bool>has a fixed set of variants, so listing them explicitly is cheap and documents the intent (note:Nonecurrently falls through toPlus— making this explicit also surfaces that default choice for reviewers).♻️ Suggested change
fn convert_tq_mode(plus: Option<bool>) -> TQMode { match plus { Some(false) => TQMode::Normal, - _ => TQMode::Plus, + Some(true) | None => TQMode::Plus, } }As per coding guidelines: "Prefer explicit exhaustive matches over catch-all
_arm in Rust match expressions, so we don't miss handling new enum variants when they are added later".🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lib/segment/src/vector_storage/quantized/quantized_vectors.rs` around lines 2214 - 2219, The match in function convert_tq_mode currently uses a catch-all `_` arm; replace it with an exhaustive match over Option<bool> (explicitly handle Some(true) and None) so the three cases are clear and intentional: map Some(false) => TQMode::Normal, Some(true) => TQMode::Plus, and None => TQMode::Plus (or whichever explicit default is intended) to remove the `_` arm and document the default choice for reviewers.
🤖 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/quantized/quantized_vectors.rs`:
- Around line 2015-2069: The issue is that create_turbo allows
QuantizedVectorsStorageType::Mutable (creating a TQChunkedMmap) but load_turbo
rejects Mutable, causing reload failures; fix by adding a Mutable branch in
load_turbo that mirrors the BinaryChunkedMmap path: detect
QuantizedVectorsStorageType::Mutable in load_turbo, construct a
QuantizedChunkedMmapStorageBuilder (same params used in create_turbo), and call
EncodedVectorsTQ::load (or the corresponding load method) to return
QuantizedVectorStorage::TQChunkedMmap; update any error handling/arguments to
match the other load branches so load_turbo now supports TQChunkedMmap.
---
Nitpick comments:
In `@lib/segment/src/vector_storage/quantized/quantized_vectors.rs`:
- Around line 2214-2219: The match in function convert_tq_mode currently uses a
catch-all `_` arm; replace it with an exhaustive match over Option<bool>
(explicitly handle Some(true) and None) so the three cases are clear and
intentional: map Some(false) => TQMode::Normal, Some(true) => TQMode::Plus, and
None => TQMode::Plus (or whichever explicit default is intended) to remove the
`_` arm and document the default choice for reviewers.
🪄 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: ee169287-88a9-48c8-be34-01eb98467e09
📒 Files selected for processing (1)
lib/segment/src/vector_storage/quantized/quantized_vectors.rs
There was a problem hiding this comment.
🧹 Nitpick comments (1)
lib/segment/src/vector_storage/quantized/quantized_vectors.rs (1)
2289-2294: Consider making theNonedefault inconvert_tq_modeexplicit.
Some(true)andNoneboth fall through the_arm toTQMode::Plus, which hides thatNoneis being treated as “enable plus.” An explicit spelling makes the default intent obvious and satisfies the exhaustive-match guideline without relying on the closed-set exception.♻️ Proposed refactor
fn convert_tq_mode(plus: Option<bool>) -> TQMode { match plus { + Some(true) | None => TQMode::Plus, Some(false) => TQMode::Normal, - _ => TQMode::Plus, } }As per coding guidelines: "Prefer explicit exhaustive matches over catch-all
_arm in Rust match expressions".🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lib/segment/src/vector_storage/quantized/quantized_vectors.rs` around lines 2289 - 2294, The match in convert_tq_mode currently uses a catch-all arm that folds Some(true) and None into TQMode::Plus; make the None case explicit to clarify default behavior and satisfy exhaustive-match guidelines by matching on Some(false) => TQMode::Normal, Some(true) => TQMode::Plus, and None => TQMode::Plus (or None => desired default) so intent is explicit for the TQMode enum.
🤖 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/vector_storage/quantized/quantized_vectors.rs`:
- Around line 2289-2294: The match in convert_tq_mode currently uses a catch-all
arm that folds Some(true) and None into TQMode::Plus; make the None case
explicit to clarify default behavior and satisfy exhaustive-match guidelines by
matching on Some(false) => TQMode::Normal, Some(true) => TQMode::Plus, and None
=> TQMode::Plus (or None => desired default) so intent is explicit for the
TQMode enum.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 5117ef8f-011a-4207-8925-03c43d9fa922
📒 Files selected for processing (1)
lib/segment/src/vector_storage/quantized/quantized_vectors.rs
* create and load TQ * appendable TQ creation
* create and load TQ * appendable TQ creation
This PR fixed
todo!()for TQ create and load in the segment crate