Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
fix for shutdown of DocumentIndex objects
orbiteraca8a78eb8f6
diff --git a/source/de/anomic/kelondro/text/DocumentIndex.java b/source/de/anomic/kelondro/text/DocumentIndex.javaindex ebf8ba3e2..631546a91 100644--- a/source/de/anomic/kelondro/text/DocumentIndex.java+++ b/source/de/anomic/kelondro/text/DocumentIndex.java@@ -52,7 +52,7 @@ import de.anomic.yacy.logging.Log;*/public class DocumentIndex extends Segment {- private RankingProfile textRankingDefault = new RankingProfile(QueryParams.CONTENTDOM_TEXT);+ private static final RankingProfile textRankingDefault = new RankingProfile(QueryParams.CONTENTDOM_TEXT);//private Bitfield zeroConstraint = new Bitfield(4);File poison = new File(".");@@ -155,8 +155,7 @@ public class DocumentIndex extends Segment {* @return a list of files that contain the given string*/public ArrayList<File> find(String querystring, int pos, int count) {- QueryParams query = new QueryParams(querystring, 100, textRankingDefault, null);- ArrayList<URLMetadataRow> result = findMetadata(query, this);+ ArrayList<URLMetadataRow> result = findMetadata(querystring, this);ArrayList<File> files = new ArrayList<File>();for (URLMetadataRow row : result) {files.add(row.metadata().url().getLocalFile());@@ -165,6 +164,13 @@ public class DocumentIndex extends Segment {}return files;}++ public static final ArrayList<URLMetadataRow> findMetadata(+ final String querystring,+ final Segment indexSegment) {+ QueryParams query = new QueryParams(querystring, 100, textRankingDefault, null);+ return findMetadata(query, indexSegment);+ }public static final ArrayList<URLMetadataRow> findMetadata(final QueryParams query,@@ -189,13 +195,25 @@ public class DocumentIndex extends Segment {return find(querystring, 0, 20);}+ /**+ * close the index.+ * This terminates all worker threads and then closes the segment.+ */public void close() {- super.close();+ // send termination signal to worker threadsfor (int i = 0; i < this.worker.length; i++) {try {this.queue.put(poison);} catch (InterruptedException e) {}}+ // wait for termination+ for (int i = 0; i < this.worker.length; i++) {+ try {+ this.worker[i].join();+ } catch (InterruptedException e) {}+ }+ // close the segment+ super.close();}public static void main(String[] args) {