Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
- fix for problem with concurrency when computing word hashes - fix for search in case that a urlfilter was used and zero results were returned
orbiter3a64c9d02fac
diff --git a/source/de/anomic/plasma/parser/Word.java b/source/de/anomic/plasma/parser/Word.javaindex fb2425374..fd65fd07a 100644--- a/source/de/anomic/plasma/parser/Word.java+++ b/source/de/anomic/plasma/parser/Word.java@@ -82,11 +82,15 @@ public class Word {// create a word hashpublic 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;}diff --git a/source/de/anomic/plasma/plasmaSearchRankingProcess.java b/source/de/anomic/plasma/plasmaSearchRankingProcess.javaindex fbb5891b1..de9ca3836 100644--- a/source/de/anomic/plasma/plasmaSearchRankingProcess.java+++ b/source/de/anomic/plasma/plasmaSearchRankingProcess.java@@ -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 listwhile ((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());}