[hibernate-commits] Hibernate SVN: r15381 - search/trunk/src/java/org/hibernate/search/backend/impl/lucene.
hibernate-commits at lists.jboss.org
hibernate-commits at lists.jboss.org
Thu Oct 23 06:55:33 EDT 2008
Author: sannegrinovero
Date: 2008-10-23 06:55:33 -0400 (Thu, 23 Oct 2008)
New Revision: 15381
Modified:
search/trunk/src/java/org/hibernate/search/backend/impl/lucene/IndexInteractionType.java
search/trunk/src/java/org/hibernate/search/backend/impl/lucene/PerDPQueueProcessor.java
Log:
make sure HSEARCH-222 is solved, even in case new LuceneWorkDelegates are created (removed dangerous constant "NEED_INDEXREADER").
Modified: search/trunk/src/java/org/hibernate/search/backend/impl/lucene/IndexInteractionType.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/backend/impl/lucene/IndexInteractionType.java 2008-10-23 09:33:14 UTC (rev 15380)
+++ search/trunk/src/java/org/hibernate/search/backend/impl/lucene/IndexInteractionType.java 2008-10-23 10:55:33 UTC (rev 15381)
@@ -1,25 +1,29 @@
package org.hibernate.search.backend.impl.lucene;
/**
+ * Constants to make the LuceneWorkDelegates advertise the type
+ * of resource they are going to need to perform the work.
+ *
+ * NEEDS_INDEXREADER is missing to make sure there always is an optimal
+ * solution, as some operations can be done both through an IndexReader
+ * and an IndexWriter, but as of Lucene 2.4 there are no operations which
+ * can't be done using an IndexWriter.
+ *
* @author Sanne Grinovero
*/
public enum IndexInteractionType {
/**
- * means the workType needs an IndexWriter.
+ * The workType needs an IndexWriter.
*/
NEEDS_INDEXWRITER,
/**
- * means the workType needs an IndexReader.
- */
- NEEDS_INDEXREADER,
- /**
- * means an IndexWriter should work best but it's possible
+ * An IndexWriter should work best but it's possible
* to use an IndexReader instead.
*/
PREFER_INDEXWRITER,
/**
- * means an IndexReader should work best but it's possible
+ * An IndexReader should work best but it's possible
* to use an IndexWriter instead.
*/
PREFER_INDEXREADER
Modified: search/trunk/src/java/org/hibernate/search/backend/impl/lucene/PerDPQueueProcessor.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/backend/impl/lucene/PerDPQueueProcessor.java 2008-10-23 09:33:14 UTC (rev 15380)
+++ search/trunk/src/java/org/hibernate/search/backend/impl/lucene/PerDPQueueProcessor.java 2008-10-23 10:55:33 UTC (rev 15381)
@@ -26,7 +26,6 @@
// if any work passed to addWork needs one, set corresponding flag to true:
private boolean batchmode = false;
- private boolean needsReader = false;
private boolean needsWriter = false;
private boolean preferReader = false;
@@ -42,9 +41,6 @@
}
IndexInteractionType type = work.getWorkDelegate( worker ).getIndexInteractionType();
switch ( type ) {
- case NEEDS_INDEXREADER :
- needsReader = true;
- //fall through:
case PREFER_INDEXREADER :
preferReader = true;
workOnReader.add( work );
@@ -64,7 +60,7 @@
// skip "resource optimization mode" when in batch to have all tasks use preferred (optimal) mode.
if ( ! batchmode ) {
// see if we can skip using some resource
- if ( ! needsReader && ! needsWriter ) { // no specific need:
+ if ( ! needsWriter ) { // no specific need:
if ( preferReader ) {
useReaderOnly();
}
@@ -72,12 +68,13 @@
useWriterOnly();
}
}
- else if ( needsReader && !needsWriter ) {
- useReaderOnly();
- }
- else if ( !needsReader && needsWriter ) {
+ else {
useWriterOnly();
}
+ if ( ! (workOnWriter.isEmpty() || workOnReader.isEmpty() ) ) {
+ throw new AssertionFailure(
+ "During non-batch mode performWorks tries to use both IndexWriter and IndexReader." );
+ }
}
// apply changes to index:
log.trace( "Locking Workspace (or waiting to...)" );
@@ -116,7 +113,6 @@
finally {
workspace.closeIndexWriter();
}
-
}
/**
More information about the hibernate-commits
mailing list