Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
- non-blocking word hash computation with dynamic digest object generation (this was important!) - (very) small performance enhancement in did-you-mean
orbiter09ba6814c0e6
diff --git a/source/de/anomic/data/DidYouMean.java b/source/de/anomic/data/DidYouMean.javaindex 12defa1b9..366610314 100644--- a/source/de/anomic/data/DidYouMean.java+++ b/source/de/anomic/data/DidYouMean.java@@ -356,7 +356,7 @@ public class DidYouMean {public void run() {String s;try {- while (!(s = guessLib.take()).equals(POISON_STRING)) {+ while ((s = guessLib.take()) != POISON_STRING) {if (s.length() >= MinimumOutputWordLength && index.has(Word.word2hash(s))) resultSet.add(s);if (System.currentTimeMillis() > timeLimit) return;}diff --git a/source/net/yacy/kelondro/order/Digest.java b/source/net/yacy/kelondro/order/Digest.javaindex 4d5dc592b..1958252ad 100644--- a/source/net/yacy/kelondro/order/Digest.java+++ b/source/net/yacy/kelondro/order/Digest.java@@ -50,7 +50,7 @@ import net.yacy.kelondro.logging.Log;public class Digest {- private final static int digestThreads = Runtime.getRuntime().availableProcessors() * 2 + 1;+ private final static int digestThreads = Runtime.getRuntime().availableProcessors() * 4;public static BlockingQueue<MessageDigest> digestPool = new ArrayBlockingQueue<MessageDigest>(digestThreads);static {for (int i = 0; i < digestThreads; i++)@@ -115,7 +115,17 @@ public class Digest {public static byte[] encodeMD5Raw(final String key) {MessageDigest digest = null;boolean fromPool = true;- try {+ if (digestPool.size() == 0) {+ // if there are no digest objects left, create some on the fly+ // this is not the most effective way but if we wouldn't do that the encoder would block+ try {+ digest = MessageDigest.getInstance("MD5");+ digest.reset();+ fromPool = false;+ } catch (NoSuchAlgorithmException e) {+ }+ }+ if (digest == null) try {digest = digestPool.take();} catch (InterruptedException e) {Log.logWarning("Digest", "using generic instead of pooled digest");