Ted-Jiang commented on code in PR #3115:
URL: https://github.com/apache/arrow-rs/pull/3115#discussion_r1023715387
##########
arrow-buffer/src/buffer/immutable.rs:
##########
@@ -227,6 +227,28 @@ impl Buffer {
pub fn count_set_bits_offset(&self, offset: usize, len: usize) -> usize {
UnalignedBitChunk::new(self.as_slice(), offset, len).count_ones()
}
+
+ /// Returns `MutableBuffer` for mutating the buffer if this buffer is not
shared.
+ pub fn into_mutable(self, len: usize) -> Result<MutableBuffer, Self> {
+ let offset_ptr = self.as_ptr();
+ let offset = self.offset;
+ let length = self.length;
+ Arc::try_unwrap(self.data)
+ .map(|bytes| {
+ // The pointer of underlying buffer should not be offset.
Review Comment:
@tustvold Sorry another question: I think in datafusion most
`PrimitiveArray` data have only one reference during query. So base on this,
most unary change using `unary_mut` like +1, will avoid `memcpy` than before
using `unary` ?
--
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]