Skip to content

refactor: split PayloadFieldIndex into read + write traits - #8966

Merged
generall merged 1 commit into
devfrom
refactor-payload-field-index-read-trait
May 9, 2026
Merged

generall merged 1 commit into
devfrom
refactor-payload-field-index-read-trait

Conversation

@generall

@generall generall commented May 9, 2026

Copy link
Copy Markdown
Member

Summary

  • Split PayloadFieldIndex into a read-only supertrait PayloadFieldIndexRead (carrying count_indexed_points, filter, estimate_cardinality, for_each_payload_block) and the existing PayloadFieldIndex: PayloadFieldIndexRead for storage-lifecycle methods (wipe, flusher, files, immutable_files).
  • Mirrors the existing IdTracker / IdTrackerRead split — lets read-only consumers depend on the query surface without pulling in storage-lifecycle methods.
  • Updated all 11 impls (numeric_index, map_index x3, null_index x3, bool_index x3, full_text_index, geo_index) to split into two impl blocks.
  • Adjusted test imports that call read-side methods (numeric_index/tests.rs, full_text_index/tests/test_congruence.rs, mutable_text_index.rs).

Pure refactor — no behavior changes. Trait-object users (&dyn PayloadFieldIndex) still get all methods through the supertrait.

Test plan

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

🤖 Generated with Claude Code

…ldIndexRead

Mirror the IdTracker / IdTrackerRead split. PayloadFieldIndexRead holds the
read-only query surface (count_indexed_points, filter, estimate_cardinality,
for_each_payload_block); PayloadFieldIndex: PayloadFieldIndexRead retains
storage-lifecycle methods (wipe, flusher, files, immutable_files).

All 11 impls updated (numeric_index, map_index x3, null_index x3, bool_index
x3, full_text_index, geo_index). Test imports adjusted where they use the
read-side methods.

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: d178c26f-6018-4641-99a6-6628d8b04ddc

📥 Commits

Reviewing files that changed from the base of the PR and between 29b577e and bf3134d.

📒 Files selected for processing (15)
  • lib/segment/src/index/field_index/bool_index/immutable_bool_index.rs
  • lib/segment/src/index/field_index/bool_index/mod.rs
  • lib/segment/src/index/field_index/bool_index/mutable_bool_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/full_text_index/mutable_text_index.rs
  • lib/segment/src/index/field_index/full_text_index/tests/test_congruence.rs
  • lib/segment/src/index/field_index/full_text_index/text_index.rs
  • lib/segment/src/index/field_index/geo_index/mod.rs
  • lib/segment/src/index/field_index/map_index/mod.rs
  • lib/segment/src/index/field_index/null_index/immutable_null_index.rs
  • lib/segment/src/index/field_index/null_index/mod.rs
  • lib/segment/src/index/field_index/null_index/mutable_null_index.rs
  • lib/segment/src/index/field_index/numeric_index/mod.rs
  • lib/segment/src/index/field_index/numeric_index/tests.rs

📝 Walkthrough

Walkthrough

This pull request refactors the payload field index trait system to separate read and write concerns. A new PayloadFieldIndexRead trait is introduced to expose query capabilities (count_indexed_points, filter, estimate_cardinality, for_each_payload_block), while PayloadFieldIndex is narrowed to lifecycle and storage operations (wipe, flusher, files, immutable_files), with PayloadFieldIndex now extending PayloadFieldIndexRead as a supertrait. All implementations across bool, null, numeric, map, full-text, and geo index types are refactored to define separate trait blocks, moving read methods into the new trait.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • qdrant/qdrant#8858: Similar trait refactoring pattern introducing a new read-only trait and moving existing read/query methods into separate trait implementations across the same payload index infrastructure.
  • qdrant/qdrant#8841: Related refactoring of payload field index trait structure and implementations to add PayloadFieldIndexRead and reorganize read/query methods.
  • qdrant/qdrant#8965: Precursor refactoring that restructures the field_index_base module and introduces payload_field_index.rs, enabling the trait extraction done in this PR.

Suggested labels

release:1.18.0

Suggested reviewers

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

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 32.31% 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 PayloadFieldIndex into read + write traits' accurately and concisely describes the main change: splitting a trait into read-only and write trait components.
Description check ✅ Passed The description comprehensively covers the changeset, explaining the trait split pattern, all affected implementations, test adjustments, and confirming no behavior changes occurred.
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-payload-field-index-read-trait

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 a85ab22 into dev May 9, 2026
15 checks passed
@generall
generall deleted the refactor-payload-field-index-read-trait branch May 9, 2026 15:51
@generall generall mentioned this pull request May 10, 2026
2 of 3 tasks
generall added a commit that referenced this pull request May 10, 2026
Mirror the PayloadFieldIndex / PayloadFieldIndexRead split (#8966) one layer
up at the FieldIndex enum level. FieldIndexRead names the uniform read-only
surface (filter, estimate_cardinality, count_indexed_points,
for_each_payload_block, get_telemetry_data, values_count, values_is_empty,
special_check_condition, as_numeric, as_facet_index) — the methods that
StructPayloadIndexReadView and its helpers reach through IndexesMap.

Trait declaration only. No impl, no callers in this PR — this is purely
additive. Follow-up PRs will impl it on FieldIndex, then migrate
non-destructuring helpers to a FieldIndexRead bound.

as_numeric and as_facet_index use return-position impl Trait
(impl NumericFieldIndexRead + '_, impl FacetIndex + '_), matching how
PayloadIndexRead exposes the same shapes. The trait is therefore not
object-safe; consumers will use a generic bound rather than
&dyn FieldIndexRead.

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
generall added a commit that referenced this pull request May 22, 2026
…ldIndexRead (#8966)

Mirror the IdTracker / IdTrackerRead split. PayloadFieldIndexRead holds the
read-only query surface (count_indexed_points, filter, estimate_cardinality,
for_each_payload_block); PayloadFieldIndex: PayloadFieldIndexRead retains
storage-lifecycle methods (wipe, flusher, files, immutable_files).

All 11 impls updated (numeric_index, map_index x3, null_index x3, bool_index
x3, full_text_index, geo_index). Test imports adjusted where they use the
read-side methods.

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
generall added a commit that referenced this pull request May 22, 2026
Mirror the PayloadFieldIndex / PayloadFieldIndexRead split (#8966) one layer
up at the FieldIndex enum level. FieldIndexRead names the uniform read-only
surface (filter, estimate_cardinality, count_indexed_points,
for_each_payload_block, get_telemetry_data, values_count, values_is_empty,
special_check_condition, as_numeric, as_facet_index) — the methods that
StructPayloadIndexReadView and its helpers reach through IndexesMap.

Trait declaration only. No impl, no callers in this PR — this is purely
additive. Follow-up PRs will impl it on FieldIndex, then migrate
non-destructuring helpers to a FieldIndexRead bound.

as_numeric and as_facet_index use return-position impl Trait
(impl NumericFieldIndexRead + '_, impl FacetIndex + '_), matching how
PayloadIndexRead exposes the same shapes. The trait is therefore not
object-safe; consumers will use a generic bound rather than
&dyn FieldIndexRead.

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

1 participant