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:
committed by
Jan Alexander Steffens (heftig)
parent
88fc47d819
commit
c31ba2750f
22
src/main.rs
22
src/main.rs
@@ -119,6 +119,13 @@ fn main() {
|
||||
.help("The maximum state group to process up to")
|
||||
.takes_value(true)
|
||||
.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::with_name("output_file")
|
||||
.short("o")
|
||||
@@ -165,6 +172,10 @@ fn main() {
|
||||
.value_of("max_state_group")
|
||||
.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 level_sizes = value_t_or_exit!(matches, "level_sizes", LevelSizes);
|
||||
@@ -217,6 +228,17 @@ fn main() {
|
||||
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
|
||||
// `transactions` argument is set we wrap each change to a state group in a
|
||||
// transaction.
|
||||
|
||||
Reference in New Issue
Block a user