mirror of
https://github.com/deuxfleurs-org/garage.git
synced 2026-08-31 09:18:29 +00:00
New multipart upload table layout
This commit is contained in:
@@ -8,6 +8,8 @@ use garage_util::migrate::Migrate;
|
||||
|
||||
use crate::crdt::Crdt;
|
||||
|
||||
// =================================== PARTITION KEYS
|
||||
|
||||
/// Trait for field used to partition data
|
||||
pub trait PartitionKey:
|
||||
Clone + PartialEq + Serialize + for<'de> Deserialize<'de> + Send + Sync + 'static
|
||||
@@ -31,6 +33,8 @@ impl PartitionKey for FixedBytes32 {
|
||||
}
|
||||
}
|
||||
|
||||
// =================================== SORT KEYS
|
||||
|
||||
/// Trait for field used to sort data
|
||||
pub trait SortKey: Clone + Serialize + for<'de> Deserialize<'de> + Send + Sync + 'static {
|
||||
/// Get the key used to sort
|
||||
@@ -49,6 +53,14 @@ impl SortKey for FixedBytes32 {
|
||||
}
|
||||
}
|
||||
|
||||
impl SortKey for u32 {
|
||||
fn sort_key(&self) -> Cow<'_, [u8]> {
|
||||
Cow::from(u32::to_be_bytes(*self).to_vec())
|
||||
}
|
||||
}
|
||||
|
||||
// =================================== SCHEMA
|
||||
|
||||
/// Trait for an entry in a table. It must be sortable and partitionnable.
|
||||
pub trait Entry<P: PartitionKey, S: SortKey>:
|
||||
Crdt + PartialEq + Clone + Migrate + Send + Sync + 'static
|
||||
|
||||
Reference in New Issue
Block a user