pub fn maximum_encoded_size(&self, logical_rows: &[usize]) -> Result<usize> {
        match self {
            VectorValue::Int(_) => Ok(logical_rows.len() * 9),

            // Some elements might be NULLs which encoded size is 1 byte. However it's fine because
            // this function only calculates a maximum encoded size (for constructing buffers), not
            // actual encoded size.
            VectorValue::Real(_) => Ok(logical_rows.len() * 9),
            VectorValue::Decimal(vec) => {
                let mut size = 0;
                for idx in logical_rows {
                    let el = &vec[*idx];
                    match el {
                        Some(v) => {
                            // FIXME: We don't need approximate size. Maximum size is enough (so
                            // that we don't need to iterate each value).
                            size += 1 /* FLAG */ + v.approximate_encoded_size();
                        }
                        None => {
                            size += 1;
                        }
                    }
                }
                Ok(size)
            }
            VectorValue::Bytes(vec) => {
                let mut size = 0;
                for idx in logical_rows {
                    let el = &vec[*idx];
                    match el {
                        Some(v) => {
                            size += 1 /* FLAG */ + 10 /* MAX VARINT LEN */ + v.len();
                        }
                        None => {
                            size += 1;
                        }
                    }
                }
                Ok(size)
            }
            VectorValue::DateTime(_) => Ok(logical_rows.len() * 9),
            VectorValue::Duration(_) => Ok(logical_rows.len() * 9),
            VectorValue::Json(vec) => {
                let mut size = 0;
                for idx in logical_rows {
                    let el = &vec[*idx];
                    match el {
                        Some(v) => {
                            size += 1 /* FLAG */ + v.binary_len();
                        }
                        None => {
                            size += 1;
                        }
                    }
                }
                Ok(size)
            }
        }
    }
/// Returns maximum encoded size in binary format.
Returns maximum encoded size in binary format.
Returns maximum encoded size in binary format .
pub fn maximum_encoded_size(&self, logical_rows: &[usize]) -> Result<usize> {
        match self {
            VectorValue::Int(_) => Ok(logical_rows.len() * 9),
            // Some elements might be NULLs which encoded size is 1 byte. However it's fine because
            // this function only calculates a maximum encoded size (for constructing buffers), not
            // actual encoded size.
            VectorValue::Real(_) => Ok(logical_rows.len() * 9),
            VectorValue::Decimal(vec) => {
                let mut size = 0;
                for idx in logical_rows {
                    let el = &vec[*idx];
                    match el {
                        Some(v) => {
                            // FIXME: We don't need approximate size. Maximum size is enough (so
                            // that we don't need to iterate each value).
                            size += 1 /* FLAG */ + v.approximate_encoded_size();
                        }
                        None => {
                            size += 1;
                        }
                    }
                }
                Ok(size)
            }
            VectorValue::Bytes(vec) => {
                let mut size = 0;
                for idx in logical_rows {
                    let el = &vec[*idx];
                    match el {
                        Some(v) => {
                            size += 1 /* FLAG */ + 10 /* MAX VARINT LEN */ + v.len();
                        }
                        None => {
                            size += 1;
                        }
                    }
                }
                Ok(size)
            }
            VectorValue::DateTime(_) => Ok(logical_rows.len() * 9),
            VectorValue::Duration(_) => Ok(logical_rows.len() * 9),
            VectorValue::Json(vec) => {
                let mut size = 0;
                for idx in logical_rows {
                    let el = &vec[*idx];
                    match el {
                        Some(v) => {
                            size += 1 /* FLAG */ + v.binary_len();
                        }
                        None => {
                            size += 1;
                        }
                    }
                }
                Ok(size)
            }
        }
    }
pub fn maximum_encoded_size ( & self , logical_rows : & [ usize ] ) -> Result < usize > { match self { VectorValue :: Int ( _ ) => Ok ( logical_rows . len ( ) * 9 ) , // Some elements might be NULLs which encoded size is 1 byte. However it's fine because // this function only calculates a maximum encoded size (for constructing buffers), not // actual encoded size. VectorValue :: Real ( _ ) => Ok ( logical_rows . len ( ) * 9 ) , VectorValue :: Decimal ( vec ) => { let mut size = 0 ; for idx in logical_rows { let el = & vec [ * idx ] ; match el { Some ( v ) => { // FIXME: We don't need approximate size. Maximum size is enough (so // that we don't need to iterate each value). size += 1 /* FLAG */ + v . approximate_encoded_size ( ) ; } None => { size += 1 ; } } } Ok ( size ) } VectorValue :: Bytes ( vec ) => { let mut size = 0 ; for idx in logical_rows { let el = & vec [ * idx ] ; match el { Some ( v ) => { size += 1 /* FLAG */ + 10 /* MAX VARINT LEN */ + v . len ( ) ; } None => { size += 1 ; } } } Ok ( size ) } VectorValue :: DateTime ( _ ) => Ok ( logical_rows . len ( ) * 9 ) , VectorValue :: Duration ( _ ) => Ok ( logical_rows . len ( ) * 9 ) , VectorValue :: Json ( vec ) => { let mut size = 0 ; for idx in logical_rows { let el = & vec [ * idx ] ; match el { Some ( v ) => { size += 1 /* FLAG */ + v . binary_len ( ) ; } None => { size += 1 ; } } } Ok ( size ) } } }
Returns maximum encoded size in binary format.
Returns maximum encoded size in binary format .
&self
logical_rows
&[usize]
&self
logical_rows
&[usize]