git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@2238 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 19 years ago
parent a5661de880
commit dd560e4b2f

@ -81,7 +81,7 @@ public class kelondroRecords {
// constants // constants
private static final int NUL = Integer.MIN_VALUE; // the meta value for the kelondroRecords' NUL abstraction private static final int NUL = Integer.MIN_VALUE; // the meta value for the kelondroRecords' NUL abstraction
private static final long memBlock = 50000000; // do not fill cache further if the amount of available memory is less that this private static final long memBlock = 500000; // do not fill cache further if the amount of available memory is less that this
public final static boolean useWriteBuffer = false; public final static boolean useWriteBuffer = false;
// memory calculation // memory calculation
@ -427,9 +427,9 @@ public class kelondroRecords {
this.cacheScore = new kelondroMScoreCluster(); // cache control of CP_HIGH caches this.cacheScore = new kelondroMScoreCluster(); // cache control of CP_HIGH caches
} }
this.cacheHeaders = new kelondroIntBytesMap[]{ this.cacheHeaders = new kelondroIntBytesMap[]{
new kelondroIntBytesMap(this.headchunksize, this.cacheSize / 4),
new kelondroIntBytesMap(this.headchunksize, 0), new kelondroIntBytesMap(this.headchunksize, 0),
new kelondroIntBytesMap(this.headchunksize, 0), new kelondroIntBytesMap(this.headchunksize, this.cacheSize / 4)
new kelondroIntBytesMap(this.headchunksize, this.cacheSize / 2)
}; };
this.cacheHeaders[0].setOrdering(kelondroNaturalOrder.naturalOrder, 0); this.cacheHeaders[0].setOrdering(kelondroNaturalOrder.naturalOrder, 0);
this.cacheHeaders[1].setOrdering(kelondroNaturalOrder.naturalOrder, 0); this.cacheHeaders[1].setOrdering(kelondroNaturalOrder.naturalOrder, 0);
@ -447,7 +447,7 @@ public class kelondroRecords {
private static final long max = Runtime.getRuntime().maxMemory(); private static final long max = Runtime.getRuntime().maxMemory();
private static final Runtime runtime = Runtime.getRuntime(); private static final Runtime runtime = Runtime.getRuntime();
private static long availableMemory() { public static long availableMemory() {
// memory that is available including increasing total memory up to maximum // memory that is available including increasing total memory up to maximum
return max - runtime.totalMemory() + runtime.freeMemory(); return max - runtime.totalMemory() + runtime.freeMemory();
} }
@ -930,9 +930,9 @@ public class kelondroRecords {
// we simply clear the cache // we simply clear the cache
String error = "cachScore error: " + e.getMessage() + "; cachesize=" + cacheSize + ", cache.size()=[" + cacheHeaders[0].size() + "," + cacheHeaders[1].size() + "," + cacheHeaders[2].size() + "], cacheScore.size()=" + cacheScore.size(); String error = "cachScore error: " + e.getMessage() + "; cachesize=" + cacheSize + ", cache.size()=[" + cacheHeaders[0].size() + "," + cacheHeaders[1].size() + "," + cacheHeaders[2].size() + "], cacheScore.size()=" + cacheScore.size();
cacheScore = new kelondroMScoreCluster(); cacheScore = new kelondroMScoreCluster();
cacheHeaders[CP_LOW] = new kelondroIntBytesMap(headchunksize, 0); cacheHeaders[CP_LOW] = new kelondroIntBytesMap(headchunksize, cacheSize / 4);
cacheHeaders[CP_MEDIUM] = new kelondroIntBytesMap(headchunksize, 0); cacheHeaders[CP_MEDIUM] = new kelondroIntBytesMap(headchunksize, 0);
cacheHeaders[CP_HIGH] = new kelondroIntBytesMap(headchunksize, cacheSize / 2); cacheHeaders[CP_HIGH] = new kelondroIntBytesMap(headchunksize, cacheSize / 4);
cacheHeaders[0].setOrdering(kelondroNaturalOrder.naturalOrder, 0); cacheHeaders[0].setOrdering(kelondroNaturalOrder.naturalOrder, 0);
cacheHeaders[1].setOrdering(kelondroNaturalOrder.naturalOrder, 0); cacheHeaders[1].setOrdering(kelondroNaturalOrder.naturalOrder, 0);
cacheHeaders[2].setOrdering(kelondroNaturalOrder.naturalOrder, 0); cacheHeaders[2].setOrdering(kelondroNaturalOrder.naturalOrder, 0);

@ -31,7 +31,9 @@ import java.util.Random;
public class kelondroRowBufferedSet extends kelondroRowSet { public class kelondroRowBufferedSet extends kelondroRowSet {
private static final int bufferFlushLimit = 10000; private static final long memBlockLimit = 2000000; // do not fill cache further if the amount of available memory is less that this
private static final int bufferFlushLimit = 100000;
private static final int bufferFlushMinimum = 1000;
private final boolean useRowCollection = true; private final boolean useRowCollection = true;
private TreeMap buffer; // this must be a TreeSet bacause HashMap does not work with byte[] private TreeMap buffer; // this must be a TreeSet bacause HashMap does not work with byte[]
@ -145,7 +147,8 @@ public class kelondroRowBufferedSet extends kelondroRowSet {
if (oldentry == null) { if (oldentry == null) {
// this was not anywhere // this was not anywhere
buffer.put(key, newentry); buffer.put(key, newentry);
if (buffer.size() > bufferFlushLimit) flush(); if (((buffer.size() > bufferFlushMinimum) && (kelondroRecords.availableMemory() > memBlockLimit)) ||
(buffer.size() > bufferFlushLimit)) flush();
return null; return null;
} else { } else {
// replace old entry // replace old entry

Loading…
Cancel
Save