Dandandan commented on a change in pull request #10046:
URL: https://github.com/apache/arrow/pull/10046#discussion_r614133898
##########
File path: rust/arrow/src/array/array_primitive.rs
##########
@@ -88,12 +88,23 @@ impl<T: ArrowPrimitiveType> PrimitiveArray<T> {
PrimitiveBuilder::<T>::new(capacity)
}
+ /// Returns the primitive value at index `i`.
+ ///
+ /// # Safety
+ ///
+ /// caller must ensure that the passed in offset is less than the array
len()
+ pub unsafe fn value_unchecked(&self, i: usize) -> T::Native {
+ let offset = i + self.offset();
+ *self.raw_values.as_ptr().add(offset)
+ }
+
/// Returns the primitive value at index `i`.
///
/// Note this doesn't do any bound checking, for performance reason.
/// # Safety
/// caller must ensure that the passed in offset is less than the array
len()
pub fn value(&self, i: usize) -> T::Native {
+ debug_assert!(i < self.len());
let offset = i + self.offset();
Review comment:
This might use `value_unchecked` now?
--
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:
[email protected]