fn read_group_hash_with_vec_key<'a>(
        &'a self,
        dst: &mut ReadAggregateResult<'a>,
        groupby_encoded_ids: &[Vec<u32>],
        aggregate_columns_data: &[Values<'a>],
    ) {
        // Now begin building the group keys.
        let mut groups: HashMap<Vec<u32>, Vec<AggregateResult<'_>>> = HashMap::default();
        let total_rows = groupby_encoded_ids[0].len();
        assert!(groupby_encoded_ids.iter().all(|x| x.len() == total_rows));

        // key_buf will be used as a temporary buffer for group keys, which are
        // themselves integers.
        let mut key_buf = vec![0; dst.schema.group_columns.len()];

        for row in 0..total_rows {
            // update the group key buffer with the group key for this row
            for (j, col_ids) in groupby_encoded_ids.iter().enumerate() {
                key_buf[j] = col_ids[row];
            }

            match groups.raw_entry_mut().from_key(&key_buf) {
                // aggregates for this group key are already present. Update
                // them
                hash_map::RawEntryMut::Occupied(mut entry) => {
                    for (i, values) in aggregate_columns_data.iter().enumerate() {
                        entry.get_mut()[i].update(values.value(row));
                    }
                }
                // group key does not exist, so create it.
                hash_map::RawEntryMut::Vacant(entry) => {
                    let mut group_key_aggs = Vec::with_capacity(dst.schema.aggregate_columns.len());
                    for (_, agg_type, _) in &dst.schema.aggregate_columns {
                        group_key_aggs.push(AggregateResult::from(agg_type));
                    }

                    for (i, values) in aggregate_columns_data.iter().enumerate() {
                        group_key_aggs[i].update(values.value(row));
                    }

                    entry.insert(key_buf.clone(), group_key_aggs);
                }
            }
        }

        // Finally, build results set. Each encoded group key needs to be
        // materialised into a logical group key
        let columns = dst
            .schema
            .group_column_names_iter()
            .map(|name| self.column_by_name(name))
            .collect::<Vec<_>>();
        let mut group_key_vec: Vec<GroupKey<'_>> = Vec::with_capacity(groups.len());
        let mut aggregate_vec: Vec<AggregateResults<'_>> = Vec::with_capacity(groups.len());

        for (group_key, aggs) in groups.into_iter() {
            let mut logical_key = Vec::with_capacity(group_key.len());
            for (col_idx, &encoded_id) in group_key.iter().enumerate() {
                // TODO(edd): address the cast to u32
                logical_key.push(columns[col_idx].decode_id(encoded_id as u32));
            }

            group_key_vec.push(GroupKey(logical_key));
            aggregate_vec.push(AggregateResults(aggs));
        }

        // update results
        dst.group_keys = group_key_vec;
        dst.aggregates = aggregate_vec;
    }
// This function is used with `read_group_hash` when the number of columns
// being grouped on requires the use of a `Vec<u32>` as the group key in the
// hash map.
This function is used with `read_group_hash` when the number of columns
being grouped on requires the use of a `Vec` as the group key in the
hash map.
This function is used with ` read_group_hash ` when the number of columns being grouped on requires the use of a ` Vec ` as the group key in the hash map .
fn read_group_hash_with_vec_key<'a>(
        &'a self,
        dst: &mut ReadAggregateResult<'a>,
        groupby_encoded_ids: &[Vec<u32>],
        aggregate_columns_data: &[Values<'a>],
    ) {
        // Now begin building the group keys.
        let mut groups: HashMap<Vec<u32>, Vec<AggregateResult<'_>>> = HashMap::default();
        let total_rows = groupby_encoded_ids[0].len();
        assert!(groupby_encoded_ids.iter().all(|x| x.len() == total_rows));
        // key_buf will be used as a temporary buffer for group keys, which are
        // themselves integers.
        let mut key_buf = vec![0; dst.schema.group_columns.len()];
        for row in 0..total_rows {
            // update the group key buffer with the group key for this row
            for (j, col_ids) in groupby_encoded_ids.iter().enumerate() {
                key_buf[j] = col_ids[row];
            }
            match groups.raw_entry_mut().from_key(&key_buf) {
                // aggregates for this group key are already present. Update
                // them
                hash_map::RawEntryMut::Occupied(mut entry) => {
                    for (i, values) in aggregate_columns_data.iter().enumerate() {
                        entry.get_mut()[i].update(values.value(row));
                    }
                }
                // group key does not exist, so create it.
                hash_map::RawEntryMut::Vacant(entry) => {
                    let mut group_key_aggs = Vec::with_capacity(dst.schema.aggregate_columns.len());
                    for (_, agg_type, _) in &dst.schema.aggregate_columns {
                        group_key_aggs.push(AggregateResult::from(agg_type));
                    }
                    for (i, values) in aggregate_columns_data.iter().enumerate() {
                        group_key_aggs[i].update(values.value(row));
                    }
                    entry.insert(key_buf.clone(), group_key_aggs);
                }
            }
        }
        // Finally, build results set. Each encoded group key needs to be
        // materialised into a logical group key
        let columns = dst
            .schema
            .group_column_names_iter()
            .map(|name| self.column_by_name(name))
            .collect::<Vec<_>>();
        let mut group_key_vec: Vec<GroupKey<'_>> = Vec::with_capacity(groups.len());
        let mut aggregate_vec: Vec<AggregateResults<'_>> = Vec::with_capacity(groups.len());
        for (group_key, aggs) in groups.into_iter() {
            let mut logical_key = Vec::with_capacity(group_key.len());
            for (col_idx, &encoded_id) in group_key.iter().enumerate() {
                // TODO(edd): address the cast to u32
                logical_key.push(columns[col_idx].decode_id(encoded_id as u32));
            }
            group_key_vec.push(GroupKey(logical_key));
            aggregate_vec.push(AggregateResults(aggs));
        }
        // update results
        dst.group_keys = group_key_vec;
        dst.aggregates = aggregate_vec;
    }
