pub(crate) fn create_key(
    group_by_keys: &[ArrayRef],
    row: usize,
    vec: &mut Vec<u8>,
) -> Result<()> {
    vec.clear();
    for i in 0..group_by_keys.len() {
        let col = &group_by_keys[i];
        match col.data_type() {
            DataType::UInt8 => {
                let array = col.as_any().downcast_ref::<UInt8Array>().unwrap();
                vec.extend(array.value(row).to_le_bytes().iter());
            }
            DataType::UInt16 => {
                let array = col.as_any().downcast_ref::<UInt16Array>().unwrap();
                vec.extend(array.value(row).to_le_bytes().iter());
            }
            DataType::UInt32 => {
                let array = col.as_any().downcast_ref::<UInt32Array>().unwrap();
                vec.extend(array.value(row).to_le_bytes().iter());
            }
            DataType::UInt64 => {
                let array = col.as_any().downcast_ref::<UInt64Array>().unwrap();
                vec.extend(array.value(row).to_le_bytes().iter());
            }
            DataType::Int8 => {
                let array = col.as_any().downcast_ref::<Int8Array>().unwrap();
                vec.extend(array.value(row).to_le_bytes().iter());
            }
            DataType::Int16 => {
                let array = col.as_any().downcast_ref::<Int16Array>().unwrap();
                vec.extend(array.value(row).to_le_bytes().iter());
            }
            DataType::Int32 => {
                let array = col.as_any().downcast_ref::<Int32Array>().unwrap();
                vec.extend(array.value(row).to_le_bytes().iter());
            }
            DataType::Int64 => {
                let array = col.as_any().downcast_ref::<Int64Array>().unwrap();
                vec.extend(array.value(row).to_le_bytes().iter());
            }
            DataType::Utf8 => {
                let array = col.as_any().downcast_ref::<StringArray>().unwrap();
                let value = array.value(row);
                // store the size
                vec.extend(value.len().to_le_bytes().iter());
                // store the string value
                vec.extend(array.value(row).as_bytes().iter());
            }
            _ => {
                // This is internal because we should have caught this before.
                return Err(DataFusionError::Internal(
                    "Unsupported GROUP BY data type".to_string(),
                ));
            }
        }
    }
    Ok(())
}
/// Create a key `Vec<u8>` that is used as key for the hashmap
Create a key `Vec` that is used as key for the hashmap
Create a key ` Vec ` that is used as key for the hashmap
pub(crate) fn create_key(
    group_by_keys: &[ArrayRef],
    row: usize,
    vec: &mut Vec<u8>,
) -> Result<()> {
    vec.clear();
    for i in 0..group_by_keys.len() {
        let col = &group_by_keys[i];
        match col.data_type() {
            DataType::UInt8 => {
                let array = col.as_any().downcast_ref::<UInt8Array>().unwrap();
                vec.extend(array.value(row).to_le_bytes().iter());
            }
            DataType::UInt16 => {
                let array = col.as_any().downcast_ref::<UInt16Array>().unwrap();
                vec.extend(array.value(row).to_le_bytes().iter());
            }
            DataType::UInt32 => {
                let array = col.as_any().downcast_ref::<UInt32Array>().unwrap();
                vec.extend(array.value(row).to_le_bytes().iter());
            }
            DataType::UInt64 => {
                let array = col.as_any().downcast_ref::<UInt64Array>().unwrap();
                vec.extend(array.value(row).to_le_bytes().iter());
            }
            DataType::Int8 => {
                let array = col.as_any().downcast_ref::<Int8Array>().unwrap();
                vec.extend(array.value(row).to_le_bytes().iter());
            }
            DataType::Int16 => {
                let array = col.as_any().downcast_ref::<Int16Array>().unwrap();
                vec.extend(array.value(row).to_le_bytes().iter());
            }
            DataType::Int32 => {
                let array = col.as_any().downcast_ref::<Int32Array>().unwrap();
                vec.extend(array.value(row).to_le_bytes().iter());
            }
            DataType::Int64 => {
                let array = col.as_any().downcast_ref::<Int64Array>().unwrap();
                vec.extend(array.value(row).to_le_bytes().iter());
            }
            DataType::Utf8 => {
                let array = col.as_any().downcast_ref::<StringArray>().unwrap();
                let value = array.value(row);
                // store the size
                vec.extend(value.len().to_le_bytes().iter());
                // store the string value
                vec.extend(array.value(row).as_bytes().iter());
            }
            _ => {
                // This is internal because we should have caught this before.
                return Err(DataFusionError::Internal(
                    "Unsupported GROUP BY data type".to_string(),
                ));
            }
        }
    }
    Ok(())
}
pub ( crate ) fn create_key ( group_by_keys : & [ ArrayRef ] , row : usize , vec : & mut Vec < u8 > , ) -> Result < ( ) > { vec . clear ( ) ; for i in 0 .. group_by_keys . len ( ) { let col = & group_by_keys [ i ] ; match col . data_type ( ) { DataType :: UInt8 => { let array = col . as_any ( ) . downcast_ref :: < UInt8Array > ( ) . unwrap ( ) ; vec . extend ( array . value ( row ) . to_le_bytes ( ) . iter ( ) ) ; } DataType :: UInt16 => { let array = col . as_any ( ) . downcast_ref :: < UInt16Array > ( ) . unwrap ( ) ; vec . extend ( array . value ( row ) . to_le_bytes ( ) . iter ( ) ) ; } DataType :: UInt32 => { let array = col . as_any ( ) . downcast_ref :: < UInt32Array > ( ) . unwrap ( ) ; vec . extend ( array . value ( row ) . to_le_bytes ( ) . iter ( ) ) ; } DataType :: UInt64 => { let array = col . as_any ( ) . downcast_ref :: < UInt64Array > ( ) . unwrap ( ) ; vec . extend ( array . value ( row ) . to_le_bytes ( ) . iter ( ) ) ; } DataType :: Int8 => { let array = col . as_any ( ) . downcast_ref :: < Int8Array > ( ) . unwrap ( ) ; vec . extend ( array . value ( row ) . to_le_bytes ( ) . iter ( ) ) ; } DataType :: Int16 => { let array = col . as_any ( ) . downcast_ref :: < Int16Array > ( ) . unwrap ( ) ; vec . extend ( array . value ( row ) . to_le_bytes ( ) . iter ( ) ) ; } DataType :: Int32 => { let array = col . as_any ( ) . downcast_ref :: < Int32Array > ( ) . unwrap ( ) ; vec . extend ( array . value ( row ) . to_le_bytes ( ) . iter ( ) ) ; } DataType :: Int64 => { let array = col . as_any ( ) . downcast_ref :: < Int64Array > ( ) . unwrap ( ) ; vec . extend ( array . value ( row ) . to_le_bytes ( ) . iter ( ) ) ; } DataType :: Utf8 => { let array = col . as_any ( ) . downcast_ref :: < StringArray > ( ) . unwrap ( ) ; let value = array . value ( row ) ; // store the size vec . extend ( value . len ( ) . to_le_bytes ( ) . iter ( ) ) ; // store the string value vec . extend ( array . value ( row ) . as_bytes ( ) . iter ( ) ) ; } _ => { // This is internal because we should have caught this before. return Err ( DataFusionError :: Internal ( " " . to_string ( ) , ) ) ; } } } Ok ( ( ) ) }
Create a key `Vec<u8>` that is used as key for the hashmap
Create a key ` Vec<u8 > ` that is used as key for the hashmap
group_by_keys
&[ArrayRef]
row
usize
vec
&mut Vec<u8>
group_by_keys
&[ArrayRef]
row
usize
vec
&mut Vec<u8>