main: new argument -m to give a minimal saving

Some compressions yield only a few hundred lines saving which isn't worth
the database update and the time needed to validate the compression. With
the new commandline argument `-m` the output would be suppressed, if not
at least the given number of database records would be saved.
This commit is contained in:
Jörg Sommer
2019-06-12 23:02:43 +02:00
committed by Jan Alexander Steffens (heftig)
parent 88fc47d819
commit c31ba2750f

View File

@@ -119,6 +119,13 @@ fn main() {
.help("The maximum state group to process up to") .help("The maximum state group to process up to")
.takes_value(true) .takes_value(true)
.required(false), .required(false),
).arg(
Arg::with_name("min_saved_rows")
.short("m")
.value_name("COUNT")
.help("Suppress output if fewer than COUNT rows would be saved")
.takes_value(true)
.required(false),
).arg( ).arg(
Arg::with_name("output_file") Arg::with_name("output_file")
.short("o") .short("o")
@@ -165,6 +172,10 @@ fn main() {
.value_of("max_state_group") .value_of("max_state_group")
.map(|s| s.parse().expect("max_state_group must be an integer")); .map(|s| s.parse().expect("max_state_group must be an integer"));
let min_saved_rows = matches
.value_of("min_saved_rows")
.map(|v| v.parse().expect("COUNT must be an integer"));
let transactions = matches.is_present("transactions"); let transactions = matches.is_present("transactions");
let level_sizes = value_t_or_exit!(matches, "level_sizes", LevelSizes); let level_sizes = value_t_or_exit!(matches, "level_sizes", LevelSizes);
@@ -217,6 +228,17 @@ fn main() {
compressor.stats.state_groups_changed compressor.stats.state_groups_changed
); );
if let Some(min) = min_saved_rows {
let saving = (original_summed_size - compressed_summed_size) as i32;
if saving < min {
println!(
"Only {} rows would be saved by this compression. Skipping output.",
saving
);
return;
}
}
// If we are given an output file, we output the changes as SQL. If the // If we are given an output file, we output the changes as SQL. If the
// `transactions` argument is set we wrap each change to a state group in a // `transactions` argument is set we wrap each change to a state group in a
// transaction. // transaction.