Skip to content

refactor: split field_index_base.rs into a module - #8965

Merged
generall merged 1 commit into
devfrom
refactor-field-index-base-file
May 9, 2026
Merged

generall merged 1 commit into
devfrom
refactor-field-index-base-file

Conversation

@generall

@generall generall commented May 9, 2026

Copy link
Copy Markdown
Member

Summary

  • Break up the 778-line lib/segment/src/index/field_index/field_index_base.rs into focused submodules under field_index_base/: payload_field_index, value_indexer, field_index, builder.
  • Move NumericFieldIndex / NumericFieldIndexRead out of the umbrella file and into the numeric_index module where they naturally belong.
  • Update the four callers that imported NumericFieldIndex{,Read} via the old crate::index::field_index::* re-export path to use crate::index::field_index::numeric_index::* directly.

Pure refactor — no behavior changes. Public surface in field_index/mod.rs is preserved (pub use field_index_base::*; still exports FieldIndex, FieldIndexBuilder, FieldIndexBuilderTrait, PayloadFieldIndex, ValueIndexer).

Test plan

  • `cargo check -p segment`
  • `cargo check -p segment --tests`
  • CI: full workspace build + segment unit tests

🤖 Generated with Claude Code

Break up the 778-line field_index_base.rs into focused submodules
under field_index_base/ (payload_field_index, value_indexer,
field_index, builder) and relocate NumericFieldIndex /
NumericFieldIndexRead into the numeric_index module where they
naturally belong.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented May 9, 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 704643cf-da44-4481-87b0-a630f4cecbef

📥 Commits

Reviewing files that changed from the base of the PR and between dc1ec94 and 279a0c3.

📒 Files selected for processing (11)
  • lib/segment/src/index/field_index/field_index_base/builder.rs
  • lib/segment/src/index/field_index/field_index_base/field_index.rs
  • lib/segment/src/index/field_index/field_index_base/mod.rs
  • lib/segment/src/index/field_index/field_index_base/payload_field_index.rs
  • lib/segment/src/index/field_index/field_index_base/value_indexer.rs
  • lib/segment/src/index/field_index/numeric_index/mod.rs
  • lib/segment/src/index/field_index/numeric_index/numeric_field_index.rs
  • lib/segment/src/index/payload_index_base.rs
  • lib/segment/src/index/plain_payload_index.rs
  • lib/segment/src/index/struct_payload_index.rs
  • lib/segment/src/segment/read_view/order_by.rs

📝 Walkthrough

Walkthrough

This PR restructures the field-index type hierarchy by extracting abstractions into dedicated submodules. It creates FieldIndexBuilderTrait and FieldIndexBuilder to standardize index builder operations across all types (numeric, map, geo, full-text, bool, UUID, null). The PayloadFieldIndex and ValueIndexer traits are moved from field_index.rs into separate modules, and NumericFieldIndex with NumericFieldIndexRead are extracted into a new numeric-index submodule. A new field_index_base/mod.rs serves as the module entry point with public re-exports. The refactoring updates downstream imports across four consumer files to reference traits from their new submodule paths.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

  • qdrant/qdrant#8841: Uses NumericFieldIndexRead and related field-index APIs introduced by this refactoring for payload/numeric indexing functionality.
  • qdrant/qdrant#8858: Refactors payload/index read interfaces by updating imports to use newly split read-only index traits (NumericFieldIndexRead, PayloadIndexRead).
  • qdrant/qdrant#8647: Modifies the PayloadFieldIndex::filter API signature that is introduced by this PR.

Suggested reviewers

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

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 36.36% 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 'refactor: split field_index_base.rs into a module' accurately summarizes the main change: breaking up a large file into focused submodules.
Description check ✅ Passed The description is directly related to the changeset, detailing the file reorganization, module structure, import updates, and test plan for the refactoring work.
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 refactor-field-index-base-file

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 29b577e into dev May 9, 2026
15 checks passed
@generall
generall deleted the refactor-field-index-base-file branch May 9, 2026 14:56
generall added a commit that referenced this pull request May 22, 2026
Break up the 778-line field_index_base.rs into focused submodules
under field_index_base/ (payload_field_index, value_indexer,
field_index, builder) and relocate NumericFieldIndex /
NumericFieldIndexRead into the numeric_index module where they
naturally belong.

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

1 participant