Created
February 10, 2016 23:55
-
-
Save zchtodd/d13489387b93ed99d8a3 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
let mut records = vec![]; | |
while reader.read_line(&mut s).unwrap() > 0 { | |
let line = s.clone(); | |
let line: Vec<&str> = line.trim().split("\t").collect(); | |
let mut matched = true; | |
for (column, filter_types) in &filters { | |
let exact = filter_types.get("exact").unwrap(); | |
let contains = filter_types.get("contains").unwrap(); | |
let col = header_map.get(column).unwrap(); | |
for value in exact { | |
if line[*col] != value { | |
matched = false; | |
break; | |
} | |
} | |
for value in contains { | |
if !line[*col].contains(value) { | |
matched = false; | |
break; | |
} | |
} | |
if !matched { | |
break; | |
} | |
} | |
if matched { | |
seen += 1; | |
if seen > query.offset { | |
let record = line.clone(); | |
records.push(record.to_string()); | |
counted += 1; | |
if counted >= query.limit { | |
} | |
} | |
} | |
s.clear(); | |
} | |
println!("{}", counted); | |
Ok(Response::with(status::Ok)) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment