You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2020/12/23 09:13:20 UTC

[GitHub] [arrow] jhorstmann commented on a change in pull request #8973: ARROW-10989: [Rust] Iterate primitive buffers by slice

jhorstmann commented on a change in pull request #8973:
URL: https://github.com/apache/arrow/pull/8973#discussion_r547839892



##########
File path: rust/arrow/src/array/array_primitive.rs
##########
@@ -63,17 +63,28 @@ impl<T: ArrowPrimitiveType> PrimitiveArray<T> {
         self.data.is_empty()
     }
 
-    /// Returns a raw pointer to the values of this array.
-    pub fn raw_values(&self) -> *const T::Native {
-        unsafe { self.raw_values.get().add(self.data.offset()) }
-    }
-
     /// Returns a slice for the given offset and length
     ///
     /// Note this doesn't do any bound checking, for performance reason.
-    pub fn value_slice(&self, offset: usize, len: usize) -> &[T::Native] {
-        let raw =
-            unsafe { std::slice::from_raw_parts(self.raw_values().add(offset), len) };
+    /// # Safety
+    /// caller must ensure that the passed in offset + len are less than the array len()
+    #[deprecated(note = "Please use values() instead")]
+    pub unsafe fn value_slice(&self, offset: usize, len: usize) -> &[T::Native] {

Review comment:
       Since `value_slice` is now only used in the simd comparison kernels, I can remove it later in [ARROW-10990][1].
   
   I think this PR is a nice simplification and also makes the code more safe, thanks!
   
    [1]: https://github.com/apache/arrow/pull/8975




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org