Author: mickw
Date: 2006-05-10 13:01:42 +0200 (Wed, 10 May 2006)
New Revision: 2888
Modified:
trunk/src/java/no/schibstedsok/front/searchportal/query/parser/AndClauseImpl.java
trunk/src/java/no/schibstedsok/front/searchportal/query/parser/AndNotClauseImpl.java
trunk/src/java/no/schibstedsok/front/searchportal/query/parser/DefaultOperatorClauseImpl.java
trunk/src/java/no/schibstedsok/front/searchportal/query/parser/EmailClauseImpl.java
trunk/src/java/no/schibstedsok/front/searchportal/query/parser/IntegerClauseImpl.java
trunk/src/java/no/schibstedsok/front/searchportal/query/parser/NotClauseImpl.java
trunk/src/java/no/schibstedsok/front/searchportal/query/parser/OrClauseImpl.java
trunk/src/java/no/schibstedsok/front/searchportal/query/parser/OrganisationNumberClauseImpl.java
trunk/src/java/no/schibstedsok/front/searchportal/query/parser/PhoneNumberClauseImpl.java
trunk/src/java/no/schibstedsok/front/searchportal/query/parser/PhraseClauseImpl.java
trunk/src/java/no/schibstedsok/front/searchportal/query/parser/UrlClauseImpl.java
trunk/src/java/no/schibstedsok/front/searchportal/query/parser/WordClauseImpl.java
trunk/src/java/no/schibstedsok/front/searchportal/query/parser/XorClauseImpl.java
trunk/src/java/no/schibstedsok/front/searchportal/query/token/TokenEvaluatorFactory.java
trunk/src/java/no/schibstedsok/front/searchportal/query/token/TokenEvaluatorFactoryImpl.java
trunk/src/java/no/schibstedsok/front/searchportal/site/Site.java
Log:
clauses should only be cached on a per site basis, not be cached globally.
Modified:
trunk/src/java/no/schibstedsok/front/searchportal/query/parser/AndClauseImpl.java
===================================================================
---
trunk/src/java/no/schibstedsok/front/searchportal/query/parser/AndClauseImpl.java
2006-05-09 20:59:22 UTC (rev 2887)
+++
trunk/src/java/no/schibstedsok/front/searchportal/query/parser/AndClauseImpl.java
2006-05-10 11:01:42 UTC (rev 2888)
@@ -15,6 +15,7 @@
import no.schibstedsok.front.searchportal.query.LeafClause;
import no.schibstedsok.front.searchportal.query.token.TokenEvaluatorFactory;
import no.schibstedsok.front.searchportal.query.token.TokenPredicate;
+import no.schibstedsok.front.searchportal.site.Site;
/**
* The AndClauseImpl represents a joining clause between two terms in the
query.
@@ -29,8 +30,9 @@
/** Values are WeakReference object to AbstractClause.
* Unsynchronized are there are no 'changing values', just existance or
not of the AbstractClause in the system.
*/
- private static final Map<String,WeakReference<AndClauseImpl>> WEAK_CACHE =
new HashMap<String,WeakReference<AndClauseImpl>>();
-
+ private static final Map<Site,Map<String,WeakReference<AndClauseImpl>>>
WEAK_CACHE
+ = new HashMap<Site,Map<String,WeakReference<AndClauseImpl>>>();
+
/* A WordClause specific collection of TokenPredicates that *could* apply
to this Clause type. */
private static final Collection<TokenPredicate> PREDICATES_APPLICABLE;
@@ -79,6 +81,13 @@
// update the factory with what the current term is
predicate2evaluatorFactory.setCurrentTerm(term);
+
+ // the weakCache to use.
+ Map<String,WeakReference<AndClauseImpl>> weakCache =
WEAK_CACHE.get(predicate2evaluatorFactory.getSite());
+ if( weakCache == null ){
+ weakCache = new HashMap<String,WeakReference<AndClauseImpl>>();
+ WEAK_CACHE.put(predicate2evaluatorFactory.getSite(),weakCache);
+ }
// use helper method from AbstractLeafClause
return createClause(
@@ -87,7 +96,7 @@
first,
second,
predicate2evaluatorFactory,
- PREDICATES_APPLICABLE, WEAK_CACHE);
+ PREDICATES_APPLICABLE, weakCache);
}
/**
Modified:
trunk/src/java/no/schibstedsok/front/searchportal/query/parser/AndNotClauseImpl.java
===================================================================
---
trunk/src/java/no/schibstedsok/front/searchportal/query/parser/AndNotClauseImpl.java
2006-05-09 20:59:22 UTC (rev 2887)
+++
trunk/src/java/no/schibstedsok/front/searchportal/query/parser/AndNotClauseImpl.java
2006-05-10 11:01:42 UTC (rev 2888)
@@ -15,6 +15,7 @@
import no.schibstedsok.front.searchportal.query.LeafClause;
import no.schibstedsok.front.searchportal.query.token.TokenEvaluatorFactory;
import no.schibstedsok.front.searchportal.query.token.TokenPredicate;
+import no.schibstedsok.front.searchportal.site.Site;
/**
* The AndNotClauseImpl represents a joining not clause between two terms in
the query.
@@ -31,8 +32,9 @@
* Unsynchronized are there are no 'changing values', just existance or
not of the AbstractClause in the system.
* An overlap of creation is non-critical.
*/
- private static final Map<String,WeakReference<AndNotClauseImpl>>
WEAK_CACHE = new HashMap<String,WeakReference<AndNotClauseImpl>>();
-
+ private static final Map<Site,Map<String,WeakReference<AndNotClauseImpl>>>
WEAK_CACHE
+ = new HashMap<Site,Map<String,WeakReference<AndNotClauseImpl>>>();
+
/* A WordClause specific collection of TokenPredicates that *could* apply
to this Clause type. */
private static final Collection<TokenPredicate> PREDICATES_APPLICABLE;
@@ -75,6 +77,13 @@
// update the factory with what the current term is
predicate2evaluatorFactory.setCurrentTerm(term);
+
+ // the weakCache to use.
+ Map<String,WeakReference<AndNotClauseImpl>> weakCache =
WEAK_CACHE.get(predicate2evaluatorFactory.getSite());
+ if( weakCache == null ){
+ weakCache = new HashMap<String,WeakReference<AndNotClauseImpl>>();
+ WEAK_CACHE.put(predicate2evaluatorFactory.getSite(),weakCache);
+ }
// use helper method from AbstractLeafClause
return createClause(
@@ -83,7 +92,7 @@
first,
null,
predicate2evaluatorFactory,
- PREDICATES_APPLICABLE, WEAK_CACHE);
+ PREDICATES_APPLICABLE, weakCache);
}
/**
Modified:
trunk/src/java/no/schibstedsok/front/searchportal/query/parser/DefaultOperatorClauseImpl.java
===================================================================
---
trunk/src/java/no/schibstedsok/front/searchportal/query/parser/DefaultOperatorClauseImpl.java
2006-05-09 20:59:22 UTC (rev 2887)
+++
trunk/src/java/no/schibstedsok/front/searchportal/query/parser/DefaultOperatorClauseImpl.java
2006-05-10 11:01:42 UTC (rev 2888)
@@ -15,6 +15,7 @@
import no.schibstedsok.front.searchportal.query.LeafClause;
import no.schibstedsok.front.searchportal.query.token.TokenEvaluatorFactory;
import no.schibstedsok.front.searchportal.query.token.TokenPredicate;
+import no.schibstedsok.front.searchportal.site.Site;
/**
* The OrClauseImpl represents a joining clause between two terms in the query.
@@ -29,8 +30,9 @@
/** Values are WeakReference object to AbstractClause.
* Unsynchronized are there are no 'changing values', just existance or
not of the AbstractClause in the system.
*/
- private static final Map<String,WeakReference<DefaultOperatorClauseImpl>>
WEAK_CACHE = new HashMap<String,WeakReference<DefaultOperatorClauseImpl>>();
-
+ private static final
Map<Site,Map<String,WeakReference<DefaultOperatorClauseImpl>>> WEAK_CACHE
+ = new
HashMap<Site,Map<String,WeakReference<DefaultOperatorClauseImpl>>>();
+
/* A WordClause specific collection of TokenPredicates that *could* apply
to this Clause type. */
private static final Collection<TokenPredicate> PREDICATES_APPLICABLE;
@@ -80,6 +82,13 @@
// update the factory with what the current term is
predicate2evaluatorFactory.setCurrentTerm(term);
+
+ // the weakCache to use.
+ Map<String,WeakReference<DefaultOperatorClauseImpl>> weakCache =
WEAK_CACHE.get(predicate2evaluatorFactory.getSite());
+ if( weakCache == null ){
+ weakCache = new
HashMap<String,WeakReference<DefaultOperatorClauseImpl>>();
+ WEAK_CACHE.put(predicate2evaluatorFactory.getSite(),weakCache);
+ }
// use helper method from AbstractLeafClause
return createClause(
@@ -88,7 +97,7 @@
first,
second,
predicate2evaluatorFactory,
- PREDICATES_APPLICABLE, WEAK_CACHE);
+ PREDICATES_APPLICABLE, weakCache);
}
/**
Modified:
trunk/src/java/no/schibstedsok/front/searchportal/query/parser/EmailClauseImpl.java
===================================================================
---
trunk/src/java/no/schibstedsok/front/searchportal/query/parser/EmailClauseImpl.java
2006-05-09 20:59:22 UTC (rev 2887)
+++
trunk/src/java/no/schibstedsok/front/searchportal/query/parser/EmailClauseImpl.java
2006-05-10 11:01:42 UTC (rev 2888)
@@ -14,6 +14,7 @@
import no.schibstedsok.front.searchportal.query.IntegerClause;
import no.schibstedsok.front.searchportal.query.token.TokenEvaluatorFactory;
import no.schibstedsok.front.searchportal.query.token.TokenPredicate;
+import no.schibstedsok.front.searchportal.site.Site;
/**
* EmailClauseImpl. Contains one email address.
@@ -28,8 +29,9 @@
/** Values are WeakReference object to AbstractClause.
* Unsynchronized are there are no 'changing values', just existance or
not of the AbstractClause in the system.
*/
- private static final Map<String,WeakReference<EmailClauseImpl>> WEAK_CACHE
= new HashMap<String,WeakReference<EmailClauseImpl>>();
-
+ private static final Map<Site,Map<String,WeakReference<EmailClauseImpl>>>
WEAK_CACHE
+ = new HashMap<Site,Map<String,WeakReference<EmailClauseImpl>>>();
+
/* A IntegerClauseImpl specific collection of TokenPredicates that *could*
apply to this Clause type. */
private static final Collection<TokenPredicate> PREDICATES_APPLICABLE;
@@ -65,13 +67,21 @@
// update the factory with what the current term is
predicate2evaluatorFactory.setCurrentTerm(term);
+
+ // the weakCache to use.
+ Map<String,WeakReference<EmailClauseImpl>> weakCache =
WEAK_CACHE.get(predicate2evaluatorFactory.getSite());
+ if( weakCache == null ){
+ weakCache = new HashMap<String,WeakReference<EmailClauseImpl>>();
+ WEAK_CACHE.put(predicate2evaluatorFactory.getSite(),weakCache);
+ }
+
// use helper method from AbstractLeafClause
return createClause(
EmailClauseImpl.class,
term,
field,
predicate2evaluatorFactory,
- PREDICATES_APPLICABLE, WEAK_CACHE);
+ PREDICATES_APPLICABLE, weakCache);
}
/**
Modified:
trunk/src/java/no/schibstedsok/front/searchportal/query/parser/IntegerClauseImpl.java
===================================================================
---
trunk/src/java/no/schibstedsok/front/searchportal/query/parser/IntegerClauseImpl.java
2006-05-09 20:59:22 UTC (rev 2887)
+++
trunk/src/java/no/schibstedsok/front/searchportal/query/parser/IntegerClauseImpl.java
2006-05-10 11:01:42 UTC (rev 2888)
@@ -13,6 +13,7 @@
import no.schibstedsok.front.searchportal.query.IntegerClause;
import no.schibstedsok.front.searchportal.query.token.TokenEvaluatorFactory;
import no.schibstedsok.front.searchportal.query.token.TokenPredicate;
+import no.schibstedsok.front.searchportal.site.Site;
/**
* IntegerClauseImpl. Contains only digits.
@@ -27,8 +28,9 @@
/** Values are WeakReference object to AbstractClause.
* Unsynchronized are there are no 'changing values', just existance or
not of the AbstractClause in the system.
*/
- private static final Map<String,WeakReference<IntegerClauseImpl>>
WEAK_CACHE = new HashMap<String,WeakReference<IntegerClauseImpl>>();
-
+ private static final
Map<Site,Map<String,WeakReference<IntegerClauseImpl>>> WEAK_CACHE
+ = new HashMap<Site,Map<String,WeakReference<IntegerClauseImpl>>>();
+
/* A IntegerClauseImpl specific collection of TokenPredicates that *could*
apply to this Clause type. */
private static final Collection<TokenPredicate> PREDICATES_APPLICABLE;
@@ -64,13 +66,20 @@
// update the factory with what the current term is
predicate2evaluatorFactory.setCurrentTerm(term);
+ // the weakCache to use.
+ Map<String,WeakReference<IntegerClauseImpl>> weakCache =
WEAK_CACHE.get(predicate2evaluatorFactory.getSite());
+ if( weakCache == null ){
+ weakCache = new HashMap<String,WeakReference<IntegerClauseImpl>>();
+ WEAK_CACHE.put(predicate2evaluatorFactory.getSite(),weakCache);
+ }
+
// use helper method from AbstractLeafClause
return createClause(
IntegerClauseImpl.class,
term,
field,
predicate2evaluatorFactory,
- PREDICATES_APPLICABLE, WEAK_CACHE);
+ PREDICATES_APPLICABLE, weakCache);
}
/**
Modified:
trunk/src/java/no/schibstedsok/front/searchportal/query/parser/NotClauseImpl.java
===================================================================
---
trunk/src/java/no/schibstedsok/front/searchportal/query/parser/NotClauseImpl.java
2006-05-09 20:59:22 UTC (rev 2887)
+++
trunk/src/java/no/schibstedsok/front/searchportal/query/parser/NotClauseImpl.java
2006-05-10 11:01:42 UTC (rev 2888)
@@ -15,6 +15,7 @@
import no.schibstedsok.front.searchportal.query.NotClause;
import no.schibstedsok.front.searchportal.query.token.TokenEvaluatorFactory;
import no.schibstedsok.front.searchportal.query.token.TokenPredicate;
+import no.schibstedsok.front.searchportal.site.Site;
/**
* The NotClauseImpl represents a not clause between prefixing another term in
the query.
@@ -29,8 +30,9 @@
/** Values are WeakReference object to AbstractClause.
* Unsynchronized are there are no 'changing values', just existance or
not of the AbstractClause in the system.
*/
- private static final Map<String,WeakReference<NotClauseImpl>> WEAK_CACHE =
new HashMap<String,WeakReference<NotClauseImpl>>();
-
+ private static final Map<Site,Map<String,WeakReference<NotClauseImpl>>>
WEAK_CACHE
+ = new HashMap<Site,Map<String,WeakReference<NotClauseImpl>>>();
+
/* A WordClause specific collection of TokenPredicates that *could* apply
to this Clause type. */
private static final Collection<TokenPredicate> PREDICATES_APPLICABLE;
@@ -69,6 +71,12 @@
// update the factory with what the current term is
predicate2evaluatorFactory.setCurrentTerm(term);
+ // the weakCache to use.
+ Map<String,WeakReference<NotClauseImpl>> weakCache =
WEAK_CACHE.get(predicate2evaluatorFactory.getSite());
+ if( weakCache == null ){
+ weakCache = new HashMap<String,WeakReference<NotClauseImpl>>();
+ WEAK_CACHE.put(predicate2evaluatorFactory.getSite(),weakCache);
+ }
// use helper method from AbstractLeafClause
return createClause(
@@ -77,7 +85,7 @@
first,
null,
predicate2evaluatorFactory,
- PREDICATES_APPLICABLE, WEAK_CACHE);
+ PREDICATES_APPLICABLE, weakCache);
}
/**
Modified:
trunk/src/java/no/schibstedsok/front/searchportal/query/parser/OrClauseImpl.java
===================================================================
---
trunk/src/java/no/schibstedsok/front/searchportal/query/parser/OrClauseImpl.java
2006-05-09 20:59:22 UTC (rev 2887)
+++
trunk/src/java/no/schibstedsok/front/searchportal/query/parser/OrClauseImpl.java
2006-05-10 11:01:42 UTC (rev 2888)
@@ -15,6 +15,7 @@
import no.schibstedsok.front.searchportal.query.OrClause;
import no.schibstedsok.front.searchportal.query.token.TokenEvaluatorFactory;
import no.schibstedsok.front.searchportal.query.token.TokenPredicate;
+import no.schibstedsok.front.searchportal.site.Site;
/**
* The OrClauseImpl represents a joining clause between two terms in the query.
@@ -29,8 +30,9 @@
/** Values are WeakReference object to AbstractClause.
* Unsynchronized are there are no 'changing values', just existance or
not of the AbstractClause in the system.
*/
- private static final Map<String,WeakReference<OrClauseImpl>> WEAK_CACHE =
new HashMap<String,WeakReference<OrClauseImpl>>();
-
+ private static final Map<Site,Map<String,WeakReference<OrClauseImpl>>>
WEAK_CACHE
+ = new HashMap<Site,Map<String,WeakReference<OrClauseImpl>>>();
+
/* A WordClause specific collection of TokenPredicates that *could* apply
to this Clause type. */
private static final Collection<TokenPredicate> PREDICATES_APPLICABLE;
@@ -79,6 +81,12 @@
// update the factory with what the current term is
predicate2evaluatorFactory.setCurrentTerm(term);
+ // the weakCache to use.
+ Map<String,WeakReference<OrClauseImpl>> weakCache =
WEAK_CACHE.get(predicate2evaluatorFactory.getSite());
+ if( weakCache == null ){
+ weakCache = new HashMap<String,WeakReference<OrClauseImpl>>();
+ WEAK_CACHE.put(predicate2evaluatorFactory.getSite(),weakCache);
+ }
// use helper method from AbstractLeafClause
return createClause(
@@ -87,7 +95,7 @@
first,
second,
predicate2evaluatorFactory,
- PREDICATES_APPLICABLE, WEAK_CACHE);
+ PREDICATES_APPLICABLE, weakCache);
}
/**
Modified:
trunk/src/java/no/schibstedsok/front/searchportal/query/parser/OrganisationNumberClauseImpl.java
===================================================================
---
trunk/src/java/no/schibstedsok/front/searchportal/query/parser/OrganisationNumberClauseImpl.java
2006-05-09 20:59:22 UTC (rev 2887)
+++
trunk/src/java/no/schibstedsok/front/searchportal/query/parser/OrganisationNumberClauseImpl.java
2006-05-10 11:01:42 UTC (rev 2888)
@@ -13,6 +13,7 @@
import no.schibstedsok.front.searchportal.query.OrganisationNumberClause;
import no.schibstedsok.front.searchportal.query.token.TokenEvaluatorFactory;
import no.schibstedsok.front.searchportal.query.token.TokenPredicate;
+import no.schibstedsok.front.searchportal.site.Site;
/**
* Nine digit organisation clause.
@@ -28,8 +29,9 @@
/** Values are WeakReference object to AbstractClause.
* Unsynchronized are there are no 'changing values', just existance or
not of the AbstractClause in the system.
*/
- private static final
Map<String,WeakReference<OrganisationNumberClauseImpl>> WEAK_CACHE = new
HashMap<String,WeakReference<OrganisationNumberClauseImpl>>();
-
+ private static final
Map<Site,Map<String,WeakReference<OrganisationNumberClauseImpl>>> WEAK_CACHE
+ = new
HashMap<Site,Map<String,WeakReference<OrganisationNumberClauseImpl>>>();
+
/* A IntegerClause specific collection of TokenPredicates that *could*
apply to this Clause type. */
private static final Collection<TokenPredicate> PREDICATES_APPLICABLE;
@@ -67,13 +69,20 @@
final String t = term.replaceAll(" ","");
// update the factory with what the current term is
predicate2evaluatorFactory.setCurrentTerm(t);
+ // the weakCache to use.
+ Map<String,WeakReference<OrganisationNumberClauseImpl>> weakCache =
WEAK_CACHE.get(predicate2evaluatorFactory.getSite());
+ if( weakCache == null ){
+ weakCache = new
HashMap<String,WeakReference<OrganisationNumberClauseImpl>>();
+ WEAK_CACHE.put(predicate2evaluatorFactory.getSite(),weakCache);
+ }
+
// use helper method from AbstractLeafClause
return createClause(
OrganisationNumberClauseImpl.class,
t,
field,
predicate2evaluatorFactory,
- PREDICATES_APPLICABLE, WEAK_CACHE);
+ PREDICATES_APPLICABLE, weakCache);
}
/**
Modified:
trunk/src/java/no/schibstedsok/front/searchportal/query/parser/PhoneNumberClauseImpl.java
===================================================================
---
trunk/src/java/no/schibstedsok/front/searchportal/query/parser/PhoneNumberClauseImpl.java
2006-05-09 20:59:22 UTC (rev 2887)
+++
trunk/src/java/no/schibstedsok/front/searchportal/query/parser/PhoneNumberClauseImpl.java
2006-05-10 11:01:42 UTC (rev 2888)
@@ -13,6 +13,7 @@
import no.schibstedsok.front.searchportal.query.PhoneNumberClause;
import no.schibstedsok.front.searchportal.query.token.TokenEvaluatorFactory;
import no.schibstedsok.front.searchportal.query.token.TokenPredicate;
+import no.schibstedsok.front.searchportal.site.Site;
/**
*
@@ -25,8 +26,9 @@
/** Values are WeakReference object to AbstractClause.
* Unsynchronized are there are no 'changing values', just existance or
not of the AbstractClause in the system.
*/
- private static final Map<String,WeakReference<PhoneNumberClauseImpl>>
WEAK_CACHE = new HashMap<String,WeakReference<PhoneNumberClauseImpl>>();
-
+ private static final
Map<Site,Map<String,WeakReference<PhoneNumberClauseImpl>>> WEAK_CACHE
+ = new
HashMap<Site,Map<String,WeakReference<PhoneNumberClauseImpl>>>();
+
/* A IntegerClause specific collection of TokenPredicates that *could*
apply to this Clause type. */
private static final Collection<TokenPredicate> PREDICATES_APPLICABLE;
@@ -65,13 +67,20 @@
final String t = term.replaceAll(" ","");
// update the factory with what the current term is
predicate2evaluatorFactory.setCurrentTerm(term);
+ // the weakCache to use.
+ Map<String,WeakReference<PhoneNumberClauseImpl>> weakCache =
WEAK_CACHE.get(predicate2evaluatorFactory.getSite());
+ if( weakCache == null ){
+ weakCache = new
HashMap<String,WeakReference<PhoneNumberClauseImpl>>();
+ WEAK_CACHE.put(predicate2evaluatorFactory.getSite(),weakCache);
+ }
+
// use helper method from AbstractLeafClause
return createClause(
PhoneNumberClauseImpl.class,
t,
field,
predicate2evaluatorFactory,
- PREDICATES_APPLICABLE, WEAK_CACHE);
+ PREDICATES_APPLICABLE, weakCache);
}
/**
Modified:
trunk/src/java/no/schibstedsok/front/searchportal/query/parser/PhraseClauseImpl.java
===================================================================
---
trunk/src/java/no/schibstedsok/front/searchportal/query/parser/PhraseClauseImpl.java
2006-05-09 20:59:22 UTC (rev 2887)
+++
trunk/src/java/no/schibstedsok/front/searchportal/query/parser/PhraseClauseImpl.java
2006-05-10 11:01:42 UTC (rev 2888)
@@ -13,6 +13,7 @@
import no.schibstedsok.front.searchportal.query.PhraseClause;
import no.schibstedsok.front.searchportal.query.token.TokenEvaluatorFactory;
import no.schibstedsok.front.searchportal.query.token.TokenPredicate;
+import no.schibstedsok.front.searchportal.site.Site;
/**
*
@@ -25,8 +26,9 @@
/** Values are WeakReference object to AbstractClause.
* Unsynchronized are there are no 'changing values', just existance or
not of the AbstractClause in the system.
*/
- private static final Map<String,WeakReference<PhraseClauseImpl>>
WEAK_CACHE = new HashMap<String,WeakReference<PhraseClauseImpl>>();
-
+ private static final Map<Site,Map<String,WeakReference<PhraseClauseImpl>>>
WEAK_CACHE
+ = new HashMap<Site,Map<String,WeakReference<PhraseClauseImpl>>>();
+
/* A WordClauseImpl specific collection of TokenPredicates that *could*
apply to this Clause type. */
private static final Collection<TokenPredicate> PREDICATES_APPLICABLE;
@@ -67,13 +69,20 @@
// update the factory with what the current term is
predicate2evaluatorFactory.setCurrentTerm(term);
+ // the weakCache to use.
+ Map<String,WeakReference<PhraseClauseImpl>> weakCache =
WEAK_CACHE.get(predicate2evaluatorFactory.getSite());
+ if( weakCache == null ){
+ weakCache = new HashMap<String,WeakReference<PhraseClauseImpl>>();
+ WEAK_CACHE.put(predicate2evaluatorFactory.getSite(),weakCache);
+ }
+
// use helper method from AbstractLeafClause
return createClause(
PhraseClauseImpl.class,
term,
field,
predicate2evaluatorFactory,
- PREDICATES_APPLICABLE, WEAK_CACHE);
+ PREDICATES_APPLICABLE, weakCache);
}
Modified:
trunk/src/java/no/schibstedsok/front/searchportal/query/parser/UrlClauseImpl.java
===================================================================
---
trunk/src/java/no/schibstedsok/front/searchportal/query/parser/UrlClauseImpl.java
2006-05-09 20:59:22 UTC (rev 2887)
+++
trunk/src/java/no/schibstedsok/front/searchportal/query/parser/UrlClauseImpl.java
2006-05-10 11:01:42 UTC (rev 2888)
@@ -14,6 +14,7 @@
import no.schibstedsok.front.searchportal.query.UrlClause;
import no.schibstedsok.front.searchportal.query.token.TokenEvaluatorFactory;
import no.schibstedsok.front.searchportal.query.token.TokenPredicate;
+import no.schibstedsok.front.searchportal.site.Site;
/**
* UrlClauseImpl. Contains one http URL.
@@ -28,8 +29,9 @@
/** Values are WeakReference object to AbstractClause.
* Unsynchronized are there are no 'changing values', just existance or
not of the AbstractClause in the system.
*/
- private static final Map<String,WeakReference<UrlClauseImpl>> WEAK_CACHE =
new HashMap<String,WeakReference<UrlClauseImpl>>();
-
+ private static final Map<Site,Map<String,WeakReference<UrlClauseImpl>>>
WEAK_CACHE
+ = new HashMap<Site,Map<String,WeakReference<UrlClauseImpl>>>();
+
/* A IntegerClauseImpl specific collection of TokenPredicates that *could*
apply to this Clause type. */
private static final Collection<TokenPredicate> PREDICATES_APPLICABLE;
@@ -65,13 +67,20 @@
// update the factory with what the current term is
predicate2evaluatorFactory.setCurrentTerm(term);
+ // the weakCache to use.
+ Map<String,WeakReference<UrlClauseImpl>> weakCache =
WEAK_CACHE.get(predicate2evaluatorFactory.getSite());
+ if( weakCache == null ){
+ weakCache = new HashMap<String,WeakReference<UrlClauseImpl>>();
+ WEAK_CACHE.put(predicate2evaluatorFactory.getSite(),weakCache);
+ }
+
// use helper method from AbstractLeafClause
return createClause(
UrlClauseImpl.class,
term,
field,
predicate2evaluatorFactory,
- PREDICATES_APPLICABLE, WEAK_CACHE);
+ PREDICATES_APPLICABLE, weakCache);
}
/**
Modified:
trunk/src/java/no/schibstedsok/front/searchportal/query/parser/WordClauseImpl.java
===================================================================
---
trunk/src/java/no/schibstedsok/front/searchportal/query/parser/WordClauseImpl.java
2006-05-09 20:59:22 UTC (rev 2887)
+++
trunk/src/java/no/schibstedsok/front/searchportal/query/parser/WordClauseImpl.java
2006-05-10 11:01:42 UTC (rev 2888)
@@ -13,6 +13,7 @@
import no.schibstedsok.front.searchportal.query.WordClause;
import no.schibstedsok.front.searchportal.query.token.TokenEvaluatorFactory;
import no.schibstedsok.front.searchportal.query.token.TokenPredicate;
+import no.schibstedsok.front.searchportal.site.Site;
/**
* Represent a word in the query. May contain the optional field (field:word).
* May contain both character and digits but cannot contain only digits
@@ -26,7 +27,8 @@
/** Values are WeakReference object to AbstractClause.
* Unsynchronized are there are no 'changing values', just existance or
not of the AbstractClause in the system.
*/
- private static final Map<String,WeakReference<WordClauseImpl>> WEAK_CACHE
= new HashMap<String,WeakReference<WordClauseImpl>>();
+ private static final Map<Site,Map<String,WeakReference<WordClauseImpl>>>
WEAK_CACHE
+ = new HashMap<Site,Map<String,WeakReference<WordClauseImpl>>>();
/* A WordClauseImpl specific collection of TokenPredicates that *could*
apply to this Clause type. */
private static final Collection<TokenPredicate> PREDICATES_APPLICABLE;
@@ -70,13 +72,20 @@
// update the factory with what the current term is
predicate2evaluatorFactory.setCurrentTerm(term);
+ // the weakCache to use.
+ Map<String,WeakReference<WordClauseImpl>> weakCache =
WEAK_CACHE.get(predicate2evaluatorFactory.getSite());
+ if( weakCache == null ){
+ weakCache = new HashMap<String,WeakReference<WordClauseImpl>>();
+ WEAK_CACHE.put(predicate2evaluatorFactory.getSite(),weakCache);
+ }
+
// use helper method from AbstractLeafClause
return createClause(
WordClauseImpl.class,
term,
field,
predicate2evaluatorFactory,
- PREDICATES_APPLICABLE, WEAK_CACHE);
+ PREDICATES_APPLICABLE, weakCache);
}
/**
Modified:
trunk/src/java/no/schibstedsok/front/searchportal/query/parser/XorClauseImpl.java
===================================================================
---
trunk/src/java/no/schibstedsok/front/searchportal/query/parser/XorClauseImpl.java
2006-05-09 20:59:22 UTC (rev 2887)
+++
trunk/src/java/no/schibstedsok/front/searchportal/query/parser/XorClauseImpl.java
2006-05-10 11:01:42 UTC (rev 2888)
@@ -17,6 +17,7 @@
import no.schibstedsok.front.searchportal.query.XorClause;
import no.schibstedsok.front.searchportal.query.token.TokenEvaluatorFactory;
import no.schibstedsok.front.searchportal.query.token.TokenPredicate;
+import no.schibstedsok.front.searchportal.site.Site;
import org.apache.commons.collections.Predicate;
/**
@@ -32,8 +33,9 @@
/** Values are WeakReference object to AbstractClause.
* Unsynchronized are there are no 'changing values', just existance or
not of the AbstractClause in the system.
*/
- private static final Map<String,WeakReference<XorClauseImpl>> WEAK_CACHE =
new HashMap<String,WeakReference<XorClauseImpl>>();
-
+ private static final Map<Site,Map<String,WeakReference<XorClauseImpl>>>
WEAK_CACHE
+ = new HashMap<Site,Map<String,WeakReference<XorClauseImpl>>>();
+
/* A WordClause specific collection of TokenPredicates that *could* apply
to this Clause type. */
private static final Collection<TokenPredicate> PREDICATES_APPLICABLE;
@@ -80,12 +82,19 @@
// update the factory with what the current term is
predicate2evaluatorFactory.setCurrentTerm(term);
+ // the weakCache to use.
+ Map<String,WeakReference<XorClauseImpl>> weakCache =
WEAK_CACHE.get(predicate2evaluatorFactory.getSite());
+ if( weakCache == null ){
+ weakCache = new HashMap<String,WeakReference<XorClauseImpl>>();
+ WEAK_CACHE.put(predicate2evaluatorFactory.getSite(),weakCache);
+ }
+
// we can't use the helper method because of the extra Hint argument
to the XorClauseImpl constructor
// check weak reference cache of immutable wordClauses here.
// no need to synchronise, no big lost if duplicate identical objects
are created and added over each other
// into the cache, compared to the performance lost of trying to
synchronise this.
- XorClauseImpl clause = findClauseInUse(term, WEAK_CACHE);
+ XorClauseImpl clause = findClauseInUse(term, weakCache);
if (clause == null) {
// Doesn't exist in weak-reference cache. let's find the
predicates and create the WordClause.
@@ -106,7 +115,7 @@
predicate2evaluatorFactory.getClausesPossiblePredicates()
);
- addClauseInUse(term, clause, WEAK_CACHE);
+ addClauseInUse(term, clause, weakCache);
}
return clause;
Modified:
trunk/src/java/no/schibstedsok/front/searchportal/query/token/TokenEvaluatorFactory.java
===================================================================
---
trunk/src/java/no/schibstedsok/front/searchportal/query/token/TokenEvaluatorFactory.java
2006-05-09 20:59:22 UTC (rev 2887)
+++
trunk/src/java/no/schibstedsok/front/searchportal/query/token/TokenEvaluatorFactory.java
2006-05-10 11:01:42 UTC (rev 2888)
@@ -4,6 +4,7 @@
package no.schibstedsok.front.searchportal.query.token;
import java.util.Set;
+import no.schibstedsok.front.searchportal.site.Site;
/**
* A TokenEvaluateFactory provides knowledge about which implementation of
@@ -44,4 +45,6 @@
void setClausesPossiblePredicates(Set<TokenPredicate> possiblePredicates);
Set<TokenPredicate> getClausesPossiblePredicates();
+
+ Site getSite();
}
Modified:
trunk/src/java/no/schibstedsok/front/searchportal/query/token/TokenEvaluatorFactoryImpl.java
===================================================================
---
trunk/src/java/no/schibstedsok/front/searchportal/query/token/TokenEvaluatorFactoryImpl.java
2006-05-09 20:59:22 UTC (rev 2887)
+++
trunk/src/java/no/schibstedsok/front/searchportal/query/token/TokenEvaluatorFactoryImpl.java
2006-05-10 11:01:42 UTC (rev 2888)
@@ -15,6 +15,7 @@
import no.schibstedsok.front.searchportal.http.HTTPClient;
import no.schibstedsok.front.searchportal.query.QueryStringContext;
+import no.schibstedsok.front.searchportal.site.Site;
import org.apache.commons.collections.Predicate;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -139,6 +140,10 @@
return possiblePredicates;
}
+ public Site getSite() {
+ return context.getSite();
+ }
+
private final class FastEvaluatorCreator implements Runnable{
public void run() {
final String host =
getProperties().getProperty("tokenevaluator.host");
Modified: trunk/src/java/no/schibstedsok/front/searchportal/site/Site.java
===================================================================
--- trunk/src/java/no/schibstedsok/front/searchportal/site/Site.java
2006-05-09 20:59:22 UTC (rev 2887)
+++ trunk/src/java/no/schibstedsok/front/searchportal/site/Site.java
2006-05-10 11:01:42 UTC (rev 2888)
@@ -170,7 +170,6 @@
private static final String SITE_DEFAULT_FALLBACK = "sesam.no";
static {
- Locale.setDefault(new Locale("no","NO"));
final Properties props = new Properties();
try {
_______________________________________________
Kernel-commits mailing list
[email protected]
http://sesat.no/mailman/listinfo/kernel-commits