integrated number of remote targets as 'partitions' into remote search protocol

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@3317 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 18 years ago
parent f696d3c1eb
commit c2d6edf21d

@ -99,6 +99,7 @@ public final class search {
final String prefer = post.get("prefer", ""); final String prefer = post.get("prefer", "");
final String contentdom = post.get("contentdom", "text"); final String contentdom = post.get("contentdom", "text");
final String filter = post.get("filter", ".*"); final String filter = post.get("filter", ".*");
final int partitions = post.getInt("partitions", 30);
String profile = post.get("profile", ""); // remote profile hand-over String profile = post.get("profile", ""); // remote profile hand-over
if (profile.length() > 0) profile = crypt.simpleDecode(profile, null); if (profile.length() > 0) profile = crypt.simpleDecode(profile, null);
final boolean includesnippet = post.get("includesnippet", "false").equals("true"); final boolean includesnippet = post.get("includesnippet", "false").equals("true");
@ -238,7 +239,7 @@ public final class search {
//yacyCore.log.logFine("DEBUG HASH SEARCH: " + indexabstract); //yacyCore.log.logFine("DEBUG HASH SEARCH: " + indexabstract);
} }
} }
sb.requestedQueries = sb.requestedQueries + 1d / 30d; // increase query counter TODO: put number of remote peers into protocol if (partitions > 0) sb.requestedQueries = sb.requestedQueries + 1d / (double) partitions; // increase query counter
} }
prop.putASIS("indexabstract", indexabstract.toString()); prop.putASIS("indexabstract", indexabstract.toString());

@ -373,6 +373,7 @@ public final class yacyClient {
String filter, String filter,
int maxDistance, int maxDistance,
boolean global, boolean global,
int partitions,
yacySeed targetPeer, yacySeed targetPeer,
plasmaCrawlLURL urlManager, plasmaCrawlLURL urlManager,
plasmaWordIndex wordIndex, plasmaWordIndex wordIndex,
@ -397,6 +398,7 @@ public final class yacyClient {
// fwden : forward deny, a list of seed hashes. They may NOT be target of forward hopping // fwden : forward deny, a list of seed hashes. They may NOT be target of forward hopping
// count : maximum number of wanted results // count : maximum number of wanted results
// global : if "true", then result may consist of answers from other peers // global : if "true", then result may consist of answers from other peers
// partitions : number of remote peers that are asked (for evaluation of QPM)
// duetime : maximum time that a peer should spent to create a result // duetime : maximum time that a peer should spent to create a result
// request result // request result
@ -426,6 +428,7 @@ public final class yacyClient {
obj.put("key", key); obj.put("key", key);
obj.put("count", timingProfile.getTargetCount(plasmaSearchTimingProfile.PROCESS_POSTSORT)); obj.put("count", timingProfile.getTargetCount(plasmaSearchTimingProfile.PROCESS_POSTSORT));
obj.put("resource", ((global) ? "global" : "local")); obj.put("resource", ((global) ? "global" : "local"));
obj.put("partitions", partitions);
obj.put("query", wordhashes); obj.put("query", wordhashes);
obj.put("urls", urlhashes); obj.put("urls", urlhashes);
obj.put("prefer", prefer); obj.put("prefer", prefer);

@ -66,6 +66,7 @@ public class yacySearch extends Thread {
final private String wordhashes, urlhashes; final private String wordhashes, urlhashes;
final private boolean global; final private boolean global;
final private int partitions;
final private plasmaCrawlLURL urlManager; final private plasmaCrawlLURL urlManager;
final private plasmaWordIndex wordIndex; final private plasmaWordIndex wordIndex;
final private indexContainer containerCache; final private indexContainer containerCache;
@ -81,7 +82,7 @@ public class yacySearch extends Thread {
final private kelondroBitfield constraint; final private kelondroBitfield constraint;
public yacySearch(String wordhashes, String urlhashes, String prefer, String filter, int maxDistance, public yacySearch(String wordhashes, String urlhashes, String prefer, String filter, int maxDistance,
boolean global, yacySeed targetPeer, plasmaCrawlLURL urlManager, plasmaWordIndex wordIndex, boolean global, int partitions, yacySeed targetPeer, plasmaCrawlLURL urlManager, plasmaWordIndex wordIndex,
indexContainer containerCache, Map abstractCache, indexContainer containerCache, Map abstractCache,
plasmaURLPattern blacklist, plasmaSnippetCache snippetCache, plasmaURLPattern blacklist, plasmaSnippetCache snippetCache,
plasmaSearchTimingProfile timingProfile, plasmaSearchRankingProfile rankingProfile, plasmaSearchTimingProfile timingProfile, plasmaSearchRankingProfile rankingProfile,
@ -93,6 +94,7 @@ public class yacySearch extends Thread {
this.prefer = prefer; this.prefer = prefer;
this.filter = filter; this.filter = filter;
this.global = global; this.global = global;
this.partitions = partitions;
this.urlManager = urlManager; this.urlManager = urlManager;
this.wordIndex = wordIndex; this.wordIndex = wordIndex;
this.containerCache = containerCache; this.containerCache = containerCache;
@ -108,7 +110,10 @@ public class yacySearch extends Thread {
} }
public void run() { public void run() {
this.urls = yacyClient.search(wordhashes, urlhashes, prefer, filter, maxDistance, global, targetPeer, urlManager, wordIndex, containerCache, abstractCache, blacklist, snippetCache, timingProfile, rankingProfile, constraint); this.urls = yacyClient.search(
wordhashes, urlhashes, prefer, filter, maxDistance, global, partitions,
targetPeer, urlManager, wordIndex, containerCache, abstractCache,
blacklist, snippetCache, timingProfile, rankingProfile, constraint);
if (urls != null) { if (urls != null) {
StringBuffer urllist = new StringBuffer(this.urls.length * 13); StringBuffer urllist = new StringBuffer(this.urls.length * 13);
for (int i = 0; i < this.urls.length; i++) urllist.append(this.urls[i]).append(' '); for (int i = 0; i < this.urls.length; i++) urllist.append(this.urls[i]).append(' ');
@ -218,7 +223,7 @@ public class yacySearch extends Thread {
if (targets == 0) return null; if (targets == 0) return null;
yacySearch[] searchThreads = new yacySearch[targets]; yacySearch[] searchThreads = new yacySearch[targets];
for (int i = 0; i < targets; i++) { for (int i = 0; i < targets; i++) {
searchThreads[i]= new yacySearch(wordhashes, urlhashes, prefer, filter, maxDist, true, targetPeers[i], searchThreads[i]= new yacySearch(wordhashes, urlhashes, prefer, filter, maxDist, true, targets, targetPeers[i],
urlManager, wordIndex, containerCache, abstractCache, blacklist, snippetCache, timingProfile, rankingProfile, constraint); urlManager, wordIndex, containerCache, abstractCache, blacklist, snippetCache, timingProfile, rankingProfile, constraint);
searchThreads[i].start(); searchThreads[i].start();
//try {Thread.sleep(20);} catch (InterruptedException e) {} //try {Thread.sleep(20);} catch (InterruptedException e) {}
@ -239,7 +244,7 @@ public class yacySearch extends Thread {
//Set wordhashes = plasmaSearch.words2hashes(querywords); //Set wordhashes = plasmaSearch.words2hashes(querywords);
final yacySeed targetPeer = yacyCore.seedDB.getConnected(targethash); final yacySeed targetPeer = yacyCore.seedDB.getConnected(targethash);
if (targetPeer == null) return null; if (targetPeer == null) return null;
yacySearch searchThread = new yacySearch(wordhashes, urlhashes, "", "", 9999, true, targetPeer, yacySearch searchThread = new yacySearch(wordhashes, urlhashes, "", "", 9999, true, 0, targetPeer,
urlManager, wordIndex, containerCache, new TreeMap(), blacklist, snippetCache, timingProfile, rankingProfile, constraint); urlManager, wordIndex, containerCache, new TreeMap(), blacklist, snippetCache, timingProfile, rankingProfile, constraint);
searchThread.start(); searchThread.start();
return searchThread; return searchThread;

Loading…
Cancel
Save