Various updates
too lazy to split commits. some refactoring, clap, more binaries.
This commit is contained in:
+67
-25
@@ -12,7 +12,7 @@ struct Cfg {
|
||||
path: PathBuf
|
||||
}
|
||||
|
||||
fn make_store<T: Descriptor>(descriptor: T, input_path: PathBuf, save_path: PathBuf) -> () {
|
||||
fn make_store<T: Descriptor>(descriptor: T, input_path: PathBuf, save_path: PathBuf) -> DescriptorStore {
|
||||
let mut store =
|
||||
DescriptorStore::new()
|
||||
.with_file(save_path);
|
||||
@@ -20,6 +20,13 @@ fn make_store<T: Descriptor>(descriptor: T, input_path: PathBuf, save_path: Path
|
||||
store.insert_directory(input_path, descriptor);
|
||||
info!("{}", store);
|
||||
store.save().expect("Error saving");
|
||||
store
|
||||
}
|
||||
|
||||
struct StoreParams {
|
||||
desc: DCT,
|
||||
input_path: PathBuf,
|
||||
save_path: PathBuf,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
@@ -28,32 +35,67 @@ fn main() {
|
||||
|
||||
let mut threads = vec![];
|
||||
|
||||
let dct_50 =
|
||||
DCT::new()
|
||||
.with_quality(50);
|
||||
let dct_30 =
|
||||
DCT::new()
|
||||
.with_quality(30);
|
||||
let dct_10 =
|
||||
DCT::new()
|
||||
.with_quality(10);
|
||||
let params = vec![
|
||||
StoreParams {
|
||||
desc: DCT::new().with_quality(50),
|
||||
input_path: cfg.path.clone(),
|
||||
save_path: "dct50.messagepack".into(),
|
||||
},
|
||||
// StoreParams {
|
||||
// desc: DCT::new().with_quality(30),
|
||||
// input_path: cfg.path.clone(),
|
||||
// save_path: "dct30.messagepack".into(),
|
||||
// },
|
||||
// StoreParams {
|
||||
// desc: DCT::new().with_quality(10),
|
||||
// input_path: cfg.path.clone(),
|
||||
// save_path: "dct10.messagepack".into(),
|
||||
// },
|
||||
];
|
||||
|
||||
threads.push(
|
||||
thread::spawn(move || {
|
||||
make_store(dct_50, "data".into(), "dct50.messagepack".into());
|
||||
})
|
||||
);
|
||||
threads.push(
|
||||
thread::spawn(move || {
|
||||
make_store(dct_30, "data".into(), "dct30.messagepack".into());
|
||||
})
|
||||
);
|
||||
threads.push(
|
||||
thread::spawn(move || {
|
||||
make_store(dct_10, "data".into(), "dct10.messagepack".into());
|
||||
})
|
||||
);
|
||||
// let dct_50 =
|
||||
// DCT::new()
|
||||
// .with_quality(50);
|
||||
// let dct_30 =
|
||||
// DCT::new()
|
||||
// .with_quality(30);
|
||||
// let dct_10 =
|
||||
// DCT::new()
|
||||
// .with_quality(10);
|
||||
|
||||
//let (tx, rx) = mpsc::channel::<DescriptorStore>();
|
||||
|
||||
for param in params {
|
||||
threads.push(
|
||||
thread::spawn(move || {
|
||||
let store = make_store(param.desc, param.input_path, param.save_path);
|
||||
store.print_most_dups();
|
||||
//tx.send(store).unwrap();
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
// let path_50 = cfg.path.clone();
|
||||
// threads.push(
|
||||
// thread::spawn(move || {
|
||||
// let store = make_store(dct_50, path_50, "dct50.messagepack".into());
|
||||
// tx.send(store).expect("Thread send result error");
|
||||
// })
|
||||
// );
|
||||
// let path_30 = cfg.path.clone();
|
||||
// threads.push(
|
||||
// thread::spawn(move || {
|
||||
// dct_30_store = make_store(dct_30, path_30, "dct30.messagepack".into());
|
||||
// })
|
||||
// );
|
||||
// let path_10 = cfg.path.clone();
|
||||
// threads.push(
|
||||
// thread::spawn(move || {
|
||||
// dct_50_store = make_store(dct_10, path_10, "dct10.messagepack".into());
|
||||
// })
|
||||
// );
|
||||
for thread in threads {
|
||||
let _ = thread.join();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user