vertexclique commented on a change in pull request #8598:
URL: https://github.com/apache/arrow/pull/8598#discussion_r518741098



##########
File path: rust/arrow/src/buffer.rs
##########
@@ -259,16 +260,20 @@ impl Buffer {
     /// Returns a slice of this buffer starting at a certain bit offset.
     /// If the offset is byte-aligned the returned buffer is a shallow clone,
     /// otherwise a new buffer is allocated and filled with a copy of the bits 
in the range.
-    pub fn bit_slice(&self, offset: usize, len: usize) -> Self {
-        if offset % 8 == 0 && len % 8 == 0 {
-            return self.slice(offset / 8);
+    pub fn bit_view(&self, offset_in_bits: usize, len_in_bits: usize) -> Self {
+        if offset_in_bits % 8 == 0 && len_in_bits % 8 == 0 {
+            self.slice(offset_in_bits / 8)

Review comment:
       That is the idea, bit view doesn't cover the whole Buffer. If you give 
the whole buffer's length in bits and start offset as 0 then it will cover the 
whole buffer. Otherwise, we can use a partial bit view on the Buffer.

##########
File path: rust/arrow/src/buffer.rs
##########
@@ -402,19 +407,27 @@ where
     let mut result =
         MutableBuffer::new(ceil(len_in_bits, 8)).with_bitset(len_in_bits / 64 
* 8, false);
 
-    let left_chunks = left.bit_chunks(left_offset_in_bits, len_in_bits);
-    let right_chunks = right.bit_chunks(right_offset_in_bits, len_in_bits);
+    let left_slice = left.bit_slice().view(left_offset_in_bits, len_in_bits);

Review comment:
       I have moved the remainder calculation here. The remainder calculation 
was at the end of this method. It looks like more code because now we 
explicitly know what is bit view and what is chunk iterator. It was quite a bit 
blurry before. Now you can have a bit view over the buffer while having chunks 
and remaining bits do their work. It is for readability and not consuming chunk 
iterator.




----------------------------------------------------------------
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:
us...@infra.apache.org


Reply via email to