[hibernate-commits] Hibernate SVN: r14946 - in search/trunk: src/java/org/hibernate/search and 5 other directories.
hibernate-commits at lists.jboss.org
hibernate-commits at lists.jboss.org
Thu Jul 17 05:44:31 EDT 2008
Author: hardy.ferentschik
Date: 2008-07-17 05:44:30 -0400 (Thu, 17 Jul 2008)
New Revision: 14946
Modified:
search/trunk/doc/reference/en/modules/query.xml
search/trunk/src/java/org/hibernate/search/Environment.java
search/trunk/src/java/org/hibernate/search/annotations/CacheBitResults.java
search/trunk/src/java/org/hibernate/search/annotations/FullTextFilterDef.java
search/trunk/src/java/org/hibernate/search/engine/SearchFactoryImplementor.java
search/trunk/src/java/org/hibernate/search/impl/SearchFactoryImpl.java
search/trunk/src/java/org/hibernate/search/query/FullTextQueryImpl.java
search/trunk/src/test/org/hibernate/search/test/filter/FilterTest.java
Log:
HSEARCH-174:
* Some name refactoring. Getting rid of as many references to CachingWrapperFilter as possible.
* Updated and improved the documentation.
Modified: search/trunk/doc/reference/en/modules/query.xml
===================================================================
--- search/trunk/doc/reference/en/modules/query.xml 2008-07-17 04:30:45 UTC (rev 14945)
+++ search/trunk/doc/reference/en/modules/query.xml 2008-07-17 09:44:30 UTC (rev 14946)
@@ -593,17 +593,21 @@
implementation to each of the parameters equals and hashcode
methods.</para>
- <para>The filter cache is enabled by default and uses the notion of
- SoftReferences to dispose memory when needed. To adjust the size of the
- hard reference cache, use
+ <para>The filter cache is enabled by default and uses a combination of
+ hard and soft references to allow disposal of memory when needed. The hard
+ reference cache keeps track of the most recently used filters and
+ transforms the ones least used to <classname>SoftReferences</classname>
+ when needed. Once the limit of the hard reference cache is reached
+ addtional filters are cached as <classname>SoftReferences</classname>. To
+ adjust the size of the hard reference cache, use
<literal>hibernate.search.filter.cache_strategy.size</literal> (defaults
to 128). For advance use of filter caching, you can implement your own
<classname>FilterCachingStrategy</classname>. The classname is defined by
<literal>hibernate.search.filter.cache_strategy</literal>.</para>
- <para>The described filter cache should not be confused with caching the
- actual filter results. In Lucene it is common practise to wrap filters
- using the <classname>IndexReader</classname> around a
+ <para>The described filter cache mechanism should not be confused with
+ caching the actual filter results. In Lucene it is common practise to wrap
+ filters using the <classname>IndexReader</classname> around a
<classname>CachingWrapperFilter.</classname> The wrapper will cache the
<classname>BitSet</classname> returned from the
<methodname>bits(IndexReader reader)</methodname>method to avoid expensive
@@ -616,12 +620,12 @@
CachingWrapperFilter
(<classname>org.hibernate.search.filter.CachingWrapperFilter</classname>).
In contrast to Lucene's version of this class SoftReferences are used
- together with a hard reference count. The hard reference count can be
- adjusted using
- <literal>hibernate.search.filter.caching_wrapper.size</literal> (defaults
- to 5). The wrapping behaviour can be controlled by
- <literal>@FullTextFilterDef.useCachingWrapperFilter</literal>. There are
- three differerent values for this parameter:</para>
+ together with a hard reference count (see dicussion about filter cache).
+ The hard reference count can be adjusted using
+ <literal>hibernate.search.filter.cache_bit_results.size</literal>
+ (defaults to 5). The wrapping behaviour can be controlled by
+ <literal>@FullTextFilterDef.cacheBitResult</literal>. There are three
+ differerent values for this parameter:</para>
<para><informaltable align="left" width="">
<tgroup cols="2">
Modified: search/trunk/src/java/org/hibernate/search/Environment.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/Environment.java 2008-07-17 04:30:45 UTC (rev 14945)
+++ search/trunk/src/java/org/hibernate/search/Environment.java 2008-07-17 09:44:30 UTC (rev 14946)
@@ -1,4 +1,4 @@
-//$Id$
+// $Id$
package org.hibernate.search;
/**
@@ -71,5 +71,5 @@
/**
* Property name for the hard ref count of our <code>CachingWrapperFilter</code>.
*/
- public static final String CACHING_WRAPPER_FILTER_SIZE = "hibernate.search.filter.caching_wrapper.size";
+ public static final String CACHE_BIT_RESULT_SIZE = "hibernate.search.filter.cache_bit_results.size";
}
Modified: search/trunk/src/java/org/hibernate/search/annotations/CacheBitResults.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/annotations/CacheBitResults.java 2008-07-17 04:30:45 UTC (rev 14945)
+++ search/trunk/src/java/org/hibernate/search/annotations/CacheBitResults.java 2008-07-17 09:44:30 UTC (rev 14946)
@@ -1,15 +1,15 @@
-// $Id:$
+// $Id$
package org.hibernate.search.annotations;
/**
- * Defines the strategy for using <code>CachingWrappingFilter</code>
+ * Defines the strategy for caching the <code>BitSet</code> returned by a defined filter.
*
* @author Hardy Ferentschik
* @see org.hibernate.search.filter.CachingWrapperFilter
*/
public enum CacheBitResults {
/**
- * Use a <code>CachingWrapperFilter<code> depending on the value of the <code>cache</code>
+ * Caching is dependent on the value of the <code>cache</code>
* parameter of the filter definition. If <code>cache == true</code> a wrapping filter will
* be used, otherwise not.
* @see FullTextFilterDef#cache()
@@ -17,12 +17,12 @@
AUTOMATIC,
/**
- * Wrap the filter around a <code>CachingWrappingFilter</code>.
+ * The filters <code>BitSet</code> will be cached.
*/
YES,
/**
- * Do not use a <code>CachingWrappingFilter</code>.
+ * No caching of the filter's <code>BitSet</code>.
*/
NO;
}
\ No newline at end of file
Modified: search/trunk/src/java/org/hibernate/search/annotations/FullTextFilterDef.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/annotations/FullTextFilterDef.java 2008-07-17 04:30:45 UTC (rev 14945)
+++ search/trunk/src/java/org/hibernate/search/annotations/FullTextFilterDef.java 2008-07-17 09:44:30 UTC (rev 14946)
@@ -40,7 +40,8 @@
boolean cache() default true;
/**
- * Determines whether the filter should be wrapped around a <code>CachingWrapperFilter</code>.
+ * Determines whether the <code>BitSet</code> returned from the filter should be
+ * cached or not. Default is <code>CacheBitResults.AUTOMATIC</code>.
*/
- CacheBitResults useCachingWrapperFilter() default CacheBitResults.AUTOMATIC;
+ CacheBitResults cacheBitResult() default CacheBitResults.AUTOMATIC;
}
Modified: search/trunk/src/java/org/hibernate/search/engine/SearchFactoryImplementor.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/engine/SearchFactoryImplementor.java 2008-07-17 04:30:45 UTC (rev 14945)
+++ search/trunk/src/java/org/hibernate/search/engine/SearchFactoryImplementor.java 2008-07-17 09:44:30 UTC (rev 14946)
@@ -55,5 +55,5 @@
void addDirectoryProvider(DirectoryProvider<?> provider);
- int getCachingWrapperFilterSize();
+ int getFilterCacheBitResultsSize();
}
Modified: search/trunk/src/java/org/hibernate/search/impl/SearchFactoryImpl.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/impl/SearchFactoryImpl.java 2008-07-17 04:30:45 UTC (rev 14945)
+++ search/trunk/src/java/org/hibernate/search/impl/SearchFactoryImpl.java 2008-07-17 09:44:30 UTC (rev 14946)
@@ -22,7 +22,6 @@
import org.hibernate.annotations.common.reflection.XClass;
import org.hibernate.annotations.common.reflection.java.JavaReflectionManager;
import org.hibernate.annotations.common.util.StringHelper;
-import org.hibernate.mapping.PersistentClass;
import org.hibernate.search.Environment;
import org.hibernate.search.SearchException;
import org.hibernate.search.Version;
@@ -76,7 +75,7 @@
private final FilterCachingStrategy filterCachingStrategy;
private Map<String, Analyzer> analyzers;
private final AtomicBoolean stopped = new AtomicBoolean( false );
- private final int cachingWrapperFilterSize;
+ private final int cacheBitResultsSize;
/*
* used as a barrier (piggyback usage) between initialization and subsequent usage of searchFactory in different threads
* this is due to our use of the initialize pattern is a few areas
@@ -121,7 +120,7 @@
this.worker = WorkerFactory.createWorker( cfg, this );
this.readerProvider = ReaderProviderFactory.createReaderProvider( cfg, this );
this.filterCachingStrategy = buildFilterCachingStrategy( cfg.getProperties() );
- this.cachingWrapperFilterSize = ConfigurationParseHelper.getIntValue( cfg.getProperties(), Environment.CACHING_WRAPPER_FILTER_SIZE, CachingWrapperFilter.DEFAULT_SIZE );
+ this.cacheBitResultsSize = ConfigurationParseHelper.getIntValue( cfg.getProperties(), Environment.CACHE_BIT_RESULT_SIZE, CachingWrapperFilter.DEFAULT_SIZE );
this.barrier = 1; //write barrier
}
@@ -195,7 +194,7 @@
FilterDef filterDef = new FilterDef();
filterDef.setImpl( defAnn.impl() );
filterDef.setCache( defAnn.cache() );
- filterDef.setUseCachingWrapperFilter( defAnn.useCachingWrapperFilter() );
+ filterDef.setUseCachingWrapperFilter( defAnn.cacheBitResult() );
try {
filterDef.getImpl().newInstance();
}
@@ -388,9 +387,8 @@
this.dirProviderData.put( provider, new DirectoryProviderData() );
}
- public int getCachingWrapperFilterSize() {
+ public int getFilterCacheBitResultsSize() {
if (barrier != 0) {} //read barrier
- return cachingWrapperFilterSize;
+ return cacheBitResultsSize;
}
-
}
Modified: search/trunk/src/java/org/hibernate/search/query/FullTextQueryImpl.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/query/FullTextQueryImpl.java 2008-07-17 04:30:45 UTC (rev 14945)
+++ search/trunk/src/java/org/hibernate/search/query/FullTextQueryImpl.java 2008-07-17 09:44:30 UTC (rev 14946)
@@ -412,7 +412,7 @@
if (def.getUseCachingWrapperFilter() == CacheBitResults.YES
|| (def.getUseCachingWrapperFilter() == CacheBitResults.AUTOMATIC && def
.isCache())) {
- int cachingWrapperFilterSize = getSearchFactoryImplementor().getCachingWrapperFilterSize();
+ int cachingWrapperFilterSize = getSearchFactoryImplementor().getFilterCacheBitResultsSize();
filter = new org.hibernate.search.filter.CachingWrapperFilter(filter, cachingWrapperFilterSize);
}
Modified: search/trunk/src/test/org/hibernate/search/test/filter/FilterTest.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/filter/FilterTest.java 2008-07-17 04:30:45 UTC (rev 14945)
+++ search/trunk/src/test/org/hibernate/search/test/filter/FilterTest.java 2008-07-17 09:44:30 UTC (rev 14946)
@@ -3,7 +3,6 @@
import java.util.Calendar;
-import org.apache.lucene.analysis.StopAnalyzer;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.search.BooleanQuery;
@@ -11,11 +10,9 @@
import org.apache.lucene.search.RangeFilter;
import org.apache.lucene.search.TermQuery;
import org.hibernate.Session;
-import org.hibernate.search.Environment;
import org.hibernate.search.FullTextQuery;
import org.hibernate.search.FullTextSession;
import org.hibernate.search.Search;
-import org.hibernate.search.store.RAMDirectoryProvider;
import org.hibernate.search.test.SearchTestCase;
/**
@@ -174,6 +171,6 @@
protected void configure(org.hibernate.cfg.Configuration cfg) {
super.configure(cfg);
- cfg.setProperty( "hibernate.search.filter.caching_wrapper.size", "10" );
+ cfg.setProperty( "hibernate.search.filter.cache_bit_results.size", "10" );
}
}
More information about the hibernate-commits
mailing list