Class AbstractSimilarityCacheMatrix

    • Field Detail

      • serialVersionUID

        protected static final long serialVersionUID
        Constant serialVersionUID=4515348786028162812L
        See Also:
        Constant Field Values
      • logger

        protected transient org.slf4j.Logger logger
      • dirtySimilarityMatrix

        protected final org.apache.commons.collections4.map.MultiKeyMap<String,​Double> dirtySimilarityMatrix
        Contains all similarity pairs that have not been serialized already.
      • cleanSimilarityMatrix

        protected org.apache.commons.collections4.map.MultiKeyMap<String,​Double> cleanSimilarityMatrix
        Contains all similarity pairs that have been serialized already.
    • Constructor Detail

      • AbstractSimilarityCacheMatrix

        public AbstractSimilarityCacheMatrix()
    • Method Detail

      • addDirtySimilarity

        protected void addDirtySimilarity​(String queryId,
                                          String caseId,
                                          double similarity)

        addDirtySimilarity.

        Parameters:
        queryId - a String object
        caseId - a String object
        similarity - a double
      • getSimilarity

        public double getSimilarity​(String queryId,
                                    String caseId)

        getSimilarity.

        Parameters:
        queryId - a String object
        caseId - a String object
        Returns:
        a double
      • getCases

        public List<String> getCases()

        getCases.

        Returns:
        a List object
      • size

        public int size()

        size.

        Returns:
        a int
      • print

        public void print()

        print.

      • addDirtyCase

        public abstract void addDirtyCase​(String queryID,
                                          String caseID,
                                          Similarity similarity)
        Adds a case to the dirty matrix. This means that this similarity is not serialized to disk, yet.
        Parameters:
        queryID - the ID of the query
        caseID - the ID of the case
        similarity - the similarity object
      • removeCase

        public abstract void removeCase​(String caseID)
        Removes the case with the given ID from the similarity cache matrix.
        Parameters:
        caseID - the ID of the case to remove
      • hasSimilarity

        public boolean hasSimilarity​(String queryID,
                                     String caseID)
        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 query
        caseID - the ID of the case
        Returns:
        true, if the similarity is already there, false, otherwise.
      • readCleanSimilarityCacheMatrix

        public abstract void readCleanSimilarityCacheMatrix​(String path)
        This method reads a similarity cache matrix from disk.
        Parameters:
        path - the path to read from
      • writeDirtySimilarityCacheMatrix

        public abstract void writeDirtySimilarityCacheMatrix​(String path)
        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