- 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
pull/1/head
orbiter 16 years ago
parent d3f8aa5a2a
commit 3a64c9d02f

@ -84,9 +84,13 @@ public class Word {
public static final byte[] word2hash(final String word) {
byte[] h = hashCache.get(word);
if (h != null) return h;
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;
}

@ -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,9 +309,13 @@ 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
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());
}
return null;

Loading…
Cancel
Save