Repository navigation
[UIO] Explicit padding for numeric point - #8668
Conversation
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
lib/segment/src/index/field_index/numeric_index/mmap_numeric_index.rs (1)
300-302: Consider explicit field ignoring for_padding.Per coding guidelines, explicit field ignoring using
: _is preferred over..in struct destructuring. However, since_paddingis an internal implementation detail that will never affect logic, this is acceptable.Optional: Explicit field ignoring
- .map(|Point { val, idx, .. }| (val, idx)) + .map(|Point { val, idx, _padding: _ }| (val, idx))🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lib/segment/src/index/field_index/numeric_index/mmap_numeric_index.rs` around lines 300 - 302, The destructuring in the iterator mapping uses Point { val, idx, .. } which relies on a blanket ignore; change it to explicitly ignore the internal padding field by using Point { val, idx, _padding: _ } (or the exact padding field name) in the closure so the intent is explicit; update the closure in values_range_iterator(...).map(|Point { val, idx, .. }| (val, idx)) to use the explicit ignored field name while returning (val, idx).
🤖 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/src/index/field_index/histogram.rs`:
- Around line 76-89: The derive_point_padding function can return align when the
summed size is already a multiple of align; change the logic to compute the
remainder rem = (size_of::<T>() + size_of::<PointOffsetType>()) % align and
return 0 if rem == 0 else return align - rem so derive_point_padding<T>() (which
defines struct Point<T>) yields zero padding when already aligned and only the
minimal positive padding otherwise.
---
Nitpick comments:
In `@lib/segment/src/index/field_index/numeric_index/mmap_numeric_index.rs`:
- Around line 300-302: The destructuring in the iterator mapping uses Point {
val, idx, .. } which relies on a blanket ignore; change it to explicitly ignore
the internal padding field by using Point { val, idx, _padding: _ } (or the
exact padding field name) in the closure so the intent is explicit; update the
closure in values_range_iterator(...).map(|Point { val, idx, .. }| (val, idx))
to use the explicit ignored field name while returning (val, idx).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 1a194799-83ea-4e75-8db1-7354b0ff091d
📒 Files selected for processing (6)
lib/segment/src/index/field_index/histogram.rslib/segment/src/index/field_index/numeric_index/immutable_numeric_index.rslib/segment/src/index/field_index/numeric_index/mmap_numeric_index.rslib/segment/src/index/field_index/numeric_index/mutable_numeric_index.rslib/segment/src/index/field_index/tests/histogram_i64_tests.rslib/segment/src/index/field_index/tests/histogram_tests.rs
Why is it needed now?
What is padding in this case?
previos implementation used conversion from bytes? |
fb96459 to
e75f42b
Compare
Because, in #8641, we are going to be using it within
Padding is just
It was |
e75f42b to
19e71fb
Compare
545d963 to
e82459c
Compare
e82459c to
6063cb6
Compare
6063cb6 to
ba93027
Compare
* derive Pod for Point<T> * remove clones on Copy type * fix annoying clippy lint * serde skip padding * extract point into a new file * assert aligment
We need to derive
bytemuck::PodforPoint<T>, but doing so for a generic requires it to be#[repr(C, packed)], which means we have to handle the padding ourselves.This PR makes the padding part of the
Numericabletrait, and marksPoint<T>as aPodtype. This enables it to be used in aTypedStorage<Point<T>>, which we need to migrate the mmap numeric index.