mirror of
https://github.com/romanz/electrs.git
synced 2025-02-24 06:57:53 +01:00
Support SSTable ingestion into DB
This commit is contained in:
parent
e69686f988
commit
49ec4d1c38
1 changed files with 11 additions and 1 deletions
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…
Add table
Reference in a new issue