ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vjapa...@apache.org
Subject svn commit: r1641399 - /ctakes/trunk/ctakes-ytex/src/main/java/org/apache/ctakes/ytex/kernel/metric/ConceptSimilarityServiceImpl.java
Date Mon, 24 Nov 2014 14:28:28 GMT
Author: vjapache
Date: Mon Nov 24 14:28:28 2014
New Revision: 1641399

URL: http://svn.apache.org/r1641399
Log:
fix cache keys to support multiple concept graphs

Modified:
    ctakes/trunk/ctakes-ytex/src/main/java/org/apache/ctakes/ytex/kernel/metric/ConceptSimilarityServiceImpl.java

Modified: ctakes/trunk/ctakes-ytex/src/main/java/org/apache/ctakes/ytex/kernel/metric/ConceptSimilarityServiceImpl.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-ytex/src/main/java/org/apache/ctakes/ytex/kernel/metric/ConceptSimilarityServiceImpl.java?rev=1641399&r1=1641398&r2=1641399&view=diff
==============================================================================
--- ctakes/trunk/ctakes-ytex/src/main/java/org/apache/ctakes/ytex/kernel/metric/ConceptSimilarityServiceImpl.java
(original)
+++ ctakes/trunk/ctakes-ytex/src/main/java/org/apache/ctakes/ytex/kernel/metric/ConceptSimilarityServiceImpl.java
Mon Nov 24 14:28:28 2014
@@ -648,9 +648,15 @@ public class ConceptSimilarityServiceImp
 
 	@SuppressWarnings("unchecked")
 	private int getLCSFromCache(ConcRel cr1, ConcRel cr2, Set<String> lcses) {
-		OrderedPair<String> cacheKey = new OrderedPair<String>(
-				cr1.getConceptID(), cr2.getConceptID());
-		Element e = this.lcsCache.get(cacheKey);
+		StringBuilder cacheKeyBuilder = new StringBuilder(this.conceptGraphName);
+		cacheKeyBuilder
+				.append(cr1.getConceptID().compareTo(cr2.getConceptID()) < 0 ? cr1
+						.getConceptID() : cr2.getConceptID());
+		cacheKeyBuilder
+				.append(cr1.getConceptID().compareTo(cr2.getConceptID()) >= 0 ? cr2
+						.getConceptID() : cr1.getConceptID());
+		String cacheKey = cacheKeyBuilder.toString();
+		Element e = this.lcsCache != null ? this.lcsCache.get(cacheKey) : null;
 		if (e != null) {
 			// hit the cache - unpack the lcs
 			if (e.getObjectValue() != null) {
@@ -673,8 +679,10 @@ public class ConceptSimilarityServiceImp
 				}
 				val[1] = lcses;
 			}
-			e = new Element(cacheKey, val);
-			this.lcsCache.put(e);
+			if (this.lcsCache != null) {
+				e = new Element(cacheKey, val);
+				this.lcsCache.put(e);
+			}
 			return dist;
 		}
 	}



Mime
View raw message