aboutsummaryrefslogtreecommitdiff
path: root/src/storage
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2023-12-19 19:21:36 +0100
committerQuentin Dufour <quentin@deuxfleurs.fr>2023-12-19 19:21:36 +0100
commit8bc40fa0877714aabbc6134357622ab47c628f0c (patch)
treed15e7a90e41a0465e383b0c0c33dc30cecb4d73d /src/storage
parentc75f2d91ff969dd791cb476031ee80870c6ad61a (diff)
downloadaerogramme-8bc40fa0877714aabbc6134357622ab47c628f0c.tar.gz
aerogramme-8bc40fa0877714aabbc6134357622ab47c628f0c.zip
wip in mem storage bug fixes
Diffstat (limited to 'src/storage')
-rw-r--r--src/storage/in_memory.rs20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/storage/in_memory.rs b/src/storage/in_memory.rs
index c18bec3..7d8d108 100644
--- a/src/storage/in_memory.rs
+++ b/src/storage/in_memory.rs
@@ -23,12 +23,21 @@ impl InternalData {
}
}
-#[derive(Debug, Default)]
+#[derive(Debug)]
struct InternalRowVal {
data: Vec<InternalData>,
version: u64,
change: Arc<Notify>,
}
+impl std::default::Default for InternalRowVal {
+ fn default() -> Self {
+ Self {
+ data: vec![],
+ version: 1,
+ change: Arc::new(Notify::new()),
+ }
+ }
+}
impl InternalRowVal {
fn concurrent_values(&self) -> Vec<Alternative> {
self.data.iter().map(InternalData::to_alternative).collect()
@@ -227,12 +236,9 @@ impl IStore for MemStore {
};
let notify_me = {
- let store = self.row.read().or(Err(StorageError::Internal))?;
- let intval = store
- .get(shard)
- .ok_or(StorageError::NotFound)?
- .get(sort)
- .ok_or(StorageError::NotFound)?;
+ let mut store = self.row.write().or(Err(StorageError::Internal))?;
+ let bt = store.entry(shard.to_string()).or_default();
+ let intval = bt.entry(sort.to_string()).or_default();
if intval.version != cauz {
return Ok(intval.to_row_val(value.clone()));