You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by ec...@apache.org on 2011/12/23 17:15:36 UTC
svn commit: r1222719 -
/incubator/accumulo/trunk/contrib/accumulo_sample/query/src/main/java/parser/QueryParser.java
Author: ecn
Date: Fri Dec 23 16:15:36 2011
New Revision: 1222719
URL: http://svn.apache.org/viewvc?rev=1222719&view=rev
Log:
ACCUMULO-230
Fixed concurrency problems with query cache
Modified:
incubator/accumulo/trunk/contrib/accumulo_sample/query/src/main/java/parser/QueryParser.java
Modified: incubator/accumulo/trunk/contrib/accumulo_sample/query/src/main/java/parser/QueryParser.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/trunk/contrib/accumulo_sample/query/src/main/java/parser/QueryParser.java?rev=1222719&r1=1222718&r2=1222719&view=diff
==============================================================================
--- incubator/accumulo/trunk/contrib/accumulo_sample/query/src/main/java/parser/QueryParser.java (original)
+++ incubator/accumulo/trunk/contrib/accumulo_sample/query/src/main/java/parser/QueryParser.java Fri Dec 23 16:15:36 2011
@@ -283,8 +283,11 @@ public class QueryParser implements Pars
// Check to see if its in the cache
Hash hash = MurmurHash.getInstance();
this.hashVal = hash.hash(query.getBytes(), SEED);
- if (cache.containsKey(hashVal)) {
- CacheEntry entry = (CacheEntry) cache.get(hashVal);
+ CacheEntry entry = null;
+ synchronized (cache) {
+ entry = (CacheEntry) cache.get(hashVal);
+ }
+ if (entry != null) {
this.negatedTerms = entry.getNegatedTerms();
this.andTerms = entry.getAndTerms();
this.orTerms = entry.getOrTerms();
@@ -298,16 +301,14 @@ public class QueryParser implements Pars
rootNode.childrenAccept(this, null);
TreeBuilder builder = new TreeBuilder(rootNode);
tree = builder.getRootNode();
- CacheEntry entry = new CacheEntry(this.negatedTerms, this.andTerms, this.orTerms, this.literals, this.terms, rootNode, tree);
- cache.put(hashVal, entry);
+ entry = new CacheEntry(this.negatedTerms, this.andTerms, this.orTerms, this.literals, this.terms, rootNode, tree);
+ synchronized (cache) {
+ cache.put(hashVal, entry);
+ }
}
}
- public static void clearCache() {
- cache.clear();
- }
-
/**
*
* @return this queries hash value