-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.rs
43 lines (40 loc) · 1.36 KB
/
main.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
use clap::StructOpt;
use jemallocator::Jemalloc;
use ttv::{cli, Compression, Result, SplitterBuilder};
#[global_allocator]
static GLOBAL: Jemalloc = Jemalloc;
fn main() -> Result<()> {
env_logger::init();
let opt = cli::Opt::parse();
match opt.cmd {
cli::Command::Split(x) => {
let mut splitter = SplitterBuilder::new(&x.input, x.rows, x.prop)?;
if x.decompress_input {
splitter = splitter.input_compression(Compression::GzipCompression);
}
if x.compress_output {
splitter = splitter.output_compression(Compression::GzipCompression);
}
if x.csv {
splitter = splitter.csv(true);
}
if x.no_header {
splitter = splitter.has_header(false);
}
if let Some(seed) = x.seed {
splitter = splitter.seed(seed);
}
if let Some(output_prefix) = x.output_prefix {
splitter = splitter.output_prefix(output_prefix);
}
if let Some(chunk_size) = x.chunk_size {
splitter = splitter.chunk_size(chunk_size);
}
if let Some(total_rows) = x.total_rows {
splitter = splitter.total_rows(total_rows);
}
splitter.build()?.run()?;
}
};
Ok(())
}