In addition to having a data type, a column in a table can be assigned a CRDT type. The assigned CRDT controls how merging of the column is performed.
A Last Write Wins register is a register which can hold any primitive value. Multiple writes to the same register by different peers are resolved by taking the last write. If the two writes were concurrent, the largest value is taken.
By default, all columns in a
crr are treated as last write wins registers.
Fractional indices are used to assign a user defined ordering to a row. They work by dividing the space available between two rows and assigning that number to the thing being moved.
If we want to insert an item between
b, we can divide the space between them by two and assign that number to the new item.
Moving is a similar process. If we want to move
a, we can divide the space between
c by two and assign that number to
CR-SQLite's distributed fractional index primitive takes care of:
- Allowing nodes to assign orderings without coordinating
- Handling precision overflow
- Calculating new positions
- Handling conflicting ordering assignments
See api-methods/crsql_fract_as_ordered for usage instructions.
Counter CRDTs are currently not yet supported.