fn read_group_hash_with_vec_key < ' a > ( & ' a self , dst : & mut ReadAggregateResult < ' a > , groupby_encoded_ids : & [ Vec < u32 > ] , aggregate_columns_data : & [ Values < ' a > ] , ) { // Now begin building the group keys. let mut groups : HashMap < Vec < u32 > , Vec < AggregateResult < ' _ > > > = HashMap :: default ( ) ; let total_rows = groupby_encoded_ids [ 0 ] . len ( ) ; assert ! ( groupby_encoded_ids iter ( ) all ( x x len ( ) total_rows ) ) ; // key_buf will be used as a temporary buffer for group keys, which are // themselves integers. let mut key_buf = vec ! [ 0 dst schema group_columns len ( ) ] ; for row in 0 .. total_rows { // update the group key buffer with the group key for this row for ( j , col_ids ) in groupby_encoded_ids . iter ( ) . enumerate ( ) { key_buf [ j ] = col_ids [ row ] ; } match groups . raw_entry_mut ( ) . from_key ( & key_buf ) { // aggregates for this group key are already present. Update // them hash_map :: RawEntryMut :: Occupied ( mut entry ) => { for ( i , values ) in aggregate_columns_data . iter ( ) . enumerate ( ) { entry . get_mut ( ) [ i ] . update ( values . value ( row ) ) ; } } // group key does not exist, so create it. hash_map :: RawEntryMut :: Vacant ( entry ) => { let mut group_key_aggs = Vec :: with_capacity ( dst . schema . aggregate_columns . len ( ) ) ; for ( _ , agg_type , _ ) in & dst . schema . aggregate_columns { group_key_aggs . push ( AggregateResult :: from ( agg_type ) ) ; } for ( i , values ) in aggregate_columns_data . iter ( ) . enumerate ( ) { group_key_aggs [ i ] . update ( values . value ( row ) ) ; } entry . insert ( key_buf . clone ( ) , group_key_aggs ) ; } } } // Finally, build results set. Each encoded group key needs to be // materialised into a logical group key let columns = dst . schema . group_column_names_iter ( ) . map ( | name | self . column_by_name ( name ) ) . collect :: < Vec < _ > > ( ) ; let mut group_key_vec : Vec < GroupKey < ' _ > > = Vec :: with_capacity ( groups . len ( ) ) ; let mut aggregate_vec : Vec < AggregateResults < ' _ > > = Vec :: with_capacity ( groups . len ( ) ) ; for ( group_key , aggs ) in groups . into_iter ( ) { let mut logical_key = Vec :: with_capacity ( group_key . len ( ) ) ; for ( col_idx , & encoded_id ) in group_key . iter ( ) . enumerate ( ) { // TODO(edd): address the cast to u32 logical_key . push ( columns [ col_idx ] . decode_id ( encoded_id as u32 ) ) ; } group_key_vec . push ( GroupKey ( logical_key ) ) ; aggregate_vec . push ( AggregateResults ( aggs ) ) ; } // update results dst . group_keys = group_key_vec ; dst . aggregates = aggregate_vec ; }
This function is used with `read_group_hash` when the number of columns
being grouped on requires the use of a `Vec<u32>` as the group key in the
hash map.
This function is used with ` read_group_hash ` when the number of columns being grouped on requires the use of a ` Vec<u32 > ` as the group key in the hash map .
&'a self
dst
&mut ReadAggregateResult<'a>
groupby_encoded_ids
&[Vec<u32>]
aggregate_columns_data
&[Values<'a>]
&'a self
dst
&mut ReadAggregateResult<'a>
groupby_encoded_ids
&[Vec<u32>]
aggregate_columns_data
&[Values<'a>]