Move the documents into another file

This commit is contained in:
Clément Renault 2020-08-07 13:11:31 +02:00
parent fae694a102
commit 91282c8b6a
No known key found for this signature in database
GPG key ID: 92ADA4E935E71FA4
4 changed files with 71 additions and 43 deletions

View file

@ -1,3 +1,4 @@
use std::fs::File;
use std::io::{self, Write, BufRead};
use std::iter::once;
use std::path::PathBuf;
@ -6,6 +7,7 @@ use std::time::Instant;
use heed::EnvOpenOptions;
use log::debug;
use milli::Index;
use oxidized_mtbl::Reader;
use structopt::StructOpt;
#[cfg(target_os = "linux")]
@ -42,10 +44,17 @@ fn main() -> anyhow::Result<()> {
.map_size(100 * 1024 * 1024 * 1024) // 100 GB
.max_readers(10)
.max_dbs(10)
.open(opt.database)?;
.open(&opt.database)?;
// Open the LMDB database.
let index = Index::new(&env)?;
// Open the documents MTBL database.
let path = opt.database.join("documents.mtbl");
let file = File::open(path)?;
let mmap = unsafe { memmap::Mmap::map(&file)? };
let documents = Reader::new(mmap.as_ref())?;
let rtxn = env.read_txn()?;
let stdin = io::stdin();
@ -67,7 +76,6 @@ fn main() -> anyhow::Result<()> {
let mut stdout = io::stdout();
stdout.write_all(&headers)?;
let documents = index.documents(&rtxn)?.unwrap();
for id in &documents_ids {
let id_bytes = id.to_be_bytes();
if let Some(content) = documents.clone().get(&id_bytes)? {