feat: Make the RocksDB read-only after loading the SST file

This commit is contained in:
Kerollmops 2018-08-25 15:54:31 +02:00 committed by Clément Renault
parent c32f014108
commit b91c4f89d5
1 changed files with 4 additions and 3 deletions

View File

@ -8,7 +8,7 @@ use std::str::from_utf8_unchecked;
use std::io::{self, Write};
use elapsed::measure_time;
use fst::Streamer;
use rocksdb::{DB, IngestExternalFileOptions};
use rocksdb::{DB, DBOptions, IngestExternalFileOptions};
use raptor::{Metadata, RankedStream, LevBuilder};
fn search(metadata: &Metadata, database: &DB, lev_builder: &LevBuilder, query: &str) {
@ -50,9 +50,10 @@ fn main() {
let (elapsed, db) = measure_time(|| {
let db = DB::open_default(rocksdb).unwrap();
db.ingest_external_file(&IngestExternalFileOptions::new(), &[&sst_file]).unwrap();
db
drop(db);
DB::open_for_read_only(DBOptions::default(), rocksdb, false).unwrap()
});
println!("{} to load the RocksDB database", elapsed);
println!("{} to load the SST file in RocksDB and reopen it for read-only", elapsed);
let (elapsed, lev_builder) = measure_time(|| LevBuilder::new());
println!("{} to load the levenshtein automaton", elapsed);