pub fn compact_files_in_range_cf(
    db: &DB,
    cf_name: &str,
    start: Option<&[u8]>,
    end: Option<&[u8]>,
    output_level: Option<i32>,
) -> Result<()> {
    let cf = db.cf_handle(cf_name).unwrap();
    let cf_opts = db.get_options_cf(cf);
    let output_level = output_level.unwrap_or(cf_opts.get_num_levels() as i32 - 1);
    let output_compression = cf_opts
        .get_compression_per_level()
        .get(output_level as usize)
        .cloned()
        .unwrap_or(DBCompressionType::No);
    let output_file_size_limit = cf_opts.get_target_file_size_base() as usize;

    let mut input_files = Vec::new();
    let cf_meta = db.get_column_family_meta_data(cf);
    for (i, level) in cf_meta.get_levels().iter().enumerate() {
        if i as i32 >= output_level {
            break;
        }
        for f in level.get_files() {
            if end.is_some() && end.unwrap() <= f.get_smallestkey() {
                continue;
            }
            if start.is_some() && start.unwrap() > f.get_largestkey() {
                continue;
            }
            input_files.push(f.get_name());
        }
    }
    if input_files.is_empty() {
        return Ok(());
    }

    let mut opts = CompactionOptions::new();
    opts.set_compression(output_compression);
    let max_subcompactions = SysQuota::new().cpu_cores_quota() as i32;
    let max_subcompactions = cmp::min(cmp::max(max_subcompactions, 1), 32);
    opts.set_max_subcompactions(max_subcompactions);
    opts.set_output_file_size_limit(output_file_size_limit);
    db.compact_files_cf(cf, &opts, &input_files, output_level)?;

    Ok(())
}
/// Compacts files in the range and above the output level of the given column family.
/// Compacts all files to the bottommost level if the output level is not specified.
Compacts files in the range and above the output level of the given column family.
Compacts all files to the bottommost level if the output level is not specified.
Compacts files in the range and above the output level of the given column family . Compacts all files to the bottommost level if the output level is not specified .
pub fn compact_files_in_range_cf(
    db: &DB,
    cf_name: &str,
    start: Option<&[u8]>,
    end: Option<&[u8]>,
    output_level: Option<i32>,
) -> Result<()> {
    let cf = db.cf_handle(cf_name).unwrap();
    let cf_opts = db.get_options_cf(cf);
    let output_level = output_level.unwrap_or(cf_opts.get_num_levels() as i32 - 1);
    let output_compression = cf_opts
        .get_compression_per_level()
        .get(output_level as usize)
        .cloned()
        .unwrap_or(DBCompressionType::No);
    let output_file_size_limit = cf_opts.get_target_file_size_base() as usize;
    let mut input_files = Vec::new();
    let cf_meta = db.get_column_family_meta_data(cf);
    for (i, level) in cf_meta.get_levels().iter().enumerate() {
        if i as i32 >= output_level {
            break;
        }
        for f in level.get_files() {
            if end.is_some() && end.unwrap() <= f.get_smallestkey() {
                continue;
            }
            if start.is_some() && start.unwrap() > f.get_largestkey() {
                continue;
            }
            input_files.push(f.get_name());
        }
    }
    if input_files.is_empty() {
        return Ok(());
    }
    let mut opts = CompactionOptions::new();
    opts.set_compression(output_compression);
    let max_subcompactions = SysQuota::new().cpu_cores_quota() as i32;
    let max_subcompactions = cmp::min(cmp::max(max_subcompactions, 1), 32);
    opts.set_max_subcompactions(max_subcompactions);
    opts.set_output_file_size_limit(output_file_size_limit);
    db.compact_files_cf(cf, &opts, &input_files, output_level)?;
    Ok(())
}
pub fn compact_files_in_range_cf ( db : & DB , cf_name : & str , start : Option < & [ u8 ] > , end : Option < & [ u8 ] > , output_level : Option < i32 > , ) -> Result < ( ) > { let cf = db . cf_handle ( cf_name ) . unwrap ( ) ; let cf_opts = db . get_options_cf ( cf ) ; let output_level = output_level . unwrap_or ( cf_opts . get_num_levels ( ) as i32 - 1 ) ; let output_compression = cf_opts . get_compression_per_level ( ) . get ( output_level as usize ) . cloned ( ) . unwrap_or ( DBCompressionType :: No ) ; let output_file_size_limit = cf_opts . get_target_file_size_base ( ) as usize ; let mut input_files = Vec :: new ( ) ; let cf_meta = db . get_column_family_meta_data ( cf ) ; for ( i , level ) in cf_meta . get_levels ( ) . iter ( ) . enumerate ( ) { if i as i32 >= output_level { break ; } for f in level . get_files ( ) { if end . is_some ( ) && end . unwrap ( ) <= f . get_smallestkey ( ) { continue ; } if start . is_some ( ) && start . unwrap ( ) > f . get_largestkey ( ) { continue ; } input_files . push ( f . get_name ( ) ) ; } } if input_files . is_empty ( ) { return Ok ( ( ) ) ; } let mut opts = CompactionOptions :: new ( ) ; opts . set_compression ( output_compression ) ; let max_subcompactions = SysQuota :: new ( ) . cpu_cores_quota ( ) as i32 ; let max_subcompactions = cmp :: min ( cmp :: max ( max_subcompactions , 1 ) , 32 ) ; opts . set_max_subcompactions ( max_subcompactions ) ; opts . set_output_file_size_limit ( output_file_size_limit ) ; db . compact_files_cf ( cf , & opts , & input_files , output_level ) ? ; Ok ( ( ) ) }
Compacts files in the range and above the output level of the given column family.
Compacts files in the range and above the output level of the given column family .
db
&DB
cf_name
&str
start
Option<&[u8]>
end
Option<&[u8]>
output_level
Option<i32>
db
&DB
cf_name
&str
start
Option<&[u8]>
end
Option<&[u8]>
output_level
Option<i32>