Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

added a timeout for topic computation (solr is here much slower than the old metadata-db)

Michael Peter Christen4faa07c21474
diff --git a/htroot/yacy/search.java b/htroot/yacy/search.java
index 51c22e3a1..696eb4680 100644
--- a/htroot/yacy/search.java
+++ b/htroot/yacy/search.java
@@ -364,7 +364,7 @@ public final class search {
// prepare reference hints
final long timer = System.currentTimeMillis();
- final ScoreMap<String> topicNavigator = theSearch.rankingProcess.getTopics(5);
+ final ScoreMap<String> topicNavigator = theSearch.rankingProcess.getTopics(5, 100);
final StringBuilder refstr = new StringBuilder(6000);
final Iterator<String> navigatorIterator = topicNavigator.keys(false);
int i = 0;
diff --git a/source/net/yacy/search/query/RankingProcess.java b/source/net/yacy/search/query/RankingProcess.java
index fd932305d..0e2d28327 100644
--- a/source/net/yacy/search/query/RankingProcess.java
+++ b/source/net/yacy/search/query/RankingProcess.java
@@ -361,7 +361,7 @@ public final class RankingProcess extends Thread {
return this.localSearchInclusion;
}
- public ScoreMap<String> getTopics(final int count) {
+ public ScoreMap<String> getTopics(final int maxcount, final long maxtime) {
// create a list of words that had been computed by statistics over all
// words that appeared in the url or the description of all urls
final ScoreMap<String> result = new ConcurrentScoreMap<String>();
@@ -373,7 +373,8 @@ public final class RankingProcess extends Thread {
String word;
int c;
float q, min = Float.MAX_VALUE, max = Float.MIN_VALUE;
- int ic = count;
+ int ic = maxcount;
+ long timeout = System.currentTimeMillis() + maxtime;
while ( ic-- > 0 && i.hasNext() ) {
word = i.next();
if ( word == null ) {
@@ -386,10 +387,11 @@ public final class RankingProcess extends Thread {
max = Math.max(max, q);
counts.put(word, q);
}
+ if (System.currentTimeMillis() > timeout) break;
}
if ( max > min ) {
for ( final Map.Entry<String, Float> ce : counts.entrySet() ) {
- result.set(ce.getKey(), (int) (((double) count) * (ce.getValue() - min) / (max - min)));
+ result.set(ce.getKey(), (int) (((double) maxcount) * (ce.getValue() - min) / (max - min)));
}
}
return this.ref;
diff --git a/source/net/yacy/search/query/SearchEvent.java b/source/net/yacy/search/query/SearchEvent.java
index a4809690c..e3509d266 100644
--- a/source/net/yacy/search/query/SearchEvent.java
+++ b/source/net/yacy/search/query/SearchEvent.java
@@ -895,7 +895,7 @@ public final class SearchEvent {
*/
public ScoreMap<String> getTopicNavigator(final int count ) {
if (this.topicNavigatorCount > 0 && count >= 0) { //topicNavigatorCount set during init, 0=no nav
- return this.rankingProcess.getTopics(count != 0 ? count : this.topicNavigatorCount);
+ return this.rankingProcess.getTopics(count != 0 ? count : this.topicNavigatorCount, 500);
}
return null;
}