Skip to content

feat: readonly bool index open - #9200

Merged
dancixx merged 7 commits into
devfrom
feat/readonly-boolindex-open
May 29, 2026
Merged

dancixx merged 7 commits into
devfrom
feat/readonly-boolindex-open

Conversation

@dancixx

@dancixx dancixx commented May 27, 2026 •

Copy link
Copy Markdown
Contributor

All Submissions:

⚠️ PRs must target the dev branch. If your PR targets master, please change the base branch to dev before requesting a review.

  • My PR targets the dev branch (not master) and my branch was created 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?

@coderabbitai

coderabbitai Bot commented May 27, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: e2ebabcc-bca7-4a45-8236-b44ba88e49a7

📥 Commits

Reviewing files that changed from the base of the PR and between c5832ec and 626125f.

📒 Files selected for processing (1)
  • lib/segment/src/index/field_index/bool_index/immutable_bool_index/mod.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • lib/segment/src/index/field_index/bool_index/immutable_bool_index/mod.rs

📝 Walkthrough

Walkthrough

This 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 is a generic read-only wrapper. Read-related traits (BoolIndexRead, PayloadFieldIndexRead, FacetIndex) are delegated to the new read_ops helpers and redundant adapters are removed from the main module.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • qdrant/qdrant#8966: Directly overlaps on splitting PayloadFieldIndexRead trait implementation into a dedicated read_ops submodule for ImmutableBoolIndex.
  • qdrant/qdrant#9030: Intersects on relocation/removal of ReadOnlyBoolIndex<S> value_retriever and FacetIndex implementations from the main bool index module.
  • qdrant/qdrant#8764: Related refactor touching iterator/callback faceting and immutable index surfaces that this PR reorganizes.

Suggested reviewers

  • generall
  • coszio

"I'm a rabbit in the codeglow, hopping through Rust lanes,
Wrapping mutables tidy, keeping read-only gains.
Bitmaps and flags I tend with a carrot-shaped grin,
Flushing and testing — hop! — let new modules begin.
✨🐇"

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: readonly bool index open' directly summarizes the main change: adding an open function for readonly boolean index.
Description check ✅ Passed The description is a standard contribution checklist confirming the PR targets dev, follows guidelines, passes tests, and applies required formatting/linting.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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

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.

@dancixx
dancixx marked this pull request as ready for review May 28, 2026 08:46
@coszio
coszio self-requested a review May 28, 2026 20:15
@dancixx
dancixx marked this pull request as draft May 28, 2026 20:38
@dancixx
dancixx marked this pull request as ready for review May 29, 2026 11:49

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

It's hard to track exactly, but I assume immutable and mutable indexes were just rearranged.

Base automatically changed from feat/readonly-nullindex-open to dev May 29, 2026 20:51
@dancixx
dancixx force-pushed the feat/readonly-boolindex-open branch from 801e3d6 to 50ac53d Compare May 29, 2026 20:52

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

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 win

Stale doc parameter. The # Arguments list documents an is_on_disk parameter that isn't part of open(path, create_if_missing). Drop the is_on_disk line 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 win

Blocking: ReadOnlyRoaringFlags::open call is ambiguous (E0034) and fails to compile.

The CI build reports E0034: multiple applicable items in scope on both open calls. Two open definitions are reachable on ReadOnlyRoaringFlags<S> — most likely the inherent open(fs, path, populate) and an open brought in by the RoaringFlagsRead trait import on Line 8. The compiler cannot pick one, so this needs disambiguation.

This also ties into prior feedback that a read-only flags open shouldn't need to opt out of populating at all. The cleanest resolution is to settle on a single open signature for the read-only path (dropping the populate argument) rather than disambiguating at the call site; that removes both the ambiguity and the awkward false.

Confirm the two open definitions 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

📥 Commits

Reviewing files that changed from the base of the PR and between 6c7458d and 50ac53d.

📒 Files selected for processing (12)
  • lib/segment/src/common/flags/read_only_roaring_flags.rs
  • lib/segment/src/index/field_index/bool_index/immutable_bool_index.rs
  • lib/segment/src/index/field_index/bool_index/immutable_bool_index/lifecycle.rs
  • lib/segment/src/index/field_index/bool_index/immutable_bool_index/mod.rs
  • lib/segment/src/index/field_index/bool_index/immutable_bool_index/read_ops.rs
  • lib/segment/src/index/field_index/bool_index/mod.rs
  • lib/segment/src/index/field_index/bool_index/mutable_bool_index/lifecycle.rs
  • lib/segment/src/index/field_index/bool_index/mutable_bool_index/mod.rs
  • lib/segment/src/index/field_index/bool_index/mutable_bool_index/read_ops.rs
  • lib/segment/src/index/field_index/bool_index/read_only_bool_index/lifecycle.rs
  • lib/segment/src/index/field_index/bool_index/read_only_bool_index/mod.rs
  • lib/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

@dancixx
dancixx merged commit b0fe45d into dev May 29, 2026
15 checks passed
@dancixx
dancixx deleted the feat/readonly-boolindex-open branch May 29, 2026 21:25
@generall generall added this to the Live-reload milestone May 30, 2026
timvisee pushed a commit that referenced this pull request Jun 3, 2026
* 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
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.

3 participants