Hibernate SVN: r14722 - search/trunk/src/java/org/hibernate/search/engine.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2008-05-31 09:34:48 -0400 (Sat, 31 May 2008)
New Revision: 14722
Modified:
search/trunk/src/java/org/hibernate/search/engine/ProjectionLoader.java
Log:
HSEARCH-204 the shortcut test avoiding session calls was broken
Modified: search/trunk/src/java/org/hibernate/search/engine/ProjectionLoader.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/engine/ProjectionLoader.java 2008-05-30 22:48:49 UTC (rev 14721)
+++ search/trunk/src/java/org/hibernate/search/engine/ProjectionLoader.java 2008-05-31 13:34:48 UTC (rev 14722)
@@ -46,7 +46,7 @@
private void initThisProjectionFlag(EntityInfo entityInfo) {
if ( projectThis == null ) {
- projectThis = entityInfo.indexesOfThis != null;
+ projectThis = entityInfo.indexesOfThis.size() != 0;
if ( projectThis ) {
//TODO use QueryLoader when possible
objectLoader = new ObjectLoader();
16 years, 5 months
Hibernate SVN: r14721 - search/trunk/src/test/org/hibernate/search/test/perf.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2008-05-30 18:48:49 -0400 (Fri, 30 May 2008)
New Revision: 14721
Modified:
search/trunk/src/test/org/hibernate/search/test/perf/IndexTestDontRun.java
Log:
Add dumb perf test
Modified: search/trunk/src/test/org/hibernate/search/test/perf/IndexTestDontRun.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/perf/IndexTestDontRun.java 2008-05-30 22:48:20 UTC (rev 14720)
+++ search/trunk/src/test/org/hibernate/search/test/perf/IndexTestDontRun.java 2008-05-30 22:48:49 UTC (rev 14721)
@@ -39,7 +39,7 @@
}
public void testPerf() throws Exception {
- boolean useLucene = true;
+ boolean useLucene = false;
List<SearcherThread> threads = new ArrayList<SearcherThread>( 100 );
IndexSearcher indexsearcher = getNewSearcher();
16 years, 5 months
Hibernate SVN: r14720 - in search/trunk/src/test/org/hibernate/search/test: perf and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2008-05-30 18:48:20 -0400 (Fri, 30 May 2008)
New Revision: 14720
Added:
search/trunk/src/test/org/hibernate/search/test/perf/
search/trunk/src/test/org/hibernate/search/test/perf/Boat.java
search/trunk/src/test/org/hibernate/search/test/perf/IndexTestDontRun.java
search/trunk/src/test/org/hibernate/search/test/perf/SearcherThread.java
Log:
Add dumb perf test
Added: search/trunk/src/test/org/hibernate/search/test/perf/Boat.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/perf/Boat.java (rev 0)
+++ search/trunk/src/test/org/hibernate/search/test/perf/Boat.java 2008-05-30 22:48:20 UTC (rev 14720)
@@ -0,0 +1,33 @@
+package org.hibernate.search.test.perf;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.GeneratedValue;
+
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.DocumentId;
+import org.hibernate.search.annotations.Store;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+@Indexed
+public class Boat {
+ @Id
+ @GeneratedValue
+ @DocumentId
+ public Integer id;
+ @Field(store= Store.YES)
+ public String name;
+ @Field
+ public String description;
+
+ public Boat() {}
+
+ public Boat(String name, String description) {
+ this.name = name;
+ this.description = description;
+ }
+}
Added: search/trunk/src/test/org/hibernate/search/test/perf/IndexTestDontRun.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/perf/IndexTestDontRun.java (rev 0)
+++ search/trunk/src/test/org/hibernate/search/test/perf/IndexTestDontRun.java 2008-05-30 22:48:20 UTC (rev 14720)
@@ -0,0 +1,81 @@
+package org.hibernate.search.test.perf;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.textui.TestRunner;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.store.Directory;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.search.Search;
+import org.hibernate.search.store.FSDirectoryProvider;
+import org.hibernate.search.test.SearchTestCase;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class IndexTestDontRun extends SearchTestCase {
+ private static boolean isLucene;
+
+ public static void main(String[] args) {
+ //isLucene = Boolean.parseBoolean( args[0] );
+ TestRunner.run( IndexTestDontRun.class );
+
+ }
+
+ public void NonestInit() throws Exception {
+ long time = System.currentTimeMillis();
+ Session s = openSession();
+ Transaction tx = s.beginTransaction();
+ for (int i = 0; i < 50000; i++) {
+ s.save( new Boat( "Maria el Seb", "a long" + i + " description of the land" + i ) );
+ }
+ tx.commit();
+ s.close();
+ System.out.println( " init time = " + ( System.currentTimeMillis() - time ) );
+ }
+
+ public void testPerf() throws Exception {
+ boolean useLucene = true;
+
+ List<SearcherThread> threads = new ArrayList<SearcherThread>( 100 );
+ IndexSearcher indexsearcher = getNewSearcher();
+ SearcherThread searcherThrea = new SearcherThread( 0, "name:maria OR description:long" + 0, getSessions(), indexsearcher, useLucene );
+ searcherThrea.run();
+ for (int i = 1; i <= 100; i++) {
+ // Create a thread and invoke it
+ //if ( i % 100 == 0) indexsearcher = getNewSearcher();
+ SearcherThread searcherThread = new SearcherThread( i, "name:maria OR description:long" + i, getSessions(), indexsearcher, useLucene );
+ searcherThread.setDaemon( false );
+ threads.add( searcherThread );
+ searcherThread.start();
+ }
+ Thread.sleep( 5000 );
+ long totalTime = 0;
+ for (SearcherThread t : threads) totalTime += t.time;
+ System.out.println( "Totaltime=" + totalTime );
+ }
+
+ private IndexSearcher getNewSearcher() throws IOException {
+ final org.hibernate.classic.Session session = getSessions().openSession();
+ Directory d = Search.createFullTextSession( session ).getSearchFactory().getDirectoryProviders( Boat.class )[0].getDirectory();
+ IndexSearcher indexsearcher = new IndexSearcher( d );
+ return indexsearcher;
+ }
+
+ protected Class[] getMappings() {
+ return new Class[] {
+ Boat.class
+ };
+ }
+
+ protected void configure(Configuration cfg) {
+ super.configure( cfg );
+ cfg.setProperty( "hibernate.search.default.directory_provider", FSDirectoryProvider.class.getName() );
+ //cfg.setProperty( "hibernate.search.reader.strategy", DumbSharedReaderProvider.class.getName() );
+
+ }
+}
Added: search/trunk/src/test/org/hibernate/search/test/perf/SearcherThread.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/perf/SearcherThread.java (rev 0)
+++ search/trunk/src/test/org/hibernate/search/test/perf/SearcherThread.java 2008-05-30 22:48:20 UTC (rev 14720)
@@ -0,0 +1,128 @@
+package org.hibernate.search.test.perf;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.ArrayList;
+
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.lucene.queryParser.ParseException;
+import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.search.BooleanQuery;
+import org.apache.lucene.search.Hits;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.store.Directory;
+import org.hibernate.SessionFactory;
+import org.hibernate.classic.Session;
+import org.hibernate.search.Search;
+import org.hibernate.search.FullTextSession;
+import org.hibernate.search.FullTextQuery;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class SearcherThread extends Thread {
+ private static Logger log = LoggerFactory.getLogger( SearcherThread.class );
+ private int threadId;
+ private String queryString;
+ private SessionFactory sf;
+ private IndexSearcher indexsearcher;
+ private boolean isLucene;
+ public long time;
+
+ /**
+ * Initialize with thread-id, querystring, indexsearcher
+ */
+ public SearcherThread(int threadId, String queryString, SessionFactory sf, IndexSearcher indexSearcher, boolean isLucene) {
+ this.isLucene = isLucene;
+ this.threadId = threadId;
+ this.queryString = queryString;
+ this.sf = sf;
+ this.indexsearcher = indexSearcher;
+ }
+
+ public void run() {
+ if ( isLucene ) {
+ runLucene();
+ }
+ else {
+ runHSearch();
+ }
+ }
+
+ /**
+ * @see java.lang.Runnable#run()
+ */
+ public void runLucene() {
+
+ try {
+ QueryParser qp = new QueryParser( "t",
+ new StandardAnalyzer() );
+ qp.setLowercaseExpandedTerms( true );
+ // Parse the query
+ Query q = qp.parse( queryString );
+ if ( q instanceof BooleanQuery ) {
+ BooleanQuery
+ .setMaxClauseCount( Integer.MAX_VALUE );
+ }
+ long start = System.currentTimeMillis();
+ // Search
+ Hits hits = indexsearcher.search( q );
+ List<String> names = new ArrayList<String>(100);
+ for (int i = 1 ; i <= 100 ; i++) {
+ names.add( hits.doc( i ).get( "name" ) );
+ }
+ long totalTime = System.currentTimeMillis() - start;
+ log.error( "Lucene [ Thread-id : " + threadId + " ] Total time taken for search is : " + totalTime + "ms with total no. of matching records : " + hits.length() );
+ time = totalTime;
+ }
+ catch (ParseException e) {
+ // TODO Auto-generated catch block
+ System.out.println( "[ Thread-id : " + threadId + " ] Parse Exception for queryString : " + queryString );
+ e.printStackTrace();
+ }
+ catch (IOException e) {
+ System.out.println( "[ Thread-id : " + threadId + " ] IO Exception for queryString : " + queryString );
+ }
+ catch (Exception e) {
+ e.printStackTrace( );
+ }
+ }
+
+ public void runHSearch() {
+
+ try {
+ QueryParser qp = new QueryParser( "t",
+ new StandardAnalyzer() );
+ qp.setLowercaseExpandedTerms( true );
+
+ // Parse the query
+ Query q = qp.parse( queryString );
+
+
+ // Search
+ FullTextSession ftSession = Search.createFullTextSession( sf.openSession( ) );
+
+ final FullTextQuery textQuery = ftSession.createFullTextQuery( q, Boat.class )
+ .setMaxResults( 100 ).setProjection( "name" );
+ long start = System.currentTimeMillis();
+ List results = textQuery.list();
+ long totalTime = System.currentTimeMillis() - start;
+ ftSession.close();
+
+ log.error( "HSearch [ Thread-id : " + threadId + " ] Total time taken for search is : " + totalTime + "ms with total no. of matching records : " + textQuery.getResultSize() );
+ time = totalTime;
+ }
+ catch (ParseException e) {
+ // TODO Auto-generated catch block
+ log.error( "[ Thread-id : " + threadId + " ] Parse Exception for queryString : " + queryString );
+ e.printStackTrace();
+ }
+ catch (Throwable e) {
+ log.error( "[ Thread-id : " + threadId + " ] Exception for queryString : " + queryString );
+ e.printStackTrace( );
+ }
+ }
+}
16 years, 5 months
Hibernate SVN: r14719 - in search/trunk/src: java/org/hibernate/search/impl and 3 other directories.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2008-05-30 18:28:11 -0400 (Fri, 30 May 2008)
New Revision: 14719
Modified:
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/java/org/hibernate/search/store/DirectoryProviderFactory.java
search/trunk/src/test/org/hibernate/search/test/RamDirectoryTest.java
Log:
HSEARCH-19 no longer filter classes when DPs contains all the targeted classes
Modified: search/trunk/src/java/org/hibernate/search/engine/SearchFactoryImplementor.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/engine/SearchFactoryImplementor.java 2008-05-30 22:26:13 UTC (rev 14718)
+++ search/trunk/src/java/org/hibernate/search/engine/SearchFactoryImplementor.java 2008-05-30 22:28:11 UTC (rev 14719)
@@ -2,6 +2,7 @@
package org.hibernate.search.engine;
import java.util.Map;
+import java.util.Set;
import java.util.concurrent.locks.ReentrantLock;
import org.hibernate.search.SearchFactory;
@@ -44,4 +45,8 @@
public String getIndexingStrategy();
public void close();
+
+ void addClassToDirectoryProvider(Class clazz, DirectoryProvider<?> directoryProvider);
+
+ Set<Class> getClassesInDirectoryProvider(DirectoryProvider<?> directoryProvider);
}
Modified: search/trunk/src/java/org/hibernate/search/impl/SearchFactoryImpl.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/impl/SearchFactoryImpl.java 2008-05-30 22:26:13 UTC (rev 14718)
+++ search/trunk/src/java/org/hibernate/search/impl/SearchFactoryImpl.java 2008-05-30 22:28:11 UTC (rev 14719)
@@ -4,7 +4,9 @@
import java.beans.Introspector;
import java.lang.reflect.Method;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -13,6 +15,7 @@
import java.util.WeakHashMap;
import java.util.concurrent.locks.ReentrantLock;
+import org.apache.lucene.analysis.Analyzer;
import org.hibernate.annotations.common.reflection.ReflectionManager;
import org.hibernate.annotations.common.reflection.XClass;
import org.hibernate.annotations.common.reflection.java.JavaReflectionManager;
@@ -43,7 +46,6 @@
import org.hibernate.search.store.DirectoryProvider;
import org.hibernate.search.store.DirectoryProviderFactory;
import org.hibernate.search.store.optimization.OptimizerStrategy;
-import org.apache.lucene.analysis.Analyzer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -62,10 +64,11 @@
private final Map<Class, DocumentBuilder<Object>> documentBuilders = new HashMap<Class, DocumentBuilder<Object>>();
//keep track of the index modifiers per DirectoryProvider since multiple entity can use the same directory provider
+ //TODO move the ReentrantLock into DirectoryProviderData.lock, add a getDPLock(DP) and add a Set<DP> getDirectoryProviders() method.
private final Map<DirectoryProvider, ReentrantLock> lockableDirectoryProviders =
new HashMap<DirectoryProvider, ReentrantLock>();
- private final Map<DirectoryProvider, OptimizerStrategy> dirProviderOptimizerStrategies =
- new HashMap<DirectoryProvider, OptimizerStrategy>();
+ private final Map<DirectoryProvider, DirectoryProviderData> dirProviderData =
+ new HashMap<DirectoryProvider, DirectoryProviderData>();
private Worker worker;
private ReaderProvider readerProvider;
private BackendQueueProcessorFactory backendQueueProcessorFactory;
@@ -139,6 +142,19 @@
}
}
+ public void addClassToDirectoryProvider(Class clazz, DirectoryProvider<?> directoryProvider) {
+ DirectoryProviderData data = dirProviderData.get(directoryProvider);
+ if (data == null) {
+ data = new DirectoryProviderData();
+ dirProviderData.put( directoryProvider, data );
+ }
+ data.classes.add(clazz);
+ }
+
+ public Set<Class> getClassesInDirectoryProvider(DirectoryProvider<?> directoryProvider) {
+ return Collections.unmodifiableSet( dirProviderData.get(directoryProvider).classes );
+ }
+
private void bindFilterDefs(XClass mappedXClass) {
FullTextFilterDef defAnn = mappedXClass.getAnnotation( FullTextFilterDef.class );
if ( defAnn != null ) {
@@ -227,7 +243,12 @@
}
public void addOptimizerStrategy(DirectoryProvider<?> provider, OptimizerStrategy optimizerStrategy) {
- dirProviderOptimizerStrategies.put( provider, optimizerStrategy );
+ DirectoryProviderData data = dirProviderData.get(provider);
+ if (data == null) {
+ data = new DirectoryProviderData();
+ dirProviderData.put( provider, data );
+ }
+ data.optimizerStrategy = optimizerStrategy;
}
public void addIndexingParameters(DirectoryProvider<?> provider, LuceneIndexingParameters indexingParams) {
@@ -235,7 +256,7 @@
}
public OptimizerStrategy getOptimizerStrategy(DirectoryProvider<?> provider) {
- return dirProviderOptimizerStrategies.get( provider );
+ return dirProviderData.get( provider ).optimizerStrategy;
}
public LuceneIndexingParameters getIndexingParameters(DirectoryProvider<?> provider ) {
@@ -301,7 +322,7 @@
XClass mappedXClass = reflectionManager.toXClass(mappedClass);
if ( mappedXClass != null) {
if ( mappedXClass.isAnnotationPresent( Indexed.class ) ) {
- DirectoryProviderFactory.DirectoryProviders providers = factory.createDirectoryProviders( mappedXClass, cfg, this );
+ DirectoryProviderFactory.DirectoryProviders providers = factory.createDirectoryProviders( mappedXClass, cfg, this, reflectionManager );
final DocumentBuilder<Object> documentBuilder = new DocumentBuilder<Object>(
mappedXClass, context, providers.getProviders(), providers.getSelectionStrategy(),
@@ -349,4 +370,9 @@
public FilterDef getFilterDefinition(String name) {
return filterDefinitions.get( name );
}
+
+ private static class DirectoryProviderData {
+ public OptimizerStrategy optimizerStrategy;
+ public Set<Class> classes = new HashSet<Class>(2);
+ }
}
Modified: search/trunk/src/java/org/hibernate/search/query/FullTextQueryImpl.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/query/FullTextQueryImpl.java 2008-05-30 22:26:13 UTC (rev 14718)
+++ search/trunk/src/java/org/hibernate/search/query/FullTextQueryImpl.java 2008-05-30 22:28:11 UTC (rev 14719)
@@ -69,6 +69,8 @@
private org.apache.lucene.search.Query luceneQuery;
private Class[] classes;
private Set<Class> classesAndSubclasses;
+ //optimization: if we can avoid the filter clause (we can most of the time) do it as it has a significant perf impact
+ private boolean needClassFilterClause;
private Integer firstResult;
private Integer maxResults;
private Integer resultSize;
@@ -384,12 +386,12 @@
}
private org.apache.lucene.search.Query filterQueryByClasses(org.apache.lucene.search.Query luceneQuery) {
- //A query filter is more practical than a manual class filtering post query (esp on scrollable resultsets)
- //it also probably minimise the memory footprint
- if ( classesAndSubclasses == null ) {
+ if ( ! needClassFilterClause ) {
return luceneQuery;
}
else {
+ //A query filter is more practical than a manual class filtering post query (esp on scrollable resultsets)
+ //it also probably minimise the memory footprint
BooleanQuery classFilter = new BooleanQuery();
//annihilate the scoring impact of DocumentBuilder.CLASS_FIELDNAME
classFilter.setBoost( 0 );
@@ -429,13 +431,13 @@
List<DirectoryProvider> directories = new ArrayList<DirectoryProvider>();
Similarity searcherSimilarity = null;
-
+ //TODO check if caching this work for the last n list of classes makes a perf boost
if ( classes == null || classes.length == 0 ) {
//no class means all classes
for (DocumentBuilder builder : builders.values()) {
searcherSimilarity = checkSimilarity( searcherSimilarity, builder );
final DirectoryProvider[] directoryProviders = builder.getDirectoryProviderSelectionStrategy().getDirectoryProvidersForAllShards();
- populateDirectories( directories, directoryProviders );
+ populateDirectories( directories, directoryProviders, searchFactoryImplementor );
}
classesAndSubclasses = null;
}
@@ -455,11 +457,30 @@
final DirectoryProvider[] directoryProviders = builder.getDirectoryProviderSelectionStrategy().getDirectoryProvidersForAllShards();
searcherSimilarity = checkSimilarity( searcherSimilarity, builder );
- populateDirectories( directories, directoryProviders );
+ populateDirectories( directories, directoryProviders, searchFactoryImplementor );
}
classesAndSubclasses = involvedClasses;
}
+ //compute optimization needClassFilterClause
+ //if at least one DP contains one class that is not part of the targeted classesAndSubclasses we can't optimize
+ if ( classesAndSubclasses != null) {
+ for (DirectoryProvider dp : directories) {
+ final Set<Class> classesInDirectoryProvider = searchFactoryImplementor.getClassesInDirectoryProvider( dp );
+ // if a DP contains only one class, we know for sure it's part of classesAndSubclasses
+ if ( classesInDirectoryProvider.size() > 1 ) {
+ //risk of needClassFilterClause
+ for (Class clazz : classesInDirectoryProvider) {
+ if ( ! classesAndSubclasses.contains( clazz ) ) {
+ this.needClassFilterClause = true;
+ break;
+ }
+ }
+ }
+ if ( this.needClassFilterClause ) break;
+ }
+ }
+
//set up the searcher
final DirectoryProvider[] directoryProviders = directories.toArray( new DirectoryProvider[directories.size()] );
IndexSearcher is = new IndexSearcher( searchFactoryImplementor.getReaderProvider().openReader( directoryProviders ) );
@@ -467,7 +488,8 @@
return is;
}
- private void populateDirectories(List<DirectoryProvider> directories, DirectoryProvider[] directoryProviders) {
+ private void populateDirectories(List<DirectoryProvider> directories, DirectoryProvider[] directoryProviders,
+ SearchFactoryImplementor searchFactoryImplementor) {
for (DirectoryProvider provider : directoryProviders) {
if ( !directories.contains( provider ) ) {
directories.add( provider );
Modified: search/trunk/src/java/org/hibernate/search/store/DirectoryProviderFactory.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/store/DirectoryProviderFactory.java 2008-05-30 22:26:13 UTC (rev 14718)
+++ search/trunk/src/java/org/hibernate/search/store/DirectoryProviderFactory.java 2008-05-30 22:28:11 UTC (rev 14719)
@@ -51,7 +51,9 @@
private static final String SHARDING_STRATEGY = "sharding_strategy";
private static final String NBR_OF_SHARDS = SHARDING_STRATEGY + ".nbr_of_shards";
- public DirectoryProviders createDirectoryProviders(XClass entity, Configuration cfg, SearchFactoryImplementor searchFactoryImplementor) {
+ public DirectoryProviders createDirectoryProviders(XClass entity, Configuration cfg,
+ SearchFactoryImplementor searchFactoryImplementor,
+ ReflectionManager reflectionManager) {
//get properties
String directoryProviderName = getDirectoryProviderName( entity, cfg );
Properties[] indexProps = getDirectoryProperties( cfg, directoryProviderName );
@@ -63,7 +65,8 @@
String providerName = nbrOfProviders > 1 ?
directoryProviderName + "." + index :
directoryProviderName;
- providers[index] = createDirectoryProvider( providerName, indexProps[index], searchFactoryImplementor );
+ providers[index] = createDirectoryProvider( providerName, indexProps[index],
+ reflectionManager.toClass( entity ), searchFactoryImplementor );
}
//define sharding strategy
@@ -110,7 +113,8 @@
}
}
- private DirectoryProvider<?> createDirectoryProvider(String directoryProviderName, Properties indexProps, SearchFactoryImplementor searchFactoryImplementor) {
+ private DirectoryProvider<?> createDirectoryProvider(String directoryProviderName, Properties indexProps,
+ Class entity, SearchFactoryImplementor searchFactoryImplementor) {
String className = indexProps.getProperty( "directory_provider" );
if ( StringHelper.isEmpty( className ) ) {
className = DEFAULT_DIRECTORY_PROVIDER;
@@ -135,12 +139,15 @@
int index = providers.indexOf( provider );
if ( index != -1 ) {
//share the same Directory provider for the same underlying store
- return providers.get( index );
+ final DirectoryProvider<?> directoryProvider = providers.get( index );
+ searchFactoryImplementor.addClassToDirectoryProvider(entity, directoryProvider);
+ return directoryProvider;
}
else {
configureOptimizerStrategy( searchFactoryImplementor, indexProps, provider );
configureIndexingParameters( searchFactoryImplementor, indexProps, provider );
providers.add( provider );
+ searchFactoryImplementor.addClassToDirectoryProvider(entity, provider);
if ( !searchFactoryImplementor.getLockableDirectoryProviders().containsKey( provider ) ) {
searchFactoryImplementor.getLockableDirectoryProviders().put( provider, new ReentrantLock() );
}
Modified: search/trunk/src/test/org/hibernate/search/test/RamDirectoryTest.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/RamDirectoryTest.java 2008-05-30 22:26:13 UTC (rev 14718)
+++ search/trunk/src/test/org/hibernate/search/test/RamDirectoryTest.java 2008-05-30 22:28:11 UTC (rev 14719)
@@ -2,7 +2,11 @@
package org.hibernate.search.test;
import org.hibernate.Session;
+import org.hibernate.search.FullTextSession;
+import org.hibernate.search.Search;
import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.search.TermQuery;
/**
* @author Emmanuel Bernard
@@ -28,6 +32,11 @@
s = getSessions().openSession();
s.getTransaction().begin();
+ TermQuery q = new TermQuery(new Term("alt_title", "hibernate"));
+ assertEquals( "does not properly filter", 0,
+ Search.createFullTextSession( s ).createFullTextQuery( q, Document.class ).list().size() );
+ assertEquals( "does not properly filter", 1,
+ Search.createFullTextSession( s ).createFullTextQuery( q, Document.class, AlternateDocument.class ).list().size() );
s.delete( s.get( AlternateDocument.class, document.getId() ) );
s.getTransaction().commit();
s.close();
16 years, 5 months
Hibernate SVN: r14718 - search/trunk/src/java/org/hibernate/search/backend.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2008-05-30 18:26:13 -0400 (Fri, 30 May 2008)
New Revision: 14718
Modified:
search/trunk/src/java/org/hibernate/search/backend/Workspace.java
Log:
NPE when optimize try to apply similarity: guard against that
Modified: search/trunk/src/java/org/hibernate/search/backend/Workspace.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/backend/Workspace.java 2008-05-30 18:39:44 UTC (rev 14717)
+++ search/trunk/src/java/org/hibernate/search/backend/Workspace.java 2008-05-30 22:26:13 UTC (rev 14718)
@@ -252,7 +252,7 @@
/**
* Gets the currently open IndexWriter, or creates one.
* If a IndexReader was open, it will be closed first.
- * @param entity The entity for which the IndexWriter is needed
+ * @param entity The entity for which the IndexWriter is needed. entity can be null when calling for Optimize
* @param modificationOperation set to true if needed to perform modifications to index
* @return created or existing IndexWriter
*/
@@ -275,7 +275,9 @@
documentBuilder.getAnalyzer() :
SIMPLE_ANALYZER; //never used
writer = new IndexWriter( directoryProvider.getDirectory(), analyzer, false ); //has been created at init time
- writer.setSimilarity( documentBuilder.getSimilarity() );
+ if ( entity != null ) {
+ writer.setSimilarity( documentBuilder.getSimilarity() );
+ }
LuceneIndexingParameters indexingParams = searchFactoryImplementor.getIndexingParameters( directoryProvider );
indexingParams.applyToWriter( writer, isBatch );
}
16 years, 5 months
Hibernate SVN: r14716 - in search/trunk/src/java/org/hibernate/search: backend/configuration and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: sannegrinovero
Date: 2008-05-30 11:49:57 -0400 (Fri, 30 May 2008)
New Revision: 14716
Modified:
search/trunk/src/java/org/hibernate/search/annotations/ContainedIn.java
search/trunk/src/java/org/hibernate/search/annotations/Factory.java
search/trunk/src/java/org/hibernate/search/annotations/Key.java
search/trunk/src/java/org/hibernate/search/backend/configuration/IndexWriterSetting.java
search/trunk/src/java/org/hibernate/search/backend/impl/jms/AbstractJMSHibernateSearchController.java
search/trunk/src/java/org/hibernate/search/store/DirectoryProviderHelper.java
Log:
javadoc: fix some warnings and formatting
Modified: search/trunk/src/java/org/hibernate/search/annotations/ContainedIn.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/annotations/ContainedIn.java 2008-05-30 14:50:47 UTC (rev 14715)
+++ search/trunk/src/java/org/hibernate/search/annotations/ContainedIn.java 2008-05-30 15:49:57 UTC (rev 14716)
@@ -9,28 +9,29 @@
/**
* Describe the owning entity as being part of the target entity's
- * index (to be more accurate, being part of the indexed object graph)
- *
- * Only necessary when an @Indexed class is used as a @IndexedEmbedded
- * target class. @ContainedIn must mark the property pointing back
- * to the @IndexedEmbedded owning Entity
- *
- * Not necessary if the class is an @Embeddable class.
- *
+ * index (to be more accurate, being part of the indexed object graph).
+ * <p>
+ * Only necessary when an @Indexed class is used as a @IndexedEmbedded
+ * target class. @ContainedIn must mark the property pointing back
+ * to the @IndexedEmbedded owning Entity.
+ * <p>
+ * Not necessary if the class is an @Embeddable class.
+ * <p>
* <code>
- * @Indexed
- * public class OrderLine {
- * @IndexedEmbedded
- * private Order order;
- * }
- *
- * @Indexed
- * public class Order {
- * @ContainedBy
- * Set<OrderLine> lines;
- * }
- * </code>
- *
+ * @Indexed<br>
+ * public class OrderLine {<br>
+ * @IndexedEmbedded<br>
+ * private Order order;<br>
+ * }<br>
+ *<br>
+ * @Indexed<br>
+ * public class Order {<br>
+ * @ContainedBy<br>
+ * Set<OrderLine> lines;<br>
+ * }<br>
+ * </code><br>
+ * @see org.hibernate.search.annotations.Indexed
+ * @see org.hibernate.search.annotations.IndexedEmbedded
* @author Emmanuel Bernard
*/
@Retention( RetentionPolicy.RUNTIME )
Modified: search/trunk/src/java/org/hibernate/search/annotations/Factory.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/annotations/Factory.java 2008-05-30 14:50:47 UTC (rev 14715)
+++ search/trunk/src/java/org/hibernate/search/annotations/Factory.java 2008-05-30 15:49:57 UTC (rev 14716)
@@ -12,9 +12,9 @@
* A factory method is called whenever a new instance of a given
* type is requested.
* The factory method is used with a higher priority than a plain no-arg constructor when present
- *
- * @Factory currently works for @FullTextFilterDef.impl classes
- *
+ * <br />
+ * <code>@Factory</code> currently works for @FullTextFilterDef.impl classes
+ * @see org.hibernate.search.annotations.Factory
* @author Emmanuel Bernard
*/
@Retention( RetentionPolicy.RUNTIME )
Modified: search/trunk/src/java/org/hibernate/search/annotations/Key.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/annotations/Key.java 2008-05-30 14:50:47 UTC (rev 14715)
+++ search/trunk/src/java/org/hibernate/search/annotations/Key.java 2008-05-30 15:49:57 UTC (rev 14716)
@@ -14,8 +14,8 @@
* The key object must implement equals / hashcode so that 2 keys are equals iif
* the given target object types are the same, the set of parameters are the same.
*
- * @Factory currently works for @FullTextFilterDef.impl classes
- *
+ * @Factory currently works for @FullTextFilterDef.impl classes
+ * @see org.hibernate.search.annotations.Factory
* @author Emmanuel Bernard
*/
@Retention( RetentionPolicy.RUNTIME )
Modified: search/trunk/src/java/org/hibernate/search/backend/configuration/IndexWriterSetting.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/backend/configuration/IndexWriterSetting.java 2008-05-30 14:50:47 UTC (rev 14715)
+++ search/trunk/src/java/org/hibernate/search/backend/configuration/IndexWriterSetting.java 2008-05-30 15:49:57 UTC (rev 14716)
@@ -13,7 +13,7 @@
*/
public enum IndexWriterSetting implements Serializable {
/**
- * @see org.apache.lucene.index.IndexWriter.setMaxBufferedDeleteTerms(int)
+ * @see org.apache.lucene.index.IndexWriter#setMaxBufferedDeleteTerms(int)
*/
MAX_BUFFERED_DELETE_TERMS( "max_buffered_delete_terms" ) {
public void applySetting(IndexWriter writer, int value) {
@@ -21,7 +21,7 @@
}
} ,
/**
- * @see org.apache.lucene.index.IndexWriter.setMaxBufferedDocs(int)
+ * @see org.apache.lucene.index.IndexWriter#setMaxBufferedDocs(int)
*/
MAX_BUFFERED_DOCS( "max_buffered_docs" ) {
public void applySetting(IndexWriter writer, int value) {
@@ -29,7 +29,7 @@
}
} ,
/**
- * @see org.apache.lucene.index.IndexWriter.setMaxFieldLength(int)
+ * @see org.apache.lucene.index.IndexWriter#setMaxFieldLength(int)
*/
MAX_FIELD_LENGTH( "max_field_length" ) {
public void applySetting(IndexWriter writer, int value) {
@@ -37,7 +37,7 @@
}
} ,
/**
- * @see org.apache.lucene.index.IndexWriter.setMaxMergeDocs(int)
+ * @see org.apache.lucene.index.IndexWriter#setMaxMergeDocs(int)
*/
MAX_MERGE_DOCS( "max_merge_docs" ) {
public void applySetting(IndexWriter writer, int value) {
@@ -45,7 +45,7 @@
}
} ,
/**
- * @see org.apache.lucene.index.IndexWriter.setMergeFactor(int)
+ * @see org.apache.lucene.index.IndexWriter#setMergeFactor(int)
*/
MERGE_FACTOR( "merge_factor" ) {
public void applySetting(IndexWriter writer, int value) {
@@ -53,7 +53,7 @@
}
} ,
/**
- * @see org.apache.lucene.index.IndexWriter.setRAMBufferSizeMB(int)
+ * @see org.apache.lucene.index.IndexWriter#setRAMBufferSizeMB(double)
*/
RAM_BUFFER_SIZE( "ram_buffer_size" ) {
public void applySetting(IndexWriter writer, int value) {
@@ -61,7 +61,7 @@
}
},
/**
- * @see org.apache.lucene.index.IndexWriter.setTermIndexInterval(int)
+ * @see org.apache.lucene.index.IndexWriter#setTermIndexInterval(int)
*/
TERM_INDEX_INTERVAL( "term_index_interval" ) {
public void applySetting(IndexWriter writer, int value) {
Modified: search/trunk/src/java/org/hibernate/search/backend/impl/jms/AbstractJMSHibernateSearchController.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/backend/impl/jms/AbstractJMSHibernateSearchController.java 2008-05-30 14:50:47 UTC (rev 14715)
+++ search/trunk/src/java/org/hibernate/search/backend/impl/jms/AbstractJMSHibernateSearchController.java 2008-05-30 15:49:57 UTC (rev 14716)
@@ -20,7 +20,7 @@
* Implement the Hibernate Search controller responsible for processing the
* work send through JMS by the slave nodes.
*
- * Note the subclass implementation has to implements javax.jms.MessageListener
+ * Note the subclass implementation has to implement javax.jms.MessageListener
* //TODO Ask Bill why it is required
*
* @author Emmanuel Bernard
@@ -29,25 +29,28 @@
private static final Logger log = LoggerFactory.getLogger( AbstractJMSHibernateSearchController.class );
/**
- * return the current or give a new session
- * This session is not used per se, but is the link to access the Search configuration
- *
+ * Return the current or give a new session
+ * This session is not used per se, but is the link to access the Search configuration.
+ * <p>
* A typical EJB 3.0 usecase would be to get the session from the container (injected)
* eg in JBoss EJB 3.0
+ * <p>
* <code>
- * @PersistenceContext private Session session;
- *
- * protected Session getSession() {
- * return session
- * }
- *
- * eg in any container
+ * @PersistenceContext private Session session;<br>
+ * <br>
+ * protected Session getSession() {<br>
+ * return session<br>
+ * }<br>
+ * </code>
+ * <p>
+ * eg in any container<br>
* <code>
- * @PersistenceContext private EntityManager entityManager;
- *
- * protected Session getSession() {
- * return (Session) entityManager.getdelegate();
- * }
+ * @PersistenceContext private EntityManager entityManager;<br>
+ * <br>
+ * protected Session getSession() {<br>
+ * return (Session) entityManager.getdelegate();<br>
+ * }<br>
+ * </code>
*/
protected abstract Session getSession();
Modified: search/trunk/src/java/org/hibernate/search/store/DirectoryProviderHelper.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/store/DirectoryProviderHelper.java 2008-05-30 14:50:47 UTC (rev 14715)
+++ search/trunk/src/java/org/hibernate/search/store/DirectoryProviderHelper.java 2008-05-30 15:49:57 UTC (rev 14716)
@@ -30,7 +30,7 @@
* @param directoryProviderName
* @param properties
* @param needWritePermissions when true the directory will be tested for read-write permissions.
- * @return
+ * @return The file representing the source directory
*/
public static File getSourceDirectory( String directoryProviderName, Properties properties, boolean needWritePermissions ) {
String root = properties.getProperty( ROOTINDEX_PROP_NAME );
16 years, 5 months
Hibernate SVN: r14715 - search/trunk/src/java/org/hibernate/search/backend.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2008-05-30 10:50:47 -0400 (Fri, 30 May 2008)
New Revision: 14715
Modified:
search/trunk/src/java/org/hibernate/search/backend/LuceneWork.java
search/trunk/src/java/org/hibernate/search/backend/WorkQueue.java
Log:
Clarify the need for Serializability in LuceneWork
Modified: search/trunk/src/java/org/hibernate/search/backend/LuceneWork.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/backend/LuceneWork.java 2008-05-29 22:07:56 UTC (rev 14714)
+++ search/trunk/src/java/org/hibernate/search/backend/LuceneWork.java 2008-05-30 14:50:47 UTC (rev 14715)
@@ -8,6 +8,13 @@
/**
* Represent a Serializable Lucene unit work
*
+ * WARNING: This class aims to be serializable and passed in an asynchronous way across VMs
+ * any non backward compatible serialization change should be done with great care
+ * and publically announced. Specifically, new versions of Hibernate Search should be
+ * able to handle changes produced by older versions of Hibernate Search if reasonably possible.
+ * That is why each subclass susceptible to be pass along have a magic serialization number.
+ * NOTE: we are relying on Lucene's Document to play nice unfortunately
+ *
* @author Emmanuel Bernard
* @author Hardy Ferentschik
*/
Modified: search/trunk/src/java/org/hibernate/search/backend/WorkQueue.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/backend/WorkQueue.java 2008-05-29 22:07:56 UTC (rev 14714)
+++ search/trunk/src/java/org/hibernate/search/backend/WorkQueue.java 2008-05-30 14:50:47 UTC (rev 14715)
@@ -10,7 +10,6 @@
* @author Emmanuel Bernard
*/
public class WorkQueue {
- //TODO set a serial number
private List<Work> queue;
private List<LuceneWork> sealedQueue;
16 years, 5 months
Hibernate SVN: r14714 - in search/trunk/src/java/org/hibernate/search: engine and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: sannegrinovero
Date: 2008-05-29 18:07:56 -0400 (Thu, 29 May 2008)
New Revision: 14714
Modified:
search/trunk/src/java/org/hibernate/search/backend/LuceneIndexingParameters.java
search/trunk/src/java/org/hibernate/search/backend/Workspace.java
search/trunk/src/java/org/hibernate/search/engine/DocumentBuilder.java
Log:
HSEARCH-202 and more optimizations in Workspace (early lock releases)
Modified: search/trunk/src/java/org/hibernate/search/backend/LuceneIndexingParameters.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/backend/LuceneIndexingParameters.java 2008-05-29 15:18:15 UTC (rev 14713)
+++ search/trunk/src/java/org/hibernate/search/backend/LuceneIndexingParameters.java 2008-05-29 22:07:56 UTC (rev 14714)
@@ -129,4 +129,13 @@
}
+ public void applyToWriter(IndexWriter writer, boolean batch) {
+ if ( batch ) {
+ getBatchIndexParameters().applyToWriter( writer );
+ }
+ else {
+ getTransactionIndexParameters().applyToWriter( writer );
+ }
+ }
+
}
Modified: search/trunk/src/java/org/hibernate/search/backend/Workspace.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/backend/Workspace.java 2008-05-29 15:18:15 UTC (rev 14713)
+++ search/trunk/src/java/org/hibernate/search/backend/Workspace.java 2008-05-29 22:07:56 UTC (rev 14714)
@@ -2,9 +2,7 @@
package org.hibernate.search.backend;
import java.io.IOException;
-import java.util.ArrayList;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import java.util.concurrent.locks.ReentrantLock;
@@ -12,6 +10,7 @@
import org.apache.lucene.analysis.SimpleAnalyzer;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.store.Directory;
import org.hibernate.annotations.common.AssertionFailure;
import org.hibernate.search.SearchException;
import org.hibernate.search.engine.DocumentBuilder;
@@ -30,7 +29,7 @@
* <li>One cannot execute modification through an IndexReader when an IndexWriter has been acquired
* on the same underlying directory
* </li>
- * <li>One cannot get an IndexWriter when an IndexReader have been acquired and modificed on the same
+ * <li>One cannot get an IndexWriter when an IndexReader have been acquired and modified on the same
* underlying directory
* </li>
* <li>The recommended approach is to execute all the modifications on the IndexReaders, {@link #clean()}, and acquire the
@@ -40,22 +39,35 @@
*
* @author Emmanuel Bernard
* @author Hardy Ferentschik
+ * @author Sanne Grinovero
*/
-//TODO introduce the notion of read only IndexReader? We cannot enforce it because Lucene use abstract classes, not interfaces
+//TODO introduce the notion of read only IndexReader? We cannot enforce it because Lucene uses abstract classes, not interfaces.
public class Workspace {
+
private final Logger log = LoggerFactory.getLogger( Workspace.class );
- private Map<DirectoryProvider, IndexReader> readers = new HashMap<DirectoryProvider, IndexReader>();
- private Map<DirectoryProvider, IndexWriter> writers = new HashMap<DirectoryProvider, IndexWriter>();
- private List<DirectoryProvider> lockedProviders = new ArrayList<DirectoryProvider>();
- private Map<DirectoryProvider, DPStatistics> dpStatistics = new HashMap<DirectoryProvider, DPStatistics>();
- private SearchFactoryImplementor searchFactoryImplementor;
+ private final SearchFactoryImplementor searchFactoryImplementor;
+ private static final Analyzer SIMPLE_ANALYZER = new SimpleAnalyzer();
+ private final Map<DirectoryProvider, DPWorkspace> directorySpace = new HashMap<DirectoryProvider, DPWorkspace>() {
+ @Override
+ public DPWorkspace get(Object key) {
+ DirectoryProvider dp = (DirectoryProvider) key;
+ DPWorkspace directoryWorkSpace = super.get( dp );
+ if ( directoryWorkSpace==null ) {
+ directoryWorkSpace = new DPWorkspace( dp );
+ put( dp, directoryWorkSpace );
+ }
+ return directoryWorkSpace;
+ }
+
+ };
+
/**
- * Flag indicating if the current work should be executed the Lucene parameters for batch indexing.
+ * Flag indicating if the current work should be executed using
+ * the Lucene parameters for batch indexing.
*/
private boolean isBatch = false;
-
public Workspace(SearchFactoryImplementor searchFactoryImplementor) {
this.searchFactoryImplementor = searchFactoryImplementor;
}
@@ -65,29 +77,16 @@
}
/**
- * retrieve a read write IndexReader
+ * Retrieve a read write IndexReader; the purpose should be to
+ * modify the index. (mod count will be incremented)
* For a given DirectoryProvider, An IndexReader must be used before an IndexWriter
*/
- @SuppressWarnings( { "ThrowableInstanceNeverThrown" } )
public IndexReader getIndexReader(DirectoryProvider provider, Class entity) {
- //one cannot access a reader for update after a writer has been accessed
- if ( writers.containsKey( provider ) )
- throw new AssertionFailure( "Tries to read for update an index while a writer is accessed" + entity );
- IndexReader reader = readers.get( provider );
- if ( reader != null ) return reader;
- lockProvider( provider );
- dpStatistics.get( provider ).operations++;
- try {
- reader = IndexReader.open( provider.getDirectory() );
- readers.put( provider, reader );
- }
- catch (IOException e) {
- cleanUp( new SearchException( "Unable to open IndexReader for " + entity, e ) );
- }
- return reader;
+ DPWorkspace space = directorySpace.get( provider );
+ return space.getIndexReader( entity );
}
- //for optimization
+ //for index optimization
public IndexWriter getIndexWriter(DirectoryProvider provider) {
return getIndexWriter( provider, null, false );
}
@@ -96,66 +95,17 @@
* retrieve a read write IndexWriter
* For a given DirectoryProvider, An IndexReader must be used before an IndexWriter
*/
- @SuppressWarnings( { "ThrowableInstanceNeverThrown" } )
public IndexWriter getIndexWriter(DirectoryProvider provider, Class entity, boolean modificationOperation) {
- //one has to close a reader for update before a writer is accessed
- IndexReader reader = readers.get( provider );
- if ( reader != null ) {
- try {
- reader.close();
- }
- catch (IOException e) {
- throw new SearchException( "Exception while closing IndexReader", e );
- }
- readers.remove( provider );
- }
- IndexWriter writer = writers.get( provider );
- if ( writer != null ) return writer;
- lockProvider( provider );
- if ( modificationOperation ) dpStatistics.get( provider ).operations++;
- try {
- DocumentBuilder documentBuilder = searchFactoryImplementor.getDocumentBuilders().get( entity );
- Analyzer analyzer = entity != null ?
- documentBuilder.getAnalyzer() :
- new SimpleAnalyzer(); //never used
- writer = new IndexWriter( provider.getDirectory(), analyzer, false ); //has been created at init time
- writer.setSimilarity( documentBuilder.getSimilarity() );
-
- LuceneIndexingParameters indexingParams = searchFactoryImplementor.getIndexingParameters( provider );
- if ( isBatch ) {
- indexingParams.getBatchIndexParameters().applyToWriter(writer);
- }
- else {
- indexingParams.getTransactionIndexParameters().applyToWriter(writer);
- }
-
- writers.put( provider, writer );
- }
- catch (IOException e) {
- cleanUp(
- new SearchException( "Unable to open IndexWriter" + ( entity != null ? " for " + entity : "" ), e )
- );
- }
- return writer;
+ DPWorkspace space = directorySpace.get( provider );
+ return space.getIndexWriter( entity, modificationOperation );
}
- private void lockProvider(DirectoryProvider provider) {
- //make sure to use a semaphore
- ReentrantLock lock = searchFactoryImplementor.getLockableDirectoryProviders().get( provider );
- //of course a given thread cannot have a race cond with itself
- if ( !lock.isHeldByCurrentThread() ) {
- lock.lock();
- lockedProviders.add( provider );
- dpStatistics.put( provider, new DPStatistics() );
- }
- }
-
private void cleanUp(SearchException originalException) {
//release all readers and writers, then release locks
SearchException raisedException = originalException;
- for (IndexReader reader : readers.values()) {
+ for ( DPWorkspace space : directorySpace.values() ) {
try {
- reader.close();
+ space.closeIndexReader();
}
catch (IOException e) {
if ( raisedException != null ) {
@@ -166,46 +116,47 @@
}
}
}
- readers.clear();
- //TODO release lock of all indexes that do not need optimization early
- //don't optimze if there is a failure
- if ( raisedException == null ) {
- for (DirectoryProvider provider : lockedProviders) {
- Workspace.DPStatistics stats = dpStatistics.get( provider );
- if ( !stats.optimizationForced ) {
- OptimizerStrategy optimizerStrategy = searchFactoryImplementor.getOptimizerStrategy( provider );
- optimizerStrategy.addTransaction( stats.operations );
+ //first release all locks for DirectoryProviders not needing optimization
+ for ( DPWorkspace space : directorySpace.values() ) {
+ if ( ! space.needsOptimization() ) {
+ raisedException = closeWriterAndUnlock( space, raisedException );
+ }
+ }
+ //then for remaining DirectoryProvider
+ for ( DPWorkspace space : directorySpace.values() ) {
+ if ( space.needsOptimization() ) {
+ if ( raisedException == null ) {//avoid optimizations in case of errors or exceptions
+ OptimizerStrategy optimizerStrategy = space.getOptimizerStrategy();
+ optimizerStrategy.addTransaction( space.countOperations() );
try {
optimizerStrategy.optimize( this );
}
catch (SearchException e) {
+ //this will also cause skipping other optimizations:
raisedException = new SearchException( "Exception while optimizing directoryProvider: "
- + provider.getDirectory().toString(), e );
- break; //no point in continuing
+ + space.getDirectory().toString(), e );
}
}
+ raisedException = closeWriterAndUnlock( space, raisedException );
}
}
- for (IndexWriter writer : writers.values()) {
- try {
- writer.close();
+ if ( raisedException != null ) throw raisedException;
+ }
+
+ private SearchException closeWriterAndUnlock( DPWorkspace space, SearchException raisedException ) {
+ try {
+ space.closeIndexWriter();
+ }
+ catch (IOException e) {
+ if ( raisedException != null ) {
+ log.error( "Subsequent Exception while closing IndexWriter", e );
}
- catch (IOException e) {
- if ( raisedException != null ) {
- log.error( "Subsequent Exception while closing IndexWriter", e );
- }
- else {
- raisedException = new SearchException( "Exception while closing IndexWriter", e );
- }
+ else {
+ raisedException = new SearchException( "Exception while closing IndexWriter", e );
}
}
- for (DirectoryProvider provider : lockedProviders) {
- searchFactoryImplementor.getLockableDirectoryProviders().get( provider ).unlock();
- }
- writers.clear();
- lockedProviders.clear();
- dpStatistics.clear();
- if ( raisedException != null ) throw raisedException;
+ space.unLock();
+ return raisedException;
}
/**
@@ -216,16 +167,12 @@
}
public void optimize(DirectoryProvider provider) {
- OptimizerStrategy optimizerStrategy = searchFactoryImplementor.getOptimizerStrategy( provider );
- dpStatistics.get( provider ).optimizationForced = true;
+ DPWorkspace space = directorySpace.get( provider );
+ OptimizerStrategy optimizerStrategy = space.getOptimizerStrategy();
+ space.setOptimizationForced();
optimizerStrategy.optimizationForced();
}
- private class DPStatistics {
- boolean optimizationForced = false;
- public long operations;
- }
-
public boolean isBatch() {
return isBatch;
}
@@ -233,4 +180,180 @@
public void setBatch(boolean isBatch) {
this.isBatch = isBatch;
}
+
+ //TODO this should have it's own source file but currently needs the container-Workspace cleanup()
+ //for exceptions. Best to wait for move to parallel batchWorkers (one per Directory)?
+ /**
+ * A per-DirectoryProvider Workspace
+ */
+ private class DPWorkspace {
+
+ private final DirectoryProvider directoryProvider;
+ private final ReentrantLock lock;
+
+ private IndexReader reader;
+ private IndexWriter writer;
+ private boolean locked = false;
+ private boolean optimizationForced = false;
+ private long operations = 0L;
+
+ DPWorkspace(DirectoryProvider dp) {
+ this.directoryProvider = dp;
+ this.lock = searchFactoryImplementor.getLockableDirectoryProviders().get( dp );
+ }
+
+ public boolean needsOptimization() {
+ return isLocked() && !isOptimizationForced();
+ }
+
+ /**
+ * Sets a flag to signal optimization has been forced.
+ * Cannot be undone.
+ */
+ void setOptimizationForced() {
+ optimizationForced = true;
+ }
+
+ /**
+ * @return the Directory from the DirectoryProvider
+ */
+ Directory getDirectory() {
+ return directoryProvider.getDirectory();
+ }
+
+ /**
+ * @return A count of performed modification operations
+ */
+ long countOperations() {
+ return operations;
+ }
+
+ /**
+ * @return The OptimizerStrategy configured for this DirectoryProvider
+ */
+ OptimizerStrategy getOptimizerStrategy() {
+ return searchFactoryImplementor.getOptimizerStrategy( directoryProvider );
+ }
+
+ /**
+ * @return true if optimization has been forced
+ */
+ boolean isOptimizationForced() {
+ return optimizationForced;
+ }
+
+ /**
+ * @return true if underlying DirectoryProvider is locked
+ */
+ boolean isLocked() {
+ return locked;
+ }
+
+ /**
+ * Gets the currently open IndexWriter, or creates one.
+ * If a IndexReader was open, it will be closed first.
+ * @param entity The entity for which the IndexWriter is needed
+ * @param modificationOperation set to true if needed to perform modifications to index
+ * @return created or existing IndexWriter
+ */
+ IndexWriter getIndexWriter(Class entity, boolean modificationOperation) {
+ //one has to close a reader for update before a writer is accessed
+ try {
+ closeIndexReader();
+ }
+ catch (IOException e) {
+ throw new SearchException( "Exception while closing IndexReader", e );
+ }
+ if ( modificationOperation ) {
+ operations++; //estimate the number of modifications done on this index
+ }
+ if ( writer != null ) return writer;
+ lock();
+ try {
+ DocumentBuilder documentBuilder = searchFactoryImplementor.getDocumentBuilders().get( entity );
+ Analyzer analyzer = entity != null ?
+ documentBuilder.getAnalyzer() :
+ SIMPLE_ANALYZER; //never used
+ writer = new IndexWriter( directoryProvider.getDirectory(), analyzer, false ); //has been created at init time
+ writer.setSimilarity( documentBuilder.getSimilarity() );
+ LuceneIndexingParameters indexingParams = searchFactoryImplementor.getIndexingParameters( directoryProvider );
+ indexingParams.applyToWriter( writer, isBatch );
+ }
+ catch (IOException e) {
+ cleanUp(
+ new SearchException( "Unable to open IndexWriter" + ( entity != null ? " for " + entity : "" ), e )
+ );
+ }
+ return writer;
+ }
+
+ /**
+ * Gets an IndexReader to alter the index;
+ * (operations count will be incremented)
+ * @throws AssertionFailure if an IndexWriter is open
+ * @param entity The entity for which the IndexWriter is needed
+ * @return a new or existing IndexReader
+ */
+ IndexReader getIndexReader(Class entity) {
+ //one cannot access a reader for update after a writer has been accessed
+ if ( writer != null )
+ throw new AssertionFailure( "Tries to read for update an index while a writer is accessed for " + entity );
+ operations++; //estimate the number of modifications done on this index
+ if ( reader != null ) return reader;
+ lock();
+ try {
+ reader = IndexReader.open( directoryProvider.getDirectory() );
+ }
+ catch (IOException e) {
+ cleanUp( new SearchException( "Unable to open IndexReader for " + entity, e ) );
+ }
+ return reader;
+ }
+
+ /**
+ * Unlocks underlying DirectoryProvider iff locked.
+ */
+ void unLock() {
+ if ( locked ) {
+ lock.unlock();
+ locked = false;
+ }
+ }
+
+ /**
+ * Locks underlying DirectoryProvider iff not locked already.
+ */
+ void lock() {
+ if ( !locked ) {
+ lock.lock();
+ locked = true;
+ }
+ }
+
+ /**
+ * Closes the IndexReader, if open.
+ * @throws IOException
+ */
+ void closeIndexReader() throws IOException {
+ IndexReader toClose = reader;
+ reader = null;
+ if ( toClose!=null ) {
+ toClose.close();
+ }
+ }
+
+ /**
+ * Closes the IndexWriter, if open.
+ * @throws IOException
+ */
+ void closeIndexWriter() throws IOException {
+ IndexWriter toClose = writer;
+ writer = null;
+ if ( toClose!=null ) {
+ toClose.close();
+ }
+ }
+
+ }
+
}
Modified: search/trunk/src/java/org/hibernate/search/engine/DocumentBuilder.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/engine/DocumentBuilder.java 2008-05-29 15:18:15 UTC (rev 14713)
+++ search/trunk/src/java/org/hibernate/search/engine/DocumentBuilder.java 2008-05-29 22:07:56 UTC (rev 14714)
@@ -66,7 +66,7 @@
public class DocumentBuilder<T> {
private static final Logger log = LoggerFactory.getLogger( DocumentBuilder.class );
- private final PropertiesMetadata rootPropertiesMetadata;
+ private final PropertiesMetadata rootPropertiesMetadata = new PropertiesMetadata();
private final XClass beanClass;
private final DirectoryProvider[] directoryProviders;
private final IndexShardingStrategy shardingStrategy;
@@ -79,13 +79,12 @@
private ReflectionManager reflectionManager;
private int level = 0;
private int maxLevel = Integer.MAX_VALUE;
- private ScopedAnalyzer analyzer;
+ private final ScopedAnalyzer analyzer = new ScopedAnalyzer();
private Similarity similarity;
public DocumentBuilder(XClass clazz, InitContext context, DirectoryProvider[] directoryProviders,
IndexShardingStrategy shardingStrategy, ReflectionManager reflectionManager) {
- this.analyzer = new ScopedAnalyzer();
this.beanClass = clazz;
this.directoryProviders = directoryProviders;
this.shardingStrategy = shardingStrategy;
@@ -94,7 +93,6 @@
this.similarity = context.getDefaultSimilarity();
if ( clazz == null ) throw new AssertionFailure( "Unable to build a DocumentBuilder with a null class" );
- rootPropertiesMetadata = new PropertiesMetadata();
rootPropertiesMetadata.boost = getBoost( clazz );
rootPropertiesMetadata.analyzer = context.getDefaultAnalyzer();
Set<XClass> processedClasses = new HashSet<XClass>();
16 years, 5 months
Hibernate SVN: r14713 - in search/trunk/src: java/org/hibernate/search/backend and 15 other directories.
by hibernate-commits@lists.jboss.org
Author: sannegrinovero
Date: 2008-05-29 11:18:15 -0400 (Thu, 29 May 2008)
New Revision: 14713
Modified:
search/trunk/src/java/org/hibernate/search/annotations/ClassBridge.java
search/trunk/src/java/org/hibernate/search/annotations/FieldBridge.java
search/trunk/src/java/org/hibernate/search/backend/LuceneIndexingParameters.java
search/trunk/src/java/org/hibernate/search/backend/QueueingProcessor.java
search/trunk/src/java/org/hibernate/search/backend/Work.java
search/trunk/src/java/org/hibernate/search/backend/configuration/MaskedProperty.java
search/trunk/src/java/org/hibernate/search/backend/impl/BatchedQueueingProcessor.java
search/trunk/src/java/org/hibernate/search/backend/impl/PostTransactionWorkQueueSynchronization.java
search/trunk/src/java/org/hibernate/search/backend/impl/TransactionalWorker.java
search/trunk/src/java/org/hibernate/search/backend/impl/jms/AbstractJMSHibernateSearchController.java
search/trunk/src/java/org/hibernate/search/backend/impl/lucene/LuceneBackendQueueProcessor.java
search/trunk/src/java/org/hibernate/search/backend/impl/lucene/LuceneWorker.java
search/trunk/src/java/org/hibernate/search/bridge/String2FieldBridgeAdaptor.java
search/trunk/src/java/org/hibernate/search/bridge/TwoWayString2FieldBridgeAdaptor.java
search/trunk/src/java/org/hibernate/search/bridge/builtin/DateBridge.java
search/trunk/src/java/org/hibernate/search/engine/DocumentExtractor.java
search/trunk/src/java/org/hibernate/search/engine/EntityInfo.java
search/trunk/src/java/org/hibernate/search/event/FullTextIndexEventListener.java
search/trunk/src/java/org/hibernate/search/filter/ChainedFilter.java
search/trunk/src/java/org/hibernate/search/filter/StandardFilterKey.java
search/trunk/src/java/org/hibernate/search/impl/FullTextSessionImpl.java
search/trunk/src/java/org/hibernate/search/impl/InitContext.java
search/trunk/src/java/org/hibernate/search/impl/SearchFactoryImpl.java
search/trunk/src/java/org/hibernate/search/jpa/impl/FullTextEntityManagerImpl.java
search/trunk/src/java/org/hibernate/search/jpa/impl/FullTextQueryImpl.java
search/trunk/src/java/org/hibernate/search/query/FullTextFilterImpl.java
search/trunk/src/java/org/hibernate/search/query/IteratorImpl.java
search/trunk/src/java/org/hibernate/search/query/ScrollableResultsImpl.java
search/trunk/src/java/org/hibernate/search/reader/CacheableMultiReader.java
search/trunk/src/java/org/hibernate/search/store/DirectoryProviderFactory.java
search/trunk/src/java/org/hibernate/search/store/DirectoryProviderHelper.java
search/trunk/src/test/org/hibernate/search/test/bridge/UnresolvedBridgeTest.java
Log:
general code review: unused imports deleted, typos in comments and error messages, some "final" added to fields.
Modified: search/trunk/src/java/org/hibernate/search/annotations/ClassBridge.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/annotations/ClassBridge.java 2008-05-29 15:14:13 UTC (rev 14712)
+++ search/trunk/src/java/org/hibernate/search/annotations/ClassBridge.java 2008-05-29 15:18:15 UTC (rev 14713)
@@ -10,7 +10,7 @@
/**
* This annotation allows a user to apply an implementation
* class to a Lucene document to manipulate it in any way
- * the usersees fit.
+ * the user sees fit.
*
* @author John Griffin
*/
@@ -48,7 +48,7 @@
TermVector termVector() default TermVector.NO;
/**
- * A float value of the amount of lucene defined
+ * A float value of the amount of Lucene defined
* boost to apply to a field.
*/
Boost boost() default @Boost(value=1.0F);
@@ -60,7 +60,7 @@
public Class impl() default void.class;
/**
- * Array of fields to work with. The imnpl class
+ * Array of fields to work with. The impl class
* above will work on these fields.
*/
public Parameter[] params() default {};
Modified: search/trunk/src/java/org/hibernate/search/annotations/FieldBridge.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/annotations/FieldBridge.java 2008-05-29 15:14:13 UTC (rev 14712)
+++ search/trunk/src/java/org/hibernate/search/annotations/FieldBridge.java 2008-05-29 15:18:15 UTC (rev 14713)
@@ -16,7 +16,7 @@
@Target( {ElementType.FIELD, ElementType.METHOD} )
@Documented
public @interface FieldBridge {
- //defaault to embed @FieldBridge in @Field
+ //default to embed @FieldBridge in @Field
public Class impl() default void.class;
public Parameter[] params() default {};
Modified: search/trunk/src/java/org/hibernate/search/backend/LuceneIndexingParameters.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/backend/LuceneIndexingParameters.java 2008-05-29 15:14:13 UTC (rev 14712)
+++ search/trunk/src/java/org/hibernate/search/backend/LuceneIndexingParameters.java 2008-05-29 15:18:15 UTC (rev 14713)
@@ -27,8 +27,9 @@
public class LuceneIndexingParameters implements Serializable {
private static final long serialVersionUID = 5424606407623591663L;
- private static Logger log = LoggerFactory.getLogger( LuceneIndexingParameters.class );
+ private final Logger log = LoggerFactory.getLogger( LuceneIndexingParameters.class );
+
// value keyword
public static final String EXPLICIT_DEFAULT_VALUE = "default";
// property path keywords
Modified: search/trunk/src/java/org/hibernate/search/backend/QueueingProcessor.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/backend/QueueingProcessor.java 2008-05-29 15:14:13 UTC (rev 14712)
+++ search/trunk/src/java/org/hibernate/search/backend/QueueingProcessor.java 2008-05-29 15:18:15 UTC (rev 14713)
@@ -1,11 +1,6 @@
//$Id$
package org.hibernate.search.backend;
-import java.util.List;
-import java.io.Serializable;
-
-import org.hibernate.search.backend.LuceneWork;
-
/**
* Pile work operations
* No thread safety has to be implemented, the queue being scoped already
@@ -18,7 +13,7 @@
public interface QueueingProcessor {
/**
* Add a work
- * TODO move that womewhere else, it does not really fit here
+ * TODO move that somewhere else, it does not really fit here
*/
void add(Work work, WorkQueue workQueue);
Modified: search/trunk/src/java/org/hibernate/search/backend/Work.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/backend/Work.java 2008-05-29 15:14:13 UTC (rev 14712)
+++ search/trunk/src/java/org/hibernate/search/backend/Work.java 2008-05-29 15:18:15 UTC (rev 14713)
@@ -11,31 +11,33 @@
* @author Emmanuel Bernard
*/
public class Work {
- private Object entity;
- private Class entityClass;
- private Serializable id;
- private XMember idGetter;
- private WorkType type;
+ private final Object entity;
+ private final Class entityClass;
+ private final Serializable id;
+ private final XMember idGetter;
+ private final WorkType type;
-
public Work(Object entity, Serializable id, WorkType type) {
- this.entity = entity;
- this.id = id;
- this.type = type;
+ this( entity, null, id, null, type );
}
public Work(Class entityType, Serializable id, WorkType type) {
- this.entityClass = entityType;
- this.id = id;
- this.type = type;
+ this( null, entityType, id, null, type );
}
public Work(Object entity, XMember idGetter, WorkType type) {
+ this( entity, null, null, idGetter, type );
+ }
+
+ private Work(Object entity, Class entityClass, Serializable id,
+ XMember idGetter, WorkType type) {
this.entity = entity;
+ this.entityClass = entityClass;
+ this.id = id;
this.idGetter = idGetter;
this.type = type;
}
-
+
public Class getEntityClass() {
return entityClass;
}
Modified: search/trunk/src/java/org/hibernate/search/backend/configuration/MaskedProperty.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/backend/configuration/MaskedProperty.java 2008-05-29 15:14:13 UTC (rev 14712)
+++ search/trunk/src/java/org/hibernate/search/backend/configuration/MaskedProperty.java 2008-05-29 15:18:15 UTC (rev 14713)
@@ -28,8 +28,8 @@
public class MaskedProperty extends Properties implements Serializable {
private static final long serialVersionUID = -593307257383085113L;
- private static Logger log = LoggerFactory.getLogger( MaskedProperty.class );
+ private final Logger log = LoggerFactory.getLogger( MaskedProperty.class );
private final Properties masked;
private final Properties fallBack;
private final String radix;
Modified: search/trunk/src/java/org/hibernate/search/backend/impl/BatchedQueueingProcessor.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/backend/impl/BatchedQueueingProcessor.java 2008-05-29 15:14:13 UTC (rev 14712)
+++ search/trunk/src/java/org/hibernate/search/backend/impl/BatchedQueueingProcessor.java 2008-05-29 15:18:15 UTC (rev 14713)
@@ -1,7 +1,6 @@
//$Id$
package org.hibernate.search.backend.impl;
-import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
@@ -148,7 +147,6 @@
//TODO implements parallel batchWorkers (one per Directory)
public void performWorks(WorkQueue workQueue) {
-
Runnable processor = backendQueueProcessorFactory.getProcessor( workQueue.getSealedQueue() );
if ( sync ) {
processor.run();
@@ -167,10 +165,10 @@
if ( executorService != null && !executorService.isShutdown() ) {
executorService.shutdown();
try {
- executorService.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS );
+ executorService.awaitTermination( Long.MAX_VALUE, TimeUnit.SECONDS );
}
catch (InterruptedException e) {
- log.error("Unable to property shut down asynchronous indexing work", e);
+ log.error( "Unable to properly shut down asynchronous indexing work", e );
}
}
}
Modified: search/trunk/src/java/org/hibernate/search/backend/impl/PostTransactionWorkQueueSynchronization.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/backend/impl/PostTransactionWorkQueueSynchronization.java 2008-05-29 15:14:13 UTC (rev 14712)
+++ search/trunk/src/java/org/hibernate/search/backend/impl/PostTransactionWorkQueueSynchronization.java 2008-05-29 15:18:15 UTC (rev 14713)
@@ -10,14 +10,14 @@
import org.hibernate.search.util.WeakIdentityHashMap;
/**
- * Execute some work inside a transaction sychronization
+ * Execute some work inside a transaction synchronization
*
* @author Emmanuel Bernard
*/
public class PostTransactionWorkQueueSynchronization implements Synchronization {
- private QueueingProcessor queueingProcessor;
+ private final QueueingProcessor queueingProcessor;
private boolean consumed;
- private WeakIdentityHashMap queuePerTransaction;
+ private final WeakIdentityHashMap queuePerTransaction;
private WorkQueue queue = new WorkQueue();
/**
Modified: search/trunk/src/java/org/hibernate/search/backend/impl/TransactionalWorker.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/backend/impl/TransactionalWorker.java 2008-05-29 15:14:13 UTC (rev 14712)
+++ search/trunk/src/java/org/hibernate/search/backend/impl/TransactionalWorker.java 2008-05-29 15:18:15 UTC (rev 14713)
@@ -23,7 +23,7 @@
*/
public class TransactionalWorker implements Worker {
//not a synchronized map since for a given transaction, we have not concurrent access
- protected WeakIdentityHashMap synchronizationPerTransaction = new WeakIdentityHashMap();
+ protected final WeakIdentityHashMap synchronizationPerTransaction = new WeakIdentityHashMap();
private QueueingProcessor queueingProcessor;
public void performWork(Work work, EventSource session) {
Modified: search/trunk/src/java/org/hibernate/search/backend/impl/jms/AbstractJMSHibernateSearchController.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/backend/impl/jms/AbstractJMSHibernateSearchController.java 2008-05-29 15:14:13 UTC (rev 14712)
+++ search/trunk/src/java/org/hibernate/search/backend/impl/jms/AbstractJMSHibernateSearchController.java 2008-05-29 15:18:15 UTC (rev 14713)
@@ -26,7 +26,7 @@
* @author Emmanuel Bernard
*/
public abstract class AbstractJMSHibernateSearchController implements MessageListener {
- private static Logger log = LoggerFactory.getLogger( AbstractJMSHibernateSearchController.class );
+ private static final Logger log = LoggerFactory.getLogger( AbstractJMSHibernateSearchController.class );
/**
* return the current or give a new session
@@ -83,7 +83,7 @@
}
private Runnable getWorker(List<LuceneWork> queue) {
- //FIXME casting sucks becasue we do not control what get session from
+ //FIXME casting sucks because we do not control what get session from
Session session = getSession();
Runnable processor = null;
Modified: search/trunk/src/java/org/hibernate/search/backend/impl/lucene/LuceneBackendQueueProcessor.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/backend/impl/lucene/LuceneBackendQueueProcessor.java 2008-05-29 15:14:13 UTC (rev 14712)
+++ search/trunk/src/java/org/hibernate/search/backend/impl/lucene/LuceneBackendQueueProcessor.java 2008-05-29 15:18:15 UTC (rev 14713)
@@ -32,10 +32,10 @@
/**
* Class logger.
*/
- private static Logger log = LoggerFactory.getLogger( LuceneBackendQueueProcessor.class );
+ private static final Logger log = LoggerFactory.getLogger( LuceneBackendQueueProcessor.class );
- private List<LuceneWork> queue;
- private SearchFactoryImplementor searchFactoryImplementor;
+ private final List<LuceneWork> queue;
+ private final SearchFactoryImplementor searchFactoryImplementor;
public LuceneBackendQueueProcessor(List<LuceneWork> queue, SearchFactoryImplementor searchFactoryImplementor) {
this.queue = queue;
@@ -70,7 +70,7 @@
work.getIdInString(),
work.getDocument()
);
- queueWithFlatDPs.add( new LuceneWorker.WorkWithPayload(work, provider) );
+ queueWithFlatDPs.add( new LuceneWorker.WorkWithPayload( work, provider ) );
}
else if ( DeleteLuceneWork.class.isAssignableFrom( work.getClass() ) ) {
DirectoryProvider[] providers = shardingStrategy.getDirectoryProvidersForDeletion(
@@ -79,20 +79,20 @@
work.getIdInString()
);
for (DirectoryProvider provider : providers) {
- queueWithFlatDPs.add( new LuceneWorker.WorkWithPayload(work, provider) );
+ queueWithFlatDPs.add( new LuceneWorker.WorkWithPayload( work, provider ) );
}
}
else if ( OptimizeLuceneWork.class.isAssignableFrom( work.getClass() ) ) {
DirectoryProvider[] providers = shardingStrategy.getDirectoryProvidersForAllShards();
for (DirectoryProvider provider : providers) {
- queueWithFlatDPs.add( new LuceneWorker.WorkWithPayload(work, provider) );
+ queueWithFlatDPs.add( new LuceneWorker.WorkWithPayload( work, provider ) );
}
}
else {
throw new AssertionFailure( "Unknown work type: " + work.getClass() );
}
}
- deadlockFreeQueue(queueWithFlatDPs, searchFactoryImplementor);
+ deadlockFreeQueue( queueWithFlatDPs, searchFactoryImplementor );
checkForBatchIndexing(workspace);
for ( LuceneWorker.WorkWithPayload luceneWork : queueWithFlatDPs ) {
worker.performWork( luceneWork );
@@ -107,9 +107,9 @@
private void checkForBatchIndexing(Workspace workspace) {
for ( LuceneWork luceneWork : queue ) {
// if there is at least a single batch index job we put the work space into batch indexing mode.
- if(luceneWork.isBatch()){
- log.trace("Setting batch indexing mode.");
- workspace.setBatch(true);
+ if( luceneWork.isBatch() ){
+ log.trace( "Setting batch indexing mode." );
+ workspace.setBatch( true );
break;
}
}
Modified: search/trunk/src/java/org/hibernate/search/backend/impl/lucene/LuceneWorker.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/backend/impl/lucene/LuceneWorker.java 2008-05-29 15:14:13 UTC (rev 14712)
+++ search/trunk/src/java/org/hibernate/search/backend/impl/lucene/LuceneWorker.java 2008-05-29 15:18:15 UTC (rev 14713)
@@ -30,7 +30,7 @@
* @author John Griffin
*/
public class LuceneWorker {
- private Workspace workspace;
+ private final Workspace workspace;
private static final Logger log = LoggerFactory.getLogger( LuceneWorker.class );
public LuceneWorker(Workspace workspace) {
@@ -145,16 +145,14 @@
}
public static class WorkWithPayload {
- private LuceneWork work;
- private DirectoryProvider provider;
+ private final LuceneWork work;
+ private final DirectoryProvider provider;
-
public WorkWithPayload(LuceneWork work, DirectoryProvider provider) {
this.work = work;
this.provider = provider;
}
-
public LuceneWork getWork() {
return work;
}
Modified: search/trunk/src/java/org/hibernate/search/bridge/String2FieldBridgeAdaptor.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/bridge/String2FieldBridgeAdaptor.java 2008-05-29 15:14:13 UTC (rev 14712)
+++ search/trunk/src/java/org/hibernate/search/bridge/String2FieldBridgeAdaptor.java 2008-05-29 15:18:15 UTC (rev 14713)
@@ -11,7 +11,7 @@
* @author Emmanuel Bernard
*/
public class String2FieldBridgeAdaptor implements FieldBridge {
- private StringBridge stringBridge;
+ private final StringBridge stringBridge;
public String2FieldBridgeAdaptor(StringBridge stringBridge) {
this.stringBridge = stringBridge;
Modified: search/trunk/src/java/org/hibernate/search/bridge/TwoWayString2FieldBridgeAdaptor.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/bridge/TwoWayString2FieldBridgeAdaptor.java 2008-05-29 15:14:13 UTC (rev 14712)
+++ search/trunk/src/java/org/hibernate/search/bridge/TwoWayString2FieldBridgeAdaptor.java 2008-05-29 15:18:15 UTC (rev 14713)
@@ -12,7 +12,7 @@
//TODO use Generics to avoid double declaration of stringBridge
public class TwoWayString2FieldBridgeAdaptor extends String2FieldBridgeAdaptor implements TwoWayFieldBridge {
- private TwoWayStringBridge stringBridge;
+ private final TwoWayStringBridge stringBridge;
public TwoWayString2FieldBridgeAdaptor(TwoWayStringBridge stringBridge) {
super( stringBridge );
Modified: search/trunk/src/java/org/hibernate/search/bridge/builtin/DateBridge.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/bridge/builtin/DateBridge.java 2008-05-29 15:14:13 UTC (rev 14712)
+++ search/trunk/src/java/org/hibernate/search/bridge/builtin/DateBridge.java 2008-05-29 15:18:15 UTC (rev 14713)
@@ -9,11 +9,8 @@
import org.apache.lucene.document.DateTools;
import org.hibernate.AssertionFailure;
import org.hibernate.HibernateException;
-import org.hibernate.search.bridge.StringBridge;
import org.hibernate.search.bridge.ParameterizedBridge;
-import org.hibernate.search.bridge.String2FieldBridgeAdaptor;
import org.hibernate.search.annotations.Resolution;
-import org.hibernate.search.bridge.TwoWayString2FieldBridgeAdaptor;
import org.hibernate.search.bridge.TwoWayStringBridge;
import org.hibernate.util.StringHelper;
Modified: search/trunk/src/java/org/hibernate/search/engine/DocumentExtractor.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/engine/DocumentExtractor.java 2008-05-29 15:14:13 UTC (rev 14712)
+++ search/trunk/src/java/org/hibernate/search/engine/DocumentExtractor.java 2008-05-29 15:18:15 UTC (rev 14713)
@@ -1,14 +1,12 @@
//$Id$
package org.hibernate.search.engine;
-import java.util.ArrayList;
-import java.util.List;
import java.io.IOException;
+import java.io.Serializable;
import org.apache.lucene.document.Document;
import org.apache.lucene.search.Hits;
import org.hibernate.search.engine.EntityInfo;
-import org.hibernate.search.FullTextQuery;
import org.hibernate.search.ProjectionConstants;
/**
@@ -16,8 +14,8 @@
* @author John Griffin
*/
public class DocumentExtractor {
- private SearchFactoryImplementor searchFactoryImplementor;
- private String[] projection;
+ private final SearchFactoryImplementor searchFactoryImplementor;
+ private final String[] projection;
public DocumentExtractor(SearchFactoryImplementor searchFactoryImplementor, String... projection) {
this.searchFactoryImplementor = searchFactoryImplementor;
@@ -25,18 +23,19 @@
}
private EntityInfo extract(Document document) {
- EntityInfo entityInfo = new EntityInfo();
- entityInfo.clazz = DocumentBuilder.getDocumentClass( document );
- entityInfo.id = DocumentBuilder.getDocumentId( searchFactoryImplementor, entityInfo.clazz, document );
+ Class clazz = DocumentBuilder.getDocumentClass( document );
+ Serializable id = DocumentBuilder.getDocumentId( searchFactoryImplementor, clazz, document );
+ Object[] projected = null;
if ( projection != null && projection.length > 0 ) {
- entityInfo.projection = DocumentBuilder.getDocumentFields( searchFactoryImplementor, entityInfo.clazz, document, projection );
+ projected = DocumentBuilder.getDocumentFields( searchFactoryImplementor, clazz, document, projection );
}
+ EntityInfo entityInfo = new EntityInfo( clazz, id, projected );
return entityInfo;
}
public EntityInfo extract(Hits hits, int index) throws IOException {
Document doc = hits.doc( index );
- //TODO if we are lonly looking for score (unlikely), avoid accessing doc (lazy load)
+ //TODO if we are only looking for score (unlikely), avoid accessing doc (lazy load)
EntityInfo entityInfo = extract( doc );
Object[] eip = entityInfo.projection;
@@ -60,9 +59,6 @@
else if ( ProjectionConstants.THIS.equals( projection[x] ) ) {
//THIS could be projected more than once
//THIS loading delayed to the Loader phase
- if (entityInfo.indexesOfThis == null) {
- entityInfo.indexesOfThis = new ArrayList<Integer>(1);
- }
entityInfo.indexesOfThis.add(x);
}
}
Modified: search/trunk/src/java/org/hibernate/search/engine/EntityInfo.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/engine/EntityInfo.java 2008-05-29 15:14:13 UTC (rev 14712)
+++ search/trunk/src/java/org/hibernate/search/engine/EntityInfo.java 2008-05-29 15:18:15 UTC (rev 14713)
@@ -2,6 +2,7 @@
package org.hibernate.search.engine;
import java.io.Serializable;
+import java.util.LinkedList;
import java.util.List;
/**
@@ -10,8 +11,16 @@
*/
//TODO Move to egine?
public class EntityInfo {
- public Class clazz;
- public Serializable id;
- public Object[] projection;
- public List<Integer> indexesOfThis;
+
+ public final Class clazz;
+ public final Serializable id;
+ public final Object[] projection;
+ public final List<Integer> indexesOfThis = new LinkedList<Integer>();
+
+ public EntityInfo(Class clazz, Serializable id, Object[] projection) {
+ this.clazz = clazz;
+ this.id = id;
+ this.projection = projection;
+ }
+
}
Modified: search/trunk/src/java/org/hibernate/search/event/FullTextIndexEventListener.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/event/FullTextIndexEventListener.java 2008-05-29 15:14:13 UTC (rev 14712)
+++ search/trunk/src/java/org/hibernate/search/event/FullTextIndexEventListener.java 2008-05-29 15:18:15 UTC (rev 14713)
@@ -18,8 +18,6 @@
import org.hibernate.search.engine.DocumentBuilder;
import org.hibernate.search.engine.SearchFactoryImplementor;
import org.hibernate.search.impl.SearchFactoryImpl;
-import org.hibernate.search.Environment;
-import org.hibernate.search.SearchException;
/**
* This listener supports setting a parent directory for all generated index files.
@@ -63,7 +61,7 @@
if (used) {
final Object entity = event.getEntity();
DocumentBuilder<Object> builder = searchFactoryImplementor.getDocumentBuilders().get( entity.getClass() );
- //not strictly necessary but a smal optimization
+ //not strictly necessary but a small optimization
if ( builder != null ) {
Serializable id = event.getId();
processWork( entity, id, WorkType.ADD, event );
@@ -74,7 +72,7 @@
public void onPostUpdate(PostUpdateEvent event) {
if (used) {
final Object entity = event.getEntity();
- //not strictly necessary but a smal optimization
+ //not strictly necessary but a small optimization
DocumentBuilder<Object> builder = searchFactoryImplementor.getDocumentBuilders().get( entity.getClass() );
if ( builder != null ) {
Serializable id = event.getId();
Modified: search/trunk/src/java/org/hibernate/search/filter/ChainedFilter.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/filter/ChainedFilter.java 2008-05-29 15:14:13 UTC (rev 14712)
+++ search/trunk/src/java/org/hibernate/search/filter/ChainedFilter.java 2008-05-29 15:18:15 UTC (rev 14713)
@@ -14,9 +14,10 @@
* @author Emmanuel Bernard
*/
public class ChainedFilter extends Filter {
- private List<Filter> chainedFilters = new ArrayList<Filter>();
+ private static final long serialVersionUID = -6153052295766531920L;
+
+ private final List<Filter> chainedFilters = new ArrayList<Filter>();
-
public void addFilter(Filter filter) {
this.chainedFilters.add( filter );
}
@@ -32,7 +33,6 @@
return result;
}
-
public String toString() {
StringBuilder sb = new StringBuilder("ChainedFilter [");
for (Filter filter : chainedFilters) {
Modified: search/trunk/src/java/org/hibernate/search/filter/StandardFilterKey.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/filter/StandardFilterKey.java 2008-05-29 15:14:13 UTC (rev 14712)
+++ search/trunk/src/java/org/hibernate/search/filter/StandardFilterKey.java 2008-05-29 15:18:15 UTC (rev 14713)
@@ -1,10 +1,6 @@
// $Id$
package org.hibernate.search.filter;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.Set;
-import java.util.HashSet;
import java.util.List;
import java.util.ArrayList;
@@ -16,7 +12,7 @@
* @author Emmanuel Bernard
*/
public class StandardFilterKey extends FilterKey {
- private List parameters = new ArrayList();
+ private final List parameters = new ArrayList();
private boolean implSet;
Modified: search/trunk/src/java/org/hibernate/search/impl/FullTextSessionImpl.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/impl/FullTextSessionImpl.java 2008-05-29 15:14:13 UTC (rev 14712)
+++ search/trunk/src/java/org/hibernate/search/impl/FullTextSessionImpl.java 2008-05-29 15:18:15 UTC (rev 14713)
@@ -7,8 +7,6 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.lang.reflect.Method;
-import java.lang.reflect.InvocationTargetException;
import org.hibernate.CacheMode;
import org.hibernate.Criteria;
@@ -45,7 +43,6 @@
import org.hibernate.search.FullTextQuery;
import org.hibernate.search.FullTextSession;
import org.hibernate.search.SearchFactory;
-import org.hibernate.search.SearchException;
import org.hibernate.search.backend.Work;
import org.hibernate.search.backend.WorkType;
import org.hibernate.search.engine.DocumentBuilder;
Modified: search/trunk/src/java/org/hibernate/search/impl/InitContext.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/impl/InitContext.java 2008-05-29 15:14:13 UTC (rev 14712)
+++ search/trunk/src/java/org/hibernate/search/impl/InitContext.java 2008-05-29 15:18:15 UTC (rev 14713)
@@ -27,8 +27,8 @@
* @author Emmanuel Bernard
*/
public class InitContext {
- private Map<String, AnalyzerDef> analyzerDefs = new HashMap<String, AnalyzerDef>();
- private List<DelegateNamedAnalyzer> lazyAnalyzers = new ArrayList<DelegateNamedAnalyzer>();
+ private final Map<String, AnalyzerDef> analyzerDefs = new HashMap<String, AnalyzerDef>();
+ private final List<DelegateNamedAnalyzer> lazyAnalyzers = new ArrayList<DelegateNamedAnalyzer>();
private final Analyzer defaultAnalyzer;
private final Similarity defaultSimilarity;
@@ -57,7 +57,7 @@
}
/**
- * Initilises the Lucene analyzer to use by reading the analyzer class from the configuration and instantiating it.
+ * Initializes the Lucene analyzer to use by reading the analyzer class from the configuration and instantiating it.
*
* @param cfg
* The current configuration.
@@ -91,7 +91,7 @@
}
/**
- * Initilises the Lucene similarity to use
+ * Initializes the Lucene similarity to use
*/
private Similarity initSimilarity(Configuration cfg) {
Class similarityClass;
Modified: search/trunk/src/java/org/hibernate/search/impl/SearchFactoryImpl.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/impl/SearchFactoryImpl.java 2008-05-29 15:14:13 UTC (rev 14712)
+++ search/trunk/src/java/org/hibernate/search/impl/SearchFactoryImpl.java 2008-05-29 15:18:15 UTC (rev 14713)
@@ -51,25 +51,25 @@
* @author Emmanuel Bernard
*/
public class SearchFactoryImpl implements SearchFactoryImplementor {
- private static ThreadLocal<WeakHashMap<Configuration, SearchFactoryImpl>> contexts =
+ private static final ThreadLocal<WeakHashMap<Configuration, SearchFactoryImpl>> contexts =
new ThreadLocal<WeakHashMap<Configuration, SearchFactoryImpl>>();
static {
Version.touch();
}
- private final Logger log = LoggerFactory.getLogger( SearchFactoryImpl.class );
+ private static final Logger log = LoggerFactory.getLogger( SearchFactoryImpl.class );
- private Map<Class, DocumentBuilder<Object>> documentBuilders = new HashMap<Class, DocumentBuilder<Object>>();
+ private final Map<Class, DocumentBuilder<Object>> documentBuilders = new HashMap<Class, DocumentBuilder<Object>>();
//keep track of the index modifiers per DirectoryProvider since multiple entity can use the same directory provider
- private Map<DirectoryProvider, ReentrantLock> lockableDirectoryProviders =
+ private final Map<DirectoryProvider, ReentrantLock> lockableDirectoryProviders =
new HashMap<DirectoryProvider, ReentrantLock>();
- private Map<DirectoryProvider, OptimizerStrategy> dirProviderOptimizerStrategies =
+ private final Map<DirectoryProvider, OptimizerStrategy> dirProviderOptimizerStrategies =
new HashMap<DirectoryProvider, OptimizerStrategy>();
private Worker worker;
private ReaderProvider readerProvider;
private BackendQueueProcessorFactory backendQueueProcessorFactory;
- private Map<String, FilterDef> filterDefinitions = new HashMap<String, FilterDef>();
+ private final Map<String, FilterDef> filterDefinitions = new HashMap<String, FilterDef>();
private FilterCachingStrategy filterCachingStrategy;
private Map<String, Analyzer> analyzers;
private boolean stopped = false;
Modified: search/trunk/src/java/org/hibernate/search/jpa/impl/FullTextEntityManagerImpl.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/jpa/impl/FullTextEntityManagerImpl.java 2008-05-29 15:14:13 UTC (rev 14712)
+++ search/trunk/src/java/org/hibernate/search/jpa/impl/FullTextEntityManagerImpl.java 2008-05-29 15:18:15 UTC (rev 14713)
@@ -20,7 +20,7 @@
* @author Emmanuel Bernard
*/
public class FullTextEntityManagerImpl implements FullTextEntityManager, Serializable {
- private EntityManager em;
+ private final EntityManager em;
private FullTextSession ftSession;
public FullTextEntityManagerImpl(EntityManager em) {
Modified: search/trunk/src/java/org/hibernate/search/jpa/impl/FullTextQueryImpl.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/jpa/impl/FullTextQueryImpl.java 2008-05-29 15:14:13 UTC (rev 14712)
+++ search/trunk/src/java/org/hibernate/search/jpa/impl/FullTextQueryImpl.java 2008-05-29 15:18:15 UTC (rev 14713)
@@ -42,7 +42,7 @@
*/
public class FullTextQueryImpl implements FullTextQuery {
private final org.hibernate.search.FullTextQuery query;
- private Session session;
+ private final Session session;
public FullTextQueryImpl(org.hibernate.search.FullTextQuery query, Session session) {
this.query = query;
@@ -91,11 +91,11 @@
return query.list();
}
catch (QueryExecutionRequestException he) {
- //TODO when an illegal state exceptio should be raised?
+ //TODO when an illegal state exception should be raised?
throw new IllegalStateException(he);
}
catch( TypeMismatchException e ) {
- //TODO when an illegal arg exceptio should be raised?
+ //TODO when an illegal arg exception should be raised?
throw new IllegalArgumentException(e);
}
catch (SearchException he) {
Modified: search/trunk/src/java/org/hibernate/search/query/FullTextFilterImpl.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/query/FullTextFilterImpl.java 2008-05-29 15:14:13 UTC (rev 14712)
+++ search/trunk/src/java/org/hibernate/search/query/FullTextFilterImpl.java 2008-05-29 15:18:15 UTC (rev 14713)
@@ -10,7 +10,7 @@
* @author Emmanuel Bernard
*/
public class FullTextFilterImpl implements FullTextFilter {
- private Map<String, Object> parameters = new HashMap<String, Object>();
+ private final Map<String, Object> parameters = new HashMap<String, Object>();
private String name;
public void setName(String name) {
Modified: search/trunk/src/java/org/hibernate/search/query/IteratorImpl.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/query/IteratorImpl.java 2008-05-29 15:14:13 UTC (rev 14712)
+++ search/trunk/src/java/org/hibernate/search/query/IteratorImpl.java 2008-05-29 15:18:15 UTC (rev 14713)
@@ -19,7 +19,7 @@
private final int size;
private Object next;
private int nextObjectIndex = -1;
- private Loader loader;
+ private final Loader loader;
public IteratorImpl(List<EntityInfo> entityInfos, Loader loader) {
this.entityInfos = entityInfos;
@@ -58,7 +58,7 @@
}
public void remove() {
- //TODO this is theorically doable
+ //TODO this is theoretically doable
throw new UnsupportedOperationException( "Cannot remove from a lucene query iterator" );
}
}
Modified: search/trunk/src/java/org/hibernate/search/query/ScrollableResultsImpl.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/query/ScrollableResultsImpl.java 2008-05-29 15:14:13 UTC (rev 14712)
+++ search/trunk/src/java/org/hibernate/search/query/ScrollableResultsImpl.java 2008-05-29 15:18:15 UTC (rev 14713)
@@ -50,7 +50,7 @@
* @author John Griffin
*/
public class ScrollableResultsImpl implements ScrollableResults {
- private static Logger log = LoggerFactory.getLogger( ScrollableResultsImpl.class );
+ private static final Logger log = LoggerFactory.getLogger( ScrollableResultsImpl.class );
private final IndexSearcher searcher;
private final SearchFactory searchFactory;
private final Hits hits;
@@ -58,10 +58,10 @@
private final int max;
private final int fetchSize;
private int current;
- private EntityInfo[] entityInfos;
- private Loader loader;
- private DocumentExtractor documentExtractor;
- private Map<EntityInfo, Object[]> resultContext;
+ private final EntityInfo[] entityInfos;
+ private final Loader loader;
+ private final DocumentExtractor documentExtractor;
+ private final Map<EntityInfo, Object[]> resultContext;
public ScrollableResultsImpl(
IndexSearcher searcher, Hits hits, int first, int max, int fetchSize, DocumentExtractor extractor,
Modified: search/trunk/src/java/org/hibernate/search/reader/CacheableMultiReader.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/reader/CacheableMultiReader.java 2008-05-29 15:14:13 UTC (rev 14712)
+++ search/trunk/src/java/org/hibernate/search/reader/CacheableMultiReader.java 2008-05-29 15:18:15 UTC (rev 14713)
@@ -16,7 +16,7 @@
// This is package private as the intention of the Lucene team seems to be to not
// expose this publically (it's a protected member in Lucene 2.3)
- IndexReader[] subReaders;
+ final IndexReader[] subReaders;
public CacheableMultiReader(IndexReader[] subReaders) throws IOException {
super( subReaders );
Modified: search/trunk/src/java/org/hibernate/search/store/DirectoryProviderFactory.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/store/DirectoryProviderFactory.java 2008-05-29 15:14:13 UTC (rev 14712)
+++ search/trunk/src/java/org/hibernate/search/store/DirectoryProviderFactory.java 2008-05-29 15:18:15 UTC (rev 14713)
@@ -45,7 +45,7 @@
*/
public class DirectoryProviderFactory {
- private List<DirectoryProvider<?>> providers = new ArrayList<DirectoryProvider<?>>();
+ private final List<DirectoryProvider<?>> providers = new ArrayList<DirectoryProvider<?>>();
private static String DEFAULT_DIRECTORY_PROVIDER = FSDirectoryProvider.class.getName();
private static final String SHARDING_STRATEGY = "sharding_strategy";
@@ -252,8 +252,8 @@
}
public class DirectoryProviders {
- private IndexShardingStrategy shardingStrategy;
- private DirectoryProvider[] providers;
+ private final IndexShardingStrategy shardingStrategy;
+ private final DirectoryProvider[] providers;
public DirectoryProviders(IndexShardingStrategy shardingStrategy, DirectoryProvider[] providers) {
this.shardingStrategy = shardingStrategy;
Modified: search/trunk/src/java/org/hibernate/search/store/DirectoryProviderHelper.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/store/DirectoryProviderHelper.java 2008-05-29 15:14:13 UTC (rev 14712)
+++ search/trunk/src/java/org/hibernate/search/store/DirectoryProviderHelper.java 2008-05-29 15:18:15 UTC (rev 14713)
@@ -59,7 +59,7 @@
makeSanityCheckedDirectory( rootDir, directoryProviderName, needWritePermissions );
sourceDirectory = new File( root, relative );
makeSanityCheckedDirectory( sourceDirectory, directoryProviderName, needWritePermissions );
- log.debug( "Get directory from root + relative" );
+ log.debug( "Got directory from root + relative" );
}
return sourceDirectory;
}
Modified: search/trunk/src/test/org/hibernate/search/test/bridge/UnresolvedBridgeTest.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/bridge/UnresolvedBridgeTest.java 2008-05-29 15:14:13 UTC (rev 14712)
+++ search/trunk/src/test/org/hibernate/search/test/bridge/UnresolvedBridgeTest.java 2008-05-29 15:18:15 UTC (rev 14713)
@@ -1,19 +1,11 @@
//$Id$
package org.hibernate.search.test.bridge;
-import java.io.InputStream;
-
-import org.hibernate.search.test.SearchTestCase;
import org.hibernate.search.SearchException;
import org.hibernate.search.store.RAMDirectoryProvider;
-import org.hibernate.Session;
-import org.hibernate.dialect.Dialect;
import org.hibernate.cfg.AnnotationConfiguration;
-import org.hibernate.cfg.Environment;
-import org.hibernate.cfg.Configuration;
import junit.framework.TestCase;
-
/**
* @author Emmanuel Bernard
*/
16 years, 6 months
Hibernate SVN: r14712 - search/trunk.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2008-05-29 11:14:13 -0400 (Thu, 29 May 2008)
New Revision: 14712
Modified:
search/trunk/build.xml
Log:
uncommenting hardy's fix
Modified: search/trunk/build.xml
===================================================================
--- search/trunk/build.xml 2008-05-29 15:12:25 UTC (rev 14711)
+++ search/trunk/build.xml 2008-05-29 15:14:13 UTC (rev 14712)
@@ -358,7 +358,8 @@
<!-- ivy uses the module name without hibernate- (to mimic the directory names). Revert the situation -->
<move file="${dist.lib.dir}/commons-annotations.jar" tofile="${dist.lib.dir}/hibernate-commons-annotations.jar"
failonerror="false"/>
- <!--move file="${dist.lib.dir}/test/commons-annotations.jar" tofile="${dist.lib.dir}/test/hibernate-commons-annotations.jar"/-->
+ <move file="${dist.lib.dir}/test/commons-annotations.jar" tofile="${dist.lib.dir}/test/hibernate-commons-annotations.jar"
+ failonerror="false"/>
<move file="${dist.lib.dir}/test/annotations.jar" tofile="${dist.lib.dir}/test/hibernate-annotations.jar"
failonerror="false"/>
<move file="${dist.lib.dir}/test/entitymanager.jar" tofile="${dist.lib.dir}/test/hibernate-entitymanager.jar"
16 years, 6 months