fn read_group_all_rows_all_rle<'a>(&'a self, dst: &mut ReadAggregateResult<'a>) {
        let group_columns = dst
            .schema
            .group_column_names_iter()
            .map(|name| self.column_by_name(name))
            .collect::<Vec<_>>();

        let aggregate_columns_typ = dst
            .schema
            .aggregate_columns
            .iter()
            .map(|(col_type, agg_type, _)| (self.column_by_name(col_type.as_str()), *agg_type))
            .collect::<Vec<_>>();

        let encoded_groups = dst
            .schema
            .group_column_names_iter()
            .map(|col_type| {
                self.column_by_name(col_type.as_str())
                    .grouped_row_ids()
                    .unwrap_left()
            })
            .collect::<Vec<_>>();

        // multi_cartesian_product will create the cartesian product of all
        // grouping-column values. This is likely going to be more group keys
        // than there exists row-data for, so don't materialise them yet...
        //
        // For example, we have two columns like:
        //
        //    [0, 1, 1, 2, 2, 3, 4] // column encodes the values as integers
        //    [3, 3, 3, 3, 4, 2, 1] // column encodes the values as integers
        //
        // The columns have these distinct values:
        //
        //    [0, 1, 2, 3, 4] [1, 2, 3, 4]
        //
        // We will produce the following "group key" candidates:
        //
        //    [0, 1], [0, 2], [0, 3], [0, 4] [1, 1], [1, 2], [1, 3], [1, 4]
        //    [2, 1], [2, 2], [2, 3], [2, 4] [3, 1], [3, 2], [3, 3], [3, 4]
        //    [4, 1], [4, 2], [4, 3], [4, 4]
        //
        // Based on the columns we can see that we only have data for the
        // following group keys:
        //
        //    [0, 3], [1, 3], [2, 3], [2, 4], [3, 2], [4, 1]
        //
        // We figure out which group keys have data and which don't in the loop
        // below, by intersecting bitsets for each id and checking for non-empty
        // sets.
        let group_keys = encoded_groups
            .iter()
            .map(|ids| (0..ids.len()))
            .multi_cartesian_product();

        // Let's figure out which of the candidate group keys are actually group
        // keys with data.
        'outer: for group_key in group_keys {
            let mut aggregate_row_ids =
                Cow::Borrowed(encoded_groups[0][group_key[0]].unwrap_bitmap());

            if aggregate_row_ids.is_empty() {
                continue;
            }

            for i in 1..group_key.len() {
                let other = encoded_groups[i][group_key[i]].unwrap_bitmap();

                if aggregate_row_ids.and_cardinality(other) > 0 {
                    aggregate_row_ids = Cow::Owned(aggregate_row_ids.and(other));
                } else {
                    continue 'outer;
                }
            }

            // This group key has some matching row ids. Materialise the group
            // key and calculate the aggregates.

            // TODO(edd): given these RLE columns should have low cardinality
            // there should be a reasonably low group key cardinality. It could
            // be safe to use `small_vec` here without blowing the stack up.
            let mut material_key = Vec::with_capacity(group_key.len());
            for (col_idx, &encoded_id) in group_key.iter().enumerate() {
                material_key.push(group_columns[col_idx].decode_id(encoded_id as u32));
            }
            dst.group_keys.push(GroupKey(material_key));

            let mut aggregates = Vec::with_capacity(aggregate_columns_typ.len());
            for (agg_col, typ) in &aggregate_columns_typ {
                aggregates.push(match typ {
                    AggregateType::Count => {
                        AggregateResult::Count(agg_col.count(&aggregate_row_ids.to_vec()) as u64)
                    }
                    AggregateType::First => todo!(),
                    AggregateType::Last => todo!(),
                    AggregateType::Min => {
                        AggregateResult::Min(agg_col.min(&aggregate_row_ids.to_vec()))
                    }
                    AggregateType::Max => {
                        AggregateResult::Max(agg_col.max(&aggregate_row_ids.to_vec()))
                    }
                    AggregateType::Sum => {
                        AggregateResult::Sum(agg_col.sum(&aggregate_row_ids.to_vec()))
                    }
                });
            }
            dst.aggregates.push(AggregateResults(aggregates));
        }
    }
// Optimised `read_group` method when there are no predicates and all the
// group columns are RLE-encoded.
//
// In this case all the grouping columns pre-computed bitsets for each
// distinct value.
Optimised `read_group` method when there are no predicates and all the
group columns are RLE-encoded.

