Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
refactoring of search process: - re-designed remote request result processing - re-designed local result accumulation, will be further enhanced with snippet fetcher - removed search process handling in switchboad - made snippet class static (there is no need for multiple snippet objects) - removed some redundant tasks in server-side search process, should be a little bit faster now
orbiter947fc4690424
diff --git a/htroot/Bookmarks.java b/htroot/Bookmarks.javaindex 0328bcbe1..95451fe69 100644--- a/htroot/Bookmarks.java+++ b/htroot/Bookmarks.java@@ -61,6 +61,7 @@ import de.anomic.http.httpc;import de.anomic.index.indexURLEntry;import de.anomic.net.URL;import de.anomic.plasma.plasmaParserDocument;+import de.anomic.plasma.plasmaSnippetCache;import de.anomic.plasma.plasmaSwitchboard;import de.anomic.server.serverDate;import de.anomic.server.serverObjects;@@ -172,7 +173,7 @@ public class Bookmarks {plasmaParserDocument document = null;if (urlentry != null) {indexURLEntry.Components comp = urlentry.comp();- document = switchboard.snippetCache.retrieveDocument(comp.url(), true, 5000, true);+ document = plasmaSnippetCache.retrieveDocument(comp.url(), true, 5000, true);prop.put("mode_edit", 0); // create modeprop.put("mode_url", comp.url().toNormalform(false, true));prop.put("mode_title", comp.title());diff --git a/htroot/ViewFile.java b/htroot/ViewFile.javaindex c3a6d53a2..a0cec7647 100644--- a/htroot/ViewFile.java+++ b/htroot/ViewFile.java@@ -62,6 +62,7 @@ import de.anomic.net.URL;import de.anomic.plasma.plasmaCondenser;import de.anomic.plasma.plasmaHTCache;import de.anomic.plasma.plasmaParserDocument;+import de.anomic.plasma.plasmaSnippetCache;import de.anomic.plasma.plasmaSwitchboard;import de.anomic.plasma.cache.IResourceInfo;import de.anomic.plasma.crawler.plasmaCrawlerException;@@ -168,7 +169,7 @@ public class ViewFile {if (resource == null) {plasmaHTCache.Entry entry = null;try {- entry = sb.snippetCache.loadResourceFromWeb(url, 5000, false, true);+ entry = plasmaSnippetCache.loadResourceFromWeb(url, 5000, false, true);} catch (plasmaCrawlerException e) {prop.put("error", 4);prop.put("error_errorText", e.getMessage());@@ -276,7 +277,7 @@ public class ViewFile {// parsing the resource contentplasmaParserDocument document = null;try {- document = sb.snippetCache.parseDocument(url, resourceLength, resource, resInfo);+ document = plasmaSnippetCache.parseDocument(url, resourceLength, resource, resInfo);if (document == null) {prop.put("error", 5);prop.put("error_errorText", "Unknown error");diff --git a/htroot/ViewImage.java b/htroot/ViewImage.javaindex e6f1ac299..b827addcc 100644--- a/htroot/ViewImage.java+++ b/htroot/ViewImage.java@@ -49,6 +49,7 @@ import java.net.MalformedURLException;import de.anomic.http.httpHeader;import de.anomic.net.URL;+import de.anomic.plasma.plasmaSnippetCache;import de.anomic.plasma.plasmaSwitchboard;import de.anomic.server.serverFileUtils;import de.anomic.server.serverObjects;@@ -91,7 +92,7 @@ public class ViewImage {int timeout = post.getInt("timeout", 5000);// getting the image as stream- Object[] resource = sb.snippetCache.getResource(url, true, timeout, false);+ Object[] resource = plasmaSnippetCache.getResource(url, true, timeout, false);byte[] imgb = null;if (resource == null) {if (urlString.endsWith(".ico")) {diff --git a/htroot/htdocsdefault/dir.java b/htroot/htdocsdefault/dir.javaindex f63c2942c..9ad104c97 100644--- a/htroot/htdocsdefault/dir.java+++ b/htroot/htdocsdefault/dir.java@@ -366,7 +366,7 @@ public class dir {try {final URL url = new URL(urlstring);final plasmaCondenser condenser = new plasmaCondenser(new ByteArrayInputStream(("yacyshare. " + phrase + ". " + descr).getBytes()), "UTF-8");- final indexURLEntry newEntry = switchboard.wordIndex.loadedURL.newEntry(+ final indexURLEntry newEntry = new indexURLEntry(url,"YaCyShare: " + descr,yacyCore.seedDB.mySeed.getName(),diff --git a/htroot/xml/snippet.java b/htroot/xml/snippet.javaindex d17f9001b..e72d01f48 100644--- a/htroot/xml/snippet.java+++ b/htroot/xml/snippet.java@@ -58,7 +58,7 @@ public class snippet {// find snippetif (media.equals("text")) {// attach text snippet- plasmaSnippetCache.TextSnippet snippet = switchboard.snippetCache.retrieveTextSnippet(url, queryHashes, true, pre, 260, textsnippet_timeout);+ plasmaSnippetCache.TextSnippet snippet = plasmaSnippetCache.retrieveTextSnippet(url, queryHashes, true, pre, 260, textsnippet_timeout);prop.put("status",snippet.getErrorCode());if (snippet.getErrorCode() < 11) {// no problems occurred@@ -66,14 +66,14 @@ public class snippet {prop.putASIS("text", (snippet.exists()) ? snippet.getLineMarked(queryHashes) : "unknown"); //FIXME: the ASIS should not be needed, but we have still htmlcode in .java files} else {// problems with snippet fetch- prop.put("text", (remove) ? switchboard.snippetCache.failConsequences(snippet, queryHashes) : snippet.getError());+ prop.put("text", (remove) ? plasmaSnippetCache.failConsequences(snippet, queryHashes) : snippet.getError());}prop.put("link", 0);prop.put("links", 0);prop.put("favicon",snippet.getFavicon()==null?"":snippet.getFavicon().toString());} else {// attach media information- ArrayList mediaSnippets = switchboard.snippetCache.retrieveMediaSnippets(url, queryHashes, media, true, mediasnippet_timeout);+ ArrayList mediaSnippets = plasmaSnippetCache.retrieveMediaSnippets(url, queryHashes, media, true, mediasnippet_timeout);plasmaSnippetCache.MediaSnippet ms;for (int i = 0; i < mediaSnippets.size(); i++) {ms = (plasmaSnippetCache.MediaSnippet) mediaSnippets.get(i);diff --git a/htroot/yacy/search.java b/htroot/yacy/search.javaindex 9c6bc07f0..38f0c2ed7 100644--- a/htroot/yacy/search.java+++ b/htroot/yacy/search.java@@ -1,14 +1,15 @@// search.java-// ------------------------// part of the AnomicHTTPD caching proxy-// (C) by Michael Peter Christen; [email protected]-// first published on http://www.anomic.de-// Frankfurt, Germany, 2004+// (C) 2004 by Michael Peter Christen; [email protected], Frankfurt a. M., Germany+// first published on http://yacy.net+//+// This is a part of YaCy, a peer-to-peer based web search engine//// $LastChangedDate$// $LastChangedRevision$// $LastChangedBy$//+// LICENSE+//// This program is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by// the Free Software Foundation; either version 2 of the License, or@@ -22,32 +23,11 @@// You should have received a copy of the GNU General Public License// along with this program; if not, write to the Free Software// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA-//-// Using this software in any meaning (reading, learning, copying, compiling,-// running) means that you agree that the Author(s) is (are) not responsible-// for cost, loss of data or any harm that may be caused directly or indirectly-// by usage of this softare or this documentation. The usage of this software-// is on your own risk. The installation and usage (starting/running) of this-// software may allow other people or application to access your computer and-// any attached devices and is highly dependent on the configuration of the-// software which must be done by the user of the software; the author(s) is-// (are) also not responsible for proper configuration and usage of the-// software, even if provoked by documentation provided together with-// the software.-//-// Any changes to this file according to the GPL as documented in the file-// gpl.txt aside this file in the shipment you received can be done to the-// lines that follows this copyright notice here, but changes must not be-// done inside the copyright notive above. A re-distribution must contain-// the intact and unchanged copyright notice.-// Contributions and changes to the program code must be marked as such.-// You must compile this file with// javac -classpath .:../../Classes search.java// if the shell's current path is htroot/yacy-import java.util.HashMap;import java.util.Iterator;import java.util.Map;import java.util.TreeSet;@@ -56,11 +36,9 @@ import de.anomic.http.httpHeader;import de.anomic.kelondro.kelondroBase64Order;import de.anomic.kelondro.kelondroBitfield;import de.anomic.index.indexContainer;-import de.anomic.net.natLib;import de.anomic.plasma.plasmaURL;import de.anomic.index.indexURLEntry;import de.anomic.plasma.plasmaCondenser;-import de.anomic.plasma.plasmaSearchEvent;import de.anomic.plasma.plasmaSearchPreOrder;import de.anomic.plasma.plasmaSearchQuery;import de.anomic.plasma.plasmaSearchRankingProfile;@@ -151,7 +129,7 @@ public final class search {int joincount = 0;plasmaSearchPostOrder acc = null;plasmaSearchQuery squery = null;- plasmaSearchEvent theSearch = null;+ //plasmaSearchEvent theSearch = null;if ((query.length() == 0) && (abstractSet != null)) {// this is _not_ a normal search, only a request for index abstractssquery = new plasmaSearchQuery(abstractSet, new TreeSet(kelondroBase64Order.enhancedCoder), maxdist, prefer, plasmaSearchQuery.contentdomParser(contentdom), count, duetime, filter, plasmaSearchQuery.catchall_constraint);@@ -159,11 +137,11 @@ public final class search {yacyCore.log.logInfo("INIT HASH SEARCH (abstracts only): " + plasmaSearchQuery.anonymizedQueryHashes(squery.queryHashes) + " - " + squery.wantedResults + " links");// prepare a search profile- plasmaSearchRankingProfile rankingProfile = (profile.length() == 0) ? new plasmaSearchRankingProfile(contentdom) : new plasmaSearchRankingProfile("", profile);+ //plasmaSearchRankingProfile rankingProfile = (profile.length() == 0) ? new plasmaSearchRankingProfile(contentdom) : new plasmaSearchRankingProfile("", profile);plasmaSearchProcessing localTiming = new plasmaSearchProcessing(squery.maximumTime, squery.wantedResults);- plasmaSearchProcessing remoteTiming = null;+ //plasmaSearchProcessing remoteTiming = null;- theSearch = new plasmaSearchEvent(squery, rankingProfile, localTiming, remoteTiming, true, yacyCore.log, sb.wordIndex, sb.snippetCache, null);+ //theSearch = new plasmaSearchEvent(squery, rankingProfile, localTiming, remoteTiming, true, sb.wordIndex, null);Map[] containers = localTiming.localSearchContainers(squery, sb.wordIndex, plasmaSearchQuery.hashes2Set(urls));if (containers != null) {Iterator ci = containers[0].entrySet().iterator();@@ -189,12 +167,9 @@ public final class search {// prepare a search profileplasmaSearchRankingProfile rankingProfile = (profile.length() == 0) ? new plasmaSearchRankingProfile(contentdom) : new plasmaSearchRankingProfile("", profile);plasmaSearchProcessing localProcess = new plasmaSearchProcessing(squery.maximumTime, squery.wantedResults);- plasmaSearchProcessing remoteProcess = null;+ //plasmaSearchProcessing remoteProcess = null;- theSearch = new plasmaSearchEvent(squery,- rankingProfile, localProcess, remoteProcess, true,- yacyCore.log, sb.wordIndex,- sb.snippetCache, null);+ //theSearch = new plasmaSearchEvent(squery, rankingProfile, localProcess, remoteProcess, true, sb.wordIndex, null);Map[] containers = localProcess.localSearchContainers(squery, sb.wordIndex, plasmaSearchQuery.hashes2Set(urls));// set statistic details of search result and find best result index setif (containers == null) {@@ -283,15 +258,17 @@ public final class search {// prepare search statisticsLong trackerHandle = new Long(System.currentTimeMillis());+ String client = (String) header.get("CLIENTIP");+ /*HashMap searchProfile = theSearch.resultProfile();searchProfile.put("resulttime", new Long(System.currentTimeMillis() - timestamp));searchProfile.put("resultcount", new Integer(joincount));- String client = (String) header.get("CLIENTIP");searchProfile.put("host", client);yacySeed remotepeer = yacyCore.seedDB.lookupByIP(natLib.getInetAddress(client), true, false, false);searchProfile.put("peername", (remotepeer == null) ? "unknown" : remotepeer.getName());searchProfile.put("time", trackerHandle);sb.remoteSearches.add(searchProfile);+ */TreeSet handles = (TreeSet) sb.remoteSearchTracker.get(client);if (handles == null) handles = new TreeSet();handles.add(trackerHandle);@@ -315,7 +292,7 @@ public final class search {while ((acc.hasMoreElements()) && (i < squery.wantedResults)) {urlentry = (indexURLEntry) acc.nextElement();if (includesnippet) {- snippet = sb.snippetCache.retrieveTextSnippet(urlentry.comp().url(), squery.queryHashes, false, urlentry.flags().get(plasmaCondenser.flag_cat_indexof), 260, 1000);+ snippet = plasmaSnippetCache.retrieveTextSnippet(urlentry.comp().url(), squery.queryHashes, false, urlentry.flags().get(plasmaCondenser.flag_cat_indexof), 260, 1000);} else {snippet = null;}diff --git a/htroot/yacysearch.java b/htroot/yacysearch.javaindex f6d834d8a..0b3284444 100644--- a/htroot/yacysearch.java+++ b/htroot/yacysearch.java@@ -52,8 +52,8 @@ import java.net.MalformedURLException;import java.net.URLEncoder;import java.util.HashMap;import java.util.Iterator;-import java.util.regex.PatternSyntaxException;import java.util.TreeSet;+import java.util.regex.PatternSyntaxException;import de.anomic.htmlFilter.htmlFilterImageEntry;import de.anomic.http.httpHeader;@@ -64,20 +64,23 @@ import de.anomic.kelondro.kelondroNaturalOrder;import de.anomic.net.URL;import de.anomic.plasma.plasmaCondenser;import de.anomic.plasma.plasmaParserDocument;+import de.anomic.plasma.plasmaSearchEvent;import de.anomic.plasma.plasmaSearchImages;+import de.anomic.plasma.plasmaSearchPostOrder;import de.anomic.plasma.plasmaSearchPreOrder;import de.anomic.plasma.plasmaSearchQuery;import de.anomic.plasma.plasmaSearchRankingProfile;import de.anomic.plasma.plasmaSearchProcessing;+import de.anomic.plasma.plasmaSearchResultAccumulator;import de.anomic.plasma.plasmaSnippetCache;import de.anomic.plasma.plasmaSwitchboard;import de.anomic.plasma.plasmaURL;-import de.anomic.plasma.plasmaSearchResults;import de.anomic.server.serverCore;import de.anomic.server.serverDomains;import de.anomic.server.serverDate;import de.anomic.server.serverObjects;import de.anomic.server.serverSwitch;+import de.anomic.server.logging.serverLog;import de.anomic.tools.crypt;import de.anomic.tools.nxTools;import de.anomic.yacy.yacyCore;@@ -236,7 +239,7 @@ public class yacysearch {yacyCore.newsPool.publishMyNews(yacyNewsRecord.newRecord(yacyNewsPool.CATEGORY_SURFTIPP_VOTE_ADD, map));}- // if aplus-button was hit, create new voting message+ // if a plus-button was hit, create new voting messageif (post.containsKey("recommendref")) {if (!sb.verifyAuthentication(header, true)) {prop.put("AUTHENTICATE", "admin log-in"); // force log-in@@ -247,7 +250,7 @@ public class yacysearch {if (urlentry != null) {indexURLEntry.Components comp = urlentry.comp();plasmaParserDocument document;- document = sb.snippetCache.retrieveDocument(comp.url(), true, 5000, true);+ document = plasmaSnippetCache.retrieveDocument(comp.url(), true, 5000, true);if (document != null) {// create a news messageHashMap map = new HashMap();@@ -288,110 +291,147 @@ public class yacysearch {plasmaSearchProcessing localTiming = new plasmaSearchProcessing(4 * thisSearch.maximumTime / 10, thisSearch.wantedResults);plasmaSearchProcessing remoteTiming = new plasmaSearchProcessing(6 * thisSearch.maximumTime / 10, thisSearch.wantedResults);- plasmaSearchResults results = new plasmaSearchResults();+ //**+ //searchFromLocal(thisSearch, ranking, localTiming, remoteTiming, true, (String) header.get("CLIENTIP"))+ String client = (String) header.get("CLIENTIP"); // the search client who initiated the search++ // tell all threads to do nothing for a specific time+ sb.intermissionAllThreads(2 * thisSearch.maximumTime);++ // filter out words that appear in bluelist+ thisSearch.filterOut(plasmaSwitchboard.blueList);++ // log+ serverLog.logInfo("LOCAL_SEARCH", "INIT WORD SEARCH: " + thisSearch.queryString + ":" + thisSearch.queryHashes + " - " + thisSearch.wantedResults + " links, " + (thisSearch.maximumTime / 1000) + " seconds");+ long timestamp = System.currentTimeMillis();++ // create a new search eventString wrongregex = null;+ plasmaSearchEvent theSearch = new plasmaSearchEvent(thisSearch, ranking, localTiming, remoteTiming, true, sb.wordIndex, (sb.isRobinsonMode()) ? sb.clusterhashes : null);+ plasmaSearchPostOrder acc;try{- results = sb.searchFromLocal(thisSearch, ranking, localTiming, remoteTiming, true, (String) header.get("CLIENTIP"));- }- catch(PatternSyntaxException e){+ acc = theSearch.search();+ } catch(PatternSyntaxException e){wrongregex = e.getPattern();+ acc = new plasmaSearchPostOrder(thisSearch, ranking);}++ // fetch snippets+ serverLog.logFine("LOCAL_SEARCH", "SEARCH TIME AFTER ORDERING OF SEARCH RESULTS: " + ((System.currentTimeMillis() - timestamp) / 1000) + " seconds");+ plasmaSearchResultAccumulator accu = new plasmaSearchResultAccumulator(theSearch, sb.wordIndex, plasmaSwitchboard.blueList);+ serverLog.logFine("LOCAL_SEARCH", "SEARCH TIME AFTER RESULT PREPARATION: " + ((System.currentTimeMillis() - timestamp) / 1000) + " seconds");++ // calc some more cross-reference+ long remainingTime = thisSearch.maximumTime - (System.currentTimeMillis() - timestamp);+ if (remainingTime < 0) remainingTime = 1000;+ //Object[] ws = acc.getReferences(16);+ serverLog.logFine("LOCAL_SEARCH", "SEARCH TIME AFTER XREF PREPARATION: " + ((System.currentTimeMillis() - timestamp) / 1000) + " seconds");++ // log+ serverLog.logInfo("LOCAL_SEARCH", "EXIT WORD SEARCH: " + thisSearch.queryString + " - " ++ acc.getTotalCount() + " links found, " ++ acc.filteredResults + " links filtered, " ++ acc.sizeOrdered() + " links ordered, " ++ ((System.currentTimeMillis() - timestamp) / 1000) + " seconds");+++ // prepare search statistics+ Long trackerHandle = new Long(System.currentTimeMillis());+ HashMap searchProfile = theSearch.resultProfile();+ searchProfile.put("querystring", thisSearch.queryString);+ searchProfile.put("time", trackerHandle);+ searchProfile.put("host", client);+ searchProfile.put("offset", new Integer(0));+ searchProfile.put("results", accu);+ sb.localSearches.add(searchProfile);+ TreeSet handles = (TreeSet) sb.localSearchTracker.get(client);+ if (handles == null) handles = new TreeSet();+ handles.add(trackerHandle);+ sb.localSearchTracker.put(client, handles);+ //**//prop=sb.searchFromLocal(thisSearch, ranking, localTiming, remoteTiming, true, (String) header.get("CLIENTIP"));prop=new serverObjects();//prop.put("references", 0);URL wordURL=null;- prop.put("num-results_totalcount", results.getTotalcount());- prop.put("num-results_filteredcount", results.getFilteredcount());- prop.put("num-results_orderedcount", results.getOrderedcount());- prop.put("num-results_linkcount", results.getLinkcount());+ prop.put("num-results_totalcount", acc.getTotalCount());+ prop.put("num-results_filteredcount", acc.filteredResults);+ prop.put("num-results_orderedcount", acc.sizeOrdered());+ prop.put("num-results_globalresults", acc.globalContributions);+ prop.put("num-results_linkcount", 0);prop.put("type_results", 0);- if(results.numResults()!=0){- //we've got results- prop.put("num-results_totalcount", results.getTotalcount());- prop.put("num-results_filteredcount", results.getFilteredcount());- prop.put("num-results_orderedcount", Integer.toString(results.getOrderedcount())); //why toString?- prop.put("num-results_globalresults", results.getGlobalresults());- for(int i=0;i<results.numResults();i++){- plasmaSearchResults.searchResult result=results.getResult(i);- prop.put("type_results_" + i + "_authorized_recommend", (yacyCore.newsPool.getSpecific(yacyNewsPool.OUTGOING_DB, yacyNewsPool.CATEGORY_SURFTIPP_ADD, "url", result.getUrl()) == null) ? 1 : 0);- prop.put("type_results_" + i + "_authorized_recommend_deletelink", "/yacysearch.html?search=" + results.getFormerSearch() + "&Enter=Search&count=" + results.getQuery().wantedResults + "&order=" + crypt.simpleEncode(results.getRanking().toExternalString()) + "&resource=local&time=3&deleteref=" + result.getUrlhash() + "&urlmaskfilter=.*");- prop.put("type_results_" + i + "_authorized_recommend_recommendlink", "/yacysearch.html?search=" + results.getFormerSearch() + "&Enter=Search&count=" + results.getQuery().wantedResults + "&order=" + crypt.simpleEncode(results.getRanking().toExternalString()) + "&resource=local&time=3&recommendref=" + result.getUrlhash() + "&urlmaskfilter=.*");- prop.put("type_results_" + i + "_authorized_urlhash", result.getUrlhash());- prop.put("type_results_" + i + "_description", result.getUrlentry().comp().title());- prop.put("type_results_" + i + "_url", result.getUrl());- try{- URL url=new URL(result.getUrl());- int port=url.getPort();- URL faviconURL = new URL(url.getProtocol() + "://" + url.getHost() + ((port != -1) ? (":" + String.valueOf(port)) : "") + "/favicon.ico");- // TODO: parse <link rel="favicon" /> ...- // aquire license for favicon url loading- prop.put("type_results_" + i + "_faviconCode", sb.licensedURLs.aquireLicense(faviconURL));- }catch(MalformedURLException e){}- prop.put("type_results_" + i + "_urlhash", result.getUrlhash());- prop.put("type_results_" + i + "_urlhexhash", yacySeed.b64Hash2hexHash(result.getUrlhash()));- prop.put("type_results_" + i + "_urlname", nxTools.shortenURLString(result.getUrlname(), 120));- prop.put("type_results_" + i + "_date", plasmaSwitchboard.dateString(result.getUrlentry().moddate()));- prop.put("type_results_" + i + "_ybr", plasmaSearchPreOrder.ybr(result.getUrlentry().hash()));- prop.put("type_results_" + i + "_size", Long.toString(result.getUrlentry().size()));++ for (int i = 0; i < accu.resultCount(); i++) {+ plasmaSearchResultAccumulator.Entry result = accu.resultEntry(i);+ prop.put("type_results_" + i + "_authorized_recommend", (yacyCore.newsPool.getSpecific(yacyNewsPool.OUTGOING_DB, yacyNewsPool.CATEGORY_SURFTIPP_ADD, "url", result.urlstring()) == null) ? 1 : 0);+ prop.put("type_results_" + i + "_authorized_recommend_deletelink", "/yacysearch.html?search=" + thisSearch.queryString + "&Enter=Search&count=" + thisSearch.wantedResults + "&order=" + crypt.simpleEncode(ranking.toExternalString()) + "&resource=local&time=3&deleteref=" + result.hash() + "&urlmaskfilter=.*");+ prop.put("type_results_" + i + "_authorized_recommend_recommendlink", "/yacysearch.html?search=" + thisSearch.queryString + "&Enter=Search&count=" + thisSearch.wantedResults + "&order=" + crypt.simpleEncode(ranking.toExternalString()) + "&resource=local&time=3&recommendref=" + result.hash() + "&urlmaskfilter=.*");+ prop.put("type_results_" + i + "_authorized_urlhash", result.hash());+ prop.put("type_results_" + i + "_description", result.title());+ prop.put("type_results_" + i + "_url", result.urlstring());+ int port=result.url().getPort();+ URL faviconURL;+ try {+ faviconURL = new URL(result.url().getProtocol() + "://" + result.url().getHost() + ((port != -1) ? (":" + String.valueOf(port)) : "") + "/favicon.ico");+ } catch (MalformedURLException e1) {+ continue;+ }+ prop.put("type_results_" + i + "_faviconCode", sb.licensedURLs.aquireLicense(faviconURL)); // aquire license for favicon url loading+ prop.put("type_results_" + i + "_urlhash", result.hash());+ prop.put("type_results_" + i + "_urlhexhash", yacySeed.b64Hash2hexHash(result.hash()));+ prop.put("type_results_" + i + "_urlname", nxTools.shortenURLString(result.urlname(), 120));+ prop.put("type_results_" + i + "_date", plasmaSwitchboard.dateString(result.modified()));+ prop.put("type_results_" + i + "_ybr", plasmaSearchPreOrder.ybr(result.hash()));+ prop.put("type_results_" + i + "_size", Long.toString(result.filesize()));try {prop.put("type_results_" + i + "_words", URLEncoder.encode(query[0].toString(),"UTF-8"));} catch (UnsupportedEncodingException e) {}- prop.put("type_results_" + i + "_former", results.getFormerSearch());- prop.put("type_results_" + i + "_rankingprops", result.getUrlentry().word().toPropertyForm() + ", domLengthEstimated=" + plasmaURL.domLengthEstimation(result.getUrlhash()) +- ((plasmaURL.probablyRootURL(result.getUrlhash())) ? ", probablyRootURL" : "") +- (((wordURL = plasmaURL.probablyWordURL(result.getUrlhash(), query[0])) != null) ? ", probablyWordURL=" + wordURL.toNormalform(false, true) : ""));+ prop.put("type_results_" + i + "_former", querystring);+ prop.put("type_results_" + i + "_rankingprops", result.word().toPropertyForm() + ", domLengthEstimated=" + plasmaURL.domLengthEstimation(result.hash()) ++ ((plasmaURL.probablyRootURL(result.hash())) ? ", probablyRootURL" : "") ++ (((wordURL = plasmaURL.probablyWordURL(result.hash(), query[0])) != null) ? ", probablyWordURL=" + wordURL.toNormalform(false, true) : ""));// adding snippet if availableif (result.hasSnippet()) {prop.put("type_results_" + i + "_snippet", 1);- prop.putASIS("type_results_" + i + "_snippet_text", result.getSnippet().getLineMarked(results.getQuery().queryHashes));//FIXME: the ASIS should not be needed, if there is no html in .java+ prop.putASIS("type_results_" + i + "_snippet_text", result.textSnippet().getLineMarked(theSearch.getQuery().queryHashes));//FIXME: the ASIS should not be needed, if there is no html in .java} else {if (post.containsKey("fetchSnippet")) {- /* fetch the snippet now */- try {- // snippet fetch timeout- int textsnippet_timeout = Integer.parseInt(env.getConfig("timeout_media", "10000"));-- // boolean line_end_with_punctuation- boolean pre = post.get("pre", "false").equals("true");--// if 'remove' is set to true, then RWI references to URLs that do not have the snippet are removed- boolean remove = post.get("remove", "false").equals("true");-- URL resultURL = new URL(result.getUrl());- plasmaSnippetCache.TextSnippet snippet = sb.snippetCache.retrieveTextSnippet(- resultURL,- queryHashes,- true,- pre,- 260,- textsnippet_timeout- );-- if (snippet.getErrorCode() < 11) {- // no problems occurred- //prop.put("text", (snippet.exists()) ? snippet.getLineMarked(queryHashes) : "unknown");- prop.putASIS("type_results_" + i + "_snippet_text", (snippet.exists()) ? snippet.getLineMarked(queryHashes) : "unknown");- } else {- // problems with snippet fetch- prop.put("type_results_" + i + "_snippet_text", (remove) ? sb.snippetCache.failConsequences(snippet, queryHashes) : snippet.getError());- }- prop.put("type_results_" + i + "_snippet", 1);- } catch (MalformedURLException e) {- prop.put("type_results_" + i + "_snippet", 0);- prop.put("type_results_" + i + "_snippet_text", "");- }+ // snippet fetch timeout+ int textsnippet_timeout = Integer.parseInt(env.getConfig("timeout_media", "10000"));++ // boolean line_end_with_punctuation+ boolean pre = post.get("pre", "false").equals("true");++ // if 'remove' is set to true, then RWI references to URLs that do not have the snippet are removed+ boolean remove = post.get("remove", "false").equals("true");++ plasmaSnippetCache.TextSnippet snippet = plasmaSnippetCache.retrieveTextSnippet(+ result.url(),+ queryHashes,+ true,+ pre,+ 260,+ textsnippet_timeout+ );++ if (snippet.getErrorCode() < 11) {+ // no problems occurred+ //prop.put("text", (snippet.exists()) ? snippet.getLineMarked(queryHashes) : "unknown");+ prop.putASIS("type_results_" + i + "_snippet_text", (snippet.exists()) ? snippet.getLineMarked(queryHashes) : "unknown");+ } else {+ // problems with snippet fetch+ prop.put("type_results_" + i + "_snippet_text", (remove) ? plasmaSnippetCache.failConsequences(snippet, queryHashes) : snippet.getError());+ }+ prop.put("type_results_" + i + "_snippet", 1);} else {/* no snippet available (will be fetched later via ajax) */prop.put("type_results_" + i + "_snippet", 0);prop.put("type_results_" + i + "_snippet_text", "");}}- prop.put("type_results", results.numResults());- prop.put("references", results.getReferences());- prop.put("num-results_linkcount", Integer.toString(results.numResults()));+ prop.put("type_results", accu.resultCount());+ prop.put("num-results_linkcount", Integer.toString(accu.resultCount()));}- }// remember the last search expressionenv.setConfig("last-search", querystring + contentdomString);@@ -513,7 +553,7 @@ public class yacysearch {int columns = post.getInt("columns", 6);URL url = null;try {url = new URL(post.get("url", ""));} catch (MalformedURLException e) {}- plasmaSearchImages si = new plasmaSearchImages(sb.snippetCache, 6000, url, depth);+ plasmaSearchImages si = new plasmaSearchImages(6000, url, depth);Iterator i = si.entries();htmlFilterImageEntry ie;int line = 0;diff --git a/source/de/anomic/plasma/plasmaCrawlLURL.java b/source/de/anomic/plasma/plasmaCrawlLURL.javaindex 1152e6b81..8a1d622ef 100644--- a/source/de/anomic/plasma/plasmaCrawlLURL.java+++ b/source/de/anomic/plasma/plasmaCrawlLURL.java@@ -55,7 +55,6 @@ package de.anomic.plasma;import java.io.File;import java.io.IOException;import java.net.MalformedURLException;-import java.util.Date;import java.util.HashSet;import java.util.Iterator;import java.util.LinkedList;@@ -64,7 +63,6 @@ import de.anomic.http.httpc;import de.anomic.http.httpc.response;import de.anomic.index.indexRWIEntry;import de.anomic.index.indexURLEntry;-import de.anomic.kelondro.kelondroBitfield;import de.anomic.kelondro.kelondroCache;import de.anomic.kelondro.kelondroCloneableIterator;import de.anomic.kelondro.kelondroException;@@ -206,33 +204,7 @@ public final class plasmaCrawlLURL {return null;}}-- public synchronized indexURLEntry newEntry(- URL url,- String descr,- String author,- String tags,- String ETag,- Date mod,- Date load,- Date fresh,- String referrer,- byte[] md5,- long size,- int wc,- char dt,- kelondroBitfield flags,- String lang,- int llocal,- int lother,- int laudio,- int limage,- int lvideo,- int lapp) {- return new indexURLEntry(url, descr, author, tags, ETag, mod, load, fresh, referrer, md5,- size, wc, dt, flags, lang, llocal, lother, laudio, limage, lvideo, lapp);- }-+public synchronized int getStackSize(int stack) {switch (stack) {case 1: return externResultStack.size();@@ -554,8 +526,7 @@ public final class plasmaCrawlLURL {}}}--+public static void main(String[] args) {// test-generation of url hashes for debugging// one argument requires, will be treated as urldiff --git a/source/de/anomic/plasma/plasmaSearchEvent.java b/source/de/anomic/plasma/plasmaSearchEvent.javaindex df0cfd1b4..227eb2be9 100644--- a/source/de/anomic/plasma/plasmaSearchEvent.java+++ b/source/de/anomic/plasma/plasmaSearchEvent.java@@ -27,7 +27,6 @@package de.anomic.plasma;import java.util.HashMap;-import java.util.HashSet;import java.util.Iterator;import java.util.Map;import java.util.TreeMap;@@ -38,20 +37,14 @@ import de.anomic.server.logging.serverLog;import de.anomic.yacy.yacyCore;import de.anomic.yacy.yacySearch;-public final class plasmaSearchEvent extends Thread implements Runnable {+public final class plasmaSearchEvent {public static plasmaSearchEvent lastEvent = null;- private static HashSet flushThreads = new HashSet();-- private serverLog log;private plasmaSearchQuery query;private plasmaSearchRankingProfile ranking;private plasmaWordIndex wordIndex;- private plasmaCrawlLURL urlStore;- private plasmaSnippetCache snippetCache;private indexContainer rcContainers; // cache for results- private int rcContainerFlushCount;private Map rcAbstracts; // cache for index abstracts; word:TreeMap mapping where the embedded TreeMap is a urlhash:peerlist relationprivate plasmaSearchProcessing profileLocal, profileGlobal;private boolean postsort;@@ -65,18 +58,12 @@ public final class plasmaSearchEvent extends Thread implements Runnable {plasmaSearchProcessing localTiming,plasmaSearchProcessing remoteTiming,boolean postsort,- serverLog log,plasmaWordIndex wordIndex,- plasmaSnippetCache snippetCache,TreeMap preselectedPeerHashes) {- this.log = log;this.wordIndex = wordIndex;this.query = query;this.ranking = ranking;- this.urlStore = wordIndex.loadedURL;- this.snippetCache = snippetCache;this.rcContainers = plasmaWordIndex.emptyContainer(null);- this.rcContainerFlushCount = 0;this.rcAbstracts = (query.queryHashes.size() > 1) ? new TreeMap() : null; // generate abstracts only for combined searchesthis.profileLocal = localTiming;this.profileGlobal = remoteTiming;@@ -118,9 +105,6 @@ public final class plasmaSearchEvent extends Thread implements Runnable {public plasmaSearchPostOrder search() {// combine all threads- // we synchronize with flushThreads to allow only one local search at a time,- // so all search tasks are queued- synchronized (flushThreads) {long start = System.currentTimeMillis();plasmaSearchPostOrder result;if ((query.domType == plasmaSearchQuery.SEARCHDOM_GLOBALDHT) ||@@ -131,12 +115,24 @@ public final class plasmaSearchEvent extends Thread implements Runnable {// do a global search// the result of the fetch is then in the rcGlobal- log.logFine("STARTING " + fetchpeers + " THREADS TO CATCH EACH " + profileGlobal.getTargetCount(plasmaSearchProcessing.PROCESS_POSTSORT) + " URLs WITHIN " + (profileGlobal.duetime() / 1000) + " SECONDS");+ serverLog.logFine("SEARCH_EVENT", "STARTING " + fetchpeers + " THREADS TO CATCH EACH " + profileGlobal.getTargetCount(plasmaSearchProcessing.PROCESS_POSTSORT) + " URLs WITHIN " + (profileGlobal.duetime() / 1000) + " SECONDS");long secondaryTimeout = System.currentTimeMillis() + profileGlobal.duetime() / 3 * 2;long primaryTimeout = System.currentTimeMillis() + profileGlobal.duetime();- primarySearchThreads = yacySearch.primaryRemoteSearches(plasmaSearchQuery.hashSet2hashString(query.queryHashes), plasmaSearchQuery.hashSet2hashString(query.excludeHashes), "",- query.prefer, query.urlMask, query.maxDistance, urlStore, wordIndex, rcContainers, rcAbstracts,- fetchpeers, plasmaSwitchboard.urlBlacklist, snippetCache, profileGlobal, ranking, query.constraint,+ primarySearchThreads = yacySearch.primaryRemoteSearches(+ plasmaSearchQuery.hashSet2hashString(query.queryHashes),+ plasmaSearchQuery.hashSet2hashString(query.excludeHashes),+ "",+ query.prefer,+ query.urlMask,+ query.maxDistance,+ wordIndex,+ rcContainers,+ rcAbstracts,+ fetchpeers,+ plasmaSwitchboard.urlBlacklist,+ profileGlobal,+ ranking,+ query.constraint,(query.domType == plasmaSearchQuery.SEARCHDOM_GLOBALDHT) ? null : preselectedPeerHashes);// meanwhile do a local search@@ -198,7 +194,7 @@ public final class plasmaSearchEvent extends Thread implements Runnable {int globalContributions = rcContainers.size();// finished searching- log.logFine("SEARCH TIME AFTER GLOBAL-TRIGGER TO " + primarySearchThreads.length + " PEERS: " + ((System.currentTimeMillis() - start) / 1000) + " seconds");+ serverLog.logFine("SEARCH_EVENT", "SEARCH TIME AFTER GLOBAL-TRIGGER TO " + primarySearchThreads.length + " PEERS: " + ((System.currentTimeMillis() - start) / 1000) + " seconds");// combine the result and orderindexContainer searchResult = plasmaWordIndex.emptyContainer(null);@@ -215,9 +211,6 @@ public final class plasmaSearchEvent extends Thread implements Runnable {if (result != null) {result.globalContributions = globalContributions;-- // flush results in a separate thread- this.start(); // start to flush results}} else {Map[] searchContainerMaps = profileLocal.localSearchContainers(query, wordIndex, null);@@ -242,7 +235,7 @@ public final class plasmaSearchEvent extends Thread implements Runnable {}// log the event- log.logFine("SEARCHRESULT: " + profileLocal.reportToString());+ serverLog.logFine("SEARCH_EVENT", "SEARCHRESULT: " + profileLocal.reportToString());// prepare values for statisticslastEvent = this;@@ -251,7 +244,6 @@ public final class plasmaSearchEvent extends Thread implements Runnable {// return search resultreturn result;- }}private void prepareSecondarySearch() {@@ -311,7 +303,7 @@ public final class plasmaSearchEvent extends Thread implements Runnable {System.out.println("DEBUG-INDEXABSTRACT ***: peer " + peer + " has urls: " + urls);System.out.println("DEBUG-INDEXABSTRACT ***: peer " + peer + " from words: " + words);secondarySearchThreads[c++] = yacySearch.secondaryRemoteSearch(- words, "", urls, urlStore, wordIndex, rcContainers, peer, plasmaSwitchboard.urlBlacklist, snippetCache,+ words, "", urls, wordIndex, rcContainers, peer, plasmaSwitchboard.urlBlacklist,profileGlobal, ranking, query.constraint, preselectedPeerHashes);}@@ -346,64 +338,4 @@ public final class plasmaSearchEvent extends Thread implements Runnable {return wordlist;}- public void run() {- flushThreads.add(this); // this will care that the search event object is referenced from somewhere while it is still alive-- // put all new results into wordIndex- // this must be called after search results had been computed- // it is wise to call this within a separate thread because- // this method waits until all threads are finished- serverLog.logFine("PLASMA", "STARTED FLUSHING GLOBAL SEARCH RESULTS FOR SEARCH " + query.queryString);-- int remaining = 0;- if (primarySearchThreads == null) return;- long starttime = System.currentTimeMillis();- while (true) {- flushGlobalResults(); // must be flushed before first check of remaining threads, othervise it is possible that NO results are flushed at all-- remaining = yacySearch.remainingWaiting(primarySearchThreads);- if (secondarySearchThreads != null) remaining += yacySearch.remainingWaiting(secondarySearchThreads);- if (remaining == 0) break;-- // wait a little bit before trying again- try {Thread.sleep(1000);} catch (InterruptedException e) {}- if (System.currentTimeMillis() - starttime > 90000) {- yacySearch.interruptAlive(primarySearchThreads);- if (secondarySearchThreads != null) yacySearch.interruptAlive(secondarySearchThreads);- log.logFine("SEARCH FLUSH: " + remaining + " PEERS STILL BUSY; ABANDONED; SEARCH WAS " + query.queryString);- break;- }- //log.logFine("FINISHED FLUSH RESULTS PROCESS for query " + query.hashes(","));- }-- serverLog.logFine("PLASMA", "FINISHED FLUSHING " + rcContainerFlushCount + " GLOBAL SEARCH RESULTS FOR SEARCH " + query.queryString);-- // finally delete the temporary index- rcContainers = null;-- flushThreads.remove(this);- }-- public void flushGlobalResults() {- // flush the rcGlobal as much as is there so far- // this must be called sometime after search results had been computed- int count = 0;- if ((rcContainers != null) && (rcContainers.size() > 0)) {- synchronized (rcContainers) {- String wordHash;- Iterator hashi = query.queryHashes.iterator();- while (hashi.hasNext()) {- wordHash = (String) hashi.next();- rcContainers.setWordHash(wordHash);- wordIndex.addEntries(rcContainers, System.currentTimeMillis(), true);- log.logFine("FLUSHED " + wordHash + ": " + rcContainers.size() + " url entries");- }- // the rcGlobal was flushed, empty it- count += rcContainers.size();- rcContainers.clear();- }- }- rcContainerFlushCount += count;- }-}diff --git a/source/de/anomic/plasma/plasmaSearchImages.java b/source/de/anomic/plasma/plasmaSearchImages.javaindex 2dd85db6f..5078d44a8 100644--- a/source/de/anomic/plasma/plasmaSearchImages.java+++ b/source/de/anomic/plasma/plasmaSearchImages.java@@ -57,18 +57,18 @@ public final class plasmaSearchImages {private TreeSet images;- public plasmaSearchImages(plasmaSnippetCache sc, long maxTime, URL url, int depth) {+ public plasmaSearchImages(long maxTime, URL url, int depth) {long start = System.currentTimeMillis();this.images = new TreeSet();if (maxTime > 10) {- Object[] resource = sc.getResource(url, true, (int) maxTime, false);+ Object[] resource = plasmaSnippetCache.getResource(url, true, (int) maxTime, false);InputStream res = (InputStream) resource[0];Long resLength = (Long) resource[1];if (res != null) {plasmaParserDocument document = null;try {// parse the document- document = sc.parseDocument(url, resLength.longValue(), res);+ document = plasmaSnippetCache.parseDocument(url, resLength.longValue(), res);} catch (ParserException e) {// parsing failed} finally {@@ -88,7 +88,7 @@ public final class plasmaSearchImages {String nexturlstring;try {nexturlstring = new URL((String) e.getKey()).toNormalform(true, true);- addAll(new plasmaSearchImages(sc, serverDate.remainingTime(start, maxTime, 10), new URL(nexturlstring), depth - 1));+ addAll(new plasmaSearchImages(serverDate.remainingTime(start, maxTime, 10), new URL(nexturlstring), depth - 1));} catch (MalformedURLException e1) {e1.printStackTrace();}@@ -99,13 +99,13 @@ public final class plasmaSearchImages {}}- public plasmaSearchImages(plasmaSnippetCache sc, long maxTime, plasmaSearchPostOrder sres, int depth) {+ public plasmaSearchImages(long maxTime, plasmaSearchPostOrder sres, int depth) {long start = System.currentTimeMillis();this.images = new TreeSet();indexURLEntry urlentry;while (sres.hasMoreElements()) {urlentry = sres.nextElement();- addAll(new plasmaSearchImages(sc, serverDate.remainingTime(start, maxTime, 10), urlentry.comp().url(), depth));+ addAll(new plasmaSearchImages(serverDate.remainingTime(start, maxTime, 10), urlentry.comp().url(), depth));}}diff --git a/source/de/anomic/plasma/plasmaSearchPostOrder.java b/source/de/anomic/plasma/plasmaSearchPostOrder.javaindex 292ef05b0..501f9b25a 100644--- a/source/de/anomic/plasma/plasmaSearchPostOrder.java+++ b/source/de/anomic/plasma/plasmaSearchPostOrder.java@@ -101,6 +101,10 @@ public final class plasmaSearchPostOrder {return pageAcc.size() > 0;}+ public int getTotalCount() {+ return this.localContributions + this.globalContributions;+ }+public indexURLEntry nextElement() {Object top = pageAcc.firstKey();//System.out.println("postorder-key: " + ((String) top));diff --git a/source/de/anomic/plasma/plasmaSearchResultAccumulator.java b/source/de/anomic/plasma/plasmaSearchResultAccumulator.javanew file mode 100644index 000000000..a1ff7bfc2--- /dev/null+++ b/source/de/anomic/plasma/plasmaSearchResultAccumulator.java@@ -0,0 +1,191 @@+// plasmaSearchResultAccumulator.java+// (C) 2007 by Michael Peter Christen; [email protected], Frankfurt a. M., Germany+// first published 15.08.2007 on http://yacy.net+//+// This is a part of YaCy, a peer-to-peer based web search engine+//+// $LastChangedDate: 2006-04-02 22:40:07 +0200 (So, 02 Apr 2006) $+// $LastChangedRevision: 1986 $+// $LastChangedBy: orbiter $+//+// LICENSE+//+// This program is free software; you can redistribute it and/or modify+// it under the terms of the GNU General Public License as published by+// the Free Software Foundation; either version 2 of the License, or+// (at your option) any later version.+//+// This program is distributed in the hope that it will be useful,+// but WITHOUT ANY WARRANTY; without even the implied warranty of+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+// GNU General Public License for more details.+//+// You should have received a copy of the GNU General Public License+// along with this program; if not, write to the Free Software+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA+++package de.anomic.plasma;++import java.io.UnsupportedEncodingException;+import java.util.ArrayList;+import java.util.Date;+import java.util.TreeSet;++import de.anomic.index.indexRWIEntry;+import de.anomic.index.indexURLEntry;+import de.anomic.kelondro.kelondroBitfield;+import de.anomic.net.URL;+import de.anomic.yacy.yacyCore;+import de.anomic.yacy.yacySeed;++public class plasmaSearchResultAccumulator {++ private ArrayList hits;++ public plasmaSearchResultAccumulator(plasmaSearchEvent theSearch, plasmaWordIndex wordIndex, TreeSet blueList) {++ hits = new ArrayList();+ plasmaSearchPostOrder acc = theSearch.search();++ // fetch urls+ int i = 0;+ Entry entry;+ boolean includeSnippets = false;+ while ((acc.hasMoreElements()) && (i < theSearch.getQuery().wantedResults)) {+ try {+ entry = new Entry(acc.nextElement(), wordIndex);+ } catch (RuntimeException e) {+ continue;+ }+ // check bluelist again: filter out all links where any+ // bluelisted word+ // appear either in url, url's description or search word+ // the search word was sorted out earlier+ /*+ * String s = descr.toLowerCase() + url.toString().toLowerCase();+ * for (int c = 0; c < blueList.length; c++) { if+ * (s.indexOf(blueList[c]) >= 0) return; }+ */+ if (includeSnippets) {+ entry.setSnippet(plasmaSnippetCache.retrieveTextSnippet(+ entry.url(), theSearch.getQuery().queryHashes, false,+ entry.flags().get(plasmaCondenser.flag_cat_indexof), 260,+ 1000));+ // snippet =+ // snippetCache.retrieveTextSnippet(comp.url(),+ // query.queryHashes, false,+ // urlentry.flags().get(plasmaCondenser.flag_cat_indexof),+ // 260, 1000);+ } else {+ // snippet = null;+ entry.setSnippet(null);+ }+ i++;+ hits.add(entry);+ }++ /*+ * while ((acc.hasMoreElements()) && (((time + timestamp) <+ * System.currentTimeMillis()))) { urlentry = acc.nextElement();+ * urlstring = htmlFilterContentScraper.urlNormalform(urlentry.url());+ * descr = urlentry.descr();+ *+ * addScoreForked(ref, gs, descr.split(" ")); addScoreForked(ref, gs,+ * urlstring.split("/")); }+ */++ }++ public int resultCount() {+ return hits.size();+ }++ public Entry resultEntry(int i) {+ return (Entry) hits.get(i);+ }++ public static class Entry {+ private indexURLEntry urlentry;+ private indexURLEntry.Components urlcomps; // buffer for components+ private String alternative_urlstring;+ private String alternative_urlname;+ private plasmaSnippetCache.TextSnippet snippet;++ public Entry(indexURLEntry urlentry, plasmaWordIndex wordIndex) {+ this.urlentry = urlentry;+ this.urlcomps = urlentry.comp();+ this.alternative_urlstring = null;+ this.alternative_urlname = null;+ this.snippet = null;+ String host = urlcomps.url().getHost();+ if (host.endsWith(".yacyh")) {+ // translate host into current IP+ int p = host.indexOf(".");+ String hash = yacySeed.hexHash2b64Hash(host.substring(p + 1, host.length() - 6));+ yacySeed seed = yacyCore.seedDB.getConnected(hash);+ String filename = urlcomps.url().getFile();+ String address = null;+ if ((seed == null) || ((address = seed.getPublicAddress()) == null)) {+ // seed is not known from here+ try {+ wordIndex.removeWordReferences(+ plasmaCondenser.getWords(+ ("yacyshare " ++ filename.replace('?', ' ') ++ " " ++ urlcomps.title()).getBytes(), "UTF-8").keySet(),+ urlentry.hash());+ wordIndex.loadedURL.remove(urlentry.hash()); // clean up+ throw new RuntimeException("index void");+ } catch (UnsupportedEncodingException e) {+ throw new RuntimeException("parser failed: " + e.getMessage());+ }+ }+ alternative_urlstring = "http://" + address + "/" + host.substring(0, p) + filename;+ alternative_urlname = "http://share." + seed.getName() + ".yacy" + filename;+ if ((p = alternative_urlname.indexOf("?")) > 0) alternative_urlname = alternative_urlname.substring(0, p);+ }+ }+ public String hash() {+ return urlentry.hash();+ }+ public URL url() {+ return urlcomps.url();+ }+ public kelondroBitfield flags() {+ return urlentry.flags();+ }+ public String urlstring() {+ return (alternative_urlstring == null) ? urlcomps.url().toNormalform(false, true) : alternative_urlstring;+ }+ public String urlname() {+ return (alternative_urlname == null) ? urlcomps.url().toNormalform(false, true) : alternative_urlname;+ }+ public String title() {+ return urlcomps.title();+ }+ public void setSnippet(plasmaSnippetCache.TextSnippet snippet) {+ this.snippet = snippet;+ }+ public plasmaSnippetCache.TextSnippet snippet() {+ return this.snippet;+ }+ public Date modified() {+ return urlentry.moddate();+ }+ public int filesize() {+ return urlentry.size();+ }+ public indexRWIEntry word() {+ return urlentry.word();+ }+ public boolean hasSnippet() {+ return false;+ }+ public plasmaSnippetCache.TextSnippet textSnippet() {+ return null;+ }+ }++}diff --git a/source/de/anomic/plasma/plasmaSearchResults.java b/source/de/anomic/plasma/plasmaSearchResults.javadeleted file mode 100644index bdb5f5b7a..000000000--- a/source/de/anomic/plasma/plasmaSearchResults.java+++ /dev/null@@ -1,163 +0,0 @@-// plasmaSearchResults.java - a container for search results-// ----------------------------------------------------------// part of YaCy-//-// (C) 2007 by Alexander Schier-//-// last change: $LastChangedDate: $ by $LastChangedBy: $-// $LastChangedRevision: $-//-// This program is free software; you can redistribute it and/or modify-// it under the terms of the GNU General Public License as published by-// the Free Software Foundation; either version 2 of the License, or-// (at your option) any later version.-//-// This program is distributed in the hope that it will be useful,-// but WITHOUT ANY WARRANTY; without even the implied warranty of-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-// GNU General Public License for more details.-//-// You should have received a copy of the GNU General Public License-// along with this program; if not, write to the Free Software-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA--package de.anomic.plasma;-import java.util.ArrayList;--import de.anomic.index.indexURLEntry;--public class plasmaSearchResults {- private int totalcount=0;- private int filteredcount=0;- private int orderedcount=0;- private int linkcount=0;- private int globalresults=0;- private plasmaSearchRankingProfile ranking=null;- private String formerSearch="";- private plasmaSearchQuery query=null;- private ArrayList results=null;- private Object[] references=null;-- public plasmaSearchResults(){- this.results=new ArrayList();- }- public plasmaSearchResults(int totalcount, int filteredcount, int orderedcount, int linkcount){- this.results=new ArrayList();- this.totalcount=totalcount;- this.filteredcount=filteredcount;- this.orderedcount=orderedcount;- this.linkcount=linkcount;- }- public void appendResult(searchResult result){- if (results==null)- results=new ArrayList();- results.add(result);- }- public int numResults(){- if(results==null) return 0;- return results.size();- }- public searchResult getResult(int index){- if(results==null || results.size()-1<index)- return null;- return (searchResult)results.get(index);- }- public void setTotalcount(int totalcount) {- this.totalcount = totalcount;- }- public int getTotalcount() {- return totalcount;- }- public void setFilteredcount(int filteredcount) {- this.filteredcount = filteredcount;- }- public int getFilteredcount() {- return filteredcount;- }- public void setOrderedcount(int orderedcount) {- this.orderedcount = orderedcount;- }- public int getOrderedcount() {- return orderedcount;- }- public void setLinkcount(int linkcount) {- this.linkcount = linkcount;- }- public int getLinkcount() {- return linkcount;- }- public void setGlobalresults(int globalresults) {- this.globalresults = globalresults;- }- public int getGlobalresults() {- return globalresults;- }- public void setRanking(plasmaSearchRankingProfile ranking) {- this.ranking = ranking;- }- public plasmaSearchRankingProfile getRanking() {- return ranking;- }- public searchResult createSearchResult(){- return new searchResult();- }- public void setFormerSearch(String formerSearch) {- this.formerSearch = formerSearch;- }- public String getFormerSearch() {- return formerSearch;- }- public void setQuery(plasmaSearchQuery query) {- this.query = query;- }- public plasmaSearchQuery getQuery() {- return query;- }- public void setReferences(Object[] references) {- this.references = references;- }- public Object[] getReferences() {- return references;- }- public class searchResult{- private String url="";- private String urlname="";- private plasmaSnippetCache.TextSnippet snippet=null;- private indexURLEntry urlentry=null;-- public searchResult(){-- }-- public void setUrl(String url) {- this.url = url;- }- public String getUrl() {- return url;- }- public void setUrlname(String urlname) {- this.urlname = urlname;- }- public String getUrlname() {- return urlname;- }- public void setSnippet(plasmaSnippetCache.TextSnippet snippet) {- this.snippet = snippet;- }- public plasmaSnippetCache.TextSnippet getSnippet() {- return snippet;- }- public void setUrlentry(indexURLEntry urlentry) {- this.urlentry = urlentry;- }- public indexURLEntry getUrlentry() {- return urlentry;- }- public String getUrlhash(){- return urlentry.hash();- }- public boolean hasSnippet(){- return this.snippet!=null && this.snippet.exists();- }- }-}diff --git a/source/de/anomic/plasma/plasmaSnippetCache.java b/source/de/anomic/plasma/plasmaSnippetCache.javaindex bc92207e3..0f7aefd87 100644--- a/source/de/anomic/plasma/plasmaSnippetCache.java+++ b/source/de/anomic/plasma/plasmaSnippetCache.java@@ -86,9 +86,9 @@ public class plasmaSnippetCache {public static final int ERROR_PARSER_NO_LINES = 15;public static final int ERROR_NO_MATCH = 16;- private int snippetsScoreCounter;- private kelondroMScoreCluster snippetsScore;- private HashMap snippetsCache;+ private static int snippetsScoreCounter;+ private static kelondroMScoreCluster snippetsScore;+ private static HashMap snippetsCache;/*** a cache holding URLs to favicons specified by the page content, e.g. by using the html link-tag. e.g.@@ -96,29 +96,26 @@ public class plasmaSnippetCache {* <link rel="shortcut icon" type="image/x-icon" href="../src/favicon.ico">* </pre>*/- private HashMap faviconCache;- private plasmaHTCache cacheManager;- private plasmaParser parser;- private serverLog log;- private plasmaSwitchboard sb;+ private static HashMap faviconCache;+ private static plasmaHTCache cacheManager;+ private static plasmaParser parser;+ private static serverLog log;- public plasmaSnippetCache(- plasmaSwitchboard theSb,- plasmaHTCache cacheManager,- plasmaParser parser,- serverLog log+ public static void init(+ plasmaHTCache cacheManagerx,+ plasmaParser parserx,+ serverLog logx) {- this.cacheManager = cacheManager;- this.parser = parser;- this.log = log;- this.sb = theSb;- this.snippetsScoreCounter = 0;- this.snippetsScore = new kelondroMScoreCluster();- this.snippetsCache = new HashMap();- this.faviconCache = new HashMap();+ cacheManager = cacheManagerx;+ parser = parserx;+ log = logx;+ snippetsScoreCounter = 0;+ snippetsScore = new kelondroMScoreCluster();+ snippetsCache = new HashMap();+ faviconCache = new HashMap();}- public class TextSnippet {+ public static class TextSnippet {private URL url;private String line;private String error;@@ -235,7 +232,7 @@ public class plasmaSnippetCache {}}- public class MediaSnippet {+ public static class MediaSnippet {public String type, href, name, attr;public MediaSnippet(String type, String href, String name, String attr) {this.type = type;@@ -247,12 +244,12 @@ public class plasmaSnippetCache {}}- public boolean existsInCache(URL url, Set queryhashes) {+ public static boolean existsInCache(URL url, Set queryhashes) {String hashes = yacySearch.set2string(queryhashes);return retrieveFromCache(hashes, plasmaURL.urlHash(url)) != null;}- public TextSnippet retrieveTextSnippet(URL url, Set queryhashes, boolean fetchOnline, boolean pre, int snippetMaxLength, int timeout) {+ public static TextSnippet retrieveTextSnippet(URL url, Set queryhashes, boolean fetchOnline, boolean pre, int snippetMaxLength, int timeout) {// heise = "0OQUNU3JSs05"if (queryhashes.size() == 0) {//System.out.println("found no queryhashes for URL retrieve " + url);@@ -266,7 +263,7 @@ public class plasmaSnippetCache {String line = retrieveFromCache(wordhashes, urlhash);if (line != null) {//System.out.println("found snippet for URL " + url + " in cache: " + line);- return new TextSnippet(url, line, source, null, null,(URL)this.faviconCache.get(urlhash));+ return new TextSnippet(url, line, source, null, null,(URL) faviconCache.get(urlhash));}/* ===========================================================================@@ -278,10 +275,10 @@ public class plasmaSnippetCache {IResourceInfo resInfo = null;try {// trying to load the resource from the cache- resContent = this.cacheManager.getResourceContentStream(url);+ resContent = cacheManager.getResourceContentStream(url);if (resContent != null) {// if the content was found- resContentLength = this.cacheManager.getResourceContentLength(url);+ resContentLength = cacheManager.getResourceContentLength(url);} else if (fetchOnline) {// if not found try to download it@@ -298,8 +295,8 @@ public class plasmaSnippetCache {resContent = new ByteArrayInputStream(resourceArray);resContentLength = resourceArray.length;} else {- resContent = this.cacheManager.getResourceContentStream(url);- resContentLength = this.cacheManager.getResourceContentLength(url);+ resContent = cacheManager.getResourceContentStream(url);+ resContentLength = cacheManager.getResourceContentLength(url);}}@@ -333,7 +330,7 @@ public class plasmaSnippetCache {* COMPUTE SNIPPET* =========================================================================== */URL resFavicon = document.getFavicon();- if (resFavicon != null) this.faviconCache.put(urlhash,resFavicon);+ if (resFavicon != null) faviconCache.put(urlhash,resFavicon);// we have found a parseable non-empty file: use the lines// compute snippet from text@@ -375,7 +372,7 @@ public class plasmaSnippetCache {* @param fetchOnline specifies if the resource should be loaded from web if it'as not available in the cache* @return the parsed document as {@link plasmaParserDocument}*/- public plasmaParserDocument retrieveDocument(URL url, boolean fetchOnline, int timeout, boolean forText) {+ public static plasmaParserDocument retrieveDocument(URL url, boolean fetchOnline, int timeout, boolean forText) {// load resourcelong resContentLength = 0;@@ -383,10 +380,10 @@ public class plasmaSnippetCache {IResourceInfo resInfo = null;try {// trying to load the resource from the cache- resContent = this.cacheManager.getResourceContentStream(url);+ resContent = cacheManager.getResourceContentStream(url);if (resContent != null) {// if the content was found- resContentLength = this.cacheManager.getResourceContentLength(url);+ resContentLength = cacheManager.getResourceContentLength(url);} else if (fetchOnline) {// if not found try to download it@@ -403,8 +400,8 @@ public class plasmaSnippetCache {resContent = new ByteArrayInputStream(resourceArray);resContentLength = resourceArray.length;} else {- resContent = this.cacheManager.getResourceContentStream(url);- resContentLength = this.cacheManager.getResourceContentLength(url);+ resContent = cacheManager.getResourceContentStream(url);+ resContentLength = cacheManager.getResourceContentLength(url);}}@@ -436,7 +433,7 @@ public class plasmaSnippetCache {}- public void storeToCache(String wordhashes, String urlhash, String snippet) {+ public static void storeToCache(String wordhashes, String urlhash, String snippet) {// generate keyString key = urlhash + wordhashes;@@ -462,13 +459,13 @@ public class plasmaSnippetCache {}}- private String retrieveFromCache(String wordhashes, String urlhash) {+ private static String retrieveFromCache(String wordhashes, String urlhash) {// generate keyString key = urlhash + wordhashes;return (String) snippetsCache.get(key);}- private String computeMediaSnippet(Map media, Set queryhashes) {+ private static String computeMediaSnippet(Map media, Set queryhashes) {Iterator i = media.entrySet().iterator();Map.Entry entry;String url, desc;@@ -493,7 +490,7 @@ public class plasmaSnippetCache {return result.substring(6);}- private Object[] /*{String - the snippet, Set - remaining hashes}*/+ private static Object[] /*{String - the snippet, Set - remaining hashes}*/computeTextSnippet(Iterator sentences, Set queryhashes, int maxLength) {try {if (sentences == null) return null;@@ -552,7 +549,7 @@ public class plasmaSnippetCache {}}- private Object[] /*{String - the snippet, Set - remaining hashes}*/+ private static Object[] /*{String - the snippet, Set - remaining hashes}*/computeTextSnippet(String sentence, Set queryhashes, int maxLength) {try {if (sentence == null) return null;@@ -620,7 +617,7 @@ public class plasmaSnippetCache {}}- public ArrayList retrieveMediaSnippets(URL url, Set queryhashes, String mediatype, boolean fetchOnline, int timeout) {+ public static ArrayList retrieveMediaSnippets(URL url, Set queryhashes, String mediatype, boolean fetchOnline, int timeout) {if (queryhashes.size() == 0) {serverLog.logFine("snippet fetch", "no query hashes given for url " + url);return new ArrayList();@@ -638,7 +635,7 @@ public class plasmaSnippetCache {return a;}- public ArrayList computeMediaSnippets(plasmaParserDocument document, Set queryhashes, String mediatype) {+ public static ArrayList computeMediaSnippets(plasmaParserDocument document, Set queryhashes, String mediatype) {if (document == null) return new ArrayList();Map media = null;@@ -671,7 +668,7 @@ public class plasmaSnippetCache {return result;}- public ArrayList computeImageSnippets(plasmaParserDocument document, Set queryhashes) {+ public static ArrayList computeImageSnippets(plasmaParserDocument document, Set queryhashes) {TreeSet images = document.getImages();@@ -699,7 +696,7 @@ public class plasmaSnippetCache {return result;}- private Set removeAppearanceHashes(String sentence, Set queryhashes) {+ private static Set removeAppearanceHashes(String sentence, Set queryhashes) {// remove all hashes that appear in the sentenceif (sentence == null) return queryhashes;HashMap hs = hashSentence(sentence);@@ -717,7 +714,7 @@ public class plasmaSnippetCache {return remaininghashes;}- private HashMap hashSentence(String sentence) {+ private static HashMap hashSentence(String sentence) {// generates a word-wordPos mappingHashMap map = new HashMap();Enumeration words = plasmaCondenser.wordTokenizer(sentence, "UTF-8", 0);@@ -731,7 +728,7 @@ public class plasmaSnippetCache {return map;}- public plasmaParserDocument parseDocument(URL url, long contentLength, InputStream resourceStream) throws ParserException {+ public static plasmaParserDocument parseDocument(URL url, long contentLength, InputStream resourceStream) throws ParserException {return parseDocument(url, contentLength, resourceStream, null);}@@ -744,7 +741,7 @@ public class plasmaSnippetCache {* @return the extracted data* @throws ParserException*/- public plasmaParserDocument parseDocument(URL url, long contentLength, InputStream resourceStream, IResourceInfo docInfo) throws ParserException {+ public static plasmaParserDocument parseDocument(URL url, long contentLength, InputStream resourceStream, IResourceInfo docInfo) throws ParserException {try {if (resourceStream == null) return null;@@ -752,7 +749,7 @@ public class plasmaSnippetCache {if (docInfo == null) {// try to get the header from the htcache directorytry {- docInfo = this.cacheManager.loadResourceInfo(url);+ docInfo = cacheManager.loadResourceInfo(url);} catch (Exception e) {// ignore this. resource info loading failed}@@ -765,8 +762,8 @@ public class plasmaSnippetCache {// getting URL mimeTypetry {- httpHeader header = httpc.whead(url, url.getHost(), 10000, null, null, this.sb.remoteProxyConfig);- docInfo = this.cacheManager.getResourceInfoFactory().buildResourceInfoObj(url, header);+ httpHeader header = httpc.whead(url, url.getHost(), 10000, null, null, plasmaSwitchboard.getSwitchboard().remoteProxyConfig);+ docInfo = cacheManager.getResourceInfoFactory().buildResourceInfoObj(url, header);} catch (Exception e) {// ingore this. http header download failed}@@ -774,7 +771,7 @@ public class plasmaSnippetCache {// STEP 3: if the metadata is still null try to guess the mimeType of the resourceif (docInfo == null) {- String filename = this.cacheManager.getCachePath(url).getName();+ String filename = cacheManager.getCachePath(url).getName();int p = filename.lastIndexOf('.');if ( // if no extension is available(p < 0) ||@@ -792,12 +789,12 @@ public class plasmaSnippetCache {supposedMime = plasmaParser.getMimeTypeByFileExt(filename.substring(p + 1));}- return this.parser.parseSource(url, supposedMime, null, contentLength, resourceStream);+ return parser.parseSource(url, supposedMime, null, contentLength, resourceStream);}return null;}if (plasmaParser.supportedMimeTypesContains(docInfo.getMimeType())) {- return this.parser.parseSource(url, docInfo.getMimeType(), docInfo.getCharacterEncoding(), contentLength, resourceStream);+ return parser.parseSource(url, docInfo.getMimeType(), docInfo.getCharacterEncoding(), contentLength, resourceStream);}return null;} catch (InterruptedException e) {@@ -817,15 +814,15 @@ public class plasmaSnippetCache {* <tr><td>[1]</td><td>the content-length as {@link Integer}</td></tr>* </table>*/- public Object[] getResource(URL url, boolean fetchOnline, int socketTimeout, boolean forText) {+ public static Object[] getResource(URL url, boolean fetchOnline, int socketTimeout, boolean forText) {// load the url as resource from the webtry {long contentLength = -1;// trying to load the resource body from cache- InputStream resource = this.cacheManager.getResourceContentStream(url);+ InputStream resource = cacheManager.getResourceContentStream(url);if (resource != null) {- contentLength = this.cacheManager.getResourceContentLength(url);+ contentLength = cacheManager.getResourceContentLength(url);} else if (fetchOnline) {// if the content is not available in cache try to download it from web@@ -837,8 +834,8 @@ public class plasmaSnippetCache {// in case that the reosurce was not in ram, read it from diskif (resourceArray == null) {- resource = this.cacheManager.getResourceContentStream(url);- contentLength = this.cacheManager.getResourceContentLength(url);+ resource = cacheManager.getResourceContentStream(url);+ contentLength = cacheManager.getResourceContentLength(url);} else {resource = new ByteArrayInputStream(resourceArray);contentLength = resourceArray.length;@@ -852,20 +849,20 @@ public class plasmaSnippetCache {}}- public plasmaHTCache.Entry loadResourceFromWeb(+ public static plasmaHTCache.Entry loadResourceFromWeb(URL url,int socketTimeout,boolean keepInMemory,boolean forText) throws plasmaCrawlerException {- plasmaHTCache.Entry result = this.sb.cacheLoader.loadSync(+ plasmaHTCache.Entry result = plasmaSwitchboard.getSwitchboard().cacheLoader.loadSync(url, // the url"", // name of the url, from anchor tag <a>name</a>null, // refereryacyCore.seedDB.mySeed.hash, // initiator0, // depth- (forText) ? sb.defaultTextSnippetProfile : sb.defaultMediaSnippetProfile, // crawl profile+ (forText) ? plasmaSwitchboard.getSwitchboard().defaultTextSnippetProfile : plasmaSwitchboard.getSwitchboard().defaultMediaSnippetProfile, // crawl profilesocketTimeout,keepInMemory);@@ -873,7 +870,7 @@ public class plasmaSnippetCache {return result;}- public String failConsequences(TextSnippet snippet, Set queryhashes) {+ public static String failConsequences(TextSnippet snippet, Set queryhashes) {// problems with snippet fetchif (yacyCore.seedDB.mySeed.isVirgin()) return snippet.getError() + " (no consequences, no network connection)"; // no consequences if we do not have a network connectionString urlHash = plasmaURL.urlHash(snippet.getUrl());@@ -883,12 +880,12 @@ public class plasmaSnippetCache {(snippet.getErrorCode() == ERROR_PARSER_FAILED) ||(snippet.getErrorCode() == ERROR_PARSER_NO_LINES)) {log.logInfo("error: '" + snippet.getError() + "', remove url = " + snippet.getUrl().toNormalform(false, true) + ", cause: " + snippet.getError());- sb.wordIndex.loadedURL.remove(urlHash);- sb.wordIndex.removeHashReferences(queryhashes, urlHash);+ plasmaSwitchboard.getSwitchboard().wordIndex.loadedURL.remove(urlHash);+ plasmaSwitchboard.getSwitchboard().wordIndex.removeHashReferences(queryhashes, urlHash);}if (snippet.getErrorCode() == ERROR_NO_MATCH) {log.logInfo("error: '" + snippet.getError() + "', remove words '" + querystring + "' for url = " + snippet.getUrl().toNormalform(false, true) + ", cause: " + snippet.getError());- sb.wordIndex.removeHashReferences(snippet.remaingHashes, urlHash);+ plasmaSwitchboard.getSwitchboard().wordIndex.removeHashReferences(snippet.remaingHashes, urlHash);}return snippet.getError();}diff --git a/source/de/anomic/plasma/plasmaSwitchboard.java b/source/de/anomic/plasma/plasmaSwitchboard.javaindex ee4754653..c673f7cce 100644--- a/source/de/anomic/plasma/plasmaSwitchboard.java+++ b/source/de/anomic/plasma/plasmaSwitchboard.java@@ -218,7 +218,6 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serpublic plasmaCrawlZURL errorURL, delegatedURL;public plasmaWordIndex wordIndex;public plasmaHTCache cacheManager;- public plasmaSnippetCache snippetCache;public plasmaCrawlLoader cacheLoader;public plasmaSwitchboardQueue sbQueue;public plasmaCrawlStacker sbStackCrawlThread;@@ -1292,7 +1291,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser// generate snippets cachelog.logConfig("Initializing Snippet Cache");- snippetCache = new plasmaSnippetCache(this,cacheManager, parser,log);+ plasmaSnippetCache.init(cacheManager, parser,log);// start yacy corelog.logConfig("Starting YaCy Protocol Core");@@ -2504,7 +2503,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser// create a new loaded URL db entrylong ldate = System.currentTimeMillis();- indexURLEntry newEntry = wordIndex.loadedURL.newEntry(+ indexURLEntry newEntry = new indexURLEntry(entry.url(), // URLdocDescription, // document descriptiondocument.getAuthor(), // author@@ -2892,177 +2891,6 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serif (date == null) return ""; else return DateFormatter.format(date);}- public plasmaSearchResults searchFromLocal(plasmaSearchQuery query,- plasmaSearchRankingProfile ranking,- plasmaSearchProcessing localTiming,- plasmaSearchProcessing remoteTiming,- boolean postsort,- String client) {-- // tell all threads to do nothing for a specific time- intermissionAllThreads(2 * query.maximumTime);-- plasmaSearchResults results=new plasmaSearchResults();- results.setRanking(ranking);- results.setQuery(query);- results.setFormerSearch("");- try {- // filter out words that appear in bluelist- //log.logInfo("E");- query.filterOut(blueList);- results.setQuery(query);-- // log- log.logInfo("INIT WORD SEARCH: " + query.queryString + ":" + query.queryHashes + " - " + query.wantedResults + " links, " + (query.maximumTime / 1000) + " seconds");- long timestamp = System.currentTimeMillis();-- // start a presearch, which makes only sense if we idle afterwards.- // this is especially the case if we start a global search and idle until search- //if (query.domType == plasmaSearchQuery.SEARCHDOM_GLOBALDHT) {- // Thread preselect = new presearch(query.queryHashes, order, query.maximumTime / 10, query.urlMask, 10, 3);- // preselect.start();- //}-- // create a new search event- plasmaSearchEvent theSearch = new plasmaSearchEvent(query, ranking, localTiming, remoteTiming, postsort, log, wordIndex, snippetCache, (isRobinsonMode()) ? this.clusterhashes : null);- plasmaSearchPostOrder acc = theSearch.search();-- // fetch snippets- //if (query.domType != plasmaSearchQuery.SEARCHDOM_GLOBALDHT) snippetCache.fetch(acc.cloneSmart(), query.queryHashes, query.urlMask, 10, 1000);- log.logFine("SEARCH TIME AFTER ORDERING OF SEARCH RESULTS: " + ((System.currentTimeMillis() - timestamp) / 1000) + " seconds");-- // result is a List of urlEntry elements: prepare answer- if (acc == null) {- results.setTotalcount(0);- results.setFilteredcount(0);- results.setOrderedcount(0);- results.setLinkcount(0);- } else {- results.setTotalcount(acc.globalContributions + acc.localContributions);- results.setFilteredcount(acc.filteredResults);- results.setOrderedcount(acc.sizeOrdered());- results.setGlobalresults(acc.globalContributions);- results.setRanking(ranking);-- int i = 0;- int p;- indexURLEntry urlentry;- String urlstring, urlname, filename, urlhash;- String host, hash, address;- yacySeed seed;- boolean includeSnippets = false;- results.setFormerSearch(query.queryString());- long targetTime = timestamp + query.maximumTime;- if (targetTime < System.currentTimeMillis()) targetTime = System.currentTimeMillis() + 1000;- while ((acc.hasMoreElements()) && (i < query.wantedResults) && (System.currentTimeMillis() < targetTime)) {- urlentry = acc.nextElement();- indexURLEntry.Components comp = urlentry.comp();- urlhash = urlentry.hash();- assert (urlhash != null);- assert (urlhash.length() == 12) : "urlhash = " + urlhash;- host = comp.url().getHost();- if (host.endsWith(".yacyh")) {- // translate host into current IP- p = host.indexOf(".");- hash = yacySeed.hexHash2b64Hash(host.substring(p + 1, host.length() - 6));- seed = yacyCore.seedDB.getConnected(hash);- filename = comp.url().getFile();- if ((seed == null) || ((address = seed.getPublicAddress()) == null)) {- // seed is not known from here- wordIndex.removeWordReferences(plasmaCondenser.getWords(("yacyshare " + filename.replace('?', ' ') + " " + comp.title()).getBytes(), "UTF-8").keySet(), urlentry.hash());- wordIndex.loadedURL.remove(urlentry.hash()); // clean up- continue; // next result- }- urlstring = "http://" + address + "/" + host.substring(0, p) + filename;- urlname = "http://share." + seed.getName() + ".yacy" + filename;- if ((p = urlname.indexOf("?")) > 0) urlname = urlname.substring(0, p);- } else {- urlstring = comp.url().toNormalform(false, true);- urlname = urlstring;- }--- // check bluelist again: filter out all links where any bluelisted word- // appear either in url, url's description or search word- // the search word was sorted out earlier- /*- String s = descr.toLowerCase() + url.toString().toLowerCase();- for (int c = 0; c < blueList.length; c++) {- if (s.indexOf(blueList[c]) >= 0) return;- }- */- //addScoreForked(ref, gs, descr.split(" "));- //addScoreForked(ref, gs, urlstring.split("/"));- plasmaSearchResults.searchResult result=results.createSearchResult();- result.setUrl(urlstring);- result.setUrlname(urlname);- result.setUrlentry(urlentry);- if (includeSnippets) {- result.setSnippet(snippetCache.retrieveTextSnippet(comp.url(), results.getQuery().queryHashes, false, urlentry.flags().get(plasmaCondenser.flag_cat_indexof), 260, 1000));- // snippet = snippetCache.retrieveTextSnippet(comp.url(), query.queryHashes, false, urlentry.flags().get(plasmaCondenser.flag_cat_indexof), 260, 1000);- } else {- // snippet = null;- result.setSnippet(null);- }- i++;- results.appendResult(result);- }- log.logFine("SEARCH TIME AFTER RESULT PREPARATION: " + ((System.currentTimeMillis() - timestamp) / 1000) + " seconds");-- // calc some more cross-reference- long remainingTime = query.maximumTime - (System.currentTimeMillis() - timestamp);- if (remainingTime < 0) remainingTime = 1000;- /*- while ((acc.hasMoreElements()) && (((time + timestamp) < System.currentTimeMillis()))) {- urlentry = acc.nextElement();- urlstring = htmlFilterContentScraper.urlNormalform(urlentry.url());- descr = urlentry.descr();-- addScoreForked(ref, gs, descr.split(" "));- addScoreForked(ref, gs, urlstring.split("/"));- }- **/- //Object[] ws = ref.getScores(16, false, 2, Integer.MAX_VALUE);- Object[] ws = acc.getReferences(16);- results.setReferences(ws);- log.logFine("SEARCH TIME AFTER XREF PREPARATION: " + ((System.currentTimeMillis() - timestamp) / 1000) + " seconds");-- /*- System.out.print("DEBUG WORD-SCORE: ");- for (int ii = 0; ii < ws.length; ii++) System.out.print(ws[ii] + ", ");- System.out.println(" all words = " + ref.getElementCount() + ", total count = " + ref.getTotalCount());- */- }-- // log- log.logInfo("EXIT WORD SEARCH: " + query.queryString + " - " +- results.getTotalcount() + " links found, " +- results.getFilteredcount() + " links filtered, " +- results.getOrderedcount() + " links ordered, " +- results.getLinkcount() + " links selected, " +- ((System.currentTimeMillis() - timestamp) / 1000) + " seconds");--- // prepare search statistics- Long trackerHandle = new Long(System.currentTimeMillis());- HashMap searchProfile = theSearch.resultProfile();- searchProfile.put("querystring", query.queryString);- searchProfile.put("time", trackerHandle);- searchProfile.put("host", client);- searchProfile.put("offset", new Integer(0));- searchProfile.put("results", results);- this.localSearches.add(searchProfile);- TreeSet handles = (TreeSet) this.localSearchTracker.get(client);- if (handles == null) handles = new TreeSet();- handles.add(trackerHandle);- this.localSearchTracker.put(client, handles);-- return results;- } catch (IOException e) {- return null;- }- }-public serverObjects action(String actionName, serverObjects actionInput) {// perform an action. (not used)return null;@@ -3092,12 +2920,12 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serInputStream resourceContent = null;try {// get the resource content- Object[] resource = snippetCache.getResource(comp.url(), fetchOnline, 10000, true);+ Object[] resource = plasmaSnippetCache.getResource(comp.url(), fetchOnline, 10000, true);resourceContent = (InputStream) resource[0];Long resourceContentLength = (Long) resource[1];// parse the resource- plasmaParserDocument document = snippetCache.parseDocument(comp.url(), resourceContentLength.longValue(), resourceContent);+ plasmaParserDocument document = plasmaSnippetCache.parseDocument(comp.url(), resourceContentLength.longValue(), resourceContent);// get the word setSet words = null;diff --git a/source/de/anomic/plasma/plasmaWordIndex.java b/source/de/anomic/plasma/plasmaWordIndex.javaindex 40fa7e42d..d80ae0ecc 100644--- a/source/de/anomic/plasma/plasmaWordIndex.java+++ b/source/de/anomic/plasma/plasmaWordIndex.java@@ -135,23 +135,13 @@ public final class plasmaWordIndex implements indexRI {this.flushsize = flushsize;}- public void dhtOutFlushControl() {+ public void dhtFlushControl(indexRAMRI theCache) {// check for forced flush- synchronized (dhtOutCache) {- if ((dhtOutCache.getMaxWordCount() > wCacheMaxChunk ) ||- (dhtOutCache.size() > dhtOutCache.getMaxWordCount()) ||- (serverMemory.available() < collections.minMem())) {- flushCache(dhtOutCache, dhtOutCache.size() + flushsize - dhtOutCache.getMaxWordCount());- }- }- }- public void dhtInFlushControl() {- // check for forced flush- synchronized (dhtInCache) {- if ((dhtInCache.getMaxWordCount() > wCacheMaxChunk ) ||- (dhtInCache.size() > dhtInCache.getMaxWordCount())||+ synchronized (theCache) {+ if ((theCache.getMaxWordCount() > wCacheMaxChunk ) ||+ (theCache.size() > theCache.getMaxWordCount()) ||(serverMemory.available() < collections.minMem())) {- flushCache(dhtInCache, dhtInCache.size() + flushsize - dhtInCache.getMaxWordCount());+ flushCache(theCache, theCache.size() + flushsize - theCache.getMaxWordCount());}}}@@ -173,10 +163,10 @@ public final class plasmaWordIndex implements indexRI {// add the entryif (dhtInCase) {dhtInCache.addEntry(wordHash, entry, updateTime, true);- dhtInFlushControl();+ dhtFlushControl(this.dhtInCache);} else {dhtOutCache.addEntry(wordHash, entry, updateTime, false);- dhtOutFlushControl();+ dhtFlushControl(this.dhtOutCache);}}@@ -189,10 +179,10 @@ public final class plasmaWordIndex implements indexRI {// add the entryif (dhtInCase) {dhtInCache.addEntries(entries, updateTime, true);- dhtInFlushControl();+ dhtFlushControl(this.dhtInCache);} else {dhtOutCache.addEntries(entries, updateTime, false);- dhtOutFlushControl();+ dhtFlushControl(this.dhtOutCache);}}diff --git a/source/de/anomic/yacy/yacyClient.java b/source/de/anomic/yacy/yacyClient.javaindex 5b6e2a877..188526780 100644--- a/source/de/anomic/yacy/yacyClient.java+++ b/source/de/anomic/yacy/yacyClient.java@@ -61,7 +61,6 @@ import de.anomic.kelondro.kelondroBase64Order;import de.anomic.kelondro.kelondroBitfield;import de.anomic.net.URL;import de.anomic.plasma.plasmaCondenser;-import de.anomic.plasma.plasmaCrawlLURL;import de.anomic.plasma.plasmaSearchRankingProfile;import de.anomic.plasma.plasmaSearchProcessing;import de.anomic.plasma.plasmaSnippetCache;@@ -344,12 +343,10 @@ public final class yacyClient {boolean global,int partitions,yacySeed target,- plasmaCrawlLURL urlManager,plasmaWordIndex wordIndex,indexContainer containerCache,Map abstractCache,- plasmaURLPattern blacklist,- plasmaSnippetCache snippets,+ plasmaURLPattern blacklist,plasmaSearchProcessing timingProfile,plasmaSearchRankingProfile rankingProfile,kelondroBitfield constraint@@ -460,7 +457,7 @@ public final class yacyClient {String[] urls = new String[results];for (int n = 0; n < results; n++) {// get one single search result- urlEntry = urlManager.newEntry((String) result.get("resource" + n));+ urlEntry = wordIndex.loadedURL.newEntry((String) result.get("resource" + n));if (urlEntry == null) continue;assert (urlEntry.hash().length() == 12) : "urlEntry.hash() = " + urlEntry.hash();if (urlEntry.hash().length() != 12) continue; // bad url hash@@ -482,8 +479,7 @@ public final class yacyClient {continue; // no word attached}- // the search-result-url transports all the attributes of word- // indexes+ // the search-result-url transports all the attributes of word indexesentry = urlEntry.word();if (!(entry.urlHash().equals(urlEntry.hash()))) {yacyCore.log.logInfo("remote search (client): url-hash " + urlEntry.hash() + " does not belong to word-attached-hash " + entry.urlHash() + "; url = " + comp.url() + " from peer " + target.getName());@@ -492,20 +488,19 @@ public final class yacyClient {// passed all checks, store urltry {- urlManager.store(urlEntry);- urlManager.stack(urlEntry, yacyCore.seedDB.mySeed.hash, target.hash, 2);+ wordIndex.loadedURL.store(urlEntry);+ wordIndex.loadedURL.stack(urlEntry, yacyCore.seedDB.mySeed.hash, target.hash, 2);} catch (IOException e) {yacyCore.log.logSevere("could not store search result", e);continue; // db-error}if (urlEntry.snippet() != null) {- // we don't store the snippets along the url entry, because they- // are search-specific.+ // we don't store the snippets along the url entry,+ // because they are search-specific.// instead, they are placed in a snipped-search cache.- // System.out.println("--- RECEIVED SNIPPET '" + link.snippet()- // + "'");- snippets.storeToCache(wordhashes, urlEntry.hash(), urlEntry.snippet());+ // System.out.println("--- RECEIVED SNIPPET '" + link.snippet() + "'");+ plasmaSnippetCache.storeToCache(wordhashes, urlEntry.hash(), urlEntry.snippet());}// add the url entry to the word indexesfor (int m = 0; m < words; m++) {@@ -516,10 +511,11 @@ public final class yacyClient {}// insert the containers to the index+ containerCache.addAllUnique(container[0]); // one is enoughfor (int m = 0; m < words; m++) {- containerCache.addAllUnique(container[m]);+ wordIndex.addEntries(container[m], System.currentTimeMillis(), true);}-+// read index abstractif (abstractCache != null) {Iterator i = result.entrySet().iterator();diff --git a/source/de/anomic/yacy/yacySearch.java b/source/de/anomic/yacy/yacySearch.javaindex 188e47fc6..20a577232 100644--- a/source/de/anomic/yacy/yacySearch.java+++ b/source/de/anomic/yacy/yacySearch.java@@ -54,11 +54,9 @@ import java.util.TreeMap;import de.anomic.index.indexContainer;import de.anomic.kelondro.kelondroBitfield;import de.anomic.kelondro.kelondroMScoreCluster;-import de.anomic.plasma.plasmaCrawlLURL;import de.anomic.plasma.plasmaSearchQuery;import de.anomic.plasma.plasmaSearchRankingProfile;import de.anomic.plasma.plasmaSearchProcessing;-import de.anomic.plasma.plasmaSnippetCache;import de.anomic.plasma.plasmaWordIndex;import de.anomic.plasma.urlPattern.plasmaURLPattern;import de.anomic.server.logging.serverLog;@@ -68,12 +66,10 @@ public class yacySearch extends Thread {final private String wordhashes, excludehashes, urlhashes;final private boolean global;final private int partitions;- final private plasmaCrawlLURL urlManager;final private plasmaWordIndex wordIndex;final private indexContainer containerCache;final private Map abstractCache;final private plasmaURLPattern blacklist;- final private plasmaSnippetCache snippetCache;final private yacySeed targetPeer;private String[] urls;private int maxDistance;@@ -83,9 +79,9 @@ public class yacySearch extends Thread {final private kelondroBitfield constraint;public yacySearch(String wordhashes, String excludehashes, String urlhashes, String prefer, String filter, int maxDistance,- boolean global, int partitions, yacySeed targetPeer, plasmaCrawlLURL urlManager, plasmaWordIndex wordIndex,+ boolean global, int partitions, yacySeed targetPeer, plasmaWordIndex wordIndex,indexContainer containerCache, Map abstractCache,- plasmaURLPattern blacklist, plasmaSnippetCache snippetCache,+ plasmaURLPattern blacklist,plasmaSearchProcessing timingProfile, plasmaSearchRankingProfile rankingProfile,kelondroBitfield constraint) {super("yacySearch_" + targetPeer.getName());@@ -97,12 +93,10 @@ public class yacySearch extends Thread {this.filter = filter;this.global = global;this.partitions = partitions;- this.urlManager = urlManager;this.wordIndex = wordIndex;this.containerCache = containerCache;this.abstractCache = abstractCache;this.blacklist = blacklist;- this.snippetCache = snippetCache;this.targetPeer = targetPeer;this.urls = null;this.maxDistance = maxDistance;@@ -114,9 +108,10 @@ public class yacySearch extends Thread {public void run() {this.urls = yacyClient.search(wordhashes, excludehashes, urlhashes, prefer, filter, maxDistance, global, partitions,- targetPeer, urlManager, wordIndex, containerCache, abstractCache,- blacklist, snippetCache, timingProfile, rankingProfile, constraint);+ targetPeer, wordIndex, containerCache, abstractCache,+ blacklist, timingProfile, rankingProfile, constraint);if (urls != null) {+ // urls is an array of url hashes. this is only used for log outputStringBuffer urllist = new StringBuffer(this.urls.length * 13);for (int i = 0; i < this.urls.length; i++) urllist.append(this.urls[i]).append(' ');yacyCore.log.logInfo("REMOTE SEARCH - remote peer " + targetPeer.hash + ":" + targetPeer.getName() + " contributed " + urls.length + " links for word hash " + wordhashes + ": " + new String(urllist));@@ -249,12 +244,14 @@ public class yacySearch extends Thread {return result;}- public static yacySearch[] primaryRemoteSearches(String wordhashes, String excludehashes, String urlhashes, String prefer, String filter, int maxDist,- plasmaCrawlLURL urlManager, plasmaWordIndex wordIndex,- indexContainer containerCache, Map abstractCache,- int targets, plasmaURLPattern blacklist, plasmaSnippetCache snippetCache,- plasmaSearchProcessing timingProfile, plasmaSearchRankingProfile rankingProfile,- kelondroBitfield constraint, TreeMap clusterselection) {+ public static yacySearch[] primaryRemoteSearches(+ String wordhashes, String excludehashes, String urlhashes,+ String prefer, String filter, int maxDist,+ plasmaWordIndex wordIndex,+ indexContainer containerCache, Map abstractCache,+ int targets, plasmaURLPattern blacklist,+ plasmaSearchProcessing timingProfile, plasmaSearchRankingProfile rankingProfile,+ kelondroBitfield constraint, TreeMap clusterselection) {// check own peer statusif (yacyCore.seedDB.mySeed == null || yacyCore.seedDB.mySeed.getPublicAddress() == null) { return null; }@@ -265,8 +262,8 @@ public class yacySearch extends Thread {if (targets == 0) return new yacySearch[0];yacySearch[] searchThreads = new yacySearch[targets];for (int i = 0; i < targets; i++) {- searchThreads[i]= new yacySearch(wordhashes, excludehashes, urlhashes, prefer, filter, maxDist, true, targets, targetPeers[i],- urlManager, wordIndex, containerCache, abstractCache, blacklist, snippetCache, timingProfile, rankingProfile, constraint);+ searchThreads[i] = new yacySearch(wordhashes, excludehashes, urlhashes, prefer, filter, maxDist, true, targets, targetPeers[i],+ wordIndex, containerCache, abstractCache, blacklist, timingProfile, rankingProfile, constraint);searchThreads[i].start();//try {Thread.sleep(20);} catch (InterruptedException e) {}}@@ -274,9 +271,9 @@ public class yacySearch extends Thread {}public static yacySearch secondaryRemoteSearch(String wordhashes, String excludehashes, String urlhashes,- plasmaCrawlLURL urlManager, plasmaWordIndex wordIndex,+ plasmaWordIndex wordIndex,indexContainer containerCache,- String targethash, plasmaURLPattern blacklist, plasmaSnippetCache snippetCache,+ String targethash, plasmaURLPattern blacklist,plasmaSearchProcessing timingProfile, plasmaSearchRankingProfile rankingProfile,kelondroBitfield constraint, TreeMap clusterselection) {// check own peer status@@ -287,7 +284,7 @@ public class yacySearch extends Thread {if (targetPeer == null) return null;if (clusterselection != null) targetPeer.setAlternativeAddress((String) clusterselection.get(targetPeer.hash));yacySearch searchThread = new yacySearch(wordhashes, excludehashes, urlhashes, "", "", 9999, true, 0, targetPeer,- urlManager, wordIndex, containerCache, new TreeMap(), blacklist, snippetCache, timingProfile, rankingProfile, constraint);+ wordIndex, containerCache, new TreeMap(), blacklist, timingProfile, rankingProfile, constraint);searchThread.start();return searchThread;}