Make the engine to return csv string records as documents and headers

This commit is contained in:
Kerollmops 2020-08-31 14:20:42 +02:00
parent bad0663138
commit 580ed1119a
No known key found for this signature in database
GPG key ID: 92ADA4E935E71FA4
8 changed files with 127 additions and 80 deletions

View file

@ -1,4 +1,4 @@
use std::io::{self, Write, BufRead};
use std::io::{self, BufRead};
use std::iter::once;
use std::path::PathBuf;
use std::time::Instant;
@ -70,12 +70,12 @@ fn main() -> anyhow::Result<()> {
};
let documents = index.documents(&rtxn, result.documents_ids.iter().cloned())?;
let mut stdout = io::stdout();
stdout.write_all(&headers)?;
for (_id, content) in documents {
stdout.write_all(&content)?;
let mut wtr = csv::Writer::from_writer(io::stdout());
wtr.write_record(&headers)?;
for (_id, record) in documents {
wtr.write_record(&record)?;
}
wtr.flush()?;
debug!("Took {:.02?} to find {} documents", before.elapsed(), result.documents_ids.len());
}