lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jpou...@apache.org
Subject svn commit: r1662791 [2/2] - in /lucene/dev/branches/branch_5x: ./ lucene/ lucene/core/ lucene/core/src/java/org/apache/lucene/index/ lucene/core/src/java/org/apache/lucene/search/ lucene/core/src/test/org/apache/lucene/index/ lucene/core/src/test/org/...
Date Fri, 27 Feb 2015 18:55:27 GMT
Modified: lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/CachedFilterBuilder.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/CachedFilterBuilder.java?rev=1662791&r1=1662790&r2=1662791&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/CachedFilterBuilder.java
(original)
+++ lucene/dev/branches/branch_5x/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/CachedFilterBuilder.java
Fri Feb 27 18:55:26 2015
@@ -4,7 +4,7 @@
 package org.apache.lucene.queryparser.xml.builders;
 
 import org.apache.lucene.queryparser.xml.*;
-import org.apache.lucene.search.CachingWrapperFilter;
+import org.apache.lucene.search.CachingWrapperQuery;
 import org.apache.lucene.search.Filter;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.QueryWrapperFilter;
@@ -48,7 +48,7 @@ public class CachedFilterBuilder impleme
   private final QueryBuilderFactory queryFactory;
   private final FilterBuilderFactory filterFactory;
 
-  private LRUCache<Object, Filter> filterCache;
+  private LRUCache<Object, Query> filterCache;
 
   private final int cacheSize;
 
@@ -81,20 +81,20 @@ public class CachedFilterBuilder impleme
       f = filterFactory.getFilter(childElement);
       cacheKey = f;
     }
-    Filter cachedFilter = filterCache.get(cacheKey);
+    Query cachedFilter = filterCache.get(cacheKey);
     if (cachedFilter != null) {
-      return cachedFilter; // cache hit
+      return new QueryWrapperFilter(cachedFilter); // cache hit
     }
 
     //cache miss
     if (qb != null) {
       cachedFilter = new QueryWrapperFilter(q);
     } else {
-      cachedFilter = new CachingWrapperFilter(f);
+      cachedFilter = new CachingWrapperQuery(f);
     }
 
     filterCache.put(cacheKey, cachedFilter);
-    return cachedFilter;
+    return new QueryWrapperFilter(cachedFilter);
   }
 
   static class LRUCache<K, V> extends java.util.LinkedHashMap<K, V> {

Modified: lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java?rev=1662791&r1=1662790&r2=1662791&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java
(original)
+++ lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java
Fri Feb 27 18:55:26 2015
@@ -95,10 +95,9 @@ import org.apache.lucene.index.*;
 import org.apache.lucene.index.IndexReader.ReaderClosedListener;
 import org.apache.lucene.index.TermsEnum.SeekStatus;
 import org.apache.lucene.search.AssertingIndexSearcher;
-import org.apache.lucene.search.DocIdSet;
 import org.apache.lucene.search.DocIdSetIterator;
-import org.apache.lucene.search.Filter;
-import org.apache.lucene.search.FilterCachingPolicy;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.QueryCachingPolicy;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.QueryUtils.FCInvisibleMultiReader;
 import org.apache.lucene.store.BaseDirectoryWrapper;
@@ -443,14 +442,14 @@ public abstract class LuceneTestCase ext
     CORE_DIRECTORIES.add("RAMDirectory");
   }
 
-  /** A {@link org.apache.lucene.search.FilterCachingPolicy} that randomly caches. */
-  public static final FilterCachingPolicy MAYBE_CACHE_POLICY = new FilterCachingPolicy()
{
+  /** A {@link org.apache.lucene.search.QueryCachingPolicy} that randomly caches. */
+  public static final QueryCachingPolicy MAYBE_CACHE_POLICY = new QueryCachingPolicy() {
 
     @Override
-    public void onUse(Filter filter) {}
+    public void onUse(Query query) {}
 
     @Override
-    public boolean shouldCache(Filter filter, LeafReaderContext context, DocIdSet set) throws
IOException {
+    public boolean shouldCache(Query query, LeafReaderContext context) throws IOException
{
       return random().nextBoolean();
     }
 
@@ -1702,6 +1701,7 @@ public abstract class LuceneTestCase ext
         ret = random.nextBoolean() ? new IndexSearcher(r) : new IndexSearcher(r.getContext());
       }
       ret.setSimilarity(classEnvRule.similarity);
+      ret.setQueryCachingPolicy(MAYBE_CACHE_POLICY);
       return ret;
     } else {
       int threads = 0;
@@ -1738,6 +1738,7 @@ public abstract class LuceneTestCase ext
             : new IndexSearcher(r.getContext(), ex);
       }
       ret.setSimilarity(classEnvRule.similarity);
+      ret.setQueryCachingPolicy(MAYBE_CACHE_POLICY);
       return ret;
     }
   }

Modified: lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/search/LuceneQueryOptimizer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/search/LuceneQueryOptimizer.java?rev=1662791&r1=1662790&r2=1662791&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/search/LuceneQueryOptimizer.java
(original)
+++ lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/search/LuceneQueryOptimizer.java
Fri Feb 27 18:55:26 2015
@@ -97,7 +97,7 @@ if (c.query instanceof TermQuery) {
         filter = (Filter)cache.get(filterQuery);
       }
       if (filter == null) {                       // miss
-        filter = new CachingWrapperFilter(new QueryWrapperFilter(filterQuery)); // construct
new entry
+        filter = new QueryWrapperFilter(new CachingWrapperQuery(filterQuery)); // construct
new entry
         synchronized (cache) {
           cache.put(filterQuery, filter);         // cache it
         }



Mime
View raw message