Rust implementation of the CVM algorithm for counting distinct elements in a stream
0

Configure Feed

Select the types of activity you want to include in your feed.

Better arg layout

+13 -4
+13 -4
src/main.rs
··· 21 21 .version(crate_version!()) 22 22 .author("Stephan Hügel <urschrei@gmail.com>") 23 23 .about("Use the CVM algorithm to estimate the number of unique tokens in a stream") 24 - .arg(arg!(-t --tokens <FILE> "A text file containing words").required(true).value_parser(value_parser!(PathBuf))) 25 - .arg(arg!(-e --epsilon <EPSILON> "How close you want your estimate to be to the true number of distinct tokens. A smaller ε means you require a more precise estimate. For example, ε = 0.05 means you want your estimate to be within 5 % of the actual value. An epsilon of 0.8 is a good starting point for most applications").required(true).value_parser(value_parser!(f64))) 26 - .arg(arg!(-d --delta <DELTA> "The level of certainty that the algorithm's estimate will fall within the desired accuracy range. A higher confidence (e.g., 99.9 %) means you're very sure the estimate will be accurate, while a lower confidence (e.g., 90 %) means there's a higher chance the estimate might be outside the desired range. A delta of 0.1 is a good starting point for most applications").required(true).value_parser(value_parser!(f64))) 27 - .arg(arg!(-s --streamsize <STREAM_SIZE> "This is used to determine buffer size and can be a loose approximation. The closer it is to the stream size, the more accurate the results").required(true).value_parser(value_parser!(usize))) 24 + .arg(arg!(-t --tokens <FILE> "A text file containing words") 25 + .required(true) 26 + .value_parser(value_parser!(PathBuf))) 27 + .arg(arg!(-e --epsilon <EPSILON> "How close you want your estimate to be to the true number of distinct tokens. A smaller ε means you require a more precise estimate. For example, ε = 0.05 means you want your estimate to be within 5 % of the actual value. An epsilon of 0.8 is a good starting point for most applications") 28 + .required(true) 29 + .value_parser(clap::value_parser!(f64)) 30 + ) 31 + .arg(arg!(-d --delta <DELTA> "The level of certainty that the algorithm's estimate will fall within the desired accuracy range. A higher confidence (e.g., 99.9 %) means you're very sure the estimate will be accurate, while a lower confidence (e.g., 90 %) means there's a higher chance the estimate might be outside the desired range. A delta of 0.1 is a good starting point for most applications") 32 + .required(true) 33 + .value_parser(value_parser!(f64))) 34 + .arg(arg!(-s --streamsize <STREAM_SIZE> "This is used to determine buffer size and can be a loose approximation. The closer it is to the stream size, the more accurate the results") 35 + .required(true) 36 + .value_parser(value_parser!(usize))) 28 37 .get_matches(); 29 38 let input_file = params.get_one::<PathBuf>("tokens").unwrap(); 30 39 let epsilon = params.get_one::<f64>("epsilon").unwrap();