|
|
@ -30,7 +30,6 @@ import java.util.HashSet;
|
|
|
|
import java.util.Iterator;
|
|
|
|
import java.util.Iterator;
|
|
|
|
import java.util.Locale;
|
|
|
|
import java.util.Locale;
|
|
|
|
import java.util.Set;
|
|
|
|
import java.util.Set;
|
|
|
|
|
|
|
|
|
|
|
|
import net.yacy.cora.storage.ARC;
|
|
|
|
import net.yacy.cora.storage.ARC;
|
|
|
|
import net.yacy.cora.storage.ConcurrentARC;
|
|
|
|
import net.yacy.cora.storage.ConcurrentARC;
|
|
|
|
import net.yacy.document.LargeNumberCache;
|
|
|
|
import net.yacy.document.LargeNumberCache;
|
|
|
@ -59,11 +58,17 @@ public class Word {
|
|
|
|
private static ARC<String, byte[]> hashCache = null;
|
|
|
|
private static ARC<String, byte[]> hashCache = null;
|
|
|
|
static {
|
|
|
|
static {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
hashCache = new ConcurrentARC<String, byte[]>(hashCacheSize, 2 * Runtime.getRuntime().availableProcessors());
|
|
|
|
hashCache = new ConcurrentARC<String, byte[]>(hashCacheSize, Math.max(32, 4 * Runtime.getRuntime().availableProcessors()));
|
|
|
|
} catch (OutOfMemoryError e) {
|
|
|
|
} catch (OutOfMemoryError e) {
|
|
|
|
hashCache = new ConcurrentARC<String, byte[]>(1000, Runtime.getRuntime().availableProcessors());
|
|
|
|
hashCache = new ConcurrentARC<String, byte[]>(1000, Math.max(8, 2 * Runtime.getRuntime().availableProcessors()));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
private static ConcurrentHashMap<String, byte[]> hashCache = null;
|
|
|
|
|
|
|
|
static {
|
|
|
|
|
|
|
|
hashCache = new ConcurrentHashMap<String, byte[]>();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
// object carries statistics for words and sentences
|
|
|
|
// object carries statistics for words and sentences
|
|
|
|
public int count; // number of occurrences
|
|
|
|
public int count; // number of occurrences
|
|
|
@ -122,6 +127,7 @@ public class Word {
|
|
|
|
if (MemoryControl.shortStatus()) {
|
|
|
|
if (MemoryControl.shortStatus()) {
|
|
|
|
hashCache.clear();
|
|
|
|
hashCache.clear();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
|
|
|
|
//hashCache.putIfAbsent(wordlc, h); // prevent expensive MD5 computation and encoding
|
|
|
|
hashCache.insertIfAbsent(wordlc, h); // prevent expensive MD5 computation and encoding
|
|
|
|
hashCache.insertIfAbsent(wordlc, h); // prevent expensive MD5 computation and encoding
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return h;
|
|
|
|
return h;
|
|
|
|