- fix for problem with concurrency when computing word hashes

- fix for search in case that a urlfilter was used and zero results were returned

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@5904 6c8d7289-2bf4-0310-a012-ef5d649a1542
This commit is contained in:
orbiter 2009-04-29 22:14:12 +00:00
parent d3f8aa5a2a
commit 3a64c9d02f
2 changed files with 15 additions and 7 deletions

View File

@ -82,11 +82,15 @@ public class Word {
// create a word hash
public static final byte[] word2hash(final String word) {
byte[] h = hashCache.get(word);
byte[] h = hashCache.get(word);
if (h != null) return h;
h = Base64Order.enhancedCoder.encodeSubstring(Digest.encodeMD5Raw(word.toLowerCase(Locale.ENGLISH)), yacySeedDB.commonHashLength);
assert h[2] != '@';
hashCache.put(word, h); // prevent expensive MD5 computation and encoding
synchronized(hashCache) {
h = hashCache.get(word); // we must test that again because another thread may have written the value in between
if (h != null) return h;
h = Base64Order.enhancedCoder.encodeSubstring(Digest.encodeMD5Raw(word.toLowerCase(Locale.ENGLISH)), yacySeedDB.commonHashLength);
assert h[2] != '@';
hashCache.put(word, h); // prevent expensive MD5 computation and encoding
}
return h;
}

View File

@ -301,7 +301,7 @@ public final class plasmaSearchRankingProcess {
}
public URLMetadataRow bestURL(final boolean skipDoubleDom) {
// returns from the current RWI list the best URL entry and removed this entry from the list
// returns from the current RWI list the best URL entry and removes this entry from the list
while ((stack.size() > 0) || (size() > 0)) {
if (((stack.size() == 0) && (size() == 0))) break;
final SortStack<WordReferenceVars>.stackElement obrwi = bestRWI(skipDoubleDom);
@ -309,8 +309,12 @@ public final class plasmaSearchRankingProcess {
final URLMetadataRow u = wordIndex.metadata().load(obrwi.element.metadataHash(), obrwi.element, obrwi.weight.longValue());
if (u != null) {
final URLMetadataRow.Components metadata = u.metadata();
if (metadata.url() != null) this.handover.put(u.hash(), metadata.url().toNormalform(true, false)); // remember that we handed over this url
return u;
if (metadata.url() != null) {
String urlstring = metadata.url().toNormalform(true, true);
if (urlstring == null || !urlstring.matches(query.urlMask)) continue;
this.handover.put(u.hash(), metadata.url().toNormalform(true, false)); // remember that we handed over this url
return u;
}
}
misses.add(obrwi.element.metadataHash());
}