Skip to content

Instantly share code, notes, and snippets.

@zchtodd
Created February 10, 2016 23:55
Show Gist options
  • Save zchtodd/d13489387b93ed99d8a3 to your computer and use it in GitHub Desktop.
Save zchtodd/d13489387b93ed99d8a3 to your computer and use it in GitHub Desktop.
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