Not trying to hijack this thread, @andy check out Differential Sync.

On Sat, Feb 21, 2015, 4:36 PM Andy Fingerhut <andy.finger...@gmail.com>
wrote:

> Sorry if you've already explained this and I'm missing it, but for
> example, suppose the current state on both sides is {:x {:y 1}}, and the
> 'sender' wants to change to one of these states:
>
> (a) {:x nil}
> (b) {:x {}}
> (b) {:x []}
> (c) {:x {:y nil}}
>
> Do you plan to support sending a different 'diff' in each of these cases,
> such that the 'receiver' can end up in the same final state, for each of
> these case?
>
> Or perhaps the idea is that some of those are not supported?
>
> Thanks,
> Andy
>
> On Fri, Feb 20, 2015 at 8:13 PM, Timothy Pratley <timothyprat...@gmail.com
> > wrote:
>
>> Hi Andy,
>>
>>
>> On Fri, Feb 20, 2015 at 5:51 PM, Andy Fingerhut <andy.finger...@gmail.com
>> > wrote:
>>
>>> The goal with your library is to transmit deltas between two systems,
>>> and then apply those deltas to the other system to make them match, yes?
>>>
>>
>> Correct, it works well for what I need it to do. :)
>>
>>
>>> How would you use the diff return value ({:x {:y 1}} nil nil) to cause a
>>> system that currently has {:x {:y 1}} to change to {:x {}}, as opposed to
>>> some other state?  That is, how would it know it needs to change the value
>>> associated with :x to {} as opposed to removing the key :x and its value
>>> entirely?
>>>
>>
>> The short answer is (update-in state [:x] dissoc :y).
>> Which is identical in result to (assoc state :x {}).
>> So either representation could be used to accomplish the goal, and can be
>> interchanged.
>>
>> As such I think either solution would be great! (and am happy to provide
>> a patch either way).
>>
>>
>> Below digresses from clojure.core/diff concerns, but I'm including it to
>> more fully answer your question.
>>
>> I'll expand a little on the way patchin currently works. The second
>> clojure.data/diff return value is used as replacements. The first item
>> returned from clojure.data/diff is used as the keys to dissoc, excluding
>> things that would be replaced anyway. If the patch size is greater than the
>> target, just the target is sent. So in the end it constructs the same patch
>> you described (as it is smaller). Valid patches look like either:
>> [x]
>> [diss replace]
>> So the patch sent is
>> [{:x {}}]
>> Which means "replace the state with {:x {}}
>> but for {:x {:y "foo", z "bar", w "baz"}} -> {:x {:z "bar", w "baz", q
>> "bonza"}} the patch sent is
>> [{:x {:y 1}} {:x {:q "bonza"}}]
>> Which means "replace in state [:x :q] bonza, and strip out [:x :y].
>> Plus some minor tricks to handle sets, and treat sequences as values.
>> There are good resources for sequence diff compression but haven't
>> thought of a good way to represent them in the same patch as a structural
>> diff, and haven't had the need.
>>
>> I do not think clojure.data/diff need concern itself with optimization,
>> as it currently serves the purpose of identifying differences very well,
>> and optimization comes with calculation/size tradeoffs specific to the
>> usage.
>>
>>
>> Regards,
>> Timothy
>>
>>  --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clojure@googlegroups.com
>> Note that posts from new members are moderated - please be patient with
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to clojure+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>  --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to