mirror of
https://github.com/loro-dev/loro.git
synced 2025-02-06 12:25:03 +00:00
chore: rebase main
This commit is contained in:
parent
776ca51b95
commit
dcb5ae4ec6
4 changed files with 12 additions and 56 deletions
|
@ -203,7 +203,7 @@ mod import {
|
|||
}
|
||||
b.iter(|| {
|
||||
c1.decode(
|
||||
&c2.encode(EncodeConfig::new(EncodeMode::Updates(c1.vv()), None))
|
||||
&c2.encode(EncodeConfig::new(EncodeMode::Updates(c1.vv_cloned()), None))
|
||||
.unwrap(),
|
||||
)
|
||||
.unwrap();
|
||||
|
|
|
@ -307,52 +307,3 @@ impl<'a, T: DagNode + 'a, D: Dag<Node = T>> Iterator for DagCausalIter<'a, D> {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use std::time::Instant;
|
||||
|
||||
use crate::{
|
||||
change::ChangeMergeCfg,
|
||||
configure::Configure,
|
||||
log_store::{EncodeConfig, EncodeMode},
|
||||
LoroCore,
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn parallel_case() {
|
||||
let mut c1 = LoroCore::new(
|
||||
Configure {
|
||||
change: ChangeMergeCfg {
|
||||
max_change_length: 0,
|
||||
max_change_interval: 0,
|
||||
},
|
||||
..Default::default()
|
||||
},
|
||||
Some(1),
|
||||
);
|
||||
let mut c2 = LoroCore::new(
|
||||
Configure {
|
||||
change: ChangeMergeCfg {
|
||||
max_change_length: 0,
|
||||
max_change_interval: 0,
|
||||
},
|
||||
..Default::default()
|
||||
},
|
||||
Some(2),
|
||||
);
|
||||
let mut text1 = c1.get_text("text");
|
||||
let mut text2 = c2.get_text("text");
|
||||
for _ in 0..1000 {
|
||||
text1.insert(&c1, 0, "1").unwrap();
|
||||
text2.insert(&c2, 0, "2").unwrap();
|
||||
}
|
||||
let start = Instant::now();
|
||||
c1.decode(
|
||||
&c2.encode(EncodeConfig::new(EncodeMode::Updates(c1.vv()), None))
|
||||
.unwrap(),
|
||||
)
|
||||
.unwrap();
|
||||
println!("{:?}", start.elapsed());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@ use tracing::instrument;
|
|||
use crate::{
|
||||
change::{Change, Lamport, Timestamp},
|
||||
container::ContainerID,
|
||||
event::RawEvent,
|
||||
hierarchy::{self, Hierarchy},
|
||||
id::{ClientID, Counter, ID},
|
||||
log_store::RemoteClientChanges,
|
||||
op::{RemoteContent, RemoteOp},
|
||||
|
@ -184,7 +186,12 @@ impl LoroCore {
|
|||
#[instrument(skip_all)]
|
||||
pub fn import_updates_batch(&mut self, input: &[Vec<u8>]) -> Result<(), LoroError> {
|
||||
debug_log::group!("Import updates at {}", self.client_id());
|
||||
let ans = self.log_store.write().unwrap().import_updates_batch(input);
|
||||
let mut hierarchy = self.hierarchy.try_lock().unwrap();
|
||||
let ans = self
|
||||
.log_store
|
||||
.write()
|
||||
.unwrap()
|
||||
.import_updates_batch(input, &mut hierarchy);
|
||||
let ans = match ans {
|
||||
Ok(events) => {
|
||||
self.notify(events);
|
||||
|
@ -202,6 +209,7 @@ impl LogStore {
|
|||
pub fn import_updates_batch(
|
||||
&mut self,
|
||||
batch: &[Vec<u8>],
|
||||
hierarchy: &mut Hierarchy,
|
||||
) -> Result<Vec<RawEvent>, postcard::Error> {
|
||||
// FIXME: changes may not be continuous
|
||||
let mut changes: RemoteClientChanges = Default::default();
|
||||
|
@ -215,6 +223,6 @@ impl LogStore {
|
|||
}
|
||||
}
|
||||
|
||||
Ok(self.import(changes))
|
||||
Ok(self.import(hierarchy, changes))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -270,10 +270,7 @@ impl LogStore {
|
|||
|
||||
let mut current_vv = common_ancestors_vv.clone();
|
||||
let mut already_checkout = FxHashSet::default();
|
||||
for iter in self.iter_causal(
|
||||
&common_ancestors,
|
||||
context.new_vv.sub_vec(&common_ancestors_vv),
|
||||
) {
|
||||
for iter in self.iter_causal(&common_ancestors, iter_targets) {
|
||||
debug_log::debug_dbg!(&iter);
|
||||
debug_log::debug_dbg!(¤t_vv);
|
||||
already_checkout.clear();
|
||||
|
|
Loading…
Reference in a new issue