ensure termination of shrink()

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7927 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 13 years ago
parent 52230a6864
commit 44d6416e2d

@ -177,23 +177,27 @@ public final class IndexCell<ReferenceType extends Reference> extends AbstractBu
boolean donesomething = false; boolean donesomething = false;
// first try to merge small files that match // first try to merge small files that match
while (this.merger.queueLength() < 3 || this.array.entries() >= 50) { int term = 10;
donesomething = this.array.shrinkBestSmallFiles(this.merger, targetFileSize); while (term-- > 0 && (this.merger.queueLength() < 3 || this.array.entries() >= 50)) {
if (!this.array.shrinkBestSmallFiles(this.merger, targetFileSize)) break; else donesomething = true;
} }
// then try to merge simply any small file // then try to merge simply any small file
while (this.merger.queueLength() < 2) { term = 10;
donesomething = this.array.shrinkAnySmallFiles(this.merger, targetFileSize); while (term-- > 0 && (this.merger.queueLength() < 2)) {
if (!this.array.shrinkAnySmallFiles(this.merger, targetFileSize)) break; else donesomething = true;
} }
// if there is no small file, then merge matching files up to limit // if there is no small file, then merge matching files up to limit
while (this.merger.queueLength() < 1) { term = 10;
donesomething = this.array.shrinkUpToMaxSizeFiles(this.merger, maxFileSize); while (term-- > 0 && (this.merger.queueLength() < 1)) {
if (!this.array.shrinkUpToMaxSizeFiles(this.merger, maxFileSize)) break; else donesomething = true;
} }
// rewrite old files (hack from sixcooler, see http://forum.yacy-websuche.de/viewtopic.php?p=15004#p15004) // rewrite old files (hack from sixcooler, see http://forum.yacy-websuche.de/viewtopic.php?p=15004#p15004)
while (this.merger.queueLength() < 1) { term = 10;
donesomething = this.array.shrinkOldFiles(this.merger, targetFileSize); while (term-- > 0 && (this.merger.queueLength() < 1)) {
if (!this.array.shrinkOldFiles(this.merger, targetFileSize)) break; else donesomething = true;
} }
return donesomething; return donesomething;

Loading…
Cancel
Save