Skip to content

Instantly share code, notes, and snippets.

@jacobrosenthal
Forked from elbow-jason/million_reader.rs
Last active February 9, 2019 21:00
Show Gist options
  • Save jacobrosenthal/fea14d72a41e2d253c1d581380dac1ba to your computer and use it in GitHub Desktop.
Save jacobrosenthal/fea14d72a41e2d253c1d581380dac1ba to your computer and use it in GitHub Desktop.
use std::thread;
use std::time::{Duration, Instant};
use std::fs;
use std::io;
use std::io::BufRead;
static DB_PATH: &str = "./file.db";
struct Row {
index: isize,
key: String,
value: String,
timestamp: u64,
}
pub fn main() {
println!("init");
let start = Instant::now();
let file = fs::File::open(DB_PATH).unwrap();
let mut rows: Vec<Row> = Vec::new();
for line in io::BufReader::new(file).lines() {
let l_string: String = line.unwrap();
let parts: Vec<&str> = l_string.split("::").collect();
let index: isize = parts[0].parse::<isize>().unwrap();
let ti: u64 = parts[3].parse::<u64>().unwrap();
rows.push(Row {
index: index,
key: parts[1].to_string(),
value: parts[2].to_string(),
timestamp: ti,
})
}
println!("{:?} {:?}", rows.len(), start.elapsed().as_millis())
// loop {
// thread::sleep(Duration::from_secs(60));
// }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment