fixed search result preparation

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@4427 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 17 years ago
parent 7c29bc4a87
commit 89169d54fd

@ -117,7 +117,7 @@ var progressbar = new Progressbar(#[results]#, document.getElementById("results"
#{/results}#
#(resultTable)#::</table>#(/resultTable)#
<!-- linklist end -->
<!--<div class="sidebar"><h3 class="head">Drill-Down</h3></div>-->
<!-- attach the bottomline -->
<!--#include virtual="yacysearchitem.html?bottomline=true&eventID=#[eventID]#" -->
</body>

@ -58,7 +58,7 @@ public final class plasmaSearchEvent {
public static final String URLFETCH = "urlfetch";
public static final String NORMALIZING = "normalizing";
public static int workerThreadCount = 8;
public static int workerThreadCount = 10;
public static String lastEventID = "";
private static HashMap<String, plasmaSearchEvent> lastEvents = new HashMap<String, plasmaSearchEvent>(); // a cache for objects from this class: re-use old search requests
public static final long eventLifetime = 600000; // the time an event will stay in the cache, 10 Minutes
@ -391,6 +391,17 @@ public final class plasmaSearchEvent {
}
return false;
}
private int countFinishedWorkerThreads() {
if (this.workerThreads == null) return workerThreadCount;
int c = 0;
for (int i = 0; i < workerThreadCount; i++) {
if ((this.workerThreads[i] == null) ||
!(this.workerThreads[i].isAlive()) ||
(this.workerThreads[i].busytime() >= 3000)) c++;
}
return c;
}
private boolean anyRemoteSearchAlive() {
// check primary search threads
@ -576,6 +587,7 @@ public final class plasmaSearchEvent {
public ResultEntry oneResult(int item) {
// first sleep a while to give accumulation threads a chance to work
while (((localSearchThread != null) && (localSearchThread.isAlive())) ||
((countFinishedWorkerThreads() <= item) && (item < workerThreadCount)) ||
((this.primarySearchThreads != null) && (this.primarySearchThreads.length > item) && (anyWorkerAlive()) &&
((this.resultList.size() <= item) || (countFinishedRemoteSearch() <= item)))) {
try {Thread.sleep(100);} catch (InterruptedException e) {}

@ -76,6 +76,7 @@ public class plasmaSnippetCache {
public static final int SOURCE_CACHE = 0;
public static final int SOURCE_FILE = 1;
public static final int SOURCE_WEB = 2;
public static final int SOURCE_METADATA = 3;
public static final int ERROR_NO_HASH_GIVEN = 11;
public static final int ERROR_SOURCE_LOADING = 12;
@ -280,11 +281,16 @@ public class plasmaSnippetCache {
if ((resContentLength > maxDocLen) && (!fetchOnline)) {
// content may be too large to be parsed here. To be fast, we omit calculation of snippet here
return new TextSnippet(url, null, ERROR_SOURCE_LOADING, queryhashes, "resource available, but too large: " + resContentLength + " bytes");
}/*
} else if (url.) {
}
} else if (containsAllHashes(comp.dc_title(), queryhashes)) {
// try to create the snippet from information given in the url itself
*/
return new TextSnippet(url, (comp.dc_subject().length() > 0) ? comp.dc_creator() : comp.dc_subject(), SOURCE_METADATA, null, null, faviconCache.get(url.hash()));
} else if (containsAllHashes(comp.dc_creator(), queryhashes)) {
// try to create the snippet from information given in the creator metadata
return new TextSnippet(url, comp.dc_creator(), SOURCE_METADATA, null, null, faviconCache.get(url.hash()));
} else if (containsAllHashes(comp.dc_subject(), queryhashes)) {
// try to create the snippet from information given in the subject metadata
return new TextSnippet(url, (comp.dc_creator().length() > 0) ? comp.dc_creator() : comp.dc_subject(), SOURCE_METADATA, null, null, faviconCache.get(url.hash()));
} else if (fetchOnline) {
// if not found try to download it
@ -741,7 +747,16 @@ public class plasmaSnippetCache {
}
return map;
}
private static boolean containsAllHashes(String sentence, Set<String> queryhashes) {
HashMap<String, Integer> m = hashSentence(sentence);
Iterator<String> i = queryhashes.iterator();
while (i.hasNext()) {
if (!(m.containsKey(i.next()))) return false;
}
return true;
}
public static plasmaParserDocument parseDocument(yacyURL url, long contentLength, InputStream resourceStream) throws ParserException {
return parseDocument(url, contentLength, resourceStream, null);
}

Loading…
Cancel
Save