#(showload)#Available after successful loading of rss feed in preview::
-
once
diff --git a/source/de/anomic/search/RankingProcess.java b/source/de/anomic/search/RankingProcess.java
index 17de349c7..a49a18858 100644
--- a/source/de/anomic/search/RankingProcess.java
+++ b/source/de/anomic/search/RankingProcess.java
@@ -286,17 +286,39 @@ public final class RankingProcess extends Thread {
// returns from the current RWI list the best entry and removes this entry from the list
WeakPriorityBlockingQueue m;
WeakPriorityBlockingQueue.Element rwi = null;
- try {
+
+ // check if the doubleDomCache is filled
+ /*
+ boolean doubleDomCacheFilled = false;
+ synchronized (this.doubleDomCache) {
+ final Iterator> i = this.doubleDomCache.values().iterator();
+ while (i.hasNext()) {
+ try {
+ m = i.next();
+ } catch (ConcurrentModificationException e) {
+ Log.logException(e);
+ break; // not the best solution...
+ }
+ if (m == null) continue;
+ if (m.isEmpty()) continue;
+ doubleDomCacheFilled = true;
+ break;
+ }
+ }
+ */
+
+ // take one entry from the stack if there are entries on that stack or the feeding is not yet finished
+ if (!feedingIsFinished() || stack.sizeQueue() > 0) try {
//System.out.println("stack.poll: feeders = " + this.feeders + ", stack.sizeQueue = " + stack.sizeQueue());
int loops = 0; // a loop counter to terminate the reading if all the results are from the same domain
long timeout = System.currentTimeMillis() + waitingtime;
while (this.query.itemsPerPage < 1 || loops++ < this.query.itemsPerPage) {
if (waitingtime <= 0) {
rwi = stack.poll();
- } else while (System.currentTimeMillis() < timeout) {
+ } else timeoutloop:while (System.currentTimeMillis() < timeout) {
+ if (feedingIsFinished() && stack.sizeQueue() == 0) break timeoutloop;
rwi = stack.poll(50);
- if (rwi != null) break;
- if (feedingIsFinished() && stack.sizeQueue() == 0) break;
+ if (rwi != null) break timeoutloop;
}
if (rwi == null) break;
if (!skipDoubleDom) {
@@ -306,24 +328,20 @@ public final class RankingProcess extends Thread {
// check doubledom
final String domhash = new String(rwi.getElement().metadataHash(), 6, 6);
- m = this.doubleDomCache.get(domhash);
- if (m == null) {
- // first appearance of dom
- m = new WeakPriorityBlockingQueue((query.specialRights) ? maxDoubleDomSpecial : maxDoubleDomAll);
- this.doubleDomCache.put(domhash, m);
- //System.out.println("m == null");
- return rwi;
+ synchronized (this.doubleDomCache) {
+ m = this.doubleDomCache.get(domhash);
+ if (m == null) {
+ // first appearance of dom. we create an entry to signal that one of that domain was already returned
+ m = new WeakPriorityBlockingQueue((query.specialRights) ? maxDoubleDomSpecial : maxDoubleDomAll);
+ this.doubleDomCache.put(domhash, m);
+ return rwi;
+ }
+ // second appearances of dom
+ m.put(rwi);
}
-
- // second appearances of dom
- m.put(rwi);
}
- } catch (InterruptedException e1) {
- }
- if (this.doubleDomCache.size() == 0) {
- //System.out.println("this.doubleDomCache.size() == 0");
- return null;
- }
+ } catch (InterruptedException e1) {}
+ if (this.doubleDomCache.size() == 0) return null;
// no more entries in sorted RWI entries. Now take Elements from the doubleDomCache
// find best entry from all caches
@@ -336,41 +354,26 @@ public final class RankingProcess extends Thread {
m = i.next();
} catch (ConcurrentModificationException e) {
Log.logException(e);
- break; // not the best solution...
- }
- if (m == null) {
- //System.out.println("m == null");
- continue;
- }
- if (m.isEmpty()) {
- //System.out.println("m.isEmpty()");
- continue;
+ continue; // not the best solution...
}
+ if (m == null) continue;
+ if (m.isEmpty()) continue;
if (bestEntry == null) {
bestEntry = m.peek();
- //System.out.println("bestEntry = m.peek() = " + bestEntry);
continue;
}
o = m.peek();
- if (o == null) {
- //System.out.println("o == null");
- continue;
- }
+ if (o == null) continue;
if (o.getWeight() < bestEntry.getWeight()) {
bestEntry = o;
}
}
+ if (bestEntry == null) return null;
+
+ // finally remove the best entry from the doubledom cache
+ m = this.doubleDomCache.get(new String(bestEntry.getElement().metadataHash()).substring(6));
+ bestEntry = m.poll();
}
- if (bestEntry == null) {
- //System.out.println("bestEntry == null");
- return null;
- }
-
- // finally remove the best entry from the doubledom cache
- m = this.doubleDomCache.get(new String(bestEntry.getElement().metadataHash()).substring(6));
- o = m.poll();
- //assert o == null || o.element.metadataHash().equals(bestEntry.element.metadataHash()) : "bestEntry.element.metadataHash() = " + bestEntry.element.metadataHash() + ", o.element.metadataHash() = " + o.element.metadataHash();
- //System.out.println("return bestEntry");
return bestEntry;
}
diff --git a/source/de/anomic/search/ResultFetcher.java b/source/de/anomic/search/ResultFetcher.java
index 8220c8785..a4d9abd3b 100644
--- a/source/de/anomic/search/ResultFetcher.java
+++ b/source/de/anomic/search/ResultFetcher.java
@@ -72,7 +72,7 @@ public class ResultFetcher {
final QueryParams query,
final yacySeedDB peers,
final int taketimeout) {
-
+ assert query != null;
this.loader = loader;
this.rankingProcess = rankedCache;
this.query = query;
@@ -102,7 +102,7 @@ public class ResultFetcher {
// start worker threads to fetch urls and snippets
this.workerThreads = null;
deployWorker(Math.min(10, query.itemsPerPage), query.neededResults());
- EventTracker.update(EventTracker.EClass.SEARCH, new ProfilingGraph.searchEvent(query.id(true), SearchEvent.Type.SNIPPETFETCH_START, this.workerThreads.length + " online snippet fetch threads started", 0, 0), false);
+ EventTracker.update(EventTracker.EClass.SEARCH, new ProfilingGraph.searchEvent(query.id(true), SearchEvent.Type.SNIPPETFETCH_START, ((this.workerThreads == null) ? "no" : this.workerThreads.length) + " online snippet fetch threads started", 0, 0), false);
}
public void deployWorker(int deployCount, int neededResults) {
@@ -111,7 +111,7 @@ public class ResultFetcher {
this.workerThreads = new Worker[/*(query.snippetCacheStrategy.mustBeOffline()) ? 1 : */deployCount];
synchronized(this.workerThreads) {
for (int i = 0; i < workerThreads.length; i++) {
- Worker worker = new Worker(i, 1000, query.snippetCacheStrategy, neededResults);
+ Worker worker = new Worker(i, 10000, query.snippetCacheStrategy, neededResults);
worker.start();
this.workerThreads[i] = worker;
}