Skip to content

refactor: split id_tracker_base.rs into a module - #8804

Merged
generall merged 1 commit into
devfrom
refactor/split-id-tracker-base
Apr 27, 2026
Merged

generall merged 1 commit into
devfrom
refactor/split-id-tracker-base

Conversation

@generall

Copy link
Copy Markdown
Member

Summary

  • Break the 501-line id_tracker_base.rs into a directory module, mirroring the recent mutable_id_tracker refactor (refactor: split mutable_id_tracker.rs into a module #8795).
  • trait_def.rs holds the IdTracker trait and the SEED / DELETED_POINT_VERSION constants; point_mappings_ref.rs holds PointMappingsRefEnum and the PointMappingsGuard self_cell; tracker_enum.rs holds IdTrackerEnum and its IdTracker impl; mod.rs just re-exports.
  • No logic changes. The parent id_tracker/mod.rs keeps pub use id_tracker_base::*;, so external imports resolve unchanged.

Test plan

  • mold -run cargo clippy --all-targets — clean

@coderabbitai

coderabbitai Bot commented Apr 27, 2026 •

Copy link
Copy Markdown
Contributor

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: e231dba4-0055-4d96-9083-a20aae6913a9

📥 Commits

Reviewing files that changed from the base of the PR and between 76f3cc7 and 3cb63ec.

📒 Files selected for processing (5)
  • lib/segment/src/id_tracker/id_tracker_base.rs
  • lib/segment/src/id_tracker/id_tracker_base/mod.rs
  • lib/segment/src/id_tracker/id_tracker_base/point_mappings_ref.rs
  • lib/segment/src/id_tracker/id_tracker_base/tracker_enum.rs
  • lib/segment/src/id_tracker/id_tracker_base/trait_def.rs
💤 Files with no reviewable changes (1)
  • lib/segment/src/id_tracker/id_tracker_base.rs
✅ Files skipped from review due to trivial changes (1)
  • lib/segment/src/id_tracker/id_tracker_base/mod.rs

📝 Walkthrough

Walkthrough

The PR removes a single-file id-tracker base and replaces it with a modular layout under id_tracker_base/: trait_def.rs (reintroduces the IdTracker trait and DELETED_POINT_VERSION), tracker_enum.rs (adds IdTrackerEnum delegating to concrete trackers), point_mappings_ref.rs (adds PointMappingsRefEnum and PointMappingsGuard with iterator adapters), and mod.rs (re-exports the public items). Functionality for ID mapping, version management, deletion semantics, iteration, sampling, and consistency fixing is restructured across these new modules.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • timvisee
  • generall
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The PR title accurately reflects the main change: refactoring a single file into a modular structure.
Description check ✅ Passed The description clearly explains the refactoring: splitting a 501-line file into separate modules with specific responsibilities, following a prior pattern, and confirming no logic changes.
Docstring Coverage ✅ Passed Docstring coverage is 93.55% 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
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/split-id-tracker-base

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.

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

🧹 Nitpick comments (1)
lib/segment/src/id_tracker/id_tracker_base/point_mappings_ref.rs (1)

80-122: Optional: align receiver types for the _visible variants.

iter_internal, iter_from, and iter_random (lines 25–63) take self, but their _visible counterparts take &self. Since PointMappingsRefEnum<'a> is Copy, taking self would let the returned iterators carry the full 'a lifetime instead of being narrowed to '_ of &self, matching the non-visible variants. Pure code move here, so feel free to defer — flagging only as a follow-up cleanup opportunity.

♻️ Suggested signature alignment
-    pub fn iter_internal_visible(
-        &self,
-        deferred_internal_id: Option<PointOffsetType>,
-    ) -> Box<dyn Iterator<Item = PointOffsetType> + '_> {
+    pub fn iter_internal_visible(
+        self,
+        deferred_internal_id: Option<PointOffsetType>,
+    ) -> Box<dyn Iterator<Item = PointOffsetType> + 'a> {

(and similarly for iter_from_visible / iter_random_visible)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/segment/src/id_tracker/id_tracker_base/point_mappings_ref.rs` around
lines 80 - 122, The `_visible` methods currently take `&self` which narrows the
returned iterator lifetime; change the receivers to take `self` for
iter_internal_visible, iter_from_visible, and iter_random_visible so they match
the non-visible variants (iter_internal, iter_from, iter_random) and allow the
iterators to carry the full `'a` lifetime; update the method signatures to
consume `self` and keep the existing match/logic and closures (move patterns)
intact.
🤖 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/id_tracker/id_tracker_base/point_mappings_ref.rs`:
- Around line 80-122: The `_visible` methods currently take `&self` which
narrows the returned iterator lifetime; change the receivers to take `self` for
iter_internal_visible, iter_from_visible, and iter_random_visible so they match
the non-visible variants (iter_internal, iter_from, iter_random) and allow the
iterators to carry the full `'a` lifetime; update the method signatures to
consume `self` and keep the existing match/logic and closures (move patterns)
intact.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 522ef13e-b7e0-423d-a879-697e8eec4c14

📥 Commits

Reviewing files that changed from the base of the PR and between ca4ed7a and 76f3cc7.

📒 Files selected for processing (5)
  • lib/segment/src/id_tracker/id_tracker_base.rs
  • lib/segment/src/id_tracker/id_tracker_base/mod.rs
  • lib/segment/src/id_tracker/id_tracker_base/point_mappings_ref.rs
  • lib/segment/src/id_tracker/id_tracker_base/tracker_enum.rs
  • lib/segment/src/id_tracker/id_tracker_base/trait_def.rs
💤 Files with no reviewable changes (1)
  • lib/segment/src/id_tracker/id_tracker_base.rs

Break the 501-line file into a directory module with logically separated
components: trait_def.rs (IdTracker trait + constants), point_mappings_ref.rs
(PointMappingsRefEnum + PointMappingsGuard), tracker_enum.rs (IdTrackerEnum +
its IdTracker impl), and mod.rs (re-exports). No logic changes.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@qdrant-cloud-bot
qdrant-cloud-bot force-pushed the refactor/split-id-tracker-base branch from 76f3cc7 to 3cb63ec Compare April 27, 2026 21:12
@generall
generall merged commit d4cbb61 into dev Apr 27, 2026
20 of 22 checks passed
@generall
generall deleted the refactor/split-id-tracker-base branch April 27, 2026 22:07
timvisee pushed a commit that referenced this pull request May 8, 2026
Break the 501-line file into a directory module with logically separated
components: trait_def.rs (IdTracker trait + constants), point_mappings_ref.rs
(PointMappingsRefEnum + PointMappingsGuard), tracker_enum.rs (IdTrackerEnum +
its IdTracker impl), and mod.rs (re-exports). No logic changes.

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.

2 participants