In this case all the grouping columns pre-computed bitsets for each
distinct value.
Optimised ` read_group ` method when there are no predicates and all the group columns are RLE - encoded . In this case all the grouping columns pre - computed bitsets for each distinct value .
fn read_group_all_rows_all_rle<'a>(&'a self, dst: &mut ReadAggregateResult<'a>) {
        let group_columns = dst
            .schema
            .group_column_names_iter()
            .map(|name| self.column_by_name(name))
            .collect::<Vec<_>>();
        let aggregate_columns_typ = dst
            .schema
            .aggregate_columns
            .iter()
            .map(|(col_type, agg_type, _)| (self.column_by_name(col_type.as_str()), *agg_type))
            .collect::<Vec<_>>();
        let encoded_groups = dst
            .schema
            .group_column_names_iter()
            .map(|col_type| {
                self.column_by_name(col_type.as_str())
                    .grouped_row_ids()
                    .unwrap_left()
            })
            .collect::<Vec<_>>();
        // multi_cartesian_product will create the cartesian product of all
        // grouping-column values. This is likely going to be more group keys
        // than there exists row-data for, so don't materialise them yet...
        //
        // For example, we have two columns like:
        //
        //    [0, 1, 1, 2, 2, 3, 4] // column encodes the values as integers
        //    [3, 3, 3, 3, 4, 2, 1] // column encodes the values as integers
        //
        // The columns have these distinct values:
        //
        //    [0, 1, 2, 3, 4] [1, 2, 3, 4]
        //
        // We will produce the following "group key" candidates:
        //
        //    [0, 1], [0, 2], [0, 3], [0, 4] [1, 1], [1, 2], [1, 3], [1, 4]
        //    [2, 1], [2, 2], [2, 3], [2, 4] [3, 1], [3, 2], [3, 3], [3, 4]
        //    [4, 1], [4, 2], [4, 3], [4, 4]
        //
        // Based on the columns we can see that we only have data for the
        // following group keys:
        //
        //    [0, 3], [1, 3], [2, 3], [2, 4], [3, 2], [4, 1]
        //
        // We figure out which group keys have data and which don't in the loop
        // below, by intersecting bitsets for each id and checking for non-empty
        // sets.
        let group_keys = encoded_groups
            .iter()
            .map(|ids| (0..ids.len()))
            .multi_cartesian_product();
        // Let's figure out which of the candidate group keys are actually group
        // keys with data.
        'outer: for group_key in group_keys {
            let mut aggregate_row_ids =
                Cow::Borrowed(encoded_groups[0][group_key[0]].unwrap_bitmap());
            if aggregate_row_ids.is_empty() {
                continue;
            }
            for i in 1..group_key.len() {
                let other = encoded_groups[i][group_key[i]].unwrap_bitmap();
                if aggregate_row_ids.and_cardinality(other) > 0 {
                    aggregate_row_ids = Cow::Owned(aggregate_row_ids.and(other));
                } else {
                    continue 'outer;
                }
            }
            // This group key has some matching row ids. Materialise the group
            // key and calculate the aggregates.
            // TODO(edd): given these RLE columns should have low cardinality
            // there should be a reasonably low group key cardinality. It could
            // be safe to use `small_vec` here without blowing the stack up.
            let mut material_key = Vec::with_capacity(group_key.len());
            for (col_idx, &encoded_id) in group_key.iter().enumerate() {
                material_key.push(group_columns[col_idx].decode_id(encoded_id as u32));
            }
            dst.group_keys.push(GroupKey(material_key));
            let mut aggregates = Vec::with_capacity(aggregate_columns_typ.len());
            for (agg_col, typ) in &aggregate_columns_typ {
                aggregates.push(match typ {
                    AggregateType::Count => {
                        AggregateResult::Count(agg_col.count(&aggregate_row_ids.to_vec()) as u64)
                    }
                    AggregateType::First => todo!(),
                    AggregateType::Last => todo!(),
                    AggregateType::Min => {
                        AggregateResult::Min(agg_col.min(&aggregate_row_ids.to_vec()))
                    }
                    AggregateType::Max => {
                        AggregateResult::Max(agg_col.max(&aggregate_row_ids.to_vec()))
                    }
                    AggregateType::Sum => {
                        AggregateResult::Sum(agg_col.sum(&aggregate_row_ids.to_vec()))
                    }
                });
            }
            dst.aggregates.push(AggregateResults(aggregates));
        }
    }
