alamb commented on code in PR #2693:
URL: https://github.com/apache/arrow-rs/pull/2693#discussion_r971114722


##########
arrow-buffer/src/buffer/ops.rs:
##########
@@ -20,26 +20,19 @@ use crate::util::bit_util::ceil;
 
 /// Apply a bitwise operation `op` to four inputs and return the result as a 
Buffer.
 /// The inputs are treated as bitmaps, meaning that offsets and length are 
specified in number of bits.
-#[allow(clippy::too_many_arguments)]
-pub(crate) fn bitwise_quaternary_op_helper<F>(
-    first: &Buffer,
-    first_offset_in_bits: usize,
-    second: &Buffer,
-    second_offset_in_bits: usize,
-    third: &Buffer,
-    third_offset_in_bits: usize,
-    fourth: &Buffer,
-    fourth_offset_in_bits: usize,
+pub fn bitwise_quaternary_op_helper<F>(

Review Comment:
   I wonder if we should profile with this change? It seems like it should not 
be any different given that `buffers` and `offsets` are sized (and thus the 
compiler can check and elide the bounds checks)



##########
arrow-buffer/src/lib.rs:
##########
@@ -0,0 +1,24 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Buffer abstractions for Apache Arrow

Review Comment:
   ```suggestion
   //! Buffer abstractions for Apache Arrow 
[arrow-rs](https://github.com/apache/arrow-rs)
   ```



##########
arrow/src/bitmap.rs:
##########
@@ -79,15 +80,37 @@ impl<'a, 'b> BitAnd<&'b Bitmap> for &'a Bitmap {
     type Output = Result<Bitmap>;
 
     fn bitand(self, rhs: &'b Bitmap) -> Result<Bitmap> {
-        Ok(Bitmap::from((&self.bits & &rhs.bits)?))
+        if self.bits.len() != rhs.bits.len() {
+            return Err(ArrowError::ComputeError(
+                "Buffers must be the same size to apply Bitwise 
AND.".to_string(),
+            ));
+        }
+        Ok(Bitmap::from(buffer_bin_and(
+            &self.bits,
+            0,

Review Comment:
   The same comment applies to the other operators as well



##########
arrow/src/bitmap.rs:
##########
@@ -79,15 +80,37 @@ impl<'a, 'b> BitAnd<&'b Bitmap> for &'a Bitmap {
     type Output = Result<Bitmap>;
 
     fn bitand(self, rhs: &'b Bitmap) -> Result<Bitmap> {
-        Ok(Bitmap::from((&self.bits & &rhs.bits)?))
+        if self.bits.len() != rhs.bits.len() {
+            return Err(ArrowError::ComputeError(
+                "Buffers must be the same size to apply Bitwise 
AND.".to_string(),
+            ));
+        }
+        Ok(Bitmap::from(buffer_bin_and(
+            &self.bits,
+            0,

Review Comment:
   I see this does the same things as `&` (uses offset zero) but I wonder if 
that is correct?



##########
arrow-buffer/src/alloc/mod.rs:
##########
@@ -20,34 +20,31 @@
 
 use std::alloc::{handle_alloc_error, Layout};
 use std::fmt::{Debug, Formatter};
-use std::mem::size_of;
 use std::panic::RefUnwindSafe;
 use std::ptr::NonNull;
 use std::sync::Arc;
 
 mod alignment;
-mod types;
 
 pub use alignment::ALIGNMENT;
-pub use types::NativeType;
 
 #[inline]
-unsafe fn null_pointer<T: NativeType>() -> NonNull<T> {
-    NonNull::new_unchecked(ALIGNMENT as *mut T)
+unsafe fn null_pointer() -> NonNull<u8> {
+    NonNull::new_unchecked(ALIGNMENT as *mut u8)
 }
 
 /// Allocates a cache-aligned memory region of `size` bytes with uninitialized 
values.
 /// This is more performant than using [allocate_aligned_zeroed] when all 
bytes will have
 /// an unknown or non-zero value and is semantically similar to `malloc`.
-pub fn allocate_aligned<T: NativeType>(size: usize) -> NonNull<T> {
+pub fn allocate_aligned(size: usize) -> NonNull<u8> {

Review Comment:
   maybe it was also related to a time when there were fewer things that were 
ArrowNativeType (I can't remember but that may have changed over time)



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

Reply via email to