[jsword-svn]
jsword/java/jsword/org/crosswire/jsword/book/search/lucene s
jswordcvs at crosswire.org
jswordcvs at crosswire.org
Mon Mar 7 19:31:47 MST 2005
Update of /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/lucene
In directory www.crosswire.org:/tmp/cvs-serv23386/java/jsword/org/crosswire/jsword/book/search/lucene
Modified Files:
LuceneIndex.java LuceneIndexManager.java
Log Message:
Improved the Job class allowing for cooperative interruption.
Fixed the download cancel. Improved the cancel of indexing.
It works but you have to restart to try to index again.
Index: LuceneIndex.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/lucene/LuceneIndex.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** LuceneIndex.java 6 Mar 2005 20:21:47 -0000 1.6
--- LuceneIndex.java 8 Mar 2005 02:31:45 -0000 1.7
***************
*** 1,4 ****
--- 1,5 ----
package org.crosswire.jsword.book.search.lucene;
+ import java.io.File;
import java.io.IOException;
import java.io.Reader;
***************
*** 104,111 ****
{
book.getBookMetaData().setIndexStatus(IndexStatus.CREATING);
!
// An index is created by opening an IndexWriter with the
// create argument set to true.
! IndexWriter writer = new IndexWriter(NetUtil.getAsFile(storage).getCanonicalPath(), new SimpleAnalyzer(), true);
generateSearchIndexImpl(job, writer, book.getGlobalKeyList());
--- 105,115 ----
{
book.getBookMetaData().setIndexStatus(IndexStatus.CREATING);
! File finalPath = NetUtil.getAsFile(storage);
! String finalCanonicalPath = finalPath.getCanonicalPath();
! File tempPath = new File(finalCanonicalPath + ".building"); //$NON-NLS-1$
!
// An index is created by opening an IndexWriter with the
// create argument set to true.
! IndexWriter writer = new IndexWriter(tempPath.getCanonicalPath(), new SimpleAnalyzer(), true);
generateSearchIndexImpl(job, writer, book.getGlobalKeyList());
***************
*** 116,122 ****
writer.close();
! searcher = new IndexSearcher(NetUtil.getAsFile(storage).getCanonicalPath());
! book.getBookMetaData().setIndexStatus(IndexStatus.DONE);
}
}
--- 120,133 ----
writer.close();
! job.setInterruptable(false);
! if (!job.isFinished())
! {
! tempPath.renameTo(finalPath);
!
! searcher = new IndexSearcher(finalPath.getCanonicalPath());
!
! book.getBookMetaData().setIndexStatus(IndexStatus.DONE);
! }
}
}
Index: LuceneIndexManager.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/lucene/LuceneIndexManager.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** LuceneIndexManager.java 6 Mar 2005 20:21:47 -0000 1.5
--- LuceneIndexManager.java 8 Mar 2005 02:31:45 -0000 1.6
***************
*** 101,105 ****
URL storage = getStorageArea(book.getBookMetaData());
Index index = new LuceneIndex(book, storage, true);
! INDEXES.put(book, index);
}
catch (Exception ex)
--- 101,109 ----
URL storage = getStorageArea(book.getBookMetaData());
Index index = new LuceneIndex(book, storage, true);
! // We were successful if the directory exists.
! if (NetUtil.getAsFile(storage).exists())
! {
! INDEXES.put(book, index);
! }
}
catch (Exception ex)
More information about the jsword-svn
mailing list