implemented automatic adoption of chunk-read-ahead in kelondroTree to needed chunk size

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

@ -3,7 +3,7 @@ javacSource=1.4
javacTarget=1.4 javacTarget=1.4
# Release Configuration # Release Configuration
releaseVersion=0.441 releaseVersion=0.442
releaseFile=yacy_dev_v${releaseVersion}_${DSTAMP}_${releaseNr}.tar.gz releaseFile=yacy_dev_v${releaseVersion}_${DSTAMP}_${releaseNr}.tar.gz
#releaseFile=yacy_v${releaseVersion}_${DSTAMP}_${releaseNr}.tar.gz #releaseFile=yacy_v${releaseVersion}_${DSTAMP}_${releaseNr}.tar.gz
releaseDir=yacy_dev_v${releaseVersion}_${DSTAMP}_${releaseNr} releaseDir=yacy_dev_v${releaseVersion}_${DSTAMP}_${releaseNr}

@ -83,6 +83,8 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {
private Search writeSearchObj = new Search(); private Search writeSearchObj = new Search();
protected kelondroOrder objectOrder = new kelondroNaturalOrder(true); protected kelondroOrder objectOrder = new kelondroNaturalOrder(true);
private final kelondroOrder loopDetectionOrder = new kelondroNaturalOrder(true); private final kelondroOrder loopDetectionOrder = new kelondroNaturalOrder(true);
private int readAheadChunkSize = 100;
private long lastIteratorCount = readAheadChunkSize;
public kelondroTree(File file, long buffersize, int key, int value, boolean exitOnFail) { public kelondroTree(File file, long buffersize, int key, int value, boolean exitOnFail) {
this(file, buffersize, new int[] { key, value }, new kelondroNaturalOrder(true), 1, 8, exitOnFail); this(file, buffersize, new int[] { key, value }, new kelondroNaturalOrder(true), 1, 8, exitOnFail);
@ -1057,9 +1059,12 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {
rot = rotating; rot = rotating;
count = 0; count = 0;
lastKey = null; lastKey = null;
chunkSize = (int) Math.min(100, guessedCountLimit); //System.out.println("*** rowIterator: " + filename + ": readAheadChunkSize = " + readAheadChunkSize + ", lastIteratorCount = " + lastIteratorCount);
readAheadChunkSize = Math.min(1000, 3 + (int) ((3 * readAheadChunkSize + lastIteratorCount) / 4));
chunkSize = (int) Math.min(readAheadChunkSize / 3, guessedCountLimit);
rowBuffer = rowMap(inc, rot, start, true, chunkSize); rowBuffer = rowMap(inc, rot, start, true, chunkSize);
bufferIterator = rowBuffer.entrySet().iterator(); bufferIterator = rowBuffer.entrySet().iterator();
lastIteratorCount = 0;
} }
public boolean hasNext() { public boolean hasNext() {
@ -1085,6 +1090,7 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {
// return the row // return the row
count++; count++;
lastIteratorCount++;
return entry.getValue(); return entry.getValue();
} }
@ -1114,9 +1120,12 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {
rot = rotating; rot = rotating;
count = 0; count = 0;
lastKey = null; lastKey = null;
chunkSize = (int) Math.min(100, guessedCountLimit); //System.out.println("*** keyIterator: " + filename + ": readAheadChunkSize = " + readAheadChunkSize + ", lastIteratorCount = " + lastIteratorCount);
readAheadChunkSize = Math.min(1000, 3 + (int) ((3 * readAheadChunkSize + lastIteratorCount) / 4));
chunkSize = (int) Math.min(readAheadChunkSize / 3, guessedCountLimit);
keyBuffer = keySet(inc, rot, start, true, chunkSize); keyBuffer = keySet(inc, rot, start, true, chunkSize);
bufferIterator = keyBuffer.iterator(); bufferIterator = keyBuffer.iterator();
lastIteratorCount = 0;
} }
public boolean hasNext() { public boolean hasNext() {
@ -1141,6 +1150,7 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {
// return the row // return the row
count++; count++;
lastIteratorCount++;
return lastKey; return lastKey;
} }

Loading…
Cancel
Save