From hibernate-commits at lists.jboss.org Fri Sep 5 11:26:26 2008 Content-Type: multipart/mixed; boundary="===============3882205596427161975==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r15155 - in search/trunk: src/java/org/hibernate/search/backend and 2 other directories. Date: Fri, 05 Sep 2008 11:26:25 -0400 Message-ID: --===============3882205596427161975== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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/LuceneIndexingParamet= ers.java search/trunk/src/java/org/hibernate/search/backend/configuration/Configu= rationParseHelper.java search/trunk/src/java/org/hibernate/search/backend/configuration/IndexWr= iterSetting.java search/trunk/src/test/org/hibernate/search/test/configuration/Configurat= ionParseHelperTest.java search/trunk/src/test/org/hibernate/search/test/configuration/LuceneInde= xingParametersTest.java Log: HSEARCH-258 : Add configuration option for Lucene's UseCompoundFile to Inde= xWriter settings Modified: search/trunk/doc/reference/en/modules/configuration.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/doc/reference/en/modules/configuration.xml 2008-09-04 16:0= 5:47 UTC (rev 15154) +++ search/trunk/doc/reference/en/modules/configuration.xml 2008-09-05 15:2= 6:25 UTC (rev 15155) @@ -636,7 +636,7 @@ performances, please refer to the Lucene documentation. = - List of indexing performance properties + List of indexing performance and behavior properties = @@ -746,6 +746,21 @@ = 128 + = + + hibernate.search.[default|<indexname>].i= ndexwriter.[transaction|batch].use_compound_file + + 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, b= ut + increasing the number of permitted file handlers is usually a + preferred solution. + Especially when synchronizing indexes using JMS avoid + this option as it will copy the complete index each time. + Boolean parameter, use "true" or "false". + + false +
Modified: search/trunk/src/java/org/hibernate/search/backend/LuceneIndexing= Parameters.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/java/org/hibernate/search/backend/LuceneIndexingParame= ters.java 2008-09-04 16:05:47 UTC (rev 15154) +++ search/trunk/src/java/org/hibernate/search/backend/LuceneIndexingParame= ters.java 2008-09-05 15:26:25 UTC (rev 15155) @@ -56,7 +56,7 @@ if ( log.isWarnEnabled() ) { Integer maxFieldLengthTransaction =3D transParams.parameters.get( MAX_F= IELD_LENGTH ); Integer maxFieldLengthBatch =3D transParams.parameters.get( MAX_FIELD_L= ENGTH ); - if ( notEquals( maxFieldLengthTransaction, maxFieldLengthBatch ) ){ + if ( notEquals( maxFieldLengthTransaction, maxFieldLengthBatch ) ) { log.warn( "The max_field_length value configured for transaction is di= fferent 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=3D=3Dnull){ - parameters.remove(ws); + if ( newValue =3D=3D 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 =3D=3D obj) + if ( this =3D=3D obj ) return true; - if (obj =3D=3D null) + if ( obj =3D=3D null ) return false; - if (getClass() !=3D obj.getClass()) + if ( getClass() !=3D obj.getClass() ) return false; final ParameterSet other =3D (ParameterSet) obj; if (parameters =3D=3D null) { - if (other.parameters !=3D null) + if ( other.parameters !=3D 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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/java/org/hibernate/search/backend/configuration/Config= urationParseHelper.java 2008-09-04 16:05:47 UTC (rev 15154) +++ search/trunk/src/java/org/hibernate/search/backend/configuration/Config= urationParseHelper.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 i= f 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 errorMsgOnP= arseFailure) { + // avoiding Boolean.valueOf() to have more checks: makes it easy to spot= wrong type in cfg. + if ( value =3D=3D 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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/java/org/hibernate/search/backend/configuration/IndexW= riterSetting.java 2008-09-04 16:05:47 UTC (rev 15154) +++ search/trunk/src/java/org/hibernate/search/backend/configuration/IndexW= riterSetting.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 =3D Integer.valueOf( 1 ); + private static final Integer FALSE =3D 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 =3D ConfigurationParseHelper.parseBoolean( value, + "Invalid value for " + cfgKey + ": " + value ); + return v ? TRUE : FALSE; + } + = + private static boolean intToBoolean(int value) { + return value =3D=3D TRUE.intValue(); + } + = } Modified: search/trunk/src/test/org/hibernate/search/test/configuration/Con= figurationParseHelperTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/test/org/hibernate/search/test/configuration/Configura= tionParseHelperTest.java 2008-09-04 16:05:47 UTC (rev 15154) +++ search/trunk/src/test/org/hibernate/search/test/configuration/Configura= tionParseHelperTest.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 import= ant") ); 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 =3D false; try { ConfigurationParseHelper.getIntValue( props, "value2", 8 ); - exceptionLaunched =3D false; } catch (SearchException e) { exceptionLaunched =3D 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 =3D false; + try { + ConfigurationParseHelper.parseBoolean( "5", "error" ); + } catch (SearchException e) { + exceptionLaunched =3D true; + } + assertTrue( exceptionLaunched ); + exceptionLaunched =3D false; + try { + ConfigurationParseHelper.parseBoolean( null, "error" ); + } catch (SearchException e) { + exceptionLaunched =3D true; + } + assertTrue( exceptionLaunched ); + } = } Modified: search/trunk/src/test/org/hibernate/search/test/configuration/Luc= eneIndexingParametersTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/test/org/hibernate/search/test/configuration/LuceneInd= exingParametersTest.java 2008-09-04 16:05:47 UTC (rev 15154) +++ search/trunk/src/test/org/hibernate/search/test/configuration/LuceneInd= exingParametersTest.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.IndexWriterSettin= g.MAX_BUFFERED_DOCS; import static org.hibernate.search.backend.configuration.IndexWriterSettin= g.MAX_MERGE_DOCS; import static org.hibernate.search.backend.configuration.IndexWriterSettin= g.MERGE_FACTOR; import static org.hibernate.search.backend.configuration.IndexWriterSettin= g.RAM_BUFFER_SIZE; +import static org.hibernate.search.backend.configuration.IndexWriterSettin= g.USE_COMPOUND_FILE; import static org.hibernate.search.test.configuration.ConfigurationReadTes= tCase.TransactionType.TRANSACTION; import static org.hibernate.search.test.configuration.ConfigurationReadTes= tCase.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", "tr= ue" ); //set by super : cfg.setProperty( "hibernate.search.default.batch.max_buff= ered_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_d= ocs", "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 Exceptio= n { @@ -95,8 +102,8 @@ LuceneIndexingParameters param =3D new LuceneIndexingParameters( new Pro= perties() ); LuceneIndexingParameters paramCopy =3D (LuceneIndexingParameters) SerializationTestHelper.duplicateBySerialization( param ); - assertEquals(param.getBatchIndexParameters(), paramCopy.getBatchIndexPar= ameters()); - assertEquals(param.getTransactionIndexParameters(), paramCopy.getTransac= tionIndexParameters()); + assertEquals( param.getBatchIndexParameters(), paramCopy.getBatchIndexPa= rameters() ); + assertEquals( param.getTransactionIndexParameters(), paramCopy.getTransa= ctionIndexParameters() ); } = protected Class[] getMappings() { --===============3882205596427161975==--