mirror of
https://github.com/loro-dev/loro.git
synced 2025-01-23 13:39:12 +00:00
commit
a32236e73f
6 changed files with 65 additions and 1 deletions
39
Cargo.lock
generated
39
Cargo.lock
generated
|
@ -797,6 +797,7 @@ dependencies = [
|
|||
"string_cache",
|
||||
"tabled",
|
||||
"thiserror",
|
||||
"tracing",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
|
@ -1075,6 +1076,12 @@ dependencies = [
|
|||
"syn 1.0.103",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pin-project-lite"
|
||||
version = "0.2.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116"
|
||||
|
||||
[[package]]
|
||||
name = "plotters"
|
||||
version = "0.3.4"
|
||||
|
@ -1746,6 +1753,38 @@ dependencies = [
|
|||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing"
|
||||
version = "0.1.37"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"pin-project-lite",
|
||||
"tracing-attributes",
|
||||
"tracing-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-attributes"
|
||||
version = "0.1.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.47",
|
||||
"quote 1.0.21",
|
||||
"syn 1.0.103",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-core"
|
||||
version = "0.1.30"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "typenum"
|
||||
version = "1.15.0"
|
||||
|
|
|
@ -32,6 +32,7 @@ serde_json = { version = "1.0.87", optional = true }
|
|||
arref = "0.1.0"
|
||||
serde_columnar = { version = "0.1.0" }
|
||||
debug-log = "0.1.4"
|
||||
tracing = { version = "0.1.37" }
|
||||
|
||||
[dev-dependencies]
|
||||
serde_json = "1.0.87"
|
||||
|
|
|
@ -8,6 +8,7 @@ use enum_as_inner::EnumAsInner;
|
|||
use fxhash::FxHashMap;
|
||||
use owning_ref::OwningRefMut;
|
||||
use smallvec::SmallVec;
|
||||
use tracing::instrument;
|
||||
|
||||
use crate::{
|
||||
context::Context,
|
||||
|
@ -62,6 +63,7 @@ impl Container for ContainerInstance {
|
|||
}
|
||||
}
|
||||
|
||||
#[instrument(skip_all)]
|
||||
fn tracker_checkout(&mut self, vv: &crate::VersionVector) {
|
||||
match self {
|
||||
ContainerInstance::Map(x) => x.tracker_checkout(vv),
|
||||
|
@ -71,6 +73,7 @@ impl Container for ContainerInstance {
|
|||
}
|
||||
}
|
||||
|
||||
#[instrument(skip_all)]
|
||||
fn get_value(&self) -> crate::LoroValue {
|
||||
match self {
|
||||
ContainerInstance::Map(x) => x.get_value(),
|
||||
|
@ -80,6 +83,7 @@ impl Container for ContainerInstance {
|
|||
}
|
||||
}
|
||||
|
||||
#[instrument(skip_all)]
|
||||
fn update_state_directly(
|
||||
&mut self,
|
||||
hierarchy: &mut Hierarchy,
|
||||
|
@ -94,6 +98,7 @@ impl Container for ContainerInstance {
|
|||
}
|
||||
}
|
||||
|
||||
#[instrument(skip_all)]
|
||||
fn track_retreat(&mut self, op: &IdSpanVector) {
|
||||
match self {
|
||||
ContainerInstance::Map(x) => x.track_retreat(op),
|
||||
|
@ -103,6 +108,7 @@ impl Container for ContainerInstance {
|
|||
}
|
||||
}
|
||||
|
||||
#[instrument(skip_all)]
|
||||
fn track_forward(&mut self, op: &IdSpanVector) {
|
||||
match self {
|
||||
ContainerInstance::Map(x) => x.track_forward(op),
|
||||
|
@ -112,6 +118,7 @@ impl Container for ContainerInstance {
|
|||
}
|
||||
}
|
||||
|
||||
#[instrument(skip_all)]
|
||||
fn track_apply(&mut self, hierarchy: &mut Hierarchy, op: &RichOp, ctx: &mut ImportContext) {
|
||||
match self {
|
||||
ContainerInstance::Map(x) => x.track_apply(hierarchy, op, ctx),
|
||||
|
@ -121,6 +128,7 @@ impl Container for ContainerInstance {
|
|||
}
|
||||
}
|
||||
|
||||
#[instrument(skip_all)]
|
||||
fn apply_tracked_effects_from(
|
||||
&mut self,
|
||||
h: &mut Hierarchy,
|
||||
|
@ -134,6 +142,7 @@ impl Container for ContainerInstance {
|
|||
}
|
||||
}
|
||||
|
||||
#[instrument(skip_all)]
|
||||
fn to_export(
|
||||
&mut self,
|
||||
content: crate::op::InnerContent,
|
||||
|
@ -147,6 +156,7 @@ impl Container for ContainerInstance {
|
|||
}
|
||||
}
|
||||
|
||||
#[instrument(skip_all)]
|
||||
fn to_import(&mut self, content: crate::op::RemoteContent) -> crate::op::InnerContent {
|
||||
match self {
|
||||
ContainerInstance::Map(x) => x.to_import(content),
|
||||
|
|
|
@ -5,6 +5,7 @@ use rle::{
|
|||
HasLength, RleTree,
|
||||
};
|
||||
use smallvec::SmallVec;
|
||||
use tracing::instrument;
|
||||
|
||||
use crate::{
|
||||
container::{
|
||||
|
@ -48,6 +49,7 @@ impl TextContainer {
|
|||
}
|
||||
}
|
||||
|
||||
#[instrument(skip_all)]
|
||||
pub fn insert<C: Context>(&mut self, ctx: &C, pos: usize, text: &str) -> Option<ID> {
|
||||
if text.is_empty() {
|
||||
return None;
|
||||
|
@ -88,6 +90,7 @@ impl TextContainer {
|
|||
Some(id)
|
||||
}
|
||||
|
||||
#[instrument(skip_all)]
|
||||
pub fn delete<C: Context>(&mut self, ctx: &C, pos: usize, len: usize) -> Option<ID> {
|
||||
if len == 0 {
|
||||
return None;
|
||||
|
@ -273,6 +276,7 @@ impl Container for TextContainer {
|
|||
}
|
||||
}
|
||||
|
||||
#[instrument(skip_all)]
|
||||
fn update_state_directly(
|
||||
&mut self,
|
||||
hierarchy: &mut Hierarchy,
|
||||
|
@ -321,6 +325,7 @@ impl Container for TextContainer {
|
|||
self.tracker.forward(spans);
|
||||
}
|
||||
|
||||
#[instrument(skip_all)]
|
||||
fn tracker_checkout(&mut self, vv: &crate::VersionVector) {
|
||||
if (!vv.is_empty() || self.tracker.start_vv().is_empty())
|
||||
&& self.tracker.all_vv() >= vv
|
||||
|
@ -332,6 +337,7 @@ impl Container for TextContainer {
|
|||
}
|
||||
}
|
||||
|
||||
#[instrument(skip_all)]
|
||||
fn track_apply(
|
||||
&mut self,
|
||||
_: &mut Hierarchy,
|
||||
|
@ -341,6 +347,7 @@ impl Container for TextContainer {
|
|||
self.tracker.track_apply(rich_op);
|
||||
}
|
||||
|
||||
#[instrument(skip_all)]
|
||||
fn apply_tracked_effects_from(
|
||||
&mut self,
|
||||
hierarchy: &mut Hierarchy,
|
||||
|
|
|
@ -5,6 +5,7 @@ use rle::{HasLength, RleVec, RleVecWithIndex};
|
|||
use serde::{Deserialize, Serialize};
|
||||
use serde_columnar::{columnar, compress, decompress, from_bytes, to_vec, CompressConfig};
|
||||
use smallvec::smallvec;
|
||||
use tracing::instrument;
|
||||
|
||||
use crate::{
|
||||
change::{Change, ChangeMergeCfg, Lamport, Timestamp},
|
||||
|
@ -92,6 +93,7 @@ struct Encoded {
|
|||
keys: Vec<InternalString>,
|
||||
}
|
||||
|
||||
#[instrument(skip_all)]
|
||||
fn encode_changes(store: &LogStore) -> Encoded {
|
||||
let mut client_id_to_idx: FxHashMap<ClientID, ClientIdx> = FxHashMap::default();
|
||||
let mut clients = Vec::with_capacity(store.changes.len());
|
||||
|
@ -187,6 +189,7 @@ fn encode_changes(store: &LogStore) -> Encoded {
|
|||
}
|
||||
}
|
||||
|
||||
#[instrument(skip_all)]
|
||||
fn decode_changes(
|
||||
encoded: Encoded,
|
||||
client_id: Option<ClientID>,
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
use crate::LogStore;
|
||||
use crate::{
|
||||
container::registry::ContainerIdx,
|
||||
event::{Diff, RawEvent},
|
||||
version::{Frontiers, IdSpanVector},
|
||||
LogStore,
|
||||
};
|
||||
use std::{collections::VecDeque, ops::ControlFlow, sync::MutexGuard};
|
||||
use tracing::instrument;
|
||||
|
||||
use fxhash::FxHashMap;
|
||||
|
||||
|
@ -72,6 +73,8 @@ impl LogStore {
|
|||
/// - Stage 1: we iterate over the new changes by causal order, and record them to the tracker.
|
||||
/// - Stage 2: we calculate the effects of the new changes, and apply them to the state.
|
||||
/// - Update the rest of the log store state.
|
||||
///
|
||||
#[instrument(skip_all)]
|
||||
pub fn import(&mut self, mut changes: RemoteClientChanges) {
|
||||
if let ControlFlow::Break(_) = self.tailor_changes(&mut changes) {
|
||||
return;
|
||||
|
@ -178,6 +181,7 @@ impl LogStore {
|
|||
(next_vv, next_frontiers)
|
||||
}
|
||||
|
||||
#[instrument(skip_all)]
|
||||
pub(crate) fn apply(
|
||||
&mut self,
|
||||
mut container_map: FxHashMap<ContainerIdx, MutexGuard<ContainerInstance>>,
|
||||
|
|
Loading…
Reference in a new issue