diff --git a/source/net/yacy/kelondro/rwi/IndexCell.java b/source/net/yacy/kelondro/rwi/IndexCell.java index 9bf68844e..5218d3702 100644 --- a/source/net/yacy/kelondro/rwi/IndexCell.java +++ b/source/net/yacy/kelondro/rwi/IndexCell.java @@ -177,23 +177,27 @@ public final class IndexCell extends AbstractBu boolean donesomething = false; // first try to merge small files that match - while (this.merger.queueLength() < 3 || this.array.entries() >= 50) { - donesomething = this.array.shrinkBestSmallFiles(this.merger, targetFileSize); + int term = 10; + 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 - while (this.merger.queueLength() < 2) { - donesomething = this.array.shrinkAnySmallFiles(this.merger, targetFileSize); + term = 10; + 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 - while (this.merger.queueLength() < 1) { - donesomething = this.array.shrinkUpToMaxSizeFiles(this.merger, maxFileSize); + term = 10; + 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) - while (this.merger.queueLength() < 1) { - donesomething = this.array.shrinkOldFiles(this.merger, targetFileSize); + term = 10; + while (term-- > 0 && (this.merger.queueLength() < 1)) { + if (!this.array.shrinkOldFiles(this.merger, targetFileSize)) break; else donesomething = true; } return donesomething;