3.1.5.5 Generating the Target File

To generate a target file, the protocol using RDC MUST obtain a signature file from the source location, and MUST select one or more seed files on the target location. The seed files can be selected in any vendor-specific manner, including using similarity data, as described in section 3.1.5.4.

The target location then reconstructs the target file by obtaining the necessary chunks from the source file and combining them with existing chunks from the seed files. It is the responsibility of the protocol using RDC to transport the signature file and any chunks.

The following diagram illustrates generation of a target file.

Generating the target file

Figure 5: Generating the target file

The following pseudocode specifies the process of generating the target file. Note that each FOR loop iteration is independent of the others, and so can be executed concurrently.

Note Subscripts are expressed with parentheses (for example, "SouSigi" would be expressed as "SouSig(i)").

 Given n Source Signatures, SouSig(0) .. SouSig(n-1),
   and m Seed Signatures, SeedSig(0) .. SeedSig(m-1) 
 where each Signature has fields len and hash.
  
 Produce Target File T, with bytes T(0) .. T(p) 
 where p is the sum of SouSig(i).len for all i in 0 .. n.
  
 FOR i = 0 to n-1
 BEGIN
     offset := sum SouSig(0) to SouSig(i).
     IF there exists j < m such that SeedSig(j).hash = SouSig(i).hash
                                 and SeedSig(j).len = SouSig(i).len
         T(offset) .. T(offset+SouSig(i).len) := the bytes from Chunk j
                                                 of the seed.
     ELSE
     BEGIN
         Fetch Chunk i from the source location
             (how depends on the protocol using RDC).
         T(offset) .. T(offset+SouSig(i).len) := bytes from Chunk i
                                                 of the Source.
     END
 END