rocicorp / fractional-indexing

Fractional Indexing in JavaScript
https://npmjs.com/fractional-indexing
Creative Commons Zero v1.0 Universal
304 stars 23 forks source link

Add random jitter to selected indexes? #14

Open aboodman opened 1 year ago

aboodman commented 1 year ago

See https://madebyevan.com/algos/crdt-fractional-indexing/

I wonder if there is a principled way to choose the amount of jitter such that collisions are ~impossible.

tantaman commented 1 year ago

You can also just allow conflicts and repair them iff someone tries to insert between conflicting items. You'd have to of course order by fract_index, primary_key (or something similar) to ensure a stable sort in the face of conflicts.

aboodman commented 1 year ago

Yeah I think we discovered this ourselves too. There are a number of patterns to deal with conflicts and I'm not sure which is best, I keep oscillating between options :).

quolpr commented 1 year ago

Would it be possible to add support for random jitter as an option?

codsane commented 4 months ago

@quolpr if you are still looking, this seems promising: https://github.com/TMeerhof/fractional-indexing-jittered.

While not a fork, it is apparently inspired by this package.