viirya commented on code in PR #8009:
URL: https://github.com/apache/arrow-rs/pull/8009#discussion_r2236685051
##########
arrow-buffer/src/buffer/scalar.rs:
##########
@@ -99,6 +112,16 @@ impl<T: ArrowNativeType> ScalarBuffer<T> {
pub fn ptr_eq(&self, other: &Self) -> bool {
self.buffer.ptr_eq(&other.buffer)
}
+
+ /// Returns the number of elements in the buffer
+ pub fn len(&self) -> usize {
+ self.buffer.len() / std::mem::size_of::<T>()
+ }
+
+ /// Returns if the buffer is empty
+ pub fn is_empty(&self) -> bool {
+ self.len() == 0
+ }
Review Comment:
Added them to avoid `ScalarBuffer` derefed as `[T]` in the added test.
##########
arrow-buffer/src/buffer/scalar.rs:
##########
@@ -99,6 +112,16 @@ impl<T: ArrowNativeType> ScalarBuffer<T> {
pub fn ptr_eq(&self, other: &Self) -> bool {
self.buffer.ptr_eq(&other.buffer)
}
+
+ /// Returns the number of elements in the buffer
+ pub fn len(&self) -> usize {
+ self.buffer.len() / std::mem::size_of::<T>()
+ }
+
+ /// Returns if the buffer is empty
+ pub fn is_empty(&self) -> bool {
+ self.len() == 0
+ }
Review Comment:
Added them to avoid `ScalarBuffer` derefed as `[T]` in the added test.
--
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]