Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>For that I use <a href="https://stackoverflow.com/questions/4445656/what-is-differential-execution"><em>differential execution</em></a>.</p> <p>(BTW, the word "slave" is uncomfortable for some people, with reason.)</p> <p>For each remote site, there is a sequential file at the primary site representing what exists on the remote site.</p> <p>There is a procedure at the primary site that walks through the primary collection, and as it walks it reads the corresponding file, detecting differences between what currently exists on the remote site and what should exist. Those differences produce deltas, which are transmitted to the remote site. At the same time, the procedure writes a new file representing what will exist at the remote site after the deltas are processed.</p> <p>The advantage of this is it does not depend on detecting change events in the primary collection, because often those change events are unreliable or can be self-cancelling or made irrelevant by other changes, so you cut way down on needless transmissions to the remote site.</p> <p>In the case that the collections are simple lists of things, this boils down to having local copies of the remote collections and running a <code>diff</code> algorithm to get the delta. Here are a couple such algorithms:</p> <p>If the collections can be sorted (like your A,B,C example), just run a merge loop:</p> <pre><code>while(ix&lt;nx &amp;&amp; iy&lt;ny){ if (X[ix] &lt; Y[iy]){ // X[ix] was inserted in X ix++; } else if (Y[iy] &lt; X[ix]){ // Y[iy] was deleted from X iy++; } else { // the two elements are equal. skip them both; ix++; iy++; } } while(ix&lt;nx){ // X[ix] was inserted in X ix++; } while(iy&lt;ny&gt;){ // Y[iy] was deleted from X iy++; } </code></pre> <p>If the collections cannot be sorted (note relationship to <a href="https://www.google.com/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=1&amp;cad=rja&amp;ved=0CC4QFjAA&amp;url=http://en.wikipedia.org/wiki/Levenshtein_distance&amp;ei=p5-HUv6mAuzj4APMi4CADw&amp;usg=AFQjCNHIZDhIk5K5Ml7K8baQz3u_o_-1NQ&amp;sig2=TJ4oo15ivz5PWpbtGo_vww&amp;bvm=bv.56643336,d.dmg" rel="nofollow noreferrer"><em>Levenshtein distance</em></a>),</p> <pre><code>Until we have read through both collections X and Y, See if the current items are equal else see if a single item was inserted in X else see if a single item was deleted from X else see if 2 items were inserted in X else see if a single item was replaced in X else see if 2 items were deleted from X else see if 3 items were inserted in X else see if 2 items in X replaced 1 items in Y else see if 1 items in X replaced 2 items in Y else see if 3 items were deleted from X etc. etc. up to some limit </code></pre> <p>Performance is generally not an issue, because the procedure does not have to be run at high frequency.</p> <p>There's a <a href="https://www.youtube.com/watch?v=ibPR17IZZUM" rel="nofollow noreferrer"><em>crude video demonstrating this concept</em></a>, and <a href="http://sourceforge.net/projects/dyndlgdemo/" rel="nofollow noreferrer"><em>source code where it is used for dynamically changing user interfaces</em></a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload