mirror of
https://gitlab.com/famedly/conduit.git
synced 2025-08-06 17:40:59 +00:00
feat: first implementation of KeyValue data export
This commit is contained in:
parent
c901ac0bb8
commit
6c8da70122
3 changed files with 55 additions and 2 deletions
|
@ -1,6 +1,6 @@
|
|||
use crate::{
|
||||
database::{
|
||||
abstraction::{watchers::Watchers, KeyValueDatabaseEngine, KvTree},
|
||||
abstraction::{watchers::Watchers, KeyValueDatabaseEngine, KvExport, KvTree},
|
||||
Config,
|
||||
},
|
||||
Result,
|
||||
|
@ -45,6 +45,22 @@ impl KeyValueDatabaseEngine for Arc<Engine> {
|
|||
fn flush(&self) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn export(&self, exporter: &mut Box<dyn KvExport>) -> Result<()> {
|
||||
let snapshot = self.persy.snapshot()?;
|
||||
let indexes = snapshot.list_indexes()?;
|
||||
for (index, _) in indexes {
|
||||
exporter.start_index(&index)?;
|
||||
let data = snapshot.range::<ByteVec, ByteVec, _>(&index, ..)?;
|
||||
for (key, values) in data {
|
||||
for value in values {
|
||||
exporter.key_value(&key, &value)?;
|
||||
}
|
||||
}
|
||||
exporter.end_index(&index)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
pub struct PersyTree {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue