This is an automated email from the ASF dual-hosted git repository.

tustvold pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git


The following commit(s) were added to refs/heads/main by this push:
     new ef7d753965 fix: NullBufferBuilder::allocated_size should return Size 
in Bytes (#7122)
ef7d753965 is described below

commit ef7d753965c0ab5353b103bd64a92215d591d8bc
Author: Shuoze Li <[email protected]>
AuthorDate: Wed Feb 12 04:42:27 2025 -0800

    fix: NullBufferBuilder::allocated_size should return Size in Bytes (#7122)
    
    Co-authored-by: Shuoze Li <[email protected]>
---
 arrow-buffer/src/builder/null.rs | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/arrow-buffer/src/builder/null.rs b/arrow-buffer/src/builder/null.rs
index 607daf7ddb..3c762bdebc 100644
--- a/arrow-buffer/src/builder/null.rs
+++ b/arrow-buffer/src/builder/null.rs
@@ -217,11 +217,11 @@ impl NullBufferBuilder {
         self.bitmap_builder.as_mut().map(|b| b.as_slice_mut())
     }
 
-    /// Return the allocated size of this builder, in bits, useful for memory 
accounting.
+    /// Return the allocated size of this builder, in bytes, useful for memory 
accounting.
     pub fn allocated_size(&self) -> usize {
         self.bitmap_builder
             .as_ref()
-            .map(|b| b.capacity())
+            .map(|b| b.capacity() / 8)
             .unwrap_or(0)
     }
 }
@@ -250,7 +250,7 @@ mod tests {
         builder.append_n_nulls(2);
         builder.append_n_non_nulls(2);
         assert_eq!(6, builder.len());
-        assert_eq!(512, builder.allocated_size());
+        assert_eq!(64, builder.allocated_size());
 
         let buf = builder.finish().unwrap();
         assert_eq!(&[0b110010_u8], buf.validity());
@@ -263,7 +263,7 @@ mod tests {
         builder.append_n_nulls(2);
         builder.append_slice(&[false, false, false]);
         assert_eq!(6, builder.len());
-        assert_eq!(512, builder.allocated_size());
+        assert_eq!(64, builder.allocated_size());
 
         let buf = builder.finish().unwrap();
         assert_eq!(&[0b0_u8], buf.validity());
@@ -327,7 +327,7 @@ mod tests {
         builder.append_null();
         builder.append_non_null();
         assert_eq!(builder.as_slice().unwrap(), &[0xFF, 0b10111111]);
-        assert_eq!(builder.allocated_size(), 512);
+        assert_eq!(builder.allocated_size(), 64);
     }
 
     #[test]

Reply via email to