Repository navigation
Explicit point_mappings guard in IdTracker - #8261
Conversation
point_mappnigs guard in the APIpoint_mappnigs in the API
There was a problem hiding this comment.
Actionable comments posted: 5
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
lib/shard/src/proxy_segment/segment_entry.rs (1)
236-240:⚠️ Potential issue | 🔴 CriticalFix comment text and address that dedup cannot process proxy segments.
The method is
get_points, notiter_points. More importantly,find_duplicated_points()at line 918 callsself.get_points()to retrieve all segments, then calls.iter_points()on each segment (line 928 in segment_holder/mod.rs)—which will invokeget_points()on proxy segments and panic during deduplication. Either:
- Exclude proxy segments from dedup iteration using
iter_original()pattern (as used elsewhere for optimizers), or- Implement
get_points()for proxy segments to delegate to the wrapped segment with appropriate point filtering.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lib/shard/src/proxy_segment/segment_entry.rs` around lines 236 - 240, The get_points() stub on ProxySegment currently panics and causes find_duplicated_points() (which calls self.get_points() then .iter_points() on each segment) to fail for proxy segments; either skip proxy segments during dedup by using the iter_original() pattern where segments are iterated over their original/non-proxy implementations, or implement ProxySegment::get_points() to delegate to the wrapped segment’s get_points()/iter_points() while applying the correct point filtering/visibility logic so it returns a valid PointExternalIterator instead of unimplemented!; update references in find_duplicated_points() / segment iteration so proxy segments are excluded or return a real iterator (refer to get_points, iter_points, iter_original, and find_duplicated_points to locate affected code).
🧹 Nitpick comments (2)
lib/collection/src/collection_manager/optimizers/vacuum_optimizer.rs (1)
370-373: Useget_points()consistently and fix the typo in the comment.This block still uses
iter_points().iter()while neighboring updates useget_points().iter().♻️ Suggested cleanup
- // Deget_points points + // Delete points let segment_points_to_delete = segment - .iter_points() + .get_points() .iter() .enumerate()🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lib/collection/src/collection_manager/optimizers/vacuum_optimizer.rs` around lines 370 - 373, The comment "Deget_points points" is a typo and the code uses segment.iter_points().iter() inconsistently; change the comment to "Deleted points" (or "Delete points") and replace segment.iter_points().iter() with segment.get_points().iter() so it matches neighboring code and uses the correct accessor (reference the variable segment_points_to_delete and method names iter_points and get_points in vacuum_optimizer.rs).lib/segment/src/segment/entry.rs (1)
257-261: Renameowinging_guardtoowning_guardfor clarity in unsafe-adjacent code.This makes the block easier to audit.
🧹 Suggested rename
- let owinging_guard = + let owning_guard = unsafe { OwningGuard::new(id_tracker_guard, IdTrackerEnum::point_mappings) }; PointExternalIterator { - mappings: owinging_guard, + mappings: owning_guard, }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lib/segment/src/segment/entry.rs` around lines 257 - 261, The variable name owinging_guard is a typo and should be renamed to owning_guard where it's created (unsafe { OwningGuard::new(id_tracker_guard, IdTrackerEnum::point_mappings) }) and where it's used to construct PointExternalIterator { mappings: ... }; update the identifier consistently to owning_guard to improve clarity around the unsafe block and the OwningGuard usage.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@lib/common/common/src/guards.rs`:
- Around line 26-28: The safety docs currently reference `inner_guard_fn` but
the actual parameter is named `inner_value_fn`; update the unsafe contract text
in guards.rs so all occurrences of `inner_guard_fn` are renamed to
`inner_value_fn` (and similarly verify any related mentions like `outer_guard`
remain correct) to ensure the doc matches the function signature and the unsafe
API contract precisely.
In `@lib/segment/src/id_tracker/id_tracker_base.rs`:
- Around line 256-259: Update the documentation on PointExternalIterator to
reference the current API: replace the stale mention of
NonAppendableSegmentEntry::iter_points() with
NonAppendableSegmentEntry::get_points(); edit the doc comment above
PointExternalIterator where it describes usage to mention get_points() as the
method that returns the external ID iterator and ensure wording reflects the new
method name (PointExternalIterator, NonAppendableSegmentEntry::get_points()) so
docs align with the current API.
In `@lib/segment/src/segment/tests.rs`:
- Line 277: The test still calls segment.iter_points() but the API now exposes
get_points(); update the loop to iterate over segment.get_points().iter() (or
directly segment.get_points().iter() in the for loop) wherever iter_points() is
referenced (e.g., the loop using iter_points() at the test harness), ensuring
you replace calls to iter_points() with get_points() and keep .iter() to iterate
over the returned collection.
- Around line 268-271: The assert_eq! invocation is broken by an extraneous
token "get_points"; remove the stray "get_points" so the assertion reads
assert_eq!(segment.available_point_count(),
restored_segment.available_point_count()); (locate the broken macro call around
assert_eq!, get_points, segment.available_point_count, and
restored_segment.available_point_count and fix the macro invocation to have only
the two arguments and optional message).
In `@lib/shard/src/optimize.rs`:
- Around line 381-383: Fix the typo and improve readability in the comment that
currently reads "Avoid unnecessary point removing in the cget_pointstion:" (the
comment block above the post-optimization removal logic in optimize.rs); replace
"cget_pointstion" with "critical section" and consider changing "point removing"
to "point removal" so the comment reads something like "Avoid unnecessary point
removal in the critical section: - save already removed points while avoiding
long read locks - exclude already removed points from post-optimization
removing".
---
Outside diff comments:
In `@lib/shard/src/proxy_segment/segment_entry.rs`:
- Around line 236-240: The get_points() stub on ProxySegment currently panics
and causes find_duplicated_points() (which calls self.get_points() then
.iter_points() on each segment) to fail for proxy segments; either skip proxy
segments during dedup by using the iter_original() pattern where segments are
iterated over their original/non-proxy implementations, or implement
ProxySegment::get_points() to delegate to the wrapped segment’s
get_points()/iter_points() while applying the correct point filtering/visibility
logic so it returns a valid PointExternalIterator instead of unimplemented!;
update references in find_duplicated_points() / segment iteration so proxy
segments are excluded or return a real iterator (refer to get_points,
iter_points, iter_original, and find_duplicated_points to locate affected code).
---
Nitpick comments:
In `@lib/collection/src/collection_manager/optimizers/vacuum_optimizer.rs`:
- Around line 370-373: The comment "Deget_points points" is a typo and the code
uses segment.iter_points().iter() inconsistently; change the comment to "Deleted
points" (or "Delete points") and replace segment.iter_points().iter() with
segment.get_points().iter() so it matches neighboring code and uses the correct
accessor (reference the variable segment_points_to_delete and method names
iter_points and get_points in vacuum_optimizer.rs).
In `@lib/segment/src/segment/entry.rs`:
- Around line 257-261: The variable name owinging_guard is a typo and should be
renamed to owning_guard where it's created (unsafe {
OwningGuard::new(id_tracker_guard, IdTrackerEnum::point_mappings) }) and where
it's used to construct PointExternalIterator { mappings: ... }; update the
identifier consistently to owning_guard to improve clarity around the unsafe
block and the OwningGuard usage.
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (31)
lib/collection/src/collection_manager/optimizers/vacuum_optimizer.rslib/collection/src/collection_manager/tests/mod.rslib/common/common/src/guards.rslib/common/common/src/lib.rslib/segment/src/entry/entry_point.rslib/segment/src/id_tracker/id_tracker_base.rslib/segment/src/id_tracker/immutable_id_tracker.rslib/segment/src/id_tracker/in_memory_id_tracker.rslib/segment/src/id_tracker/mod.rslib/segment/src/id_tracker/mutable_id_tracker.rslib/segment/src/id_tracker/simple_id_tracker.rslib/segment/src/index/hnsw_index/hnsw.rslib/segment/src/index/plain_payload_index.rslib/segment/src/index/query_optimization/condition_converter.rslib/segment/src/index/sparse_index/sparse_vector_index.rslib/segment/src/index/struct_payload_index.rslib/segment/src/segment/entry.rslib/segment/src/segment/sampling.rslib/segment/src/segment/scroll.rslib/segment/src/segment/segment_ops.rslib/segment/src/segment/tests.rslib/segment/src/segment_constructor/segment_constructor_base.rslib/segment/src/vector_storage/dense/memmap_dense_vector_storage.rslib/segment/src/vector_storage/tests/test_appendable_dense_vector_storage.rslib/segment/tests/integration/payload_index_test.rslib/segment/tests/integration/segment_builder_test.rslib/segment/tests/integration/segment_on_disk_snapshot.rslib/segment/tests/integration/segment_tests.rslib/shard/src/optimize.rslib/shard/src/proxy_segment/segment_entry.rslib/shard/src/segment_holder/mod.rs
point_mappnigs in the APIpoint_mappings in the API
1d761dc to
5e39fd5
Compare
5dabf89 to
ffd38f1
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
lib/segment/src/segment/entry.rs (1)
252-261: Minor naming typo in guard variable.Consider renaming
owinging_guardtoowning_guardfor readability and consistency withOwningGuard.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lib/segment/src/segment/entry.rs` around lines 252 - 261, Rename the misspelled local variable `owinging_guard` to `owning_guard` in fn get_points so the OwningGuard returned by unsafe { OwningGuard::new(id_tracker_guard, IdTrackerEnum::point_mappings) } is assigned to `owning_guard` and then used in PointMappingsGuard { mappings: owning_guard }, keeping id_tracker_guard and IdTrackerEnum::point_mappings references unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@lib/shard/src/proxy_segment/segment_entry.rs`:
- Around line 236-240: ProxySegment::get_points() currently panics via
unimplemented!() and is reachable from production through
deduplicate_points_tasks() → find_duplicated_points() which iterates all
segments in SegmentHolder and calls get_points(); fix by either (A) preventing
ProxySegment instances from being iterated there (use
SegmentHolder::iter_original() or add a predicate to skip proxies inside
find_duplicated_points()/deduplicate_points_tasks()), or (B) provide a safe
non-panicking implementation in ProxySegment::get_points() that returns an empty
or appropriately-formed PointMappingsGuard fallback; locate the symbols
ProxySegment::get_points, SegmentHolder, find_duplicated_points,
deduplicate_points_tasks, and iter_original to apply the chosen change.
---
Nitpick comments:
In `@lib/segment/src/segment/entry.rs`:
- Around line 252-261: Rename the misspelled local variable `owinging_guard` to
`owning_guard` in fn get_points so the OwningGuard returned by unsafe {
OwningGuard::new(id_tracker_guard, IdTrackerEnum::point_mappings) } is assigned
to `owning_guard` and then used in PointMappingsGuard { mappings: owning_guard
}, keeping id_tracker_guard and IdTrackerEnum::point_mappings references
unchanged.
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (12)
lib/collection/src/collection_manager/optimizers/vacuum_optimizer.rslib/collection/src/collection_manager/tests/mod.rslib/segment/src/entry/entry_point.rslib/segment/src/id_tracker/id_tracker_base.rslib/segment/src/segment/entry.rslib/segment/src/segment/tests.rslib/segment/tests/integration/segment_builder_test.rslib/segment/tests/integration/segment_on_disk_snapshot.rslib/segment/tests/integration/segment_tests.rslib/shard/src/optimize.rslib/shard/src/proxy_segment/segment_entry.rslib/shard/src/segment_holder/mod.rs
🚧 Files skipped from review as they are similar to previous changes (4)
- lib/shard/src/optimize.rs
- lib/segment/tests/integration/segment_tests.rs
- lib/segment/tests/integration/segment_on_disk_snapshot.rs
- lib/shard/src/segment_holder/mod.rs
| /// Owning guard holder. | ||
| pub struct OwningGuard<'ctx, Outer, Inner> | ||
| where | ||
| Outer: 'ctx, | ||
| { | ||
| // Fields are dropped in the order of their definition. It is important to drop the `inner_value` first. | ||
| inner_value: Inner, | ||
| _outer_guard: Outer, | ||
| phantom: PhantomData<&'ctx ()>, | ||
| } |
There was a problem hiding this comment.
I think this struct can be replaced by self_cell. We already have a few usages of it.
| pub fn iter_external(self) -> Box<dyn Iterator<Item = PointIdType> + 'a> { | ||
| match self { | ||
| PointMappingsRefEnum::Plain(m) => m.iter_external(), | ||
| PointMappingsRefEnum::Compressed(m) => m.iter_external(), | ||
| } | ||
| } |
There was a problem hiding this comment.
Performance: use enum dispatch instead of Box<dyn Iterator>.
either::Either implements iterator boilerplate for two-variant enums. So, it'll look like this:
pub fn iter_external(self) -> impl Iterator<Item = PointIdType> {
match self {
PointMappingsRefEnum::Plain(m) => Either::Left(m.iter_external()),
PointMappingsRefEnum::Compressed(m) => Either::Right(m.iter_external()),
}
}If we decide to add more variants, it can be chained, e.g.:
Either<Either<A, B>, C>
There was a problem hiding this comment.
I've tried to implement it. There are cases where there's 3 variants returned from PointMappings, but then it goes down to IdTrackerEnum which has 4 cases, so there's deeply nested Either. I wonder if it is still faster than dyn dispatch.
There was a problem hiding this comment.
I'd say enum dispatch would still be preferred because it compiles with better optimizations, even for like inlining next() calls. If we keep using impl Iterator as return type, the nesting should not be a problem for ergonomics.
There's also auto_enums crate which makes the +2 variants case more ergonomic to write
There was a problem hiding this comment.
Well, it can be simplified if implementations refer to point_mappings directly. While there are several implementations of IdTracker, they all use only two point mappings implementations. But I suggest doing it in another PR.
|
Please add explicit description and motivation of what is changed in this PR and why |
| /// Enum holding a reference to point mappings from an ID tracker. | ||
| /// | ||
| /// Provides iteration methods over external/internal IDs without requiring | ||
| /// the `IdTracker` trait to return boxed iterators. |
There was a problem hiding this comment.
While we don't return a boxed iterator from the trait, now we do still return it from pub fn iter_external(self) (and others) below
ba6c529 to
8b9ca4e
Compare
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThis PR consolidates IdTracker iteration by removing multiple iterator-returning trait methods and adding a single point_mappings() accessor that returns PointMappingsRefEnum (Plain | Compressed). PointMappingsRefEnum exposes iterator methods that delegate to the underlying mapping. Implementations (InMemory, Immutable, Mutable, Simple, and IdTrackerEnum) and all call sites across segment, index, payload, vector storage, sampling, scroll, and segment construction code were updated to use point_mappings(). A PointMappingsGuard (self_cell) was added to safely couple lifetimes for guarded iteration. A Cargo.toml dependency syntax tweak was also applied. Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
📝 Coding Plan
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
lib/segment/src/segment/order_by.rs (1)
45-50: Avoid re-enteringIdTrackerwhile the mappings view is live.Given the stated goal of moving
point_mappingsunder a lock, this iterator still keeps the mappings view alive while resolving each hit throughid_tracker.external_id(). If that lookup ends up taking the same lock, this path will need another pass. Consider either exposing the reverse lookup on the mappings view itself, or materializing the internal IDs before calling back intoid_tracker.Also applies to: 67-70
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lib/segment/src/segment/order_by.rs` around lines 45 - 50, The iterator returned by payload_index.iter_filtered_points holds point_mappings while you later call back into id_tracker.external_id(), risking re-entering IdTracker; fix by materializing the internal IDs (e.g., collect the iterator into a Vec of internal IDs) before any external_id lookups or by adding a reverse-lookup method on the point_mappings view so you can resolve external IDs without calling id_tracker again; update the code paths around point_mappings, payload_index.iter_filtered_points, and id_tracker.external_id to use the chosen approach to avoid holding the mappings view while re-entering IdTracker.lib/segment/src/index/struct_payload_index.rs (1)
620-625: Avoid a splitid_tracker/point_mappingscontract here.
iter_filtered_points()now accepts two values that must come from the same tracker, but the signature does not enforce that. Since this method only still usesid_trackerfortotal_point_count(), consider collapsing that dependency before this API spreads further.Also applies to: 642-642
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lib/segment/src/index/struct_payload_index.rs` around lines 620 - 625, iter_filtered_points currently takes both id_tracker: IdTrackerEnum and point_mappings: PointMappingsRefEnum but only uses id_tracker for total_point_count(), creating a fragile split contract; change the API to accept a single tracker/mappings object instead (e.g., replace the two params with a single enum/trait that exposes both point_mappings accessors and total_point_count(), or remove id_tracker and call total_point_count() through the existing point_mappings variant if it can provide it), update iter_filtered_points signature and all callers to pass the unified tracker/mappings value, and remove any direct references to IdTrackerEnum in this function so the contract requiring paired values is enforced by the type system.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@lib/segment/tests/integration/segment_tests.rs`:
- Around line 68-69: The test currently builds both point_ids1 and point_ids2
from the same call to segment.get_points(), so the assert_eq! only verifies
deterministic iteration rather than comparing two independent API paths; change
the second collection to use a different API or data source (for example call a
different accessor such as segment.get_point_ids() or iterate points via another
method / map lookup provided by the Segment type) so that point_ids2 is produced
by a distinct code path from get_points(), then assert_eq!(point_ids1,
point_ids2) to validate API consistency (update both occurrences around the
other assertion at lines 126-127 similarly).
---
Nitpick comments:
In `@lib/segment/src/index/struct_payload_index.rs`:
- Around line 620-625: iter_filtered_points currently takes both id_tracker:
IdTrackerEnum and point_mappings: PointMappingsRefEnum but only uses id_tracker
for total_point_count(), creating a fragile split contract; change the API to
accept a single tracker/mappings object instead (e.g., replace the two params
with a single enum/trait that exposes both point_mappings accessors and
total_point_count(), or remove id_tracker and call total_point_count() through
the existing point_mappings variant if it can provide it), update
iter_filtered_points signature and all callers to pass the unified
tracker/mappings value, and remove any direct references to IdTrackerEnum in
this function so the contract requiring paired values is enforced by the type
system.
In `@lib/segment/src/segment/order_by.rs`:
- Around line 45-50: The iterator returned by payload_index.iter_filtered_points
holds point_mappings while you later call back into id_tracker.external_id(),
risking re-entering IdTracker; fix by materializing the internal IDs (e.g.,
collect the iterator into a Vec of internal IDs) before any external_id lookups
or by adding a reverse-lookup method on the point_mappings view so you can
resolve external IDs without calling id_tracker again; update the code paths
around point_mappings, payload_index.iter_filtered_points, and
id_tracker.external_id to use the chosen approach to avoid holding the mappings
view while re-entering IdTracker.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 3c58038c-eb3d-4231-af00-796687c372e5
📒 Files selected for processing (33)
lib/collection/src/collection_manager/optimizers/vacuum_optimizer.rslib/collection/src/collection_manager/tests/mod.rslib/collection/src/tests/deferred_points_dedup.rslib/segment/Cargo.tomllib/segment/src/entry/entry_point.rslib/segment/src/id_tracker/id_tracker_base.rslib/segment/src/id_tracker/immutable_id_tracker.rslib/segment/src/id_tracker/in_memory_id_tracker.rslib/segment/src/id_tracker/mod.rslib/segment/src/id_tracker/mutable_id_tracker.rslib/segment/src/id_tracker/simple_id_tracker.rslib/segment/src/index/hnsw_index/hnsw.rslib/segment/src/index/plain_payload_index.rslib/segment/src/index/query_optimization/condition_converter.rslib/segment/src/index/sparse_index/sparse_vector_index.rslib/segment/src/index/struct_payload_index.rslib/segment/src/segment/entry.rslib/segment/src/segment/facet.rslib/segment/src/segment/order_by.rslib/segment/src/segment/sampling.rslib/segment/src/segment/scroll.rslib/segment/src/segment/segment_ops.rslib/segment/src/segment/tests.rslib/segment/src/segment_constructor/segment_constructor_base.rslib/segment/src/vector_storage/dense/memmap_dense_vector_storage.rslib/segment/src/vector_storage/tests/test_appendable_dense_vector_storage.rslib/segment/tests/integration/payload_index_test.rslib/segment/tests/integration/segment_builder_test.rslib/segment/tests/integration/segment_on_disk_snapshot.rslib/segment/tests/integration/segment_tests.rslib/shard/src/optimize.rslib/shard/src/proxy_segment/segment_entry.rslib/shard/src/segment_holder/mod.rs
coszio
left a comment
There was a problem hiding this comment.
Since we already had dynamic dispatch for all these cases, current changes are only improving code, so I'll approve. Please consider the renaming nits, though.
| pub fn iter_external(self) -> Box<dyn Iterator<Item = PointIdType> + 'a> { | ||
| match self { | ||
| PointMappingsRefEnum::Plain(m) => m.iter_external(), | ||
| PointMappingsRefEnum::Compressed(m) => m.iter_external(), | ||
| } | ||
| } |
There was a problem hiding this comment.
I'd say enum dispatch would still be preferred because it compiles with better optimizations, even for like inlining next() calls. If we keep using impl Iterator as return type, the nesting should not be a problem for ergonomics.
There's also auto_enums crate which makes the +2 variants case more ergonomic to write
Instead of IdTracker to have iter_* methods, it returns point mappings object that can be extended to contain a lock guard.
Fix potentially incorrect `unsafe` (it is still `unsafe`, but correct one).
to `get_points` because it doesn't return an iterator anymore.
6a18437 to
0196133
Compare
There was a problem hiding this comment.
♻️ Duplicate comments (1)
lib/segment/tests/integration/segment_tests.rs (1)
68-69:⚠️ Potential issue | 🟡 MinorUse an independent source for
point_ids2(current assertion is tautological).At Line 68 and Line 126, both sides of
assert_eq!come from the same call path, so the test only checks determinism, not API consistency.🔧 Suggested test adjustment
- let point_ids2: Vec<_> = segment.get_points().iter().collect(); + let point_ids2 = segment.read_range(None, None); ... - let point_ids2: Vec<_> = segment.get_points().iter().collect(); + let point_ids2 = segment.read_range(None, None);Also applies to: 126-127
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lib/segment/tests/integration/segment_tests.rs` around lines 68 - 69, The test currently assigns both point_ids1 and point_ids2 from the same call path (segment.get_points()), making the assert_eq! tautological; change point_ids2 to come from an independent source — for example, collect expected IDs from the original data fixture or from a second segment instance (or a different API such as segment.get_point_ids()/segment.iter_points() if available) and then compare that independent list to point_ids1; update uses of point_ids2 at both the earlier (point_ids1/point_ids2) and later (lines around the second assertion) locations so the assertions validate API consistency rather than determinism.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@lib/segment/tests/integration/segment_tests.rs`:
- Around line 68-69: The test currently assigns both point_ids1 and point_ids2
from the same call path (segment.get_points()), making the assert_eq!
tautological; change point_ids2 to come from an independent source — for
example, collect expected IDs from the original data fixture or from a second
segment instance (or a different API such as
segment.get_point_ids()/segment.iter_points() if available) and then compare
that independent list to point_ids1; update uses of point_ids2 at both the
earlier (point_ids1/point_ids2) and later (lines around the second assertion)
locations so the assertions validate API consistency rather than determinism.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 269b792c-26b6-4ae3-939d-6f4168552dd7
📒 Files selected for processing (33)
lib/collection/src/collection_manager/optimizers/vacuum_optimizer.rslib/collection/src/collection_manager/tests/mod.rslib/collection/src/tests/deferred_points_dedup.rslib/segment/Cargo.tomllib/segment/src/entry/entry_point.rslib/segment/src/id_tracker/id_tracker_base.rslib/segment/src/id_tracker/immutable_id_tracker.rslib/segment/src/id_tracker/in_memory_id_tracker.rslib/segment/src/id_tracker/mod.rslib/segment/src/id_tracker/mutable_id_tracker.rslib/segment/src/id_tracker/simple_id_tracker.rslib/segment/src/index/hnsw_index/hnsw.rslib/segment/src/index/plain_payload_index.rslib/segment/src/index/query_optimization/condition_converter.rslib/segment/src/index/sparse_index/sparse_vector_index.rslib/segment/src/index/struct_payload_index.rslib/segment/src/segment/entry.rslib/segment/src/segment/facet.rslib/segment/src/segment/order_by.rslib/segment/src/segment/sampling.rslib/segment/src/segment/scroll.rslib/segment/src/segment/segment_ops.rslib/segment/src/segment/tests.rslib/segment/src/segment_constructor/segment_constructor_base.rslib/segment/src/vector_storage/dense/memmap_dense_vector_storage.rslib/segment/src/vector_storage/tests/test_appendable_dense_vector_storage.rslib/segment/tests/integration/payload_index_test.rslib/segment/tests/integration/segment_builder_test.rslib/segment/tests/integration/segment_on_disk_snapshot.rslib/segment/tests/integration/segment_tests.rslib/shard/src/optimize.rslib/shard/src/proxy_segment/segment_entry.rslib/shard/src/segment_holder/mod.rs
✅ Files skipped from review due to trivial changes (7)
- lib/collection/src/collection_manager/tests/mod.rs
- lib/segment/Cargo.toml
- lib/segment/tests/integration/segment_on_disk_snapshot.rs
- lib/segment/src/vector_storage/tests/test_appendable_dense_vector_storage.rs
- lib/shard/src/segment_holder/mod.rs
- lib/segment/src/segment/scroll.rs
- lib/collection/src/tests/deferred_points_dedup.rs
🚧 Files skipped from review as they are similar to previous changes (15)
- lib/segment/src/index/query_optimization/condition_converter.rs
- lib/segment/src/vector_storage/dense/memmap_dense_vector_storage.rs
- lib/segment/src/segment/order_by.rs
- lib/collection/src/collection_manager/optimizers/vacuum_optimizer.rs
- lib/segment/src/segment/sampling.rs
- lib/segment/tests/integration/payload_index_test.rs
- lib/segment/src/id_tracker/mod.rs
- lib/shard/src/proxy_segment/segment_entry.rs
- lib/segment/src/entry/entry_point.rs
- lib/segment/tests/integration/segment_builder_test.rs
- lib/segment/src/index/plain_payload_index.rs
- lib/segment/src/index/struct_payload_index.rs
- lib/segment/src/id_tracker/mutable_id_tracker.rs
- lib/segment/src/id_tracker/immutable_id_tracker.rs
- lib/segment/src/segment/entry.rs
Use nested `self_cell` to provide an iterator.
It replaces "crate" inside a macro even if it is "pub(crate)".
41120f3 to
ceb9bea
Compare
point_mappings in the APIpoint_mappings
point_mappingspoint_mappings refs
point_mappings refspoint_mappings guard
point_mappings guardpoint_mappings guard
point_mappings guardpoint_mappings guard in IdTracker
Instead of `IdTracker` to have `iter_*` methods, it now has a `point_mappings()` method, returning a guard to `PointMapping` value. It prepares for moving the point_mappings under a lock to allow parallel searches and deletions. Also, an incorrect unsafe in `Segment::iter_points` is replaced by a safe version with `self_cell`.
Instead of `IdTracker` to have `iter_*` methods, it now has a `point_mappings()` method, returning a guard to `PointMapping` value. It prepares for moving the point_mappings under a lock to allow parallel searches and deletions. Also, an incorrect unsafe in `Segment::iter_points` is replaced by a safe version with `self_cell`.
The
IdTrackermethods do not return iterators anymore. Instead, you should take explicitely thePointMappingsRefEnumguard and use its methods. It prepares for moving thepoint_mappingsunder a lock to allow parallel searches and deletions.All Submissions:
devbranch. Did you create your branch fromdev?New Feature Submissions:
cargo +nightly fmt --allcommand prior to submission?cargo clippy --workspace --all-featurescommand?Changes to Core Features: