4.1.12.2.1 GuidSequence

Informative summary of behavior: The candidate set of objects is the set of all objects and tombstones in the local replica of NC nc, excluding objects that have not yet replicated to both the client and server replicas of NC nc. The exclusion of objects created too recently is performed using the client-supplied up-to-date vector utd.

A cluster is any subset of the candidate set such that no object in the candidate set outside the cluster has an objectGUID lying between the objectGUIDs of any two members of the cluster.

The cluster constructed by GuidSequence contains the object in the candidate set with the smallest objectGUID greater than or equal to startGUID. The cluster contains as many objects as possible, but no more than count.

Both the client and the server use GuidSequence to compute a cluster, create a sorted sequence of objectGUIDs of objects in the cluster, and compute a digest of that sequence.

 procedure GuidSequence(
     startGUID: GUID,
     count: ULONG,
     nc: DSName,
     utd: UPTODATE_VECTOR_V1_EXT,
     var s: sequence of DSName,
     var digest: sequence [0..15] of byte)

The procedure GuidSequence returns the following:

  1. A sequence s of objectGUIDs from the server's state.

  2. An MD5 digest value digest that is derived from the sequence s.

The first four parameters determine the result sequence s as follows:

  1. Construct the following set of DSNames:

       select all o subtree-ts-included nc where
          StampLessThanOrEqualUTD(AttrStamp(o, whenCreated), utd)
    
  2. Construct the GUID sequence S that contains the objectGUIDs of members of the set, sorted into ascending order by GUID value.

  3. Find the smallest integer i such that S[i] >= startGUID. If there is no such i, the result sequence s is empty, otherwise the result sequence s is as follows:

    S[i .. min(i+count, S.length)-1]

The result digest is the value of ComputeDigest applied to the result sequence s, where ComputeDigest is specified as follows:

  
 procedure ComputeDigest(s: sequence of GUID): sequence [0..15] of byte
  
 md5Context : MD5_CTX
 MD5Init(md5Context)
   for i := 0 to s.length-1
     MD5Update(md5Context, s[i], 16)
   endfor
 MD5Final(md5Context)
 return md5Context.digest