Skip to content

Commit

Permalink
bugfixes for remote search server part
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@2573 6c8d7289-2bf4-0310-a012-ef5d649a1542
  • Loading branch information
orbiter committed Sep 13, 2006
1 parent 2c6f2a1 commit 6e29071
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 29 deletions.
48 changes: 26 additions & 22 deletions htroot/yacy/search.java
Expand Up @@ -127,16 +127,20 @@ public static serverObjects respond(httpHeader header, serverObjects post, serve
Map containers = theSearch.localSearchContainers(plasmaSearchQuery.hashes2Set(urls));

// set statistic details of search result and find best result index set
String maxcounthash = null, neardhthash = null;
int joincount = 0;
plasmaSearchResult acc = null;
if (containers == null) {
prop.put("indexcount", "");
prop.put("indexcount", "0");
prop.put("joincount", "0");
prop.put("indexabstract","");
} else {
Iterator ci = containers.entrySet().iterator();
StringBuffer indexcount = new StringBuffer();
Map.Entry entry;
int maxcount = -1;
double mindhtdistance = 1.1, d;
String wordhash;
String maxcounthash = null, neardhthash = null;
while (ci.hasNext()) {
entry = (Map.Entry) ci.next();
wordhash = (String) entry.getKey();
Expand All @@ -153,27 +157,27 @@ public static serverObjects respond(httpHeader header, serverObjects post, serve
indexcount.append("indexcount.").append(container.getWordHash()).append('=').append(Integer.toString(container.size())).append(serverCore.crlfString);
}
prop.put("indexcount", new String(indexcount));
}

// join and order the result
indexContainer localResults = theSearch.localSearchJoin(containers.values());
int joincount = localResults.size();
prop.put("joincount", Integer.toString(joincount));
plasmaSearchResult acc = theSearch.orderFinal(localResults);

// generate compressed index for maxcounthash
// this is not needed if the search is restricted to specific urls, because it is a re-search
if ((maxcounthash == null) || (urls.length() != 0) || (keyhashes.size() == 1)) {
prop.put("indexabstract","");
} else {
String indexabstract = "indexabstract." + maxcounthash + "=" + indexURL.compressIndex(((indexContainer) containers.get(maxcounthash)), localResults, 1000).toString() + serverCore.crlfString;
if ((neardhthash != null) && (!(neardhthash.equals(maxcounthash)))) {
indexabstract += "indexabstract." + neardhthash + "=" + indexURL.compressIndex(((indexContainer) containers.get(neardhthash)), localResults, 1000).toString() + serverCore.crlfString;

// join and order the result
indexContainer localResults = theSearch.localSearchJoin(containers.values());
joincount = localResults.size();
prop.put("joincount", Integer.toString(joincount));
acc = theSearch.orderFinal(localResults);

// generate compressed index for maxcounthash
// this is not needed if the search is restricted to specific urls, because it is a re-search
if ((maxcounthash == null) || (urls.length() != 0) || (keyhashes.size() == 1)) {
prop.put("indexabstract","");
} else {
String indexabstract = "indexabstract." + maxcounthash + "=" + indexURL.compressIndex(((indexContainer) containers.get(maxcounthash)), localResults, 1000).toString() + serverCore.crlfString;
if ((neardhthash != null) && (!(neardhthash.equals(maxcounthash)))) {
indexabstract += "indexabstract." + neardhthash + "=" + indexURL.compressIndex(((indexContainer) containers.get(neardhthash)), localResults, 1000).toString() + serverCore.crlfString;
}
System.out.println("DEBUG-ABSTRACTGENERATION: maxcounthash = " + maxcounthash);
System.out.println("DEBUG-ABSTRACTGENERATION: neardhthash = " + neardhthash);
//yacyCore.log.logFine("DEBUG HASH SEARCH: " + indexabstract);
prop.put("indexabstract", indexabstract);
}
System.out.println("DEBUG-ABSTRACTGENERATION: maxcounthash = " + maxcounthash);
System.out.println("DEBUG-ABSTRACTGENERATION: neardhthash = " + neardhthash);
//yacyCore.log.logFine("DEBUG HASH SEARCH: " + indexabstract);
prop.put("indexabstract", indexabstract);
}

// prepare result
Expand Down
7 changes: 5 additions & 2 deletions source/de/anomic/index/indexRAMCacheRI.java
Expand Up @@ -390,8 +390,11 @@ public indexContainer getContainer(String wordHash, Set urlselection, boolean de
if (urlselection == null) {
return (indexContainer) wCache.get(wordHash);
} else {
indexContainer ic = ((indexContainer) wCache.get(wordHash)).topLevelClone();
ic.select(urlselection);
indexContainer ic = (indexContainer) wCache.get(wordHash);
if (ic != null) {
ic = ic.topLevelClone();
ic.select(urlselection);
}
return ic;
}
}
Expand Down
2 changes: 1 addition & 1 deletion source/de/anomic/plasma/plasmaSearchEvent.java
Expand Up @@ -153,7 +153,7 @@ public plasmaSearchResult search() {
if (yacySearch.remainingWaiting(primarySearchThreads) == 0) break; // all threads have finished
try {Thread.sleep(100);} catch (InterruptedException e) {}
}
prepareSecondarySearch();
if (query.size() > 1) prepareSecondarySearch();

// catch up global results:
// wait until primary timeout passed
Expand Down
13 changes: 10 additions & 3 deletions source/de/anomic/yacy/yacyClient.java
Expand Up @@ -437,7 +437,9 @@ public static int search(
final long timestamp = System.currentTimeMillis();

// sending request
final HashMap result = nxTools.table(
HashMap result = null;
try {
result = nxTools.table(
httpc.wput(
new URL(url),
targetPeer.getHexHash() + ".yacyh",
Expand All @@ -448,10 +450,15 @@ public static int search(
obj,
null
)
);
);
} catch (IOException e) {
yacyCore.log.logFine("SEARCH failed FROM " + targetPeer.hash + ":" + targetPeer.getName() + " (" + e.getMessage() + "), score=" + targetPeer.selectscore + ", DHTdist=" + yacyDHTAction.dhtDistance(targetPeer.hash, wordhashes));
yacyCore.peerActions.peerDeparture(targetPeer);
return 0;
}

if (result.size() == 0) {
yacyCore.log.logFine("SEARCH failed FROM " + targetPeer.hash + ":" + targetPeer.getName() + ", score=" + targetPeer.selectscore + ", DHTdist=" + yacyDHTAction.dhtDistance(targetPeer.hash, wordhashes));
yacyCore.log.logFine("SEARCH failed FROM " + targetPeer.hash + ":" + targetPeer.getName() + " (zero response), score=" + targetPeer.selectscore + ", DHTdist=" + yacyDHTAction.dhtDistance(targetPeer.hash, wordhashes));
return 0;
}

Expand Down
3 changes: 2 additions & 1 deletion source/de/anomic/yacy/yacySearch.java
Expand Up @@ -82,6 +82,7 @@ public yacySearch(String wordhashes, String urlhashes, String prefer, String fil
plasmaURLPattern blacklist, plasmaSnippetCache snippetCache,
plasmaSearchTimingProfile timingProfile, plasmaSearchRankingProfile rankingProfile) {
super("yacySearch_" + targetPeer.getName());
System.out.println("DEBUG - yacySearch thread " + this.getName() + " initialized " + ((urlhashes.length() == 0) ? "(primary)" : "(secondary)"));
this.wordhashes = wordhashes;
this.urlhashes = urlhashes;
this.prefer = prefer;
Expand All @@ -101,8 +102,8 @@ public yacySearch(String wordhashes, String urlhashes, String prefer, String fil

public void run() {
this.links = yacyClient.search(wordhashes, urlhashes, prefer, filter, maxDistance, global, targetPeer, urlManager, containerCache, abstractCache, blacklist, snippetCache, timingProfile, rankingProfile);
yacyCore.log.logInfo("REMOTE SEARCH - remote peer " + targetPeer.hash + ":" + targetPeer.getName() + " contributed " + links + " links for word hash " + wordhashes);
if (links != 0) {
//yacyCore.log.logInfo("REMOTE SEARCH - remote peer " + targetPeer.hash + ":" + targetPeer.getName() + " contributed " + links + " links for word hash " + wordhashes);
yacyCore.seedDB.mySeed.incRI(links);
yacyCore.seedDB.mySeed.incRU(links);
}
Expand Down

0 comments on commit 6e29071

Please sign in to comment.