rename from WeakMemoizedStorage to DerivedStorage

This commit is contained in:
Niko Matsakis 2018-10-09 12:15:33 -04:00
parent 5ad0049b9f
commit 7c65d07ea6
2 changed files with 15 additions and 13 deletions

View file

@ -24,19 +24,21 @@ use std::marker::PhantomData;
/// Memoized queries store the result plus a list of the other queries /// Memoized queries store the result plus a list of the other queries
/// that they invoked. This means we can avoid recomputing them when /// that they invoked. This means we can avoid recomputing them when
/// none of those inputs have changed. /// none of those inputs have changed.
pub type MemoizedStorage<DB, Q> = WeakMemoizedStorage<DB, Q, AlwaysMemoizeValue>; pub type MemoizedStorage<DB, Q> = DerivedStorage<DB, Q, AlwaysMemoizeValue>;
/// "Dependency" queries just track their dependencies and not the /// "Dependency" queries just track their dependencies and not the
/// actual value (which they produce on demand). This lessens the /// actual value (which they produce on demand). This lessens the
/// storage requirements. /// storage requirements.
pub type DependencyStorage<DB, Q> = WeakMemoizedStorage<DB, Q, NeverMemoizeValue>; pub type DependencyStorage<DB, Q> = DerivedStorage<DB, Q, NeverMemoizeValue>;
/// "Dependency" queries just track their dependencies and not the /// "Dependency" queries just track their dependencies and not the
/// actual value (which they produce on demand). This lessens the /// actual value (which they produce on demand). This lessens the
/// storage requirements. /// storage requirements.
pub type VolatileStorage<DB, Q> = WeakMemoizedStorage<DB, Q, VolatileValue>; pub type VolatileStorage<DB, Q> = DerivedStorage<DB, Q, VolatileValue>;
pub struct WeakMemoizedStorage<DB, Q, MP> /// Handles storage where the value is 'derived' by executing a
/// function (in contrast to "inputs").
pub struct DerivedStorage<DB, Q, MP>
where where
Q: QueryFunction<DB>, Q: QueryFunction<DB>,
DB: Database, DB: Database,
@ -138,21 +140,21 @@ where
verified_at: Revision, verified_at: Revision,
} }
impl<DB, Q, MP> Default for WeakMemoizedStorage<DB, Q, MP> impl<DB, Q, MP> Default for DerivedStorage<DB, Q, MP>
where where
Q: QueryFunction<DB>, Q: QueryFunction<DB>,
DB: Database, DB: Database,
MP: MemoizationPolicy<DB, Q>, MP: MemoizationPolicy<DB, Q>,
{ {
fn default() -> Self { fn default() -> Self {
WeakMemoizedStorage { DerivedStorage {
map: RwLock::new(FxHashMap::default()), map: RwLock::new(FxHashMap::default()),
policy: PhantomData, policy: PhantomData,
} }
} }
} }
impl<DB, Q, MP> WeakMemoizedStorage<DB, Q, MP> impl<DB, Q, MP> DerivedStorage<DB, Q, MP>
where where
Q: QueryFunction<DB>, Q: QueryFunction<DB>,
DB: Database, DB: Database,
@ -311,7 +313,7 @@ where
} }
} }
impl<DB, Q, MP> QueryStorageOps<DB, Q> for WeakMemoizedStorage<DB, Q, MP> impl<DB, Q, MP> QueryStorageOps<DB, Q> for DerivedStorage<DB, Q, MP>
where where
Q: QueryFunction<DB>, Q: QueryFunction<DB>,
DB: Database, DB: Database,
@ -392,7 +394,7 @@ where
} }
} }
impl<DB, Q, MP> UncheckedMutQueryStorageOps<DB, Q> for WeakMemoizedStorage<DB, Q, MP> impl<DB, Q, MP> UncheckedMutQueryStorageOps<DB, Q> for DerivedStorage<DB, Q, MP>
where where
Q: QueryFunction<DB>, Q: QueryFunction<DB>,
DB: Database, DB: Database,

View file

@ -16,8 +16,8 @@ use std::fmt::Display;
use std::fmt::Write; use std::fmt::Write;
use std::hash::Hash; use std::hash::Hash;
pub mod derived;
pub mod input; pub mod input;
pub mod memoized;
pub mod runtime; pub mod runtime;
/// The base trait which your "query context" must implement. Gives /// The base trait which your "query context" must implement. Gives
@ -421,19 +421,19 @@ macro_rules! query_group {
( (
@storage_ty[$DB:ident, $Self:ident, memoized] @storage_ty[$DB:ident, $Self:ident, memoized]
) => { ) => {
$crate::memoized::MemoizedStorage<$DB, $Self> $crate::derived::MemoizedStorage<$DB, $Self>
}; };
( (
@storage_ty[$DB:ident, $Self:ident, volatile] @storage_ty[$DB:ident, $Self:ident, volatile]
) => { ) => {
$crate::memoized::VolatileStorage<$DB, $Self> $crate::derived::VolatileStorage<$DB, $Self>
}; };
( (
@storage_ty[$DB:ident, $Self:ident, dependencies] @storage_ty[$DB:ident, $Self:ident, dependencies]
) => { ) => {
$crate::memoized::DependencyStorage<$DB, $Self> $crate::derived::DependencyStorage<$DB, $Self>
}; };
( (