Package io.milton.zsync
Class MakeContextEx
java.lang.Object
io.milton.zsync.MakeContext
io.milton.zsync.MakeContextEx
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 Summary
ConstructorsConstructorDescriptionMakeContextEx(ChainingHash hashtable, int blockcount, int blocksize) Constructs a MakeContextEx from an already-initialized ChainingHash. -
Method Summary
Modifier and TypeMethodDescriptionintvoiddelete(ChecksumPair key) Overridesdeletein MakeContext to do nothing.Returns a list of OffsetPairs representing the block-matches between the local and remote file.booleanmatched(int blockIndex) voidput(int blockIndex, long offset) Adds a match to the list of block matches.voidremovematch(int blockIndex)
-
Constructor Details
-
MakeContextEx
Constructs a MakeContextEx from an already-initialized ChainingHash.- Parameters:
hashtable- The hashtable obtained from a MetaFileReaderblockcount- The number of blocks in the remote fileblocksize- The number of bytes per block
-
-
Method Details
-
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:
putin classMakeContext- Parameters:
blockIndex- Index of the remote blockoffset- Byte offset of the local block
-
delete
Overridesdeletein MakeContext to do nothing. Local blocks with the identical checksums will all then match to the first matching ChecksumPair in ChainingHash- Overrides:
deletein classMakeContext- Parameters:
key- Unused in this override. Can be null
-
matched
public boolean matched(int blockIndex) - Overrides:
matchedin classMakeContext
-
removematch
public void removematch(int blockIndex) - Overrides:
removematchin classMakeContext
-
blockcount
public int blockcount()- Overrides:
blockcountin classMakeContext
-