global: snapshot

This commit is contained in:
nym21
2025-11-11 17:41:12 +01:00
parent 2dcbd8df99
commit 81da73bc53
17 changed files with 811 additions and 427 deletions
+4 -5
View File
@@ -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>>;
}
+5 -1
View File
@@ -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!()
}
+9 -12
View File
@@ -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,