[ 
https://issues.apache.org/jira/browse/ARROW-2408?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16429768#comment-16429768
 ] 

ASF GitHub Bot commented on ARROW-2408:
---------------------------------------

andygrove commented on a change in pull request #1846: ARROW-2408: [Rust] 
Ability to get `&mut [T]` from `Buffer<T>`
URL: https://github.com/apache/arrow/pull/1846#discussion_r179949092
 
 

 ##########
 File path: rust/src/builder.rs
 ##########
 @@ -48,6 +47,18 @@ impl<T> Builder<T> {
         }
     }
 
+    /// Get the internal byte-aligned memory buffer as a mutable slice
+    pub fn slice_mut(&self, start: usize, end: usize) -> &mut [T] {
+        unsafe {
+            slice::from_raw_parts_mut(self.data.offset(start as isize), (end - 
start) as usize)
+        }
+    }
+
+    /// Override the length
+    pub fn set_len(&mut self, len: usize) {
 
 Review comment:
   OK I have time to look at this today. I agree with @luben that for this 
method, adding assertions to make it safe is the way to go and I just pushed a 
PR for that.
   
   I also think @crepererum raises good points so I have filed seperate JIRA 
https://issues.apache.org/jira/browse/ARROW-2417 to review the API for safety.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> [Rust] It should be possible to get a &mut[T] from Builder<T>
> -------------------------------------------------------------
>
>                 Key: ARROW-2408
>                 URL: https://issues.apache.org/jira/browse/ARROW-2408
>             Project: Apache Arrow
>          Issue Type: New Feature
>          Components: Rust
>            Reporter: Andy Grove
>            Assignee: Andy Grove
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 0.10.0
>
>
> I am currently adding Arrow support to the parquet-rs crate and I found a 
> need to get a mutable slice from a Buffer<T> to pass to the parquet column 
> reader methods.
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to