andygrove opened a new pull request, #3222:
URL: https://github.com/apache/datafusion-comet/pull/3222
## Summary
Optimizes primitive type array iteration in native shuffle by using pointer
arithmetic instead of per-element multiplication.
**Changes:**
- Added bulk-append methods for primitive types (i8, i16, i32, i64, f32,
f64, bool, timestamp, date)
- Uses const generics (`<const NULLABLE: bool>`) for compile-time
specialization
- Avoids repeated multiplication in `get_element_offset()` calls
- Reads null bitset once per word (64 elements) instead of per-element
**Before:**
```rust
for idx in 0..array.get_num_elements() {
builder.append_value(array.get_int(idx)); // get_int does: offset + idx
* 4
}
```
**After:**
```rust
let mut ptr = self.element_offset as *const i32;
for _ in 0..num_elements {
builder.append_value(unsafe { *ptr });
ptr = unsafe { ptr.add(1) }; // just pointer increment
}
```
## Test plan
- [x] All Rust tests pass (118 tests)
- [x] Native shuffle test suite passes (16 tests)
- [x] Clippy clean
- [ ] Benchmark comparison (WIP)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]