fix(datagen): use an aligned buffer when generating random bytes arrays#7919
fix(datagen): use an aligned buffer when generating random bytes arrays#7919SAY-5 wants to merge 1 commit into
Conversation
Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
📝 WalkthroughWalkthrough
ChangesRandom byte generation
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
rust/lance-datagen/src/generator.rs (1)
3532-3548: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winExercise typed value access in the regression test.
The test currently verifies only
Array::len(). Add assertions for the expecteddata_type()and concrete primitive array downcasts, then access the non-empty values so the test proves alignment remains valid beyond construction.As per coding guidelines, every bugfix and feature must have corresponding tests.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@rust/lance-datagen/src/generator.rs` around lines 3532 - 3548, Extend test_rand_bytes_zero_rows to validate each generated array’s expected data_type and downcast it to the corresponding concrete primitive array type, then access the values from the three-row result. Retain the existing zero- and non-empty-length assertions so the test covers both construction and typed value access for Float16, Decimal128, and Decimal256.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@rust/lance-datagen/src/generator.rs`:
- Around line 3532-3548: Extend test_rand_bytes_zero_rows to validate each
generated array’s expected data_type and downcast it to the corresponding
concrete primitive array type, then access the values from the three-row result.
Retain the existing zero- and non-empty-length assertions so the test covers
both construction and typed value access for Float16, Decimal128, and
Decimal256.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: QUIET
Plan: Pro Plus
Run ID: 0782fe02-1d46-4d35-9166-fb880eb1264a
📒 Files selected for processing (1)
rust/lance-datagen/src/generator.rs
RandomBytesGeneratorfills aVec<u8>and reinterprets it asT::NativethroughScalarBuffer::new, but aVec<u8>is only byte-aligned, so generating zeroFloat16/Decimal128/Decimal256rows panics on the dangling pointer (#7911). Switching toMutableBuffer::from_len_zeroedgives an allocation that is aligned for any scalar type, for empty and non-empty arrays alike.Closes #7911