Author: cutting
Date: Thu May 12 10:53:52 2005
New Revision: 169858
URL: http://svn.apache.org/viewcvs?rev=169858&view=rev
Log:
When computing multiple summaries, do each in a separate thread to
take advantage of segments stored on different disks and/or multiple
CPUs.
Modified:
incubator/nutch/trunk/src/java/org/apache/nutch/searcher/FetchedSegments.java
Modified:
incubator/nutch/trunk/src/java/org/apache/nutch/searcher/FetchedSegments.java
URL:
http://svn.apache.org/viewcvs/incubator/nutch/trunk/src/java/org/apache/nutch/searcher/FetchedSegments.java?rev=169858&r1=169857&r2=169858&view=diff
==============================================================================
---
incubator/nutch/trunk/src/java/org/apache/nutch/searcher/FetchedSegments.java
(original)
+++
incubator/nutch/trunk/src/java/org/apache/nutch/searcher/FetchedSegments.java
Thu May 12 10:53:52 2005
@@ -146,11 +146,51 @@
return new Summarizer().getSummary(text, query).toString();
}
+ private class SummaryThread extends Thread {
+ private HitDetails details;
+ private Query query;
+
+ private String summary;
+ private Throwable throwable;
+
+ public SummaryThread(HitDetails details, Query query) {
+ this.details = details;
+ this.query = query;
+ }
+
+ public void run() {
+ try {
+ this.summary = getSummary(details, query);
+ } catch (Throwable throwable) {
+ this.throwable = throwable;
+ }
+ }
+
+ }
+
+
public String[] getSummary(HitDetails[] details, Query query)
throws IOException {
+ SummaryThread[] threads = new SummaryThread[details.length];
+ for (int i = 0; i < threads.length; i++) {
+ threads[i] = new SummaryThread(details[i], query);
+ threads[i].start();
+ }
+
String[] results = new String[details.length];
- for (int i = 0; i < details.length; i++)
- results[i] = getSummary(details[i], query);
+ for (int i = 0; i < threads.length; i++) {
+ try {
+ threads[i].join();
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+ if (threads[i].throwable instanceof IOException) {
+ throw (IOException)threads[i].throwable;
+ } else if (threads[i].throwable != null) {
+ throw new RuntimeException(threads[i].throwable);
+ }
+ results[i] = threads[i].summary;
+ }
return results;
}
-------------------------------------------------------
This SF.Net email is sponsored by Oracle Space Sweepstakes
Want to be the first software developer in space?
Enter now for the Oracle Space Sweepstakes!
http://ads.osdn.com/?ad_ids93&alloc_id281&op=click
_______________________________________________
Nutch-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nutch-cvs