1
0
mirror of https://github.com/romanz/electrs.git synced 2024-11-19 09:54:09 +01:00

Support SSTable ingestion into DB

This commit is contained in:
Roman Zeyde 2018-07-11 12:57:06 +03:00
parent e69686f988
commit 49ec4d1c38
No known key found for this signature in database
GPG Key ID: 87CAE5FA46917CBB

View File

@ -2,7 +2,7 @@ use rocksdb;
use rocksdb::Writable;
use std::cmp::Ordering;
use std::path::Path;
use std::path::{Path, PathBuf};
use util::Bytes;
@ -93,6 +93,16 @@ impl DBStore {
self.db.put(key, value).unwrap();
}
pub fn ingest(&self, sstables: &[PathBuf]) {
let mut opts = rocksdb::IngestExternalFileOptions::new();
opts.move_files(true);
let sstables: Vec<&str> = sstables.iter().map(|path| path.to_str().unwrap()).collect();
info!("ingesting {} SSTables", sstables.len());
self.db
.ingest_external_file(&opts, &sstables)
.expect("failed to ingest SSTables")
}
pub fn compact(&self) {
info!("starting full compaction");
self.db.compact_range(None, None); // would take a while