in-memory storage #32
1 changed files with 13 additions and 7 deletions
|
@ -23,12 +23,21 @@ impl InternalData {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug)]
|
||||||
struct InternalRowVal {
|
struct InternalRowVal {
|
||||||
data: Vec<InternalData>,
|
data: Vec<InternalData>,
|
||||||
version: u64,
|
version: u64,
|
||||||
change: Arc<Notify>,
|
change: Arc<Notify>,
|
||||||
}
|
}
|
||||||
|
impl std::default::Default for InternalRowVal {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
data: vec![],
|
||||||
|
version: 1,
|
||||||
|
change: Arc::new(Notify::new()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
impl InternalRowVal {
|
impl InternalRowVal {
|
||||||
fn concurrent_values(&self) -> Vec<Alternative> {
|
fn concurrent_values(&self) -> Vec<Alternative> {
|
||||||
self.data.iter().map(InternalData::to_alternative).collect()
|
self.data.iter().map(InternalData::to_alternative).collect()
|
||||||
|
@ -227,12 +236,9 @@ impl IStore for MemStore {
|
||||||
};
|
};
|
||||||
|
|
||||||
let notify_me = {
|
let notify_me = {
|
||||||
let store = self.row.read().or(Err(StorageError::Internal))?;
|
let mut store = self.row.write().or(Err(StorageError::Internal))?;
|
||||||
let intval = store
|
let bt = store.entry(shard.to_string()).or_default();
|
||||||
.get(shard)
|
let intval = bt.entry(sort.to_string()).or_default();
|
||||||
.ok_or(StorageError::NotFound)?
|
|
||||||
.get(sort)
|
|
||||||
.ok_or(StorageError::NotFound)?;
|
|
||||||
|
|
||||||
if intval.version != cauz {
|
if intval.version != cauz {
|
||||||
return Ok(intval.to_row_val(value.clone()));
|
return Ok(intval.to_row_val(value.clone()));
|
||||||
|
|
Loading…
Reference in a new issue