mirror of
https://github.com/loro-dev/loro.git
synced 2025-02-06 04:19:34 +00:00
refactor: rename "OpGroup" to "ContainerHistoryCache"
This commit is contained in:
parent
59f09e7162
commit
06cd6b577d
3 changed files with 11 additions and 6 deletions
|
@ -19,13 +19,18 @@ use crate::{
|
|||
VersionVector,
|
||||
};
|
||||
|
||||
/// A cache for the history of a container.
|
||||
///
|
||||
/// There are cases where a container needs a view of the history of the container.
|
||||
/// For example, when switching to an older version, a map container may need to know the value of a key at a certain version.
|
||||
/// This cache provides a faster way to do that than scanning the oplog.
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct OpGroups {
|
||||
pub(crate) struct ContainerHistoryCache {
|
||||
arena: SharedArena,
|
||||
groups: FxHashMap<ContainerIdx, OpGroup>,
|
||||
}
|
||||
|
||||
impl OpGroups {
|
||||
impl ContainerHistoryCache {
|
||||
pub(crate) fn fork(&self, arena: SharedArena) -> Self {
|
||||
let mut groups = FxHashMap::with_capacity_and_hasher(self.groups.len(), Default::default());
|
||||
for (container_idx, group) in self.groups.iter() {
|
|
@ -54,7 +54,7 @@ pub mod event;
|
|||
|
||||
pub use error::{LoroError, LoroResult};
|
||||
pub mod estimated_size;
|
||||
pub(crate) mod group;
|
||||
pub(crate) mod history_cache;
|
||||
pub(crate) mod macros;
|
||||
pub(crate) mod state;
|
||||
pub mod undo;
|
||||
|
|
|
@ -16,7 +16,7 @@ use crate::container::list::list_op;
|
|||
use crate::dag::{Dag, DagUtils};
|
||||
use crate::encoding::ParsedHeaderAndBody;
|
||||
use crate::encoding::{decode_oplog, encode_oplog, EncodeMode};
|
||||
use crate::group::OpGroups;
|
||||
use crate::history_cache::ContainerHistoryCache;
|
||||
use crate::id::{Counter, PeerID, ID};
|
||||
use crate::op::{FutureInnerContent, ListSlice, RawOpContent, RemoteOp, RichOp};
|
||||
use crate::span::{HasCounterSpan, HasIdSpan, HasLamportSpan};
|
||||
|
@ -45,7 +45,7 @@ pub struct OpLog {
|
|||
pub(crate) dag: AppDag,
|
||||
pub(crate) arena: SharedArena,
|
||||
change_store: ChangeStore,
|
||||
pub(crate) op_groups: OpGroups,
|
||||
pub(crate) op_groups: ContainerHistoryCache,
|
||||
/// **lamport starts from 0**
|
||||
pub(crate) next_lamport: Lamport,
|
||||
pub(crate) latest_timestamp: Timestamp,
|
||||
|
@ -187,7 +187,7 @@ impl OpLog {
|
|||
Self {
|
||||
change_store: ChangeStore::new_mem(&arena, cfg.merge_interval.clone()),
|
||||
dag: AppDag::default(),
|
||||
op_groups: OpGroups::new(arena.clone()),
|
||||
op_groups: ContainerHistoryCache::new(arena.clone()),
|
||||
arena,
|
||||
next_lamport: 0,
|
||||
latest_timestamp: Timestamp::default(),
|
||||
|
|
Loading…
Reference in a new issue