Author: tolusha
Date: 2012-02-10 05:45:28 -0500 (Fri, 10 Feb 2012)
New Revision: 5600
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AbstractIndex.java
Log:
EXOJCR-1719: revemo parallel text extractin
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AbstractIndex.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AbstractIndex.java 2012-02-10
09:10:28 UTC (rev 5599)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AbstractIndex.java 2012-02-10
10:45:28 UTC (rev 5600)
@@ -174,57 +174,43 @@
void addDocuments(final Document[] docs) throws IOException
{
final IndexWriter writer = getIndexWriter();
- DynamicPooledExecutor.Command[] commands = new
DynamicPooledExecutor.Command[docs.length];
- for (int i = 0; i < docs.length; i++)
+
+ IOException ioExc = null;
+ try
{
- // check if text extractor completed its work
- final Document doc = getFinishedDocument(docs[i]);
- // create a command for inverting the document
- commands[i] = new DynamicPooledExecutor.Command()
+ for (Document doc : docs)
{
- public Object call() throws Exception
+ try
{
- long time = System.currentTimeMillis();
- writer.addDocument(doc);
- return new Long(System.currentTimeMillis() - time);
+ writer.addDocument(getFinishedDocument(doc));
}
- };
- }
- DynamicPooledExecutor.Result[] results = EXECUTOR.executeAndWait(commands);
- invalidateSharedReader();
- IOException ex = null;
- for (int i = 0; i < results.length; i++)
- {
- if (results[i].getException() != null)
- {
- Throwable cause = results[i].getException().getCause();
- if (ex == null)
+ catch (Throwable e)
{
- // only throw the first exception
- if (cause instanceof IOException)
+ if (ioExc == null)
{
- ex = (IOException)cause;
+ if (e instanceof IOException)
+ {
+ ioExc = (IOException)e;
+ }
+ else
+ {
+ ioExc = Util.createIOException(e);
+ }
}
- else
- {
- throw Util.createIOException(cause);
- }
+
+ log.warn("Exception while inverting document", e);
}
- else
- {
- // all others are logged
- log.warn("Exception while inverting document", cause);
- }
}
- else
- {
- log.debug("Inverted document in {} ms", results[i].get());
- }
}
- if (ex != null)
+ finally
{
- throw ex;
+ invalidateSharedReader();
}
+
+ if (ioExc != null)
+ {
+ throw ioExc;
+ }
}
/**
Show replies by date