Hibernate SVN: r15156 - in search/trunk: src/java/org/hibernate/search/backend and 3 other directories.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2008-09-08 10:07:27 -0400 (Mon, 08 Sep 2008)
New Revision: 15156
Added:
search/trunk/src/test/org/hibernate/search/test/reader/SharedBufferedReaderPerfTest.java
Modified:
search/trunk/doc/reference/en/modules/query.xml
search/trunk/src/java/org/hibernate/search/backend/OptimizeLuceneWork.java
search/trunk/src/java/org/hibernate/search/impl/SearchFactoryImpl.java
search/trunk/src/java/org/hibernate/search/reader/NotSharedReaderProvider.java
search/trunk/src/java/org/hibernate/search/reader/ReaderProvider.java
search/trunk/src/java/org/hibernate/search/reader/SharedReaderProvider.java
search/trunk/src/java/org/hibernate/search/reader/SharingBufferReaderProvider.java
search/trunk/src/test/org/hibernate/search/test/reader/ReaderPerfTestCase.java
Log:
HSEARCH-235 add ReaderProvider.destroy() called during SearchFactory.close()
Modified: search/trunk/doc/reference/en/modules/query.xml
===================================================================
--- search/trunk/doc/reference/en/modules/query.xml 2008-09-05 15:26:25 UTC (rev 15155)
+++ search/trunk/doc/reference/en/modules/query.xml 2008-09-08 14:07:27 UTC (rev 15156)
@@ -606,7 +606,7 @@
<literal>hibernate.search.filter.cache_strategy</literal>.</para>
<para>The described filter cache mechanism should not be confused with
- caching the actual filter results. In Lucene it is common practise to wrap
+ caching the actual filter results. In Lucene it is common practice to wrap
filters using the <classname>IndexReader</classname> around a
<classname>CachingWrapperFilter.</classname> The wrapper will cache the
<classname>BitSet</classname> returned from the
Modified: search/trunk/src/java/org/hibernate/search/backend/OptimizeLuceneWork.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/backend/OptimizeLuceneWork.java 2008-09-05 15:26:25 UTC (rev 15155)
+++ search/trunk/src/java/org/hibernate/search/backend/OptimizeLuceneWork.java 2008-09-08 14:07:27 UTC (rev 15156)
@@ -4,6 +4,10 @@
import java.io.Serializable;
/**
+ * A unit of work triggering an optimize operation
+ * This work does not propagate to a cluster: it should be filtered before being sent to
+ * the network
+ *
* @author Andrew Hahn
* @author Emmanuel Bernard
*/
Modified: search/trunk/src/java/org/hibernate/search/impl/SearchFactoryImpl.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/impl/SearchFactoryImpl.java 2008-09-05 15:26:25 UTC (rev 15155)
+++ search/trunk/src/java/org/hibernate/search/impl/SearchFactoryImpl.java 2008-09-08 14:07:27 UTC (rev 15156)
@@ -147,6 +147,14 @@
catch (Exception e) {
log.error( "Worker raises an exception on close()", e );
}
+
+ try {
+ readerProvider.destroy();
+ }
+ catch (Exception e) {
+ log.error( "ReaderProvider raises an exception on destroy()", e );
+ }
+
//TODO move to DirectoryProviderFactory for cleaner
for (DirectoryProvider dp : getDirectoryProviders() ) {
try {
Modified: search/trunk/src/java/org/hibernate/search/reader/NotSharedReaderProvider.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/reader/NotSharedReaderProvider.java 2008-09-05 15:26:25 UTC (rev 15155)
+++ search/trunk/src/java/org/hibernate/search/reader/NotSharedReaderProvider.java 2008-09-08 14:07:27 UTC (rev 15156)
@@ -47,4 +47,7 @@
public void initialize(Properties props, SearchFactoryImplementor searchFactoryImplementor) {
}
+
+ public void destroy() {
+ }
}
Modified: search/trunk/src/java/org/hibernate/search/reader/ReaderProvider.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/reader/ReaderProvider.java 2008-09-05 15:26:25 UTC (rev 15155)
+++ search/trunk/src/java/org/hibernate/search/reader/ReaderProvider.java 2008-09-08 14:07:27 UTC (rev 15156)
@@ -30,5 +30,14 @@
*/
void closeReader(IndexReader reader);
+ /**
+ * inialize the reader provider before its use
+ */
void initialize(Properties props, SearchFactoryImplementor searchFactoryImplementor);
+
+ /**
+ * called when a SearchFactory is destroyed. This method typically releases resources
+ * This method is guaranteed to be executed after readers are released by queries (assuming no user error).
+ */
+ void destroy();
}
Modified: search/trunk/src/java/org/hibernate/search/reader/SharedReaderProvider.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/reader/SharedReaderProvider.java 2008-09-05 15:26:25 UTC (rev 15155)
+++ search/trunk/src/java/org/hibernate/search/reader/SharedReaderProvider.java 2008-09-08 14:07:27 UTC (rev 15156)
@@ -40,7 +40,7 @@
*/
private Map<DirectoryProvider, Lock> perDirectoryProviderManipulationLocks;
/**
- * Contain the active (ie non obsolete IndexReader for a given Directory
+ * Contains the active (ie non obsolete IndexReader for a given Directory
* There may be no entry (warm up)
* <p/>
* protected by semaphoreIndexReaderLock
@@ -217,67 +217,76 @@
}
for (IndexReader subReader : readers) {
- ReaderData readerData;
- //TODO can we avoid that lock?
+ closeInternalReader( trace, subReader, false );
+ }
+ }
+
+ private void closeInternalReader(boolean trace, IndexReader subReader, boolean finalClose) {
+ ReaderData readerData;
+ //TODO can we avoid that lock?
+ semaphoreIndexReaderLock.lock();
+ try {
+ readerData = searchIndexReaderSemaphores.get( subReader );
+ }
+ finally {
+ semaphoreIndexReaderLock.unlock();
+ }
+
+ if ( readerData == null ) {
+ log.error( "Trying to close a Lucene IndexReader not present: {}", subReader.directory() );
+ //TODO should we try to close?
+ return;
+ }
+
+ //acquire the locks in the same order as everywhere else
+ Lock directoryProviderLock = perDirectoryProviderManipulationLocks.get( readerData.provider );
+ boolean closeReader = false;
+ directoryProviderLock.lock();
+ try {
+ boolean isActive;
+ isActive = activeSearchIndexReaders.get( readerData.provider ) == subReader;
+ if ( trace ) log.trace( "Indexreader not active: {}", subReader );
semaphoreIndexReaderLock.lock();
try {
readerData = searchIndexReaderSemaphores.get( subReader );
- }
- finally {
- semaphoreIndexReaderLock.unlock();
- }
+ if ( readerData == null ) {
+ log.error( "Trying to close a Lucene IndexReader not present: {}" + subReader.directory() );
+ //TODO should we try to close?
+ return;
+ }
- if ( readerData == null ) {
- log.error( "Trying to close a Lucene IndexReader not present: {}", subReader.directory() );
- //TODO should we try to close?
- continue;
- }
-
- //acquire the locks in the same order as everywhere else
- Lock directoryProviderLock = perDirectoryProviderManipulationLocks.get( readerData.provider );
- boolean closeReader = false;
- directoryProviderLock.lock();
- try {
- boolean isActive;
- isActive = activeSearchIndexReaders.get( readerData.provider ) == subReader;
- if ( trace ) log.trace( "Indexreader not active: {}", subReader );
- semaphoreIndexReaderLock.lock();
- try {
- readerData = searchIndexReaderSemaphores.get( subReader );
- if ( readerData == null ) {
- log.error( "Trying to close a Lucene IndexReader not present: {}" + subReader.directory() );
- //TODO should we try to close?
- continue;
- }
+ //final close, the semaphore should be at 0 already
+ if (!finalClose) {
readerData.semaphore--;
if ( trace ) log.trace( "Semaphore decreased to: {} for {}", readerData.semaphore, subReader );
- if ( readerData.semaphore < 0 )
- log.error( "Semaphore negative: {}", subReader.directory() );
- if ( ( !isActive ) && readerData.semaphore == 0 ) {
- searchIndexReaderSemaphores.remove( subReader );
- closeReader = true;
- }
- else {
- closeReader = false;
- }
}
- finally {
- semaphoreIndexReaderLock.unlock();
+
+ if ( readerData.semaphore < 0 )
+ log.error( "Semaphore negative: {}", subReader.directory() );
+ if ( ( !isActive ) && readerData.semaphore == 0 ) {
+ searchIndexReaderSemaphores.remove( subReader );
+ closeReader = true;
}
+ else {
+ closeReader = false;
+ }
}
finally {
- directoryProviderLock.unlock();
+ semaphoreIndexReaderLock.unlock();
}
+ }
+ finally {
+ directoryProviderLock.unlock();
+ }
- if ( closeReader ) {
- if ( trace ) log.trace( "Closing IndexReader: {}", subReader );
- try {
- subReader.close();
- }
- catch (IOException e) {
- log.warn( "Unable to close Lucene IndexReader", e );
- }
+ if ( closeReader ) {
+ if ( trace ) log.trace( "Closing IndexReader: {}", subReader );
+ try {
+ subReader.close();
}
+ catch ( IOException e) {
+ log.warn( "Unable to close Lucene IndexReader", e );
+ }
}
}
@@ -290,6 +299,29 @@
perDirectoryProviderManipulationLocks = Collections.unmodifiableMap( perDirectoryProviderManipulationLocks );
}
+ public void destroy() {
+ boolean trace = log.isTraceEnabled();
+ IndexReader[] readers;
+ semaphoreIndexReaderLock.lock();
+ try {
+ //release active readers
+ activeSearchIndexReaders.clear();
+ readers = searchIndexReaderSemaphores.keySet().toArray( new IndexReader[searchIndexReaderSemaphores.size()] );
+ }
+ finally {
+ semaphoreIndexReaderLock.unlock();
+ }
+
+ for (IndexReader reader : readers) {
+ closeInternalReader( trace, reader, true );
+ }
+
+ if ( searchIndexReaderSemaphores.size() != 0 ) {
+ log.warn( "ReaderProvider contains readers not properly closed at destroy time" );
+ }
+
+ }
+
private static class ReaderData {
public ReaderData(int semaphore, DirectoryProvider provider) {
Modified: search/trunk/src/java/org/hibernate/search/reader/SharingBufferReaderProvider.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/reader/SharingBufferReaderProvider.java 2008-09-05 15:26:25 UTC (rev 15155)
+++ search/trunk/src/java/org/hibernate/search/reader/SharingBufferReaderProvider.java 2008-09-08 14:07:27 UTC (rev 15156)
@@ -76,6 +76,16 @@
currentReaders = Collections.unmodifiableMap( map );
}
+ public void destroy() {
+ IndexReader[] readers = allReaders.keySet().toArray( new IndexReader[allReaders.size()] );
+ for (IndexReader reader : readers) {
+ ReaderUsagePair usage = allReaders.get( reader );
+ usage.close();
+ }
+
+ if ( allReaders.size() != 0 ) log.warn( "ReaderProvider contains readers not properly closed at destroy time" );
+ }
+
public IndexReader openReader(DirectoryProvider... directoryProviders) {
int length = directoryProviders.length;
IndexReader[] readers = new IndexReader[length];
Modified: search/trunk/src/test/org/hibernate/search/test/reader/ReaderPerfTestCase.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/reader/ReaderPerfTestCase.java 2008-09-05 15:26:25 UTC (rev 15155)
+++ search/trunk/src/test/org/hibernate/search/test/reader/ReaderPerfTestCase.java 2008-09-08 14:07:27 UTC (rev 15156)
@@ -50,6 +50,7 @@
protected void tearDown() throws Exception {
super.tearDown();
+ if ( getSessions() != null ) getSessions().close();
File sub = getBaseIndexDir();
FileHelper.delete( sub );
}
Copied: search/trunk/src/test/org/hibernate/search/test/reader/SharedBufferedReaderPerfTest.java (from rev 15153, search/trunk/src/test/org/hibernate/search/test/reader/SharedReaderPerfTest.java)
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/reader/SharedBufferedReaderPerfTest.java (rev 0)
+++ search/trunk/src/test/org/hibernate/search/test/reader/SharedBufferedReaderPerfTest.java 2008-09-08 14:07:27 UTC (rev 15156)
@@ -0,0 +1,15 @@
+//$Id$
+package org.hibernate.search.test.reader;
+
+import org.hibernate.cfg.Configuration;
+import org.hibernate.search.Environment;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class SharedBufferedReaderPerfTest extends ReaderPerfTestCase {
+ protected void configure(Configuration cfg) {
+ super.configure( cfg );
+ cfg.setProperty( Environment.READER_STRATEGY, "shared-segments" );
+ }
+}
\ No newline at end of file
Property changes on: search/trunk/src/test/org/hibernate/search/test/reader/SharedBufferedReaderPerfTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:mergeinfo
+
16 years, 3 months
Hibernate SVN: r15155 - in search/trunk: src/java/org/hibernate/search/backend and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: sannegrinovero
Date: 2008-09-05 11:26:25 -0400 (Fri, 05 Sep 2008)
New Revision: 15155
Modified:
search/trunk/doc/reference/en/modules/configuration.xml
search/trunk/src/java/org/hibernate/search/backend/LuceneIndexingParameters.java
search/trunk/src/java/org/hibernate/search/backend/configuration/ConfigurationParseHelper.java
search/trunk/src/java/org/hibernate/search/backend/configuration/IndexWriterSetting.java
search/trunk/src/test/org/hibernate/search/test/configuration/ConfigurationParseHelperTest.java
search/trunk/src/test/org/hibernate/search/test/configuration/LuceneIndexingParametersTest.java
Log:
HSEARCH-258 : Add configuration option for Lucene's UseCompoundFile to IndexWriter settings
Modified: search/trunk/doc/reference/en/modules/configuration.xml
===================================================================
--- search/trunk/doc/reference/en/modules/configuration.xml 2008-09-04 16:05:47 UTC (rev 15154)
+++ search/trunk/doc/reference/en/modules/configuration.xml 2008-09-05 15:26:25 UTC (rev 15155)
@@ -636,7 +636,7 @@
performances, please refer to the Lucene documentation.</para>
<table>
- <title>List of indexing performance properties</title>
+ <title>List of indexing performance and behavior properties</title>
<tgroup cols="3">
<thead>
@@ -746,6 +746,21 @@
<entry>128</entry>
</row>
+
+ <row>
+ <entry><literal>hibernate.search.[default|<indexname>].indexwriter.[transaction|batch].use_compound_file</literal></entry>
+
+ <entry><para>Leaving this value to false is generally the best
+ performing option. You may need to enable it to have the index
+ written to a single compound file to use less file handlers, but
+ increasing the number of permitted file handlers is usually a
+ preferred solution.</para>
+ <para>Especially when synchronizing indexes using JMS avoid
+ this option as it will copy the complete index each time.</para>
+ <para>Boolean parameter, use "<literal>true</literal>" or "<literal>false</literal>".</para></entry>
+
+ <entry>false</entry>
+ </row>
</tbody>
</tgroup>
</table>
Modified: search/trunk/src/java/org/hibernate/search/backend/LuceneIndexingParameters.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/backend/LuceneIndexingParameters.java 2008-09-04 16:05:47 UTC (rev 15154)
+++ search/trunk/src/java/org/hibernate/search/backend/LuceneIndexingParameters.java 2008-09-05 15:26:25 UTC (rev 15155)
@@ -56,7 +56,7 @@
if ( log.isWarnEnabled() ) {
Integer maxFieldLengthTransaction = transParams.parameters.get( MAX_FIELD_LENGTH );
Integer maxFieldLengthBatch = transParams.parameters.get( MAX_FIELD_LENGTH );
- if ( notEquals( maxFieldLengthTransaction, maxFieldLengthBatch ) ){
+ if ( notEquals( maxFieldLengthTransaction, maxFieldLengthBatch ) ) {
log.warn( "The max_field_length value configured for transaction is different than the value configured for batch." );
}
}
@@ -116,14 +116,14 @@
}
public Integer getCurrentValueFor(IndexWriterSetting ws){
- return parameters.get(ws);
+ return parameters.get( ws );
}
public void setCurrentValueFor(IndexWriterSetting ws, Integer newValue){
- if (newValue==null){
- parameters.remove(ws);
+ if ( newValue == null ) {
+ parameters.remove( ws );
} else {
- parameters.put(ws, newValue);
+ parameters.put( ws, newValue );
}
}
@@ -138,17 +138,17 @@
@Override
public boolean equals(Object obj) {
- if (this == obj)
+ if ( this == obj )
return true;
- if (obj == null)
+ if ( obj == null )
return false;
- if (getClass() != obj.getClass())
+ if ( getClass() != obj.getClass() )
return false;
final ParameterSet other = (ParameterSet) obj;
if (parameters == null) {
- if (other.parameters != null)
+ if ( other.parameters != null )
return false;
- } else if (!parameters.equals(other.parameters))
+ } else if ( ! parameters.equals( other.parameters ) )
return false;
return true;
}
Modified: search/trunk/src/java/org/hibernate/search/backend/configuration/ConfigurationParseHelper.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/backend/configuration/ConfigurationParseHelper.java 2008-09-04 16:05:47 UTC (rev 15154)
+++ search/trunk/src/java/org/hibernate/search/backend/configuration/ConfigurationParseHelper.java 2008-09-05 15:26:25 UTC (rev 15155)
@@ -67,4 +67,27 @@
return parseInt( propValue, defValue, "Unable to parse " + key + ": " + propValue );
}
+ /**
+ * Parses a string to recognize exactly either "true" or "false".
+ * @param value the string to be parsed
+ * @param errorMsgOnParseFailure the message to be put in the exception if thrown
+ * @return true if value is "true", false if value is "false"
+ * @throws SearchException for invalid format or values.
+ */
+ public static final boolean parseBoolean(String value, String errorMsgOnParseFailure) {
+ // avoiding Boolean.valueOf() to have more checks: makes it easy to spot wrong type in cfg.
+ if ( value == null ) {
+ throw new SearchException( errorMsgOnParseFailure );
+ }
+ else if ( "false".equalsIgnoreCase( value.trim() ) ) {
+ return false;
+ }
+ else if ( "true".equalsIgnoreCase( value.trim() ) ) {
+ return true;
+ }
+ else {
+ throw new SearchException( errorMsgOnParseFailure );
+ }
+ }
+
}
Modified: search/trunk/src/java/org/hibernate/search/backend/configuration/IndexWriterSetting.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/backend/configuration/IndexWriterSetting.java 2008-09-04 16:05:47 UTC (rev 15154)
+++ search/trunk/src/java/org/hibernate/search/backend/configuration/IndexWriterSetting.java 2008-09-05 15:26:25 UTC (rev 15155)
@@ -13,6 +13,7 @@
* @author Sanne Grinovero
*/
public enum IndexWriterSetting implements Serializable {
+
/**
* @see org.apache.lucene.index.IndexWriter#setMaxBufferedDeleteTerms(int)
*/
@@ -60,7 +61,7 @@
public void applySetting(IndexWriter writer, int value) {
writer.setRAMBufferSizeMB( value );
}
- },
+ } ,
/**
* @see org.apache.lucene.index.IndexWriter#setTermIndexInterval(int)
*/
@@ -68,8 +69,23 @@
public void applySetting(IndexWriter writer, int value) {
writer.setTermIndexInterval( value );
}
+ } ,
+ /**
+ * @see org.apache.lucene.index.IndexWriter#setUseCompoundFile(boolean)
+ */
+ USE_COMPOUND_FILE( "use_compound_file" ) {
+ public void applySetting(IndexWriter writer, int value) {
+ writer.setUseCompoundFile( intToBoolean( value ) );
+ }
+ @Override
+ public Integer parseVal(String value) {
+ return USE_COMPOUND_FILE.parseBoolean( value );
+ }
};
+ private static final Integer TRUE = Integer.valueOf( 1 );
+ private static final Integer FALSE = Integer.valueOf( 0 );
+
private final String cfgKey;
IndexWriterSetting(String configurationKey) {
@@ -99,4 +115,14 @@
"Invalid value for " + cfgKey + ": " + value );
}
+ private Integer parseBoolean(String value) {
+ boolean v = ConfigurationParseHelper.parseBoolean( value,
+ "Invalid value for " + cfgKey + ": " + value );
+ return v ? TRUE : FALSE;
+ }
+
+ private static boolean intToBoolean(int value) {
+ return value == TRUE.intValue();
+ }
+
}
Modified: search/trunk/src/test/org/hibernate/search/test/configuration/ConfigurationParseHelperTest.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/configuration/ConfigurationParseHelperTest.java 2008-09-04 16:05:47 UTC (rev 15154)
+++ search/trunk/src/test/org/hibernate/search/test/configuration/ConfigurationParseHelperTest.java 2008-09-05 15:26:25 UTC (rev 15155)
@@ -13,7 +13,7 @@
*/
public class ConfigurationParseHelperTest extends TestCase {
- public void testIntegerParsers(){
+ public void testIntegerParsers() {
assertEquals( 0, ConfigurationParseHelper.parseInt( " 0 ", "not important") );
assertEquals( 8, ConfigurationParseHelper.parseInt( null, 8, null ) );
assertEquals( 56, ConfigurationParseHelper.parseInt( "56", 8, null ) );
@@ -22,14 +22,34 @@
assertEquals( 58, ConfigurationParseHelper.getIntValue( props, "value1", 8 ) );
assertEquals( 8, ConfigurationParseHelper.getIntValue( props, "value2", 8 ) );
props.setProperty( "value2", "nand" );
- boolean exceptionLaunched;
+ boolean exceptionLaunched = false;
try {
ConfigurationParseHelper.getIntValue( props, "value2", 8 );
- exceptionLaunched = false;
} catch (SearchException e) {
exceptionLaunched = true;
}
assertTrue( exceptionLaunched );
}
+
+ public void testBooleanParsers() {
+ assertTrue( ConfigurationParseHelper.parseBoolean( "true", null ) );
+ assertTrue( ConfigurationParseHelper.parseBoolean( " True ", null ) );
+ assertFalse( ConfigurationParseHelper.parseBoolean( "false", null ) );
+ assertFalse( ConfigurationParseHelper.parseBoolean( " False ", null ) );
+ boolean exceptionLaunched = false;
+ try {
+ ConfigurationParseHelper.parseBoolean( "5", "error" );
+ } catch (SearchException e) {
+ exceptionLaunched = true;
+ }
+ assertTrue( exceptionLaunched );
+ exceptionLaunched = false;
+ try {
+ ConfigurationParseHelper.parseBoolean( null, "error" );
+ } catch (SearchException e) {
+ exceptionLaunched = true;
+ }
+ assertTrue( exceptionLaunched );
+ }
}
Modified: search/trunk/src/test/org/hibernate/search/test/configuration/LuceneIndexingParametersTest.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/configuration/LuceneIndexingParametersTest.java 2008-09-04 16:05:47 UTC (rev 15154)
+++ search/trunk/src/test/org/hibernate/search/test/configuration/LuceneIndexingParametersTest.java 2008-09-05 15:26:25 UTC (rev 15155)
@@ -9,10 +9,12 @@
import org.hibernate.search.test.SerializationTestHelper;
import org.hibernate.search.test.query.Author;
import org.hibernate.search.test.query.Book;
+
import static org.hibernate.search.backend.configuration.IndexWriterSetting.MAX_BUFFERED_DOCS;
import static org.hibernate.search.backend.configuration.IndexWriterSetting.MAX_MERGE_DOCS;
import static org.hibernate.search.backend.configuration.IndexWriterSetting.MERGE_FACTOR;
import static org.hibernate.search.backend.configuration.IndexWriterSetting.RAM_BUFFER_SIZE;
+import static org.hibernate.search.backend.configuration.IndexWriterSetting.USE_COMPOUND_FILE;
import static org.hibernate.search.test.configuration.ConfigurationReadTestCase.TransactionType.TRANSACTION;
import static org.hibernate.search.test.configuration.ConfigurationReadTestCase.TransactionType.BATCH;
@@ -25,6 +27,7 @@
super.configure( cfg );
cfg.setProperty( "hibernate.search.default.batch.ram_buffer_size", "1" );
+ cfg.setProperty( "hibernate.search.default.batch.use_compound_file", "true" );
//set by super : cfg.setProperty( "hibernate.search.default.batch.max_buffered_docs", "1000" );
cfg.setProperty( "hibernate.search.default.transaction.ram_buffer_size", "2" );
@@ -33,6 +36,7 @@
cfg.setProperty( "hibernate.search.default.transaction.max_buffered_docs", "11" );
cfg.setProperty( "hibernate.search.Book.batch.max_merge_docs", "12" );
+ cfg.setProperty( "hibernate.search.Book.transaction.use_compound_file", "false" );
cfg.setProperty( "hibernate.search.Book.batch.merge_factor", "13" );
// new keyword "indexwriter" is also supported to group parameters:
cfg.setProperty( "hibernate.search.Book.indexwriter.batch.max_buffered_docs", "14" );
@@ -51,6 +55,8 @@
}
public void testDefaultIndexProviderParameters() throws Exception {
+ assertValueIsSet( Author.class, BATCH, USE_COMPOUND_FILE, 1 );
+ assertValueIsDefault( Author.class, TRANSACTION, USE_COMPOUND_FILE );
assertValueIsSet( Author.class, TRANSACTION, RAM_BUFFER_SIZE, 2 );
assertValueIsSet( Author.class, TRANSACTION, MAX_MERGE_DOCS, 9 );
assertValueIsSet( Author.class, TRANSACTION, MAX_BUFFERED_DOCS, 11 );
@@ -73,6 +79,7 @@
assertValueIsSet( Book.class, BATCH, MAX_MERGE_DOCS, 12 );
assertValueIsSet( Book.class, BATCH, MAX_BUFFERED_DOCS, 14 );
assertValueIsSet( Book.class, BATCH, MERGE_FACTOR, 13 );
+ assertValueIsSet( Book.class, TRANSACTION, USE_COMPOUND_FILE, 0 );
}
public void testInheritedBatchParametersFromTranscation() throws Exception {
@@ -95,8 +102,8 @@
LuceneIndexingParameters param = new LuceneIndexingParameters( new Properties() );
LuceneIndexingParameters paramCopy = (LuceneIndexingParameters)
SerializationTestHelper.duplicateBySerialization( param );
- assertEquals(param.getBatchIndexParameters(), paramCopy.getBatchIndexParameters());
- assertEquals(param.getTransactionIndexParameters(), paramCopy.getTransactionIndexParameters());
+ assertEquals( param.getBatchIndexParameters(), paramCopy.getBatchIndexParameters() );
+ assertEquals( param.getTransactionIndexParameters(), paramCopy.getTransactionIndexParameters() );
}
protected Class[] getMappings() {
16 years, 3 months
Hibernate SVN: r15154 - in search/trunk: src/java/org/hibernate/search/annotations and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2008-09-04 12:05:47 -0400 (Thu, 04 Sep 2008)
New Revision: 15154
Modified:
search/trunk/doc/reference/en/modules/query.xml
search/trunk/src/java/org/hibernate/search/annotations/CacheBitResults.java
search/trunk/src/java/org/hibernate/search/annotations/Store.java
search/trunk/src/java/org/hibernate/search/query/FullTextQueryImpl.java
Log:
HSEARCH-256 remove CacheBitResults.YES as the option was useless
also fix documentation
Modified: search/trunk/doc/reference/en/modules/query.xml
===================================================================
--- search/trunk/doc/reference/en/modules/query.xml 2008-09-04 15:59:52 UTC (rev 15153)
+++ search/trunk/doc/reference/en/modules/query.xml 2008-09-04 16:05:47 UTC (rev 15154)
@@ -624,7 +624,7 @@
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
+ <literal>@FullTextFilterDef.cacheBitResult</literal>. There are two
differerent values for this parameter:</para>
<para><informaltable align="left" width="">
@@ -641,30 +641,22 @@
<tbody>
<row>
- <entry align="left">CacheBitSet.AUTOMATIC</entry>
+ <entry align="left">CacheBitResults.AUTOMATIC</entry>
<entry>The use of <classname>CachingWrapperFilter</classname>
depends on the <literal>cache</literal> paramter of the filter
defintion. If <literal>cache</literal> is set to
<literal>true</literal> a wrapper will be used, otherwise not.
- <literal>CacheBitSet.AUTOMATIC</literal> is the default
+ <literal>CacheBitResults.AUTOMATIC</literal> is the default
value.</entry>
</row>
<row>
- <entry align="left">CacheBitSet.NO</entry>
+ <entry align="left">CacheBitResults.NO</entry>
<entry>No wrapper will be used.</entry>
</row>
- <row>
- <entry align="left">CacheBitSet.YES</entry>
-
- <entry>The specified filter will be wrapped independent of the
- <literal>cache</literal> flag. (Note, this options is quite
- meaningless, because even though the BitSet will be cached there
- is currently no way to reuse the fitler.)</entry>
- </row>
</tbody>
</tgroup>
</informaltable>Last but not least - why should filters be cached? There
Modified: search/trunk/src/java/org/hibernate/search/annotations/CacheBitResults.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/annotations/CacheBitResults.java 2008-09-04 15:59:52 UTC (rev 15153)
+++ search/trunk/src/java/org/hibernate/search/annotations/CacheBitResults.java 2008-09-04 16:05:47 UTC (rev 15154)
@@ -16,10 +16,6 @@
*/
AUTOMATIC,
- /**
- * The filters <code>BitSet</code> will be cached.
- */
- YES,
/**
* No caching of the filter's <code>BitSet</code>.
Modified: search/trunk/src/java/org/hibernate/search/annotations/Store.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/annotations/Store.java 2008-09-04 15:59:52 UTC (rev 15153)
+++ search/trunk/src/java/org/hibernate/search/annotations/Store.java 2008-09-04 16:05:47 UTC (rev 15154)
@@ -7,7 +7,10 @@
* @author Emmanuel Bernard
*/
public enum Store {
+ /** does not store the value in the index */
NO,
+ /** stores the value in the index */
YES,
+ /** stores the value in the index in a compressed form */
COMPRESS
}
Modified: search/trunk/src/java/org/hibernate/search/query/FullTextQueryImpl.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/query/FullTextQueryImpl.java 2008-09-04 15:59:52 UTC (rev 15153)
+++ search/trunk/src/java/org/hibernate/search/query/FullTextQueryImpl.java 2008-09-04 16:05:47 UTC (rev 15154)
@@ -409,9 +409,7 @@
* <code>def</code>.
*/
private Filter addCachingWrapperFilter(Filter filter, FilterDef def) {
- if (def.getUseCachingWrapperFilter() == CacheBitResults.YES
- || (def.getUseCachingWrapperFilter() == CacheBitResults.AUTOMATIC && def
- .isCache())) {
+ if (def.getUseCachingWrapperFilter() == CacheBitResults.AUTOMATIC && def.isCache() ) {
int cachingWrapperFilterSize = getSearchFactoryImplementor().getFilterCacheBitResultsSize();
filter = new org.hibernate.search.filter.CachingWrapperFilter(filter, cachingWrapperFilterSize);
}
16 years, 3 months
Hibernate SVN: r15152 - search/trunk/src/java/org/hibernate/search/filter.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2008-09-03 23:16:02 -0400 (Wed, 03 Sep 2008)
New Revision: 15152
Modified:
search/trunk/src/java/org/hibernate/search/filter/CachingWrapperFilter.java
Log:
Make CachingWrapperFilter thread safe
Modified: search/trunk/src/java/org/hibernate/search/filter/CachingWrapperFilter.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/filter/CachingWrapperFilter.java 2008-08-29 18:42:57 UTC (rev 15151)
+++ search/trunk/src/java/org/hibernate/search/filter/CachingWrapperFilter.java 2008-09-04 03:16:02 UTC (rev 15152)
@@ -33,7 +33,7 @@
*/
private transient SoftLimitMRUCache cache;
- private Filter filter;
+ private final Filter filter;
/**
* @param filter
@@ -58,6 +58,7 @@
cache = new SoftLimitMRUCache(size);
}
+ //memory barrier ensure cache == null will not always stay true on concurrent threads
synchronized (cache) { // check cache
BitSet cached = (BitSet) cache.get(reader);
if (cached != null) {
16 years, 3 months