[Schmitzm-commits] r2214 - trunk/schmitzm-core/src/main/java/de/schmitzm/regex
scm-commit at wald.intevation.org
scm-commit at wald.intevation.org
Fri Feb 1 10:32:13 CET 2013
Author: alfonx
Date: 2013-02-01 10:32:13 +0100 (Fri, 01 Feb 2013)
New Revision: 2214
Modified:
trunk/schmitzm-core/src/main/java/de/schmitzm/regex/RegexCache.java
Log:
BNDM deaktiviert...
Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/regex/RegexCache.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/regex/RegexCache.java 2013-01-31 23:44:04 UTC (rev 2213)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/regex/RegexCache.java 2013-02-01 09:32:13 UTC (rev 2214)
@@ -9,10 +9,6 @@
import org.apache.solr.util.ConcurrentLRUCache;
import org.apache.solr.util.ConcurrentLRUCache.Stats;
-import com.eaio.stringsearch.BNDM;
-import com.eaio.stringsearch.BNDMCI;
-import com.eaio.stringsearch.StringSearch;
-
/**
* Cached compilierte Pattern und auch Ergebnisse von RegExes. Use the matchers methods to obtain cached result and add
* regex to cache automatically.
@@ -26,21 +22,21 @@
private static final String KEY_STRING_TRENNER = ":*:";
final static Logger log = Logger.getLogger(RegexCache.class);
+ //
+ // final static ThreadLocal<BNDM> bndms = new ThreadLocal<BNDM>() {
+ // @Override
+ // protected BNDM initialValue() {
+ // return new BNDM();
+ // }
+ // };
+ //
+ // final static ThreadLocal<BNDMCI> bndmcis = new ThreadLocal<BNDMCI>() {
+ // @Override
+ // protected BNDMCI initialValue() {
+ // return new BNDMCI();
+ // }
+ // };
- final static ThreadLocal<BNDM> bndms = new ThreadLocal<BNDM>() {
- @Override
- protected BNDM initialValue() {
- return new BNDM();
- }
- };
-
- final static ThreadLocal<BNDMCI> bndmcis = new ThreadLocal<BNDMCI>() {
- @Override
- protected BNDMCI initialValue() {
- return new BNDMCI();
- }
- };
-
/**
* Regex-Auswertungen komplett cachen
*/
@@ -125,33 +121,33 @@
// Hier beginnt eine interessante Optimierung. Wenn der String keine Regex ist, und nicht länger 32, dann wird
// ein schnellere Stringsuche verwendet.
- boolean canSpeedup = true;
- boolean speedUpIgnorecase = true;
-
- if (regex.length() > 20)
- canSpeedup = false;
- else {
- String copy = regex;
- if (copy.startsWith("(?is)") || copy.startsWith("(?im)") || copy.startsWith("(?ims)")) {
- copy = copy.substring(5);
- speedUpIgnorecase = true;
- }
- if (copy.startsWith("^.*?")) {
- copy = copy.substring(4);
- }
- canSpeedup = !(looksLikeRegex(copy));
- }
-
- if (canSpeedup) {
-
- StringSearch bndm = speedUpIgnorecase ? bndmcis.get() : bndms.get();
- int searchString = bndm.searchString(value, regex);
-
- int idx = searchString;
- return idx >= 0;
- } else {
- return result(regex, value) != null;
- }
+ // boolean canSpeedup = true;
+ // boolean speedUpIgnorecase = true;
+ //
+ // if (regex.length() > 20)
+ // canSpeedup = false;
+ // else {
+ // String copy = regex;
+ // if (copy.startsWith("(?is)") || copy.startsWith("(?im)") || copy.startsWith("(?ims)")) {
+ // copy = copy.substring(5);
+ // speedUpIgnorecase = true;
+ // }
+ // if (copy.startsWith("^.*?")) {
+ // copy = copy.substring(4);
+ // }
+ // canSpeedup = !(looksLikeRegex(copy));
+ // }
+ //
+ // if (canSpeedup) {
+ //
+ // StringSearch bndm = speedUpIgnorecase ? bndmcis.get() : bndms.get();
+ // int searchString = bndm.searchString(value, regex);
+ //
+ // int idx = searchString;
+ // return idx >= 0;
+ // } else {
+ return result(regex, value) != null;
+ // }
}
String ERKENNE_REGEX_RX = "[\\[\\]()?\\\\+{}^$.]";
@@ -171,7 +167,6 @@
* may not be null
* @return <code>null</code> if the pattern didn't match. A {@link MatchResult} otherwise which contains the groups
* etc.
- *
* TODO Der cache sollte eine Hit-Quote halten, die irgendwann den Cache für eine Regex blockt
*/
public final MatchResult result(final String regex, final String value) {
More information about the Schmitzm-commits
mailing list