[Schmitzm-commits] r2012 - trunk/schmitzm-core/src/main/java/de/schmitzm/regex

scm-commit at wald.intevation.org scm-commit at wald.intevation.org
Sat May 26 22:47:02 CEST 2012


Author: alfonx
Date: 2012-05-26 22:47:02 +0200 (Sat, 26 May 2012)
New Revision: 2012

Modified:
   trunk/schmitzm-core/src/main/java/de/schmitzm/regex/RegexCache.java
Log:
limitedconcurrenthashmap gegen concurrenthashmap ausgetauscht.. theoretisch kann das jetzt unendlich speicher verbrauchen!

Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/regex/RegexCache.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/regex/RegexCache.java	2012-05-26 20:06:33 UTC (rev 2011)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/regex/RegexCache.java	2012-05-26 20:47:02 UTC (rev 2012)
@@ -7,9 +7,6 @@
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import de.schmitzm.lang.LimitedConcurrentHashMap;
-import de.schmitzm.lang.LimitedConcurrentHashMap.TRUNC_METHOD;
-
 /**
  * Cached compilierte Pattern und auch Ergebnisse von RegExes. Use the matchers methods to obtain cached result and add
  * regex to cache automatically.
@@ -47,9 +44,14 @@
 		return singletonInstance != null ? singletonInstance : new RegexCache();
 	}
 
-	private final LimitedConcurrentHashMap<Pattern, LimitedConcurrentHashMap<String, MyMatchResult>> matchers = new LimitedConcurrentHashMap<Pattern, LimitedConcurrentHashMap<String, MyMatchResult>>(
-			CACHE_VALUES_TO_RESULT_SIZE, LimitedConcurrentHashMap.TRUNC_METHOD.OLDEST_GET);
-	
+	// TODO
+	// http://lucene.apache.org/solr/api/org/apache/solr/util/ConcurrentLRUCache.html#ConcurrentLRUCache%28int,%20int%29
+	private final ConcurrentHashMap<Pattern, ConcurrentHashMap<String, MyMatchResult>> matchers = new ConcurrentHashMap<Pattern, ConcurrentHashMap<String, MyMatchResult>>(
+			CACHE_VALUES_TO_RESULT_SIZE);
+	// private final LimitedConcurrentHashMap<Pattern, LimitedConcurrentHashMap<String, MyMatchResult>> matchers = new
+	// LimitedConcurrentHashMap<Pattern, LimitedConcurrentHashMap<String, MyMatchResult>>(
+	// CACHE_VALUES_TO_RESULT_SIZE, LimitedConcurrentHashMap.TRUNC_METHOD.OLDEST_GET);
+
 	private final HashMap<String, Pattern> patterns = new HashMap<String, Pattern>();
 
 	private RegexCache() {
@@ -174,14 +176,21 @@
 
 		final Pattern pattern = getPattern(regex);
 
-		LimitedConcurrentHashMap<String, MyMatchResult> m;
+		ConcurrentHashMap<String, MyMatchResult> m;
 		synchronized (matchers) {
 			m = matchers.get(pattern);
 			if (m == null) {
-				matchers.put(pattern, m = new LimitedConcurrentHashMap<String, MyMatchResult>(
-						CACHE_VALUES_TO_RESULT_SIZE, TRUNC_METHOD.OLDEST_GET));
+				matchers.put(pattern, m = new ConcurrentHashMap<String, MyMatchResult>(CACHE_VALUES_TO_RESULT_SIZE));
 			}
 		}
+		// LimitedConcurrentHashMap<String, MyMatchResult> m;
+		// synchronized (matchers) {
+		// m = matchers.get(pattern);
+		// if (m == null) {
+		// matchers.put(pattern, m = new LimitedConcurrentHashMap<String, MyMatchResult>(
+		// CACHE_VALUES_TO_RESULT_SIZE, TRUNC_METHOD.OLDEST_GET));
+		// }
+		// }
 
 		MyMatchResult matcher;
 		synchronized (m) {



More information about the Schmitzm-commits mailing list