Repository navigation
feat: readonly bool index open - #9200
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis PR refactors the boolean field index architecture by reorganizing mutable, immutable, and read-only index types into separate module hierarchies. The old monolithic ImmutableBoolIndex file is replaced with modular lifecycle and read_ops submodules. MutableBoolIndex is implemented with mmap-backed RoaringFlags and precomputed counts; ImmutableBoolIndex wraps MutableBoolIndex and provides immutable lifecycle semantics; ReadOnlyBoolIndex Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
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 |
coszio
left a comment
There was a problem hiding this comment.
It's hard to track exactly, but I assume immutable and mutable indexes were just rearranged.
801e3d6 to
50ac53d
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
lib/segment/src/index/field_index/bool_index/mutable_bool_index/lifecycle.rs (1)
27-31:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winStale doc parameter. The
# Argumentslist documents anis_on_diskparameter that isn't part ofopen(path, create_if_missing). Drop theis_on_diskline to match the signature.📝 Proposed fix
/// # Arguments /// - `path` - The directory where the index files should live, must be exclusive to this index. - /// - `is_on_disk` - If the index should be kept on disk. Memory will be populated if false. /// - `create_if_missing` - If true, creates the index if it doesn't exist.🤖 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/index/field_index/bool_index/mutable_bool_index/lifecycle.rs` around lines 27 - 31, The docs for the function open(Path, create_if_missing) are stale: they list an `is_on_disk` argument that no longer exists; update the doc comment above pub fn open(path: &Path, create_if_missing: bool) -> OperationResult<Option<Self>> by removing the `- `is_on_disk` - If the index should be kept on disk...` line so the documented `# Arguments` only lists `path` and `create_if_missing`, matching the open function signature in lifecycle.rs.
♻️ Duplicate comments (1)
lib/segment/src/index/field_index/bool_index/read_only_bool_index/lifecycle.rs (1)
24-25:⚠️ Potential issue | 🔴 Critical | ⚡ Quick winBlocking:
ReadOnlyRoaringFlags::opencall is ambiguous (E0034) and fails to compile.The CI build reports
E0034: multiple applicable items in scopeon bothopencalls. Twoopendefinitions are reachable onReadOnlyRoaringFlags<S>— most likely the inherentopen(fs, path, populate)and anopenbrought in by theRoaringFlagsReadtrait import on Line 8. The compiler cannot pick one, so this needs disambiguation.This also ties into prior feedback that a read-only flags
openshouldn't need to opt out of populating at all. The cleanest resolution is to settle on a singleopensignature for the read-only path (dropping thepopulateargument) rather than disambiguating at the call site; that removes both the ambiguity and the awkwardfalse.Confirm the two
opendefinitions in scope and whether the trait import is the source of the collision:#!/bin/bash # Find all `open` definitions associated with ReadOnlyRoaringFlags and RoaringFlagsRead ast-grep --pattern $'impl $$$ ReadOnlyRoaringFlags$$$ { $$$ pub fn open($$$) $$$ { $$$ } $$$ }' echo "----- trait RoaringFlagsRead definition -----" rg -nP --type=rust -C3 '\btrait\s+RoaringFlagsRead\b' echo "----- any fn open inside RoaringFlagsRead -----" rg -nP --type=rust -C2 '\bfn\s+open\s*\('🤖 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/index/field_index/bool_index/read_only_bool_index/lifecycle.rs` around lines 24 - 25, The calls to ReadOnlyRoaringFlags::open are ambiguous because two open functions are in scope (the inherent ReadOnlyRoaringFlags::open(fs, path, populate) and a trait-provided RoaringFlagsRead::open), so remove the ambiguity by changing the read-only API: remove the populate bool parameter from the read-only open signature and update the ReadOnlyRoaringFlags impl to provide a single pub fn open(fs, path) -> Result<...> (and remove any trait method that conflicts or implement the trait with a differently named method if needed); then update callers (e.g., the trues_flags and falses_flags usages) to call ReadOnlyRoaringFlags::open(fs, &path.join(...)) without the trailing false so the collision and awkward populate flag are gone.
🤖 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.
Outside diff comments:
In
`@lib/segment/src/index/field_index/bool_index/mutable_bool_index/lifecycle.rs`:
- Around line 27-31: The docs for the function open(Path, create_if_missing) are
stale: they list an `is_on_disk` argument that no longer exists; update the doc
comment above pub fn open(path: &Path, create_if_missing: bool) ->
OperationResult<Option<Self>> by removing the `- `is_on_disk` - If the index
should be kept on disk...` line so the documented `# Arguments` only lists
`path` and `create_if_missing`, matching the open function signature in
lifecycle.rs.
---
Duplicate comments:
In
`@lib/segment/src/index/field_index/bool_index/read_only_bool_index/lifecycle.rs`:
- Around line 24-25: The calls to ReadOnlyRoaringFlags::open are ambiguous
because two open functions are in scope (the inherent
ReadOnlyRoaringFlags::open(fs, path, populate) and a trait-provided
RoaringFlagsRead::open), so remove the ambiguity by changing the read-only API:
remove the populate bool parameter from the read-only open signature and update
the ReadOnlyRoaringFlags impl to provide a single pub fn open(fs, path) ->
Result<...> (and remove any trait method that conflicts or implement the trait
with a differently named method if needed); then update callers (e.g., the
trues_flags and falses_flags usages) to call ReadOnlyRoaringFlags::open(fs,
&path.join(...)) without the trailing false so the collision and awkward
populate flag are gone.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro
Run ID: 98d1cdff-f0bd-414e-88f5-ea1bf7d35fa5
📒 Files selected for processing (12)
lib/segment/src/common/flags/read_only_roaring_flags.rslib/segment/src/index/field_index/bool_index/immutable_bool_index.rslib/segment/src/index/field_index/bool_index/immutable_bool_index/lifecycle.rslib/segment/src/index/field_index/bool_index/immutable_bool_index/mod.rslib/segment/src/index/field_index/bool_index/immutable_bool_index/read_ops.rslib/segment/src/index/field_index/bool_index/mod.rslib/segment/src/index/field_index/bool_index/mutable_bool_index/lifecycle.rslib/segment/src/index/field_index/bool_index/mutable_bool_index/mod.rslib/segment/src/index/field_index/bool_index/mutable_bool_index/read_ops.rslib/segment/src/index/field_index/bool_index/read_only_bool_index/lifecycle.rslib/segment/src/index/field_index/bool_index/read_only_bool_index/mod.rslib/segment/src/index/field_index/bool_index/read_only_bool_index/read_ops.rs
💤 Files with no reviewable changes (1)
- lib/segment/src/index/field_index/bool_index/immutable_bool_index.rs
* feat: add readonly null index open * feat: add open method * refactor: split variants into modules * feat: add get_mutability_type to ReadOnlyBoolIndex * chore: remove duplicated impl * fix: remove populate * chore: add immutable bool index docs
All Submissions:
devbranch (notmaster) and my branch was created fromdev.New Feature Submissions:
cargo +nightly fmt --allcommand prior to submission?cargo clippy --workspace --all-featurescommand?Changes to Core Features: