summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authororbiter <orbiter@6c8d7289-2bf4-0310-a012-ef5d649a1542>2009-09-21 15:24:47 +0000
committerorbiter <orbiter@6c8d7289-2bf4-0310-a012-ef5d649a1542>2009-09-21 15:24:47 +0000
commitaca8a78eb8f64d5eee1f19e283d00682f404bc2e (patch)
treed88a241c9b814ba0b1e626d19b9f12151d8dcd8d
parent23ab6fbca4eded4bbe691cb9e8a81951987b1fdb (diff)
fix for shutdown of DocumentIndex objects
git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@6333 6c8d7289-2bf4-0310-a012-ef5d649a1542
-rw-r--r--source/de/anomic/kelondro/text/DocumentIndex.java26
1 files changed, 22 insertions, 4 deletions
diff --git a/source/de/anomic/kelondro/text/DocumentIndex.java b/source/de/anomic/kelondro/text/DocumentIndex.java
index 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 threads
for (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) {