Here are the two methods, one original, one mirror.<br><br> /**<br> * Dig down into a Key indexing as we go.<br> */<br> private void newgenerateSearchIndexImpl( List errors, IndexWriter writer, Key key) throws BookException, IOException
<br> {<br> int bookNum = 0;<br> int oldBookNum = -1;<br> int percent = 0;<br> String name = ""; //$NON-NLS-1$<br> String text = ""; //$NON-NLS-1$<br> BookData data = null;
<br> Key subkey = null;<br> Verse verse = null;<br> Document doc = null;<br> for (Iterator it = key.iterator(); it.hasNext(); )<br> {<br> subkey = (Key) it.next();<br> if (
subkey.canHaveChildren())<br> {<br> newgenerateSearchIndexImpl( errors, writer, subkey);<br> }<br> else<br> {<br> data = null;<br> try
<br> {<br> data = book.getData(subkey);<br> }<br> catch (BookException e)<br> {<br> errors.add(subkey);<br> continue;
<br> }<br><br> text = data.getVerseText();<br><br> // Do the actual indexing<br> if (text != null && text.length() > 0)<br> {<br> doc = new Document();
<br> doc.add(new Field(FIELD_NAME, subkey.getOsisRef(), Field.Store.YES, <a href="http://Field.Index.NO">Field.Index.NO</a>));<br> doc.add(new Field(FIELD_BODY, new StringReader(text)));
<br> writer.addDocument(doc);<br> }<br><br> // report progress<br> verse = KeyUtil.getVerse(subkey);<br><br> try<br> {<br> percent = 95 *
verse.getOrdinal() / BibleInfo.versesInBible();<br> bookNum = verse.getBook();<br> if (oldBookNum != bookNum)<br> {<br> name = BibleInfo.getBookName
(bookNum);<br> oldBookNum = bookNum;<br> }<br> }<br> catch (NoSuchVerseException ex)<br> {<br> log.error("Failed to get book name from verse: " + verse, ex); //$NON-NLS-1$
<br> assert false;<br> name = subkey.getName();<br> }<br><br> <br> }<br> }<br> }<br><br> /**<br> * Dig down into a Key indexing as we go.
<br> */<br> private void generateSearchIndexImpl(Job job, List errors, IndexWriter writer, Key key) throws BookException, IOException<br> {<br> int bookNum = 0;<br> int oldBookNum = -1;<br> int percent = 0;
<br> String name = ""; //$NON-NLS-1$<br> String text = ""; //$NON-NLS-1$<br> BookData data = null;<br> Key subkey = null;<br> Verse verse = null;<br> Document doc = null;
<br> for (Iterator it = key.iterator(); it.hasNext(); )<br> {<br> subkey = (Key) it.next();<br> if (subkey.canHaveChildren())<br> {<br> generateSearchIndexImpl(job, errors, writer, subkey);
<br> }<br> else<br> {<br> data = null;<br> try<br> {<br> data = book.getData(subkey);<br> }<br> catch (BookException e)
<br> {<br> errors.add(subkey);<br> continue;<br> }<br> <br> text = data.getVerseText();<br> <br> // Do the actual indexing
<br> if (text != null && text.length() > 0)<br> {<br> doc = new Document();<br> doc.add(new Field(FIELD_NAME, subkey.getOsisRef(), Field.Store.YES
, <a href="http://Field.Index.NO">Field.Index.NO</a>));<br> doc.add(new Field(FIELD_BODY, new StringReader(text)));<br> writer.addDocument(doc);<br> }<br> <br> // report progress
<br> verse = KeyUtil.getVerse(subkey);<br> <br> try<br> {<br> percent = 95 * verse.getOrdinal() / BibleInfo.versesInBible();<br> bookNum =
verse.getBook();<br> if (oldBookNum != bookNum)<br> {<br> name = BibleInfo.getBookName(bookNum);<br> oldBookNum = bookNum;<br> }
<br> }<br> catch (NoSuchVerseException ex)<br> {<br> log.error("Failed to get book name from verse: " + verse, ex); //$NON-NLS-1$<br> assert false;
<br> name = subkey.getName();<br> }<br> <br> job.setProgress(percent, Msg.INDEXING.toString(name));<br> <br> // This could take a long time ...<br>
Thread.yield();<br> if (Thread.currentThread().isInterrupted())<br> {<br> break;<br> }<br> }<br> }<br> }<br><br><br><div><span class="gmail_quote">
On 12/19/06, <b class="gmail_sendername">Zhaojun Li</b> <<a href="mailto:lzj369@gmail.com">lzj369@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi, Dear all,<br><br>I am new to Lucene, so please help.<br><br>I need to remove the job class from the current Lucene implementation. What I did is: create mirror method from generateSearchIndexImpl by removing any Job class reference. I tested it and it works.
<br><br>However, the speed is not good. In the design, it is a recursive call. How to do multithreading for this? I mean by usual thread class, not JSWORD Job api.<br><br>Thanks!<br><span class="sg"><br>Zhaojun<br><br>
<br><br>
</span></blockquote></div><br>