mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-07-30 12:18:11 -07:00
global: snapshot
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
use brk_error::Result;
|
||||
use brk_types::{Height, Version};
|
||||
use fjall2::{InnerItem, PartitionHandle};
|
||||
use fjall3::Item;
|
||||
|
||||
pub trait AnyStore: Send + Sync {
|
||||
fn name(&self) -> &'static str;
|
||||
@@ -10,8 +8,9 @@ pub trait AnyStore: Send + Sync {
|
||||
fn needs(&self, height: Height) -> bool;
|
||||
fn version(&self) -> Version;
|
||||
fn export_meta_if_needed(&mut self, height: Height) -> Result<()>;
|
||||
fn partition(&self) -> &PartitionHandle;
|
||||
fn take_all_f2(&mut self) -> Vec<InnerItem>;
|
||||
fn take_all_f3(&mut self) -> Vec<Item>;
|
||||
fn keyspace(&self) -> &fjall3::Keyspace;
|
||||
fn partition(&self) -> &fjall2::PartitionHandle;
|
||||
fn take_all_f2(&mut self) -> Vec<fjall2::InnerItem>;
|
||||
fn take_all_f3(&mut self) -> Vec<fjall3::InnerItem>;
|
||||
// fn take_all_f3(&mut self) -> Box<dyn Iterator<Item = Item>>;
|
||||
}
|
||||
|
||||
@@ -174,6 +174,10 @@ where
|
||||
ByteView: From<K> + From<V>,
|
||||
Self: Send + Sync,
|
||||
{
|
||||
fn keyspace(&self) -> &fjall3::Keyspace {
|
||||
panic!()
|
||||
}
|
||||
|
||||
fn partition(&self) -> &fjall2::PartitionHandle {
|
||||
self.partition.inner()
|
||||
}
|
||||
@@ -192,7 +196,7 @@ where
|
||||
items.into_iter().map(InnerItem::from).collect()
|
||||
}
|
||||
|
||||
fn take_all_f3(&mut self) -> Vec<fjall3::Item> {
|
||||
fn take_all_f3(&mut self) -> Vec<fjall3::InnerItem> {
|
||||
panic!()
|
||||
}
|
||||
|
||||
|
||||
@@ -175,6 +175,10 @@ where
|
||||
ByteView: From<K> + From<V>,
|
||||
Self: Send + Sync,
|
||||
{
|
||||
fn keyspace(&self) -> &fjall3::Keyspace {
|
||||
&self.keyspace
|
||||
}
|
||||
|
||||
fn take_all_f2(&mut self) -> Vec<fjall2::InnerItem> {
|
||||
vec![]
|
||||
}
|
||||
@@ -183,7 +187,7 @@ where
|
||||
panic!()
|
||||
}
|
||||
|
||||
fn take_all_f3(&mut self) -> Vec<fjall3::Item> {
|
||||
fn take_all_f3(&mut self) -> Vec<fjall3::InnerItem> {
|
||||
let mut items = mem::take(&mut self.puts)
|
||||
.into_iter()
|
||||
.map(|(key, value)| Item::Value { key, value })
|
||||
@@ -194,10 +198,7 @@ where
|
||||
)
|
||||
.collect::<Vec<_>>();
|
||||
items.sort_unstable();
|
||||
items
|
||||
.into_iter()
|
||||
.map(|v| v.fjalled(&self.keyspace))
|
||||
.collect()
|
||||
items.into_iter().map(|v| v.fjalled()).collect()
|
||||
}
|
||||
|
||||
fn export_meta_if_needed(&mut self, height: Height) -> Result<()> {
|
||||
@@ -261,22 +262,18 @@ impl<K, V> Item<K, V> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn fjalled(self, keyspace: &Keyspace) -> fjall3::Item
|
||||
pub fn fjalled(self) -> fjall3::InnerItem
|
||||
where
|
||||
K: Into<ByteView>,
|
||||
V: Into<ByteView>,
|
||||
{
|
||||
let keyspace_id = keyspace.id;
|
||||
// let keyspace_id = keyspace.inner().id;
|
||||
match self {
|
||||
Item::Value { key, value } => fjall3::Item {
|
||||
keyspace_id,
|
||||
Item::Value { key, value } => fjall3::InnerItem {
|
||||
key: key.into().into(),
|
||||
value: value.into().into(),
|
||||
value_type: ValueType::Value,
|
||||
},
|
||||
Item::Tomb(key) => fjall3::Item {
|
||||
keyspace_id,
|
||||
Item::Tomb(key) => fjall3::InnerItem {
|
||||
key: key.into().into(),
|
||||
value: [].into(),
|
||||
value_type: ValueType::Tombstone,
|
||||
|
||||
Reference in New Issue
Block a user