fn buffer_len(&self, i: usize) -> Result<usize> {
        // Inner type is not important for buffer length.
        let data_type = &self.data_type()?;

        Ok(match (data_type, i) {
            (DataType::Utf8, 1)
            | (DataType::LargeUtf8, 1)
            | (DataType::Binary, 1)
            | (DataType::LargeBinary, 1)
            | (DataType::List(_), 1)
            | (DataType::LargeList(_), 1) => {
                // the len of the offset buffer (buffer 1) equals length + 1
                let bits = bit_width(data_type, i)?;
                debug_assert_eq!(bits % 8, 0);
                (self.array().length as usize + 1) * (bits / 8)
            }
            (DataType::Utf8, 2) | (DataType::Binary, 2) | (DataType::List(_), 2) => {
                // the len of the data buffer (buffer 2) equals the last value of the offset buffer (buffer 1)
                let len = self.buffer_len(1)?;
                // first buffer is the null buffer => add(1)
                // we assume that pointer is aligned for `i32`, as Utf8 uses `i32` offsets.
                #[allow(clippy::cast_ptr_alignment)]
                let offset_buffer = unsafe {
                    *(self.array().buffers as *mut *const u8).add(1) as *const i32
                };
                // get last offset
                (unsafe { *offset_buffer.add(len / size_of::<i32>() - 1) }) as usize
            }
            (DataType::LargeUtf8, 2)
            | (DataType::LargeBinary, 2)
            | (DataType::LargeList(_), 2) => {
                // the len of the data buffer (buffer 2) equals the last value of the offset buffer (buffer 1)
                let len = self.buffer_len(1)?;
                // first buffer is the null buffer => add(1)
                // we assume that pointer is aligned for `i64`, as Large uses `i64` offsets.
                #[allow(clippy::cast_ptr_alignment)]
                let offset_buffer = unsafe {
                    *(self.array().buffers as *mut *const u8).add(1) as *const i64
                };
                // get last offset
                (unsafe { *offset_buffer.add(len / size_of::<i64>() - 1) }) as usize
            }
            // buffer len of primitive types
            _ => {
                let bits = bit_width(data_type, i)?;
                bit_util::ceil(self.array().length as usize * bits, 8)
            }
        })
    }
/// Returns the length, in bytes, of the buffer `i` (indexed according to the C data interface)
// Rust implementation uses fixed-sized buffers, which require knowledge of their `len`.
// for variable-sized buffers, such as the second buffer of a stringArray, we need
// to fetch offset buffer's len to build the second buffer.
Returns the length, in bytes, of the buffer `i` (indexed according to the C data interface)
Rust implementation uses fixed-sized buffers, which require knowledge of their `len`.
for variable-sized buffers, such as the second buffer of a stringArray, we need
to fetch offset buffer's len to build the second buffer.
Returns the length in bytes of the buffer ` i ` ( indexed according to the C data interface ) Rust implementation uses fixed - sized buffers which require knowledge of their ` len ` . for variable - sized buffers such as the second buffer of a stringArray we need to fetch offset buffer ' s len to build the second buffer .
fn buffer_len(&self, i: usize) -> Result<usize> {
        // Inner type is not important for buffer length.
        let data_type = &self.data_type()?;
        Ok(match (data_type, i) {
            (DataType::Utf8, 1)
            | (DataType::LargeUtf8, 1)
            | (DataType::Binary, 1)
            | (DataType::LargeBinary, 1)
            | (DataType::List(_), 1)
            | (DataType::LargeList(_), 1) => {
                // the len of the offset buffer (buffer 1) equals length + 1
                let bits = bit_width(data_type, i)?;
                debug_assert_eq!(bits % 8, 0);
                (self.array().length as usize + 1) * (bits / 8)
            }
            (DataType::Utf8, 2) | (DataType::Binary, 2) | (DataType::List(_), 2) => {
                // the len of the data buffer (buffer 2) equals the last value of the offset buffer (buffer 1)
                let len = self.buffer_len(1)?;
                // first buffer is the null buffer => add(1)
                // we assume that pointer is aligned for `i32`, as Utf8 uses `i32` offsets.
                #[allow(clippy::cast_ptr_alignment)]
                let offset_buffer = unsafe {
                    *(self.array().buffers as *mut *const u8).add(1) as *const i32
                };
                // get last offset
                (unsafe { *offset_buffer.add(len / size_of::<i32>() - 1) }) as usize
            }
            (DataType::LargeUtf8, 2)
            | (DataType::LargeBinary, 2)
            | (DataType::LargeList(_), 2) => {
                // the len of the data buffer (buffer 2) equals the last value of the offset buffer (buffer 1)
                let len = self.buffer_len(1)?;
                // first buffer is the null buffer => add(1)
                // we assume that pointer is aligned for `i64`, as Large uses `i64` offsets.
                #[allow(clippy::cast_ptr_alignment)]
                let offset_buffer = unsafe {
                    *(self.array().buffers as *mut *const u8).add(1) as *const i64
                };
                // get last offset
                (unsafe { *offset_buffer.add(len / size_of::<i64>() - 1) }) as usize
            }
            // buffer len of primitive types
            _ => {
                let bits = bit_width(data_type, i)?;
                bit_util::ceil(self.array().length as usize * bits, 8)
            }
        })
    }
fn buffer_len ( & self , i : usize ) -> Result < usize > { // Inner type is not important for buffer length. let data_type = & self . data_type ( ) ? ; Ok ( match ( data_type , i ) { ( DataType :: Utf8 , 1 ) | ( DataType :: LargeUtf8 , 1 ) | ( DataType :: Binary , 1 ) | ( DataType :: LargeBinary , 1 ) | ( DataType :: List ( _ ) , 1 ) | ( DataType :: LargeList ( _ ) , 1 ) => { // the len of the offset buffer (buffer 1) equals length + 1 let bits = bit_width ( data_type , i ) ? ; debug_assert_eq ! ( bits 8 0 ) ; ( self . array ( ) . length as usize + 1 ) * ( bits / 8 ) } ( DataType :: Utf8 , 2 ) | ( DataType :: Binary , 2 ) | ( DataType :: List ( _ ) , 2 ) => { // the len of the data buffer (buffer 2) equals the last value of the offset buffer (buffer 1) let len = self . buffer_len ( 1 ) ? ; // first buffer is the null buffer => add(1) // we assume that pointer is aligned for `i32`, as Utf8 uses `i32` offsets. # [ allow ( clippy cast_ptr_alignment ) ] let offset_buffer = unsafe { * ( self . array ( ) . buffers as * mut * const u8 ) . add ( 1 ) as * const i32 } ; // get last offset ( unsafe { * offset_buffer . add ( len / size_of :: < i32 > ( ) - 1 ) } ) as usize } ( DataType :: LargeUtf8 , 2 ) | ( DataType :: LargeBinary , 2 ) | ( DataType :: LargeList ( _ ) , 2 ) => { // the len of the data buffer (buffer 2) equals the last value of the offset buffer (buffer 1) let len = self . buffer_len ( 1 ) ? ; // first buffer is the null buffer => add(1) // we assume that pointer is aligned for `i64`, as Large uses `i64` offsets. # [ allow ( clippy cast_ptr_alignment ) ] let offset_buffer = unsafe { * ( self . array ( ) . buffers as * mut * const u8 ) . add ( 1 ) as * const i64 } ; // get last offset ( unsafe { * offset_buffer . add ( len / size_of :: < i64 > ( ) - 1 ) } ) as usize } // buffer len of primitive types _ => { let bits = bit_width ( data_type , i ) ? ; bit_util :: ceil ( self . array ( ) . length as usize * bits , 8 ) } } ) }
Returns the length, in bytes, of the buffer `i` (indexed according to the C data interface)
Rust implementation uses fixed-sized buffers, which require knowledge of their `len`.
Returns the length in bytes of the buffer ` i ` ( indexed according to the C data interface ) Rust implementation uses fixed - sized buffers which require knowledge of their ` len ` .
&self
i
usize
&self
i
usize