Class MakeContextEx

java.lang.Object
io.milton.zsync.MakeContext
io.milton.zsync.MakeContextEx

public class MakeContextEx extends MakeContext
An extension of MakeContext that stores block matches in a way more suitable for upload.

This object differs from a MakeContext in that it allows multiple local blocks to be matched to a single remote block. It does this by overriding the put method to save matches to an array of Lists, rather than to fileMap, which only allows one entry per remote block. It also overrides the delete method to do nothing, instead of removing the ChecksumPair from the ChainingHash.

MakeContextEx is used internally by UploadMakerEx in place of MakeContext as an argument to MapMatcher.mapMatcher.

Author:
Nick
See Also:
  • Constructor Details

    • MakeContextEx

      public MakeContextEx(ChainingHash hashtable, int blockcount, int blocksize)
      Constructs a MakeContextEx from an already-initialized ChainingHash.
      Parameters:
      hashtable - The hashtable obtained from a MetaFileReader
      blockcount - The number of blocks in the remote file
      blocksize - The number of bytes per block
  • Method Details

    • getReverseMap

      public List<OffsetPair> getReverseMap()
      Returns a list of OffsetPairs representing the block-matches between the local and remote file.
      Returns:
      The list of block matches
      See Also:
    • put

      public void put(int blockIndex, long offset)
      Adds a match to the list of block matches. Matching of overlapping client-side blocks is prevented.
      Overrides:
      put in class MakeContext
      Parameters:
      blockIndex - Index of the remote block
      offset - Byte offset of the local block
    • delete

      public void delete(ChecksumPair key)
      Overrides delete in MakeContext to do nothing. Local blocks with the identical checksums will all then match to the first matching ChecksumPair in ChainingHash
      Overrides:
      delete in class MakeContext
      Parameters:
      key - Unused in this override. Can be null
    • matched

      public boolean matched(int blockIndex)
      Overrides:
      matched in class MakeContext
    • removematch

      public void removematch(int blockIndex)
      Overrides:
      removematch in class MakeContext
    • blockcount

      public int blockcount()
      Overrides:
      blockcount in class MakeContext