#crdt #local-first #index #collaborative #encoded #compression #element

loro-rle

A internal library of loro for storing and manipulating run-length encoded data. Do not use it directly.

10 releases (5 breaking)

new 1.0.0-beta.5 Oct 22, 2024
0.16.12 Sep 7, 2024
0.16.10 Aug 29, 2024
0.16.2 May 29, 2024
0.1.0 Nov 28, 2023

#406 in Data structures

Download history 2/week @ 2024-07-01 148/week @ 2024-07-08 72/week @ 2024-07-15 20/week @ 2024-07-22 125/week @ 2024-07-29 72/week @ 2024-08-05 173/week @ 2024-08-12 243/week @ 2024-08-19 141/week @ 2024-08-26 435/week @ 2024-09-02 239/week @ 2024-09-09 207/week @ 2024-09-16 120/week @ 2024-09-23 120/week @ 2024-09-30 79/week @ 2024-10-07 124/week @ 2024-10-14

463 downloads per month
Used in 4 crates (2 directly)

MIT license

31KB
899 lines

Run length encoding library.

There are many mergeable types. By merging them together we can get a more compact representation of the data. For example, in many cases, [0..5, 5..10] can be merged into 0..10.

RleVec

RleVec is a vector that can be compressed using run-length encoding.

A T value may be merged with its neighbors. When we push new element, the new value may be merged with the last element in the array. Each value has a length, so there are two types of indexes:

  1. (merged) It refers to the index of the merged element.
  2. (atom) The index of substantial elements. It refers to the index of the atom element.

By default, we use atom index in RleVec.

  • len() returns the number of atom elements in the array.
  • get(index) returns the atom element at the index.
  • slice(from, to) returns a slice of atom elements from the index from to the index to.

Dependencies

~0.6–0.9MB
~19K SLoC