I'm writing a little OT database server, and pulling out some of the model code to use with it. Each OT document will be an opaque JSON object. Each OT document type will be defined by the following functions:
1. snapshot = New() 2. snapshot' = Apply(snapshot, op) 3. (op1', op2') = Transform(op1, op2) Optional: 4. op' = Invert(op) For the wave data types, I'd also like some helper functions for clients to create the ops. (Nindo and all that). I think I know what types I should be using, but I'm not 100% sure. Do you mind checking that I'm doing this right? My plan is: Concrete data types: - Wave document snapshots are WaveletDataImpl objects - Ops are WaveletOperations The database stores a tuple of: - ByteStringMessage<ProtocolAppliedWaveletDelta> applied; - TransformedWaveletDelta transformed; (The applied deltas are signed, and the transformed deltas are what was actually applied to the snapshot). For consistency with the current implementation, null is used for the doc snapshot until the first op is applied. When that happens, snapshot = WaveletDataUtil.buildWaveletFromFirstDelta(waveletName, transformedDelta); and later, snapshots are applied using: WaveletDataUtil.applyWaveletDelta(transformedDelta, snapshot); So thus: New() = WaveletDataUtil.buildWaveletFromFirstDelta(waveletName, op.transformedDelta); Apply(snapshot, op) = WaveletDataUtil.applyWaveletDelta(op.transformedDelta, snapshot); Transform(op1, op2) = org.waveprotocol.wave.model.operation.wave.Transform.transform(op1, op2) Invert should be trivial, but I can't find it. To make the ops in the first place, my understanding is that I want to create a document, apply nindo to it and get the doc ops out the other side. Which document class do I want to use? (There's about 20 to choose from.) Do I poll to get the DocOps out or should I make a custom sink class which gets sent the ops? Cheers Joseph