fn read_group_all_rows_all_rle < ' a > ( & ' a self , dst : & mut ReadAggregateResult < ' a > ) { let group_columns = dst . schema . group_column_names_iter ( ) . map ( | name | self . column_by_name ( name ) ) . collect :: < Vec < _ > > ( ) ; let aggregate_columns_typ = dst . schema . aggregate_columns . iter ( ) . map ( | ( col_type , agg_type , _ ) | ( self . column_by_name ( col_type . as_str ( ) ) , * agg_type ) ) . collect :: < Vec < _ > > ( ) ; let encoded_groups = dst . schema . group_column_names_iter ( ) . map ( | col_type | { self . column_by_name ( col_type . as_str ( ) ) . grouped_row_ids ( ) . unwrap_left ( ) } ) . collect :: < Vec < _ > > ( ) ; // multi_cartesian_product will create the cartesian product of all // grouping-column values. This is likely going to be more group keys // than there exists row-data for, so don't materialise them yet... // // For example, we have two columns like: // //    [0, 1, 1, 2, 2, 3, 4] // column encodes the values as integers //    [3, 3, 3, 3, 4, 2, 1] // column encodes the values as integers // // The columns have these distinct values: // //    [0, 1, 2, 3, 4] [1, 2, 3, 4] // // We will produce the following "group key" candidates: // //    [0, 1], [0, 2], [0, 3], [0, 4] [1, 1], [1, 2], [1, 3], [1, 4] //    [2, 1], [2, 2], [2, 3], [2, 4] [3, 1], [3, 2], [3, 3], [3, 4] //    [4, 1], [4, 2], [4, 3], [4, 4] // // Based on the columns we can see that we only have data for the // following group keys: // //    [0, 3], [1, 3], [2, 3], [2, 4], [3, 2], [4, 1] // // We figure out which group keys have data and which don't in the loop // below, by intersecting bitsets for each id and checking for non-empty // sets. let group_keys = encoded_groups . iter ( ) . map ( | ids | ( 0 .. ids . len ( ) ) ) . multi_cartesian_product ( ) ; // Let's figure out which of the candidate group keys are actually group // keys with data. ' outer : for group_key in group_keys { let mut aggregate_row_ids = Cow :: Borrowed ( encoded_groups [ 0 ] [ group_key [ 0 ] ] . unwrap_bitmap ( ) ) ; if aggregate_row_ids . is_empty ( ) { continue ; } for i in 1 .. group_key . len ( ) { let other = encoded_groups [ i ] [ group_key [ i ] ] . unwrap_bitmap ( ) ; if aggregate_row_ids . and_cardinality ( other ) > 0 { aggregate_row_ids = Cow :: Owned ( aggregate_row_ids . and ( other ) ) ; } else { continue ' outer ; } } // This group key has some matching row ids. Materialise the group // key and calculate the aggregates. // TODO(edd): given these RLE columns should have low cardinality // there should be a reasonably low group key cardinality. It could // be safe to use `small_vec` here without blowing the stack up. let mut material_key = Vec :: with_capacity ( group_key . len ( ) ) ; for ( col_idx , & encoded_id ) in group_key . iter ( ) . enumerate ( ) { material_key . push ( group_columns [ col_idx ] . decode_id ( encoded_id as u32 ) ) ; } dst . group_keys . push ( GroupKey ( material_key ) ) ; let mut aggregates = Vec :: with_capacity ( aggregate_columns_typ . len ( ) ) ; for ( agg_col , typ ) in & aggregate_columns_typ { aggregates . push ( match typ { AggregateType :: Count => { AggregateResult :: Count ( agg_col . count ( & aggregate_row_ids . to_vec ( ) ) as u64 ) } AggregateType :: First => todo ! ( ) , AggregateType :: Last => todo ! ( ) , AggregateType :: Min => { AggregateResult :: Min ( agg_col . min ( & aggregate_row_ids . to_vec ( ) ) ) } AggregateType :: Max => { AggregateResult :: Max ( agg_col . max ( & aggregate_row_ids . to_vec ( ) ) ) } AggregateType :: Sum => { AggregateResult :: Sum ( agg_col . sum ( & aggregate_row_ids . to_vec ( ) ) ) } } ) ; } dst . aggregates . push ( AggregateResults ( aggregates ) ) ; } }
Optimised `read_group` method when there are no predicates and all the
group columns are RLE-encoded.
Optimised ` read_group ` method when there are no predicates and all the group columns are RLE - encoded .
&'a self
dst
&mut ReadAggregateResult<'a>
&'a self
dst
&mut ReadAggregateResult<'a>