From b6cce080198828162d5786b0363de6b7ec3afd37 Mon Sep 17 00:00:00 2001 From: orbiter Date: Tue, 27 Apr 2010 22:22:16 +0000 Subject: [PATCH] fixed a bug in rwi storage data size allocation git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@6843 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- .../yacy/kelondro/index/ObjectIndexCache.java | 2 +- .../net/yacy/kelondro/index/RowCollection.java | 16 ++++++++-------- source/net/yacy/kelondro/index/RowSet.java | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/source/net/yacy/kelondro/index/ObjectIndexCache.java b/source/net/yacy/kelondro/index/ObjectIndexCache.java index 98735ef4b..5fbbc6e57 100644 --- a/source/net/yacy/kelondro/index/ObjectIndexCache.java +++ b/source/net/yacy/kelondro/index/ObjectIndexCache.java @@ -92,7 +92,7 @@ public final class ObjectIndexCache implements ObjectIndex, Iterable // finish initialization phase index0.sort(); index0.uniq(); - index0.trim(false); + index0.trim(); index1 = new RowSet(rowdef); //new RowSetArray(rowdef, spread); } } diff --git a/source/net/yacy/kelondro/index/RowCollection.java b/source/net/yacy/kelondro/index/RowCollection.java index f533d5b05..a9acee52c 100644 --- a/source/net/yacy/kelondro/index/RowCollection.java +++ b/source/net/yacy/kelondro/index/RowCollection.java @@ -220,11 +220,12 @@ public class RowCollection implements Iterable, Cloneable { public synchronized byte[] exportCollection() { // returns null if the collection is empty - trim(false); sort(); // experimental; supervise CPU load + //uniq(); + //trim(); assert this.sortBound == this.chunkcount; // on case the collection is sorted - assert this.size() * this.rowdef.objectsize == this.chunkcache.length : "this.size() = " + this.size() + ", objectsize = " + this.rowdef.objectsize + ", chunkcache.length = " + this.chunkcache.length; - final Row row = exportRow(chunkcache.length); + assert this.size() * this.rowdef.objectsize <= this.chunkcache.length : "this.size() = " + this.size() + ", objectsize = " + this.rowdef.objectsize + ", chunkcache.length = " + this.chunkcache.length; + final Row row = exportRow(this.size() * this.rowdef.objectsize); final Row.Entry entry = row.newEntry(); assert (sortBound <= chunkcount) : "sortBound = " + sortBound + ", chunkcount = " + chunkcount; assert (this.chunkcount <= chunkcache.length / rowdef.objectsize) : "chunkcount = " + this.chunkcount + ", chunkcache.length = " + chunkcache.length + ", rowdef.objectsize = " + rowdef.objectsize; @@ -296,10 +297,10 @@ public class RowCollection implements Iterable, Cloneable { return neededSpaceForEnsuredSize(chunkcount + 1, false); } - protected synchronized void trim(final boolean plusGrowFactor) { + protected synchronized void trim() { if (chunkcache.length == 0) return; long needed = chunkcount * rowdef.objectsize; - if (plusGrowFactor) needed = neededSpaceForEnsuredSize(chunkcount, false); + assert needed <= chunkcache.length; if (needed >= chunkcache.length) return; // in case that the growfactor causes that the cache would // grow instead of shrink, simply ignore the growfactor @@ -308,8 +309,7 @@ public class RowCollection implements Iterable, Cloneable { // This is not critical. Otherwise we provoke a serious // problem with OOM final byte[] newChunkcache = new byte[(int) needed]; - System.arraycopy(chunkcache, 0, newChunkcache, 0, Math.min( - chunkcache.length, newChunkcache.length)); + System.arraycopy(chunkcache, 0, newChunkcache, 0, Math.min(chunkcache.length, newChunkcache.length)); chunkcache = newChunkcache; } @@ -945,7 +945,7 @@ public class RowCollection implements Iterable, Cloneable { collection.addUnique(get(i + 1, false)); removeRow(i + 1, false); if (i + 1 < chunkcount - 1) u = false; - collection.trim(false); + collection.trim(); report.add(collection); collection = new RowSet(this.rowdef, 2); } diff --git a/source/net/yacy/kelondro/index/RowSet.java b/source/net/yacy/kelondro/index/RowSet.java index 06ae061b8..4dca8e49a 100644 --- a/source/net/yacy/kelondro/index/RowSet.java +++ b/source/net/yacy/kelondro/index/RowSet.java @@ -515,7 +515,7 @@ public class RowSet extends RowCollection implements ObjectIndex, Iterable