Author: orbiter
Date: 2008-02-02 01:16:00 +0100 (Sat, 02 Feb 2008)
New Revision: 4427

Modified:
   trunk/htroot/yacysearch.html
   trunk/source/de/anomic/plasma/plasmaSearchEvent.java
   trunk/source/de/anomic/plasma/plasmaSnippetCache.java
Log:
fixed search result preparation

Modified: trunk/htroot/yacysearch.html
===================================================================
--- trunk/htroot/yacysearch.html        2008-02-01 19:22:32 UTC (rev 4426)
+++ trunk/htroot/yacysearch.html        2008-02-02 00:16:00 UTC (rev 4427)
@@ -117,7 +117,7 @@
 #{/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>

Modified: trunk/source/de/anomic/plasma/plasmaSearchEvent.java
===================================================================
--- trunk/source/de/anomic/plasma/plasmaSearchEvent.java        2008-02-01 
19:22:32 UTC (rev 4426)
+++ trunk/source/de/anomic/plasma/plasmaSearchEvent.java        2008-02-02 
00:16:00 UTC (rev 4427)
@@ -58,7 +58,7 @@
     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 @@
         }
         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 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) {}

Modified: trunk/source/de/anomic/plasma/plasmaSnippetCache.java
===================================================================
--- trunk/source/de/anomic/plasma/plasmaSnippetCache.java       2008-02-01 
19:22:32 UTC (rev 4426)
+++ trunk/source/de/anomic/plasma/plasmaSnippetCache.java       2008-02-02 
00:16:00 UTC (rev 4427)
@@ -76,6 +76,7 @@
     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 @@
                 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 @@
         }
         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);
     }

_______________________________________________
YaCy-svn mailing list
YaCy-svn@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/yacy-svn

Antwort per Email an