Class AbstractSimilarityCacheMatrix
java.lang.Object
de.uni_trier.wi2.procake.adaptation.cache.AbstractSimilarityCacheMatrix
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
SimilarityCacheMatrix
,SimpleSimilarityCacheMatrix
Abstract AbstractSimilarityCacheMatrix class.
- Author:
- Maximilian Hoffmann
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionContains all similarity pairs that have been serialized already.Contains all similarity pairs that have not been serialized already.protected org.slf4j.Logger
protected static final long
ConstantserialVersionUID=4515348786028162812L
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract void
addDirtyCase
(String queryID, String caseID, Similarity similarity) Adds a case to the dirty matrix.protected void
addDirtySimilarity
(String queryId, String caseId, double similarity) addDirtySimilarity.getCases()
getCases.double
getSimilarity
(String queryId, String caseId) getSimilarity.boolean
hasSimilarity
(String queryID, String caseID) Checks if a similarity is already in the matrix.void
print()
print.abstract void
This method reads a similarity cache matrix from disk.abstract void
removeCase
(String caseID) Removes the case with the given ID from the similarity cache matrix.int
size()
size.abstract void
This method writes out the dirty similarity cache to disk.
-
Field Details
-
serialVersionUID
protected static final long serialVersionUIDConstantserialVersionUID=4515348786028162812L
- See Also:
-
logger
protected transient org.slf4j.Logger logger -
dirtySimilarityMatrix
protected final org.apache.commons.collections4.map.MultiKeyMap<String,Double> dirtySimilarityMatrixContains all similarity pairs that have not been serialized already. -
cleanSimilarityMatrix
Contains all similarity pairs that have been serialized already.
-
-
Constructor Details
-
AbstractSimilarityCacheMatrix
public AbstractSimilarityCacheMatrix()
-
-
Method Details
-
addDirtySimilarity
addDirtySimilarity.
-
getSimilarity
getSimilarity.
-
getCases
getCases.
- Returns:
- a
List
object
-
size
public int size()size.
- Returns:
- a int
-
print
public void print()print.
-
addDirtyCase
Adds a case to the dirty matrix. This means that this similarity is not serialized to disk, yet.- Parameters:
queryID
- the ID of the querycaseID
- the ID of the casesimilarity
- the similarity object
-
removeCase
Removes the case with the given ID from the similarity cache matrix.- Parameters:
caseID
- the ID of the case to remove
-
hasSimilarity
Checks if a similarity is already in the matrix. This could be the case when a cache was read.- Parameters:
queryID
- the ID of the querycaseID
- the ID of the case- Returns:
- true, if the similarity is already there, false, otherwise.
-
readCleanSimilarityCacheMatrix
This method reads a similarity cache matrix from disk.- Parameters:
path
- the path to read from
-
writeDirtySimilarityCacheMatrix
This method writes out the dirty similarity cache to disk. In this process, the matrix is temporarily locked for further access and after the serialization, the similarities are copied to the clean matrix.- Parameters:
path
- the path to write to
-