mirror of
https://github.com/loro-dev/loro.git
synced 2025-02-05 20:17:13 +00:00
chore: yata init
This commit is contained in:
parent
41167b4af0
commit
92a2e48ef5
9 changed files with 46 additions and 13 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -161,9 +161,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "crdt-list"
|
||||
version = "0.1.3"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "15ab0245d29050a50d3431ad32d13bc59a187aa9c0e543b235ab8190f6b0d8af"
|
||||
checksum = "44c6c20076c40cfc4fc484455bda1ba3cac6f9585b2e5a464b98fc4a2600f95b"
|
||||
dependencies = [
|
||||
"arbitrary",
|
||||
"arref",
|
||||
|
|
|
@ -19,7 +19,7 @@ thiserror = "1.0.31"
|
|||
im = "15.1.0"
|
||||
enum-as-inner = "0.5.1"
|
||||
num = "0.4.0"
|
||||
crdt-list = "0.1.3"
|
||||
crdt-list = "0.2.0"
|
||||
rand = { version = "0.8.5", optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
|
|
4
crates/loro-core/fuzz/Cargo.lock
generated
4
crates/loro-core/fuzz/Cargo.lock
generated
|
@ -79,9 +79,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
|||
|
||||
[[package]]
|
||||
name = "crdt-list"
|
||||
version = "0.1.3"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "15ab0245d29050a50d3431ad32d13bc59a187aa9c0e543b235ab8190f6b0d8af"
|
||||
checksum = "44c6c20076c40cfc4fc484455bda1ba3cac6f9585b2e5a464b98fc4a2600f95b"
|
||||
dependencies = [
|
||||
"arbitrary",
|
||||
"arref",
|
||||
|
|
|
@ -9,7 +9,7 @@ edition = "2018"
|
|||
cargo-fuzz = true
|
||||
|
||||
[dependencies]
|
||||
crdt-list = "0.1.2"
|
||||
crdt-list = "0.2.0"
|
||||
libfuzzer-sys = "0.4"
|
||||
|
||||
[dependencies.loro-core]
|
||||
|
|
|
@ -2,10 +2,13 @@ use std::ops::{Deref, DerefMut};
|
|||
|
||||
use rle::{
|
||||
rle_tree::{Position, SafeCursor, SafeCursorMut, UnsafeCursor},
|
||||
HasLength, RleTree,
|
||||
HasLength, RleTree, RleVec,
|
||||
};
|
||||
|
||||
use crate::id::ID;
|
||||
use crate::{
|
||||
id::{Counter, ID},
|
||||
span::IdSpan,
|
||||
};
|
||||
|
||||
use super::y_span::{StatusChange, YSpan, YSpanTreeTrait};
|
||||
|
||||
|
@ -137,6 +140,19 @@ impl ContentMap {
|
|||
(None, None)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_id_spans(&mut self, pos: usize, len: usize) -> RleVec<IdSpan> {
|
||||
let mut ans = RleVec::new();
|
||||
for cursor in self.iter_range(pos, Some(pos + len)) {
|
||||
ans.push(IdSpan::new(
|
||||
cursor.id.client_id,
|
||||
cursor.id.counter,
|
||||
cursor.id.counter + cursor.len as Counter,
|
||||
));
|
||||
}
|
||||
|
||||
ans
|
||||
}
|
||||
}
|
||||
|
||||
impl Deref for ContentMap {
|
||||
|
|
|
@ -5,7 +5,7 @@ use enum_as_inner::EnumAsInner;
|
|||
use rle::{
|
||||
range_map::RangeMap,
|
||||
rle_tree::{node::LeafNode, Position, SafeCursor, SafeCursorMut},
|
||||
HasLength, Mergable, Sliceable,
|
||||
HasLength, Mergable, RleVec, Sliceable,
|
||||
};
|
||||
|
||||
use crate::{id::ID, span::IdSpan};
|
||||
|
@ -20,7 +20,7 @@ pub(super) enum Marker {
|
|||
ptr: NonNull<LeafNode<'static, YSpan, YSpanTreeTrait>>,
|
||||
len: usize,
|
||||
},
|
||||
Delete(IdSpan),
|
||||
Delete(RleVec<IdSpan>),
|
||||
// TODO: REDO, UNDO
|
||||
}
|
||||
|
||||
|
|
|
@ -178,10 +178,12 @@ pub mod fuzz {
|
|||
test::{Action, TestFramework},
|
||||
yata::Yata,
|
||||
};
|
||||
use rle::RleVec;
|
||||
|
||||
use crate::{
|
||||
container::text::tracker::Tracker,
|
||||
id::{ClientID, ID},
|
||||
span::IdSpan,
|
||||
};
|
||||
|
||||
use super::YataImpl;
|
||||
|
@ -236,6 +238,20 @@ pub mod fuzz {
|
|||
pos % 10 + 1,
|
||||
)
|
||||
}
|
||||
|
||||
type DeleteOp = RleVec<IdSpan>;
|
||||
|
||||
fn new_del_op(container: &Self::Container, pos: usize, len: usize) -> Self::DeleteOp {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn integrate_delete_op(container: &mut Self::Container, op: Self::DeleteOp) {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn can_apply_del_op(container: &Self::Container, op: &Self::DeleteOp) -> bool {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -74,7 +74,7 @@ pub trait RleTreeTrait<T: Rle>: Sized + Debug {
|
|||
fn update_cache_leaf(node: &mut LeafNode<'_, T, Self>);
|
||||
fn update_cache_internal(node: &mut InternalNode<'_, T, Self>);
|
||||
|
||||
/// - `child_index` can only equal to children.len() when it's zero
|
||||
/// - `child_index` can only equal to children.len() when index out of range
|
||||
/// - We need the `offset` so we can perform `find_pos_internal(child, new_search_index)`.
|
||||
/// - We need the `pos` to determine whether the child is included or excluded
|
||||
/// - If not found, then `found` should be false and `child_index` should be the index of the insert position
|
||||
|
@ -83,7 +83,7 @@ pub trait RleTreeTrait<T: Rle>: Sized + Debug {
|
|||
index: Self::Int,
|
||||
) -> FindPosResult<Self::Int>;
|
||||
|
||||
/// - `child_index` can only equal to children.len() when it's zero
|
||||
/// - `child_index` can only equal to children.len() when index out of range
|
||||
/// - if `pos == Middle`, we need to split the node
|
||||
/// - We need the third arg to determine whether the child is included or excluded
|
||||
/// - If not found, then `found` should be false and `child_index` should be the index of the insert position
|
||||
|
@ -259,6 +259,7 @@ impl<T: Rle + HasGlobalIndex, const MAX_CHILD: usize> RleTreeTrait<T>
|
|||
return;
|
||||
}
|
||||
|
||||
// TODO: Maybe panic if overlap?
|
||||
node.cache.end = node
|
||||
.children()
|
||||
.iter()
|
||||
|
|
|
@ -15,7 +15,7 @@ version = "0.5.1"
|
|||
[[audits.crdt-list]]
|
||||
who = "Zixuan Chen <remch183@outlook.com>"
|
||||
criteria = "safe-to-deploy"
|
||||
version = "0.1.3"
|
||||
version = "0.2.0"
|
||||
notes = "I'm the author of this crate"
|
||||
|
||||
[[audits.ctor]]
|
||||
|
|
Loading…
Reference in a new issue