rluvaton commented on code in PR #23990:
URL: https://github.com/apache/datafusion/pull/23990#discussion_r3948267835
##########
datafusion/physical-plan/src/sorts/cursor.rs:
##########
@@ -195,12 +214,31 @@ impl RowValues {
reservation.size(),
"memory reservation mismatch"
);
- assert!(rows.num_rows() > 0);
+ let len = rows.num_rows();
+ assert!(len > 0);
+ // Extract raw ptr + length while the temporary `Row` is still alive.
+ // The pointer is into `rows`'s Arc buffer heap and stays valid.
+ let (current_ptr, current_len) = {
+ let row = rows.row(0);
+ let bytes: &[u8] = row.as_ref();
+ (bytes.as_ptr(), bytes.len())
+ };
Self {
rows,
+ len,
+ current_ptr,
+ current_len,
_reservation: reservation,
}
}
+
+ #[inline(always)]
+ fn current_slice(&self) -> &[u8] {
+ // SAFETY: `set_offset` (or `new` for offset 0) populated `current_ptr`
+ // / `current_len` from `rows.row(offset).as_ref()`, and the ptr is
Review Comment:
```suggestion
// SAFETY: `set_offset` (or `new` for offset 0) populated
`current_ptr` / `current_len`
// from `rows.row(offset).as_ref()`, and the ptr is
```
--
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]