loro-dev / columnar Goto Github PK
View Code? Open in Web Editor NEWergonomic columnar storage encoding crate
License: MIT License
ergonomic columnar storage encoding crate
License: MIT License
null
#[columnar(ver, ser,de)]
struct Data<T, P>{
t: T,
#[columnar(skip)]
p: P
}
we need add trait bound for T
#[columnar(ser, de)]
struct B<'a> {
a: &'a str
}
#[columnar(vec)]
struct Data{
id: u64
}
#[columnar(vec)]
struct Store{
#[columnar(type="vec", warp)]
data: Vec<Data>,
#[columnar(strategy="DeltaRle")]
id: u64
}
#[columnar]
struct NestedStrore{
#[columnar(type="vec")]
stores: Vec<Store>
}
I think maybe we could still impl nested case without wrap
attribute, by always wrapping vec or map.
const doc = new Loro();
const text = doc.getText("text");
const doc2 = new Loro();
const text2 = doc2.getText("text");
text.subscribe(doc, (event)=>{
const e = event.diff as TextDiff;
text2.applyDelta(e.diff);
});
text.insert(0, "foo");
text.mark({start: 0, end: 3, expand: "none"}, "link", true);
// doc.commit(); // multi delta
text.insert(3, "baz");
doc.commit();
await new Promise((r) => setTimeout(r, 1));
expect(text2.toDelta()).toStrictEqual([ { insert: 'foo', attributes: { link: true } }, { insert: 'baz' } ]);
If uncomment first doc.commit()
, the result will be wrong
From SyncLinear.com | LORO-371
There is a bug
// when there are more than two iterator
let (a, b,c ) = iter_a.into_iter().zip(iter_b.into_iter()).zip(iter_c.into_iter()).collect();
// it will get `((a, b), c)` not `(a, b, c )`
let (a, b, c) = izip!(iter_a.into_iter(), iter_b.into_iter(), iter_c.into_iter())
Generally, when encoding, we build some intermediate struct that holds value‘s borrow. And we definitely do not decode into this intermediate struct, which means it is inflexible to require the implementation of serialize
and deserialize
at the same time.
#[columnar(ver, map, ser, de)]
struct Data{
id: 64,
name: String
}
#[columnar]
enum EnumStore{
#[columnar(type="vec")]
Data(Vec<Data>),
#[columnar(type="map")]
MapData(HashMap<u64, Data>)
}
#[columnar(ser, de)]
struct Data<'a>{
#[columnar(borrow)]
a: Cow<'a, str>
}
The number of fields is variable because of supporting forward and backward compatibility, so we could not reuse the borrow
attribute from serde
directly.
From SyncLinear.com | LORO-287
cache the encoded inputs then decode them all at once when needed.
remove the decode_batch
method from Loro
and make importing a lot of things within a transaction pretty fast.
From SyncLinear.com | LORO-257
For example
#[columnar(vec, ser, de)]
#[derive(Clone, Serialize, Deserialize)]
struct Data{
#[columnar(strategy="Rle")]
id: u64
#[columnar(no_strategy)]
other_data: T: !PartialEq,
}
#[columnar(ser, de)]
struct Store{
#[columnar(type="vec")]
data: Vec<Data>,
}
#[columnar(ser, de)]
struct Store{
#[columnar(class="map", key_strategy="DeltaRle")]
mapping: BTreeMap<u64, String>
}
Considering cases like:
// old version
struct Data{
id: u64,
name: Option<String>
}
// new version
struct Data{
id: u64,
// delete name option field
// add a new option field
count: Option<u64>
}
cases:
Both Table Struct
and Row Struct
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.