Represents the "similar unit pairs" file used in duplicity checking algorithm.
The file contains instances of UnitPair class.
That means it contains pairs {first, second}, where first, second are identificators of units
on which we check duplicity (can be document, paragraph or sentence).
The file is sorted - the main criteria is first field, in case of tie second field.
Initialializes the file by writing producer content to disk.
Sets permID field, creates
a file on filesystem for this file and fills it with data from producer object.
The filename is in form returned by getFilename()
and will be created in the location directory. The directory must exist.
The existence of the file causes an exception because this would mean rewriting of some data.
Parameters:
p - producer object
location - path and name of the directory in which the file will be created,
must end with "/" sign
Throws:
java.io.IOException - if the file could not be created,
the file already exists
or writing data to the file failed
SimilarUnitPairsFile
public SimilarUnitPairsFile(long permID,
java.lang.String location)
throws java.io.FileNotFoundException
Initialializes the file already written to filesystem.
Sets permID and location field and tries to open a file on filesystem.
The filename is in form returned by getFilename()
and will be searched in the location directory.
Parameters:
permID - identification of the permutation to be assigned to this file
location - path and name of the directory in which the file will be searched,
must end with "/" sign
Throws:
java.io.FileNotFoundException - if the file does not exist
MergeException - on attempt to merge files corresponding to different permutations
or if temporary file could not be created
java.io.IOException
getFilename
public java.lang.String getFilename()
Returns the filename corresponding to this file.
The location and permID fields MUST be already set.
The filename is created in directory given in location field
and is in form Constants.SIMILAR_UNIT_PAIRS_FILE_PREFIX<permID>.