-
-
Save jacobrosenthal/fea14d72a41e2d253c1d581380dac1ba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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