add file listing to database abstraction.
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
bdf3997de5
commit
6b1933914d
4 changed files with 29 additions and 0 deletions
|
@ -34,6 +34,8 @@ pub(crate) trait KeyValueDatabaseEngine: Send + Sync {
|
||||||
fn backup(&self) -> Result<(), Box<dyn Error>> { unimplemented!() }
|
fn backup(&self) -> Result<(), Box<dyn Error>> { unimplemented!() }
|
||||||
|
|
||||||
fn backup_list(&self) -> Result<String> { Ok(String::new()) }
|
fn backup_list(&self) -> Result<String> { Ok(String::new()) }
|
||||||
|
|
||||||
|
fn file_list(&self) -> Result<String> { Ok(String::new()) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) trait KvTree: Send + Sync {
|
pub(crate) trait KvTree: Send + Sync {
|
||||||
|
|
|
@ -304,6 +304,30 @@ impl KeyValueDatabaseEngine for Arc<Engine> {
|
||||||
Ok(res)
|
Ok(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn file_list(&self) -> Result<String> {
|
||||||
|
match self.rocks.live_files() {
|
||||||
|
Err(e) => Ok(String::from(e)),
|
||||||
|
Ok(files) => {
|
||||||
|
let mut res = String::new();
|
||||||
|
for file in files {
|
||||||
|
let _ = std::fmt::write(
|
||||||
|
&mut res,
|
||||||
|
format_args!(
|
||||||
|
"<code>L{} {:<13} {:7}+ {:4}- {:9}</code> {}<br>",
|
||||||
|
file.level,
|
||||||
|
file.name,
|
||||||
|
file.num_entries,
|
||||||
|
file.num_deletions,
|
||||||
|
file.size,
|
||||||
|
file.column_family_name,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
Ok(res)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: figure out if this is needed for rocksdb
|
// TODO: figure out if this is needed for rocksdb
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
fn clear_caches(&self) {}
|
fn clear_caches(&self) {}
|
||||||
|
|
|
@ -286,4 +286,6 @@ lasttimelinecount_cache: {lasttimelinecount_cache}\n"
|
||||||
fn backup(&self) -> Result<(), Box<dyn std::error::Error>> { self.db.backup() }
|
fn backup(&self) -> Result<(), Box<dyn std::error::Error>> { self.db.backup() }
|
||||||
|
|
||||||
fn backup_list(&self) -> Result<String> { self.db.backup_list() }
|
fn backup_list(&self) -> Result<String> { self.db.backup_list() }
|
||||||
|
|
||||||
|
fn file_list(&self) -> Result<String> { self.db.file_list() }
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,4 +37,5 @@ pub trait Data: Send + Sync {
|
||||||
fn bump_database_version(&self, new_version: u64) -> Result<()>;
|
fn bump_database_version(&self, new_version: u64) -> Result<()>;
|
||||||
fn backup(&self) -> Result<(), Box<dyn Error>> { unimplemented!() }
|
fn backup(&self) -> Result<(), Box<dyn Error>> { unimplemented!() }
|
||||||
fn backup_list(&self) -> Result<String> { Ok(String::new()) }
|
fn backup_list(&self) -> Result<String> { Ok(String::new()) }
|
||||||
|
fn file_list(&self) -> Result<String> { Ok(String::new()) }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue