aboutsummaryrefslogtreecommitdiff
path: root/src/model
diff options
context:
space:
mode:
Diffstat (limited to 'src/model')
-rw-r--r--src/model/block.rs4
-rw-r--r--src/model/block_ref_table.rs6
-rw-r--r--src/model/bucket_table.rs9
-rw-r--r--src/model/key_table.rs15
-rw-r--r--src/model/object_table.rs7
-rw-r--r--src/model/version_table.rs6
6 files changed, 25 insertions, 22 deletions
diff --git a/src/model/block.rs b/src/model/block.rs
index 4e8bb7d9..6a5d9c5b 100644
--- a/src/model/block.rs
+++ b/src/model/block.rs
@@ -20,7 +20,7 @@ use garage_rpc::rpc_client::*;
use garage_rpc::rpc_server::*;
use garage_table::table_sharded::TableShardedReplication;
-use garage_table::TableReplication;
+use garage_table::{TableReplication, DeletedFilter};
use crate::block_ref_table::*;
@@ -306,7 +306,7 @@ impl BlockManager {
let garage = self.garage.load_full().unwrap();
let active_refs = garage
.block_ref_table
- .get_range(&hash, None, Some(()), 1)
+ .get_range(&hash, None, Some(DeletedFilter::NotDeleted), 1)
.await?;
let needed_by_others = !active_refs.is_empty();
if needed_by_others {
diff --git a/src/model/block_ref_table.rs b/src/model/block_ref_table.rs
index a00438c0..5a7d9aa1 100644
--- a/src/model/block_ref_table.rs
+++ b/src/model/block_ref_table.rs
@@ -47,7 +47,7 @@ impl TableSchema for BlockRefTable {
type P = Hash;
type S = UUID;
type E = BlockRef;
- type Filter = ();
+ type Filter = DeletedFilter;
async fn updated(&self, old: Option<Self::E>, new: Option<Self::E>) -> Result<(), Error> {
let block = &old.as_ref().or(new.as_ref()).unwrap().block;
@@ -62,7 +62,7 @@ impl TableSchema for BlockRefTable {
Ok(())
}
- fn matches_filter(entry: &Self::E, _filter: &Self::Filter) -> bool {
- !entry.deleted
+ fn matches_filter(entry: &Self::E, filter: &Self::Filter) -> bool {
+ filter.apply(entry.deleted)
}
}
diff --git a/src/model/bucket_table.rs b/src/model/bucket_table.rs
index 28234d82..35c0cc27 100644
--- a/src/model/bucket_table.rs
+++ b/src/model/bucket_table.rs
@@ -75,7 +75,7 @@ impl Entry<EmptyKey, String> for Bucket {
}
fn merge(&mut self, other: &Self) {
- if other.timestamp < self.timestamp {
+ if other.timestamp > self.timestamp {
*self = other.clone();
return;
}
@@ -104,18 +104,19 @@ impl Entry<EmptyKey, String> for Bucket {
pub struct BucketTable;
+
#[async_trait]
impl TableSchema for BucketTable {
type P = EmptyKey;
type S = String;
type E = Bucket;
- type Filter = ();
+ type Filter = DeletedFilter;
async fn updated(&self, _old: Option<Self::E>, _new: Option<Self::E>) -> Result<(), Error> {
Ok(())
}
- fn matches_filter(entry: &Self::E, _filter: &Self::Filter) -> bool {
- !entry.deleted
+ fn matches_filter(entry: &Self::E, filter: &Self::Filter) -> bool {
+ filter.apply(entry.deleted)
}
}
diff --git a/src/model/key_table.rs b/src/model/key_table.rs
index 76d163b5..05b938ce 100644
--- a/src/model/key_table.rs
+++ b/src/model/key_table.rs
@@ -104,6 +104,11 @@ impl Entry<EmptyKey, String> for Key {
}
fn merge(&mut self, other: &Self) {
+ if other.name_timestamp > self.name_timestamp {
+ self.name_timestamp = other.name_timestamp;
+ self.name = other.name.clone();
+ }
+
if other.deleted {
self.deleted = true;
}
@@ -111,10 +116,6 @@ impl Entry<EmptyKey, String> for Key {
self.authorized_buckets.clear();
return;
}
- if other.name_timestamp > self.name_timestamp {
- self.name_timestamp = other.name_timestamp;
- self.name = other.name.clone();
- }
for ab in other.authorized_buckets.iter() {
match self
@@ -142,13 +143,13 @@ impl TableSchema for KeyTable {
type P = EmptyKey;
type S = String;
type E = Key;
- type Filter = ();
+ type Filter = DeletedFilter;
async fn updated(&self, _old: Option<Self::E>, _new: Option<Self::E>) -> Result<(), Error> {
Ok(())
}
- fn matches_filter(entry: &Self::E, _filter: &Self::Filter) -> bool {
- !entry.deleted
+ fn matches_filter(entry: &Self::E, filter: &Self::Filter) -> bool {
+ filter.apply(entry.deleted)
}
}
diff --git a/src/model/object_table.rs b/src/model/object_table.rs
index 719a222c..929b63f0 100644
--- a/src/model/object_table.rs
+++ b/src/model/object_table.rs
@@ -196,7 +196,7 @@ impl TableSchema for ObjectTable {
type P = String;
type S = String;
type E = Object;
- type Filter = ();
+ type Filter = DeletedFilter;
async fn updated(&self, old: Option<Self::E>, new: Option<Self::E>) -> Result<(), Error> {
let version_table = self.version_table.clone();
@@ -228,8 +228,9 @@ impl TableSchema for ObjectTable {
Ok(())
}
- fn matches_filter(entry: &Self::E, _filter: &Self::Filter) -> bool {
- entry.versions.iter().any(|v| v.is_data())
+ fn matches_filter(entry: &Self::E, filter: &Self::Filter) -> bool {
+ let deleted = !entry.versions.iter().any(|v| v.is_data());
+ filter.apply(deleted)
}
fn try_migrate(bytes: &[u8]) -> Option<Self::E> {
diff --git a/src/model/version_table.rs b/src/model/version_table.rs
index 6054e389..0d831998 100644
--- a/src/model/version_table.rs
+++ b/src/model/version_table.rs
@@ -117,7 +117,7 @@ impl TableSchema for VersionTable {
type P = Hash;
type S = EmptyKey;
type E = Version;
- type Filter = ();
+ type Filter = DeletedFilter;
async fn updated(&self, old: Option<Self::E>, new: Option<Self::E>) -> Result<(), Error> {
let block_ref_table = self.block_ref_table.clone();
@@ -139,7 +139,7 @@ impl TableSchema for VersionTable {
Ok(())
}
- fn matches_filter(entry: &Self::E, _filter: &Self::Filter) -> bool {
- !entry.deleted
+ fn matches_filter(entry: &Self::E, filter: &Self::Filter) -> bool {
+ filter.apply(entry.deleted)
}
}