org.egothor.duplicity.file
Class MergeableSimilarUnitPairsFile
java.lang.Object
org.egothor.duplicity.file.DuplicityCheckingFile
org.egothor.duplicity.file.CommonSimilarUnitPairsFile
org.egothor.duplicity.file.MergeableSimilarUnitPairsFile
Direct Known Subclasses: AllSimilarUnitPairsFile , SimilarUnitPairsFile
public abstract class MergeableSimilarUnitPairsFile extends CommonSimilarUnitPairsFile
Adds abilitity to merge to the CommonSimilarUnitPairsFile
class.
Author:
Kate�ina Dufkov�
Field Summary
protected int
lastLoading
Helper value for the merge() method.
Methods inherited from class org.egothor.duplicity.file.DuplicityCheckingFile
createOut , createPermOut , createTempOut , delete , dump , getFilename , getLocation , getNewTempFile , getOut , hasTheSameContent , initFromProducer , openOut , remove
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
lastLoading
protected int lastLoading
Helper value for the merge() method. Ordinal number of the stream from
which we tried to load in the previous step.
MergeableSimilarUnitPairsFile
protected MergeableSimilarUnitPairsFile ()
mergeAll
protected void mergeAll (CommonSimilarUnitPairsFile mergeTo,
java.util.ArrayList<CommonSimilarUnitPairsFile > supfs)
throws java.io.IOException,
MergeException
Merges multiple files externally, on filesystem.
If the files must correnspond to the same permutation depends on the implementation
of checkPermutation(long) method in childs.
The method is written so that there is no problem if the output file is also
between the input streams, because it uses temporary file and only after it
finished merging, renames the result to output file.
Warning: The content of the output file mergeTo will be discarded.
Parameters: mergeTo
- file where the result will be placedsupfs
- list of files to be merged. Can be regular
(SimilarUnitPairsFile
or SimilarUnitPairsFile
)
or temporary (SimilarUnitPairsTempFile
).
Throws:
MergeException
- on attempt to merge files corresponding to different permutations
java.io.IOException
- if temporary file could not be created
mergeAll
protected void mergeAll (DataOutputStream dos,
java.util.ArrayList<DataInputStream > diss,
java.util.ArrayList<UnitPair > ups)
throws java.io.IOException
Merges all given input streams to given output stream. Expects to get
the leading element (first element not written to output) of each input stream
in variable ups.
Parameters: dos
- DataOutputStream to which to write outputdiss
- list of DataInputStreams to be mergedups
- leading elements of streams
Throws:
java.io.IOException
- on error reading/writing from/to stream
openInputs
protected void openInputs (java.util.ArrayList<CommonSimilarUnitPairsFile > supfs,
java.util.ArrayList<DataInputStream > diss,
java.util.ArrayList<UnitPair > ups)
throws java.io.IOException
Open input files in supfs and put the opened non-empty
DataInputStream
s to given list diss list,
and the first elements of the files to ups list.
Parameters: supfs
- list of files to be openeddiss
- output list of opened streamsups
- output list of first elements of the non-empty files
Throws:
java.io.IOException
checkPermutation
protected abstract void checkPermutation (long permID1,
long permID2)
throws MergeException
Checks if files with given permutations can be merged.
Parameters: permID1
- id of first permutationpermID2
- id of second permutation
Throws:
MergeException
- on attempt to merge files corresponding to different permutations