From 44d6416e2dce977c26ac379929b0e0809a6cb2d3 Mon Sep 17 00:00:00 2001 From: orbiter Date: Mon, 5 Sep 2011 00:22:21 +0000 Subject: [PATCH] ensure termination of shrink() git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7927 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- source/net/yacy/kelondro/rwi/IndexCell.java | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) 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;