fn group_small_contiguous_groups(
        mut file_groups: Vec<GroupWithMinTimeAndSize>,
        compaction_max_size_bytes: i64,
        compaction_max_file_count: i64,
    ) -> Vec<Vec<ParquetFileWithMetadata>> {
        let mut groups = Vec::with_capacity(file_groups.len());
        if file_groups.is_empty() {
            return groups;
        }

        // Sort the groups by their min_time
        file_groups.sort_by_key(|a| a.min_time);

        let mut current_group = vec![];
        let mut current_size = 0;
        let mut current_num_files = 0;
        for g in file_groups {
            if current_size + g.total_file_size_bytes < compaction_max_size_bytes
                && current_num_files + g.parquet_files.len()
                    < compaction_max_file_count.try_into().unwrap()
            {
                // Group this one with the current_group
                current_num_files += g.parquet_files.len();
                current_group.extend(g.parquet_files);
                current_size += g.total_file_size_bytes;
            } else {
                // Current group  cannot combine with it next one
                if !current_group.is_empty() {
                    groups.push(current_group);
                }
                current_num_files = g.parquet_files.len();
                current_group = g.parquet_files;
                current_size = g.total_file_size_bytes;
            }
        }

        // push the last one
        groups.push(current_group);

        groups
    }
// Group time-contiguous non-overlapped groups if their total size is smaller than a threshold
Group time-contiguous non-overlapped groups if their total size is smaller than a threshold
Group time - contiguous non - overlapped groups if their total size is smaller than a threshold
fn group_small_contiguous_groups(
        mut file_groups: Vec<GroupWithMinTimeAndSize>,
        compaction_max_size_bytes: i64,
        compaction_max_file_count: i64,
    ) -> Vec<Vec<ParquetFileWithMetadata>> {
        let mut groups = Vec::with_capacity(file_groups.len());
        if file_groups.is_empty() {
            return groups;
        }
        // Sort the groups by their min_time
        file_groups.sort_by_key(|a| a.min_time);
        let mut current_group = vec![];
        let mut current_size = 0;
        let mut current_num_files = 0;
        for g in file_groups {
            if current_size + g.total_file_size_bytes < compaction_max_size_bytes
                && current_num_files + g.parquet_files.len()
                    < compaction_max_file_count.try_into().unwrap()
            {
                // Group this one with the current_group
                current_num_files += g.parquet_files.len();
                current_group.extend(g.parquet_files);
                current_size += g.total_file_size_bytes;
            } else {
                // Current group  cannot combine with it next one
                if !current_group.is_empty() {
                    groups.push(current_group);
                }
                current_num_files = g.parquet_files.len();
                current_group = g.parquet_files;
                current_size = g.total_file_size_bytes;
            }
        }
        // push the last one
        groups.push(current_group);
        groups
    }
fn group_small_contiguous_groups ( mut file_groups : Vec < GroupWithMinTimeAndSize > , compaction_max_size_bytes : i64 , compaction_max_file_count : i64 , ) -> Vec < Vec < ParquetFileWithMetadata > > { let mut groups = Vec :: with_capacity ( file_groups . len ( ) ) ; if file_groups . is_empty ( ) { return groups ; } // Sort the groups by their min_time file_groups . sort_by_key ( | a | a . min_time ) ; let mut current_group = vec ! [ ] ; let mut current_size = 0 ; let mut current_num_files = 0 ; for g in file_groups { if current_size + g . total_file_size_bytes < compaction_max_size_bytes && current_num_files + g . parquet_files . len ( ) < compaction_max_file_count . try_into ( ) . unwrap ( ) { // Group this one with the current_group current_num_files += g . parquet_files . len ( ) ; current_group . extend ( g . parquet_files ) ; current_size += g . total_file_size_bytes ; } else { // Current group  cannot combine with it next one if ! current_group . is_empty ( ) { groups . push ( current_group ) ; } current_num_files = g . parquet_files . len ( ) ; current_group = g . parquet_files ; current_size = g . total_file_size_bytes ; } } // push the last one groups . push ( current_group ) ; groups }
Group time-contiguous non-overlapped groups if their total size is smaller than a threshold
Group time - contiguous non - overlapped groups if their total size is smaller than a threshold
file_groups
Vec<GroupWithMinTimeAndSize>
compaction_max_size_bytes
i64
compaction_max_file_count
i64
file_groups
Vec<GroupWithMinTimeAndSize>
compaction_max_size_bytes
i64
compaction_max_file_count
i64