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:
parent
e69686f988
commit
49ec4d1c38
12
src/store.rs
12
src/store.rs
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user