|
|
@ -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;
|
|
|
@ -54,16 +53,22 @@ public class Word {
|
|
|
|
* these hashes all shall be generated by base64.enhancedCoder
|
|
|
|
* these hashes all shall be generated by base64.enhancedCoder
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static final int commonHashLength = 12;
|
|
|
|
public static final int commonHashLength = 12;
|
|
|
|
|
|
|
|
|
|
|
|
private static final int hashCacheSize = Math.max(200000, Math.min(10000000, (int) (MemoryControl.available() / 20000L)));
|
|
|
|
private static final int hashCacheSize = Math.max(200000, Math.min(10000000, (int) (MemoryControl.available() / 20000L)));
|
|
|
|
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;
|
|
|